XForms: Slider Label Bug

From: justin.turnage@lmco.com
Date: Tue Oct 17 2000 - 13:59:40 EDT

  • Next message: Michael John Holme: "XForms: Colors problem under Linux"

    # To subscribers of the xforms list from justin.turnage@lmco.com :

    I think I've found a bug (At least I can't think of why it would be there)
    in the implementation of how XFORMS updates its labels inside of sliders.
    The problem that I see is that whenever the label is centered inside of the
    label, it creates a double image of the label inside the slider and in the
    center of the slider frame. I've tried this on two operating systems (Linux
    and Digital Unix) and they both have it in it. I've written a short program
    to demonstrate. Hit the Center Label button to switch between the top
    alignment vs. center alignment.

    Source to follow:

    /* Form definition file generated with fdesign. */

    #include <stdio.h> #include <math.h> #include <stdlib.h> #include <forms.h>

    #define TIMEOUT 100

    /** Callbacks, globals and object handlers **/ extern void button_cb(FL_OBJECT *, long);

    /**** Forms and Objects ****/ typedef struct { FL_FORM *LOAD_STATUS; void *vdata; char *cdata; long ldata; FL_OBJECT *TOTAL_LD_STATUS; FL_OBJECT *ID_OK; FL_OBJECT *ID_START; FL_OBJECT *CENTER_LABEL; } FD_LOAD_STATUS;


    extern FD_LOAD_STATUS * create_form_LOAD_STATUS(void);

    static void timer_cb(int, void *);

    int status; int ctr=0; char str[5];

    /* callbacks and freeobj handles for form LOAD_STATUS */ void button_cb(FL_OBJECT *ob, long data) { switch(data) { case 1: exit(0); break; case 2: ctr=0; fl_add_timeout(TIMEOUT,timer_cb,0); break; } }

    /* callbacks and freeobj handles for form LOAD_STATUS */ static void timer_cb(int id, void *data) { fl_check_forms(); status = fl_get_button(fd_LOAD_STATUS->CENTER_LABEL);

    if(status==1) fl_set_object_lalign(fd_LOAD_STATUS->TOTAL_LD_STATUS,FL_ALIGN_CENTER); else fl_set_object_lalign(fd_LOAD_STATUS->TOTAL_LD_STATUS,FL_ALIGN_TOP);

    fl_set_slider_value(fd_LOAD_STATUS->TOTAL_LD_STATUS,ctr); sprintf(str,"%d",ctr); fl_set_object_label(fd_LOAD_STATUS->TOTAL_LD_STATUS,str); ctr++;

    if(ctr<=100) fl_add_timeout(TIMEOUT,timer_cb,0);


    FD_LOAD_STATUS *create_form_LOAD_STATUS(void) { FL_OBJECT *obj; FD_LOAD_STATUS *fdui = (FD_LOAD_STATUS *) fl_calloc(1, sizeof(*fdui));

    fdui->LOAD_STATUS = fl_bgn_form(FL_NO_BOX, 501, 214); obj = fl_add_box(FL_UP_BOX,0,0,501,214,""); fl_set_object_color(obj,FL_LIGHTER_COL1,FL_COL1); fdui->TOTAL_LD_STATUS = obj = fl_add_slider(FL_HOR_FILL_SLIDER,77,50,345,25,""); fl_set_object_color(obj,FL_LIGHTER_COL1,FL_PALEGREEN); fl_set_object_lsize(obj,FL_MEDIUM_SIZE); fl_set_object_lalign(obj,FL_ALIGN_TOP); fl_set_slider_value(obj, 0); fl_set_slider_size(obj, 100.0); fl_set_slider_step(obj, 1); fl_set_slider_bounds(obj,0,100); fdui->ID_OK = obj = fl_add_button(FL_NORMAL_BUTTON,125,144,73,39,"OK"); fl_set_object_color(obj,FL_LIGHTER_COL1,FL_LIGHTER_COL1); fl_set_object_callback(obj,button_cb,1); fdui->ID_START = obj = fl_add_button(FL_NORMAL_BUTTON,290,145,73,39,"Start TImer"); fl_set_object_color(obj,FL_LIGHTER_COL1,FL_LIGHTER_COL1); fl_set_object_callback(obj,button_cb,2); fdui->CENTER_LABEL = obj = fl_add_checkbutton(FL_PUSH_BUTTON,196,98,25,26,"Center Label"); fl_set_object_callback(obj,button_cb,3); fl_end_form();

    fdui->LOAD_STATUS->fdui = fdui;

    return fdui; } /*---------------------------------------*/

    int main(int argc, char *argv[]) {

    fl_initialize(&argc, argv, 0, 0, 0); fd_LOAD_STATUS = create_form_LOAD_STATUS();

    /* fill-in form initialization code */

    /* show the first form */ fl_show_form(fd_LOAD_STATUS->LOAD_STATUS,FL_PLACE_CENTERFREE,FL_FULLBORDER," LOAD_STATUS");

    fl_do_forms(); return 0; } ---

    Is this a bug or is there something I missed?


    Justin Turnage _________________________________________________ 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://world.std.com/~xforms List Archive: http://bob.usuhs.mil/mailserv/list-archives/

    This archive was generated by hypermail 2b29 : Tue Oct 17 2000 - 15:38:07 EDT