Re: XForms: label color

T.C. Zhao (tc_zhao@yahoo.com)
Sat, 28 Aug 1999 09:16:59 -0700 (PDT)

# To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :

Nice demo. I am not sure about the need for
the changing label color twice thing either.
Sure feels like a bug.

--- Steve Lamont <spl@szechuan.ucsd.edu> wrote:
> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve
> Lamont) :
>
> > The color I want to change is the color of the text...(i-e
> FL_BLACK) I
> > tried to use fl_set_foreground_color(gc,FL_WHITE) to change it, but
> the
> > only result i get is a segmentation fault...
>
> Ooops. I was incorrect in my previous suggestion. FL_COL1 is not
> the
> text color, it is the label color. This will teach me to try to read
> mail during long compiles and not test my solutions. My most humble
> apologies for a misleading reply.
>
> My basic suggestion, using fl_mapcolor() was on the right track, but
> beyond there, I should have kept my mouth shut.
>
> What you want to do is to specify your own label color, then use
> fl_mapcolor() to change it.
>
> That should be the end of it but, unfortunately, it's not. I'm not
> sure why -- TC, maybe you can help us here -- but it seems that
> unless
> you do some other jiggery pokery, the label color does not get
> changed
> in the displayed form. It seems that XForms will not recognize the
> colormap change until you change the an object's color to something
> *other* than what it is supposed to be, then change it again to the
> correct label color:
>
> int red;
> int green;
> int blue;
>
> /* Fetch the color -- arbitrarily from the object's col1 */
>
> fl_getmcolor( ob->col1, &red, &green, &blue );
>
> /* Change it. */
>
> fl_mapcolor( MY_LABEL, red, green, blue );
>
> /* This part here is a hack -- I don't see why one should have
> todo it */
>
> fl_set_object_lcolor( ob, FL_RED );
> fl_set_object_lcolor( ob, MY_LABEL );
> fl_redraw_form( ob->form );
>
> The following is a little application I crufted up to illustrate
> this:
>
> - - -
> #include <stdlib.h>
> #include <forms.h>
>
> typedef struct {
> FL_FORM *try;
> void *vdata;
> char *cdata;
> long ldata;
> FL_OBJECT *red;
> FL_OBJECT *green;
> FL_OBJECT *blue;
> } FD_try;
>
> #define MY_LABEL FL_FREE_COL1
>
> void change_color_cb(FL_OBJECT *ob, long data)
> {
>
> int red;
> int green;
> int blue;
>
> /* Fetch the color -- arbitrarily from the object's col1 */
>
> fl_getmcolor( ob->col1, &red, &green, &blue );
>
> /* Change it. */
>
> fl_mapcolor( MY_LABEL, red, green, blue );
>
> /* This part here is a hack -- I don't see why one should have to
> do it */
>
> fl_set_object_lcolor( ob, FL_RED );
> fl_set_object_lcolor( ob, MY_LABEL );
> fl_redraw_form( ob->form );
>
> }
>
> FD_try *create_form_try(void)
> {
> FL_OBJECT *obj;
> FD_try *fdui = (FD_try *) fl_calloc(1, sizeof(*fdui));
>
> fdui->try = fl_bgn_form(FL_NO_BOX, 408, 80);
> obj = fl_add_box(FL_EMBOSSED_BOX,0,0,408,80,"");
> fl_set_object_color(obj,FL_LEFT_BCOL,FL_COL1);
> fdui->red = obj =
> fl_add_button(FL_NORMAL_BUTTON,12,12,116,52,"Red");
> fl_set_object_color(obj,FL_RED,FL_COL1);
> fl_set_object_lsize(obj,FL_LARGE_SIZE);
> fl_set_object_lcolor( obj, MY_LABEL );
> fl_set_object_callback(obj,change_color_cb,0);
> fdui->green = obj =
> fl_add_button(FL_NORMAL_BUTTON,144,12,116,52,"Green");
> fl_set_object_color(obj,FL_GREEN,FL_COL1);
> fl_set_object_lcolor( obj, MY_LABEL );
> fl_set_object_lsize(obj,FL_LARGE_SIZE);
> fl_set_object_callback(obj,change_color_cb,0);
> fdui->blue = obj =
> fl_add_button(FL_NORMAL_BUTTON,276,12,116,52,"Blue");
> fl_set_object_color(obj,FL_BLUE,FL_COL1);
> fl_set_object_lcolor( obj, MY_LABEL );
> fl_set_object_lsize(obj,FL_LARGE_SIZE);
> fl_set_object_callback(obj,change_color_cb,0);
> fl_end_form();
>
> fl_adjust_form_size(fdui->try);
> fdui->try->fdui = fdui;
>
> return fdui;
> }
>
> int main(int argc, char *argv[])
> {
>
> FD_try *fd_try;
>
> fl_initialize(&argc, argv, 0, 0, 0);
> fd_try = create_form_try();
>
> /* Initial label color is white */
>
> fl_mapcolor( MY_LABEL, 255, 255, 255 );
>
>
> fl_show_form(fd_try->try,FL_PLACE_CENTERFREE,FL_FULLBORDER,"try");
> fl_do_forms();
> return 0;
>
> }
> - - -
>
> The above has been tested under 0.89 under IRIX 6.2.
>
> Sorry for any confusion.
>
> spl
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>
>

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

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