XForms: Both problems (colors and scroll_bar)

Santiago Garcia Mantinan (manty@udc.es)
Fri, 23 Jan 1998 00:14:32 +0100 (CET)

To subscribers of the xforms list from Santiago Garcia Mantinan <manty@udc.es> :

On Thu, 22 Jan 1998, Steve Lamont wrote:

> This clearly shouldn't happen. Can you provide a small piece of
> example code which exhibits this behavior?

Well, I put it bellow, but don't know if it is a Linux only bug or even
something related to my VGA card, other programs don't seem to have such a
behavior, but it seems to run well on a sparc with solaris

> How are you using fl_line(), etc? Are you drawing with a Free object,
> a Canvas object, or have you created your own object class?

I'm using fl_line directly in the window that's why they get cleared,
there are quite a lot of lines, that's why I didn't want to add them to
the form, thouth it would be slow, should I change them so that I add them
to the form instead of painting them directly?

> > PS: I have managed to "bypass" the problem with the scroller by freeing
> > the form and creating it again.
> This is definitely the *wrong* answer. If I may be a bit direct, if

Yes, you may, I also think the same but the program has to be finished in
a few hours so...

BTW, the behaviour of the bar was also shown on the sparc with solaris.

What comes below is an example, maybe the color stuff does not happen to
everyone. What I find is that the lines when the program is started from
an xterm are shown in a color that is not correct, after the hide and show
and repaint then they are drawn ok!
About the scrollbar first it is ok, but after the hide I try to place it
in another range and at the left getting it only aparently done :-(((

#include "forms.h"
#include <stdlib.h>
#include <unistd.h>

typedef struct {
FL_FORM *main;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *sleep;
FL_OBJECT *bar;
} FD_main;

FD_main *fd_main;

void draw ()
{
fl_line (40,10,80,10,FL_BLACK);
fl_line (40,16,80,16,FL_BLUE);
fl_line (40,22,80,22,FL_MAGENTA);
fl_line (40,28,80,28,FL_CYAN);
fl_line (40,34,80,34,FL_GREEN);
fl_line (40,40,80,40,FL_YELLOW);
fl_line (40,46,80,46,FL_WHITE);
}

void sleep_cb(FL_OBJECT *ob, long data)
{
fl_hide_form(ob->form);
sleep (2);
fl_show_form(ob->form,FL_PLACE_CENTER,FL_FULLBORDER,"test 1");
draw(); /* we draw it again, it apears with different colors ;-( */
fl_set_scrollbar_bounds(fd_main->bar,1,3); /* bounds from 1 to 3 */
fl_set_scrollbar_value(fd_main->bar,1); /* value to 1 -> left corner */

}

FD_main *create_form_main(void)
{
FL_OBJECT *obj;
FD_main *fdui = (FD_main *) fl_calloc(1, sizeof(*fdui));

fdui->main = fl_bgn_form(FL_NO_BOX, 160, 130);
obj = fl_add_box(FL_UP_BOX,0,0,160,130,"");
fdui->sleep = obj = fl_add_button(FL_NORMAL_BUTTON,10,52,100,40,"sleep");
fl_set_object_lsize(obj,FL_MEDIUM_SIZE);
fl_set_object_callback(obj,sleep_cb,0);
fdui->bar = obj = fl_add_scrollbar(FL_HOR_SCROLLBAR,10,100,150,20,"");
fl_set_scrollbar_return(obj,FL_RETURN_CHANGED);
fl_set_scrollbar_step(obj,1);
fl_set_scrollbar_increment(obj,1,1);
fl_end_form();

fdui->main->fdui = fdui;

return fdui;

}

int main(int argc, char *argv[])
{
fl_initialize(&argc, argv, 0, 0, 0);
fd_main = create_form_main();
fl_show_form(fd_main->main,FL_PLACE_CENTER,FL_FULLBORDER,"test 1");
draw (); /* we draw it for the first time */
fl_do_forms();
return 0;
}

Thanks!

, ~,
SANTIAGO GARCIA MANTINAN (Manty/BestiaTester) mailto:manty@udc.es

, ~
FACULTAD DE INFORMATICA DE LA UNIVERSIDAD DE LA CORUNA

Also: manty@geocities.com - /cgi-bin/exit-to?http://www.geocities.com/SiliconValley/Lakes/1486

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/