On 03/26/13 10:47, Greg Ercolano wrote:
>> I wonder if it is worth poking at a few non-radio buttons
>> and see if that is "the same" or whether some of these behaviours
>> are peculiar to the radio-button case?
> 
>       Good idea; Fl_Browser is the only one I can think of that has
>       multiple states that are similar to radio buttons.
> [..]
>       So here's a big table comparing the when() behavior..
>       http://seriss.com/people/erco/fltk/when-behavior-03-26-2013.html

    Here's the test program used to generate that table.

    I'm still fleshing out the data for that table; I keep finding new
    boundary cases that have to be documented separately (eg. behavior of clicks
    on the empty area of browser), which is why there's now two tables
    at the above link:

--------------------------------------------------------------------------------

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Radio_Button.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Browser.H>

Fl_Tabs           *G_tabs = 0;
Fl_Radio_Button *G_radio1 = 0;
Fl_Radio_Button *G_radio2 = 0;
Fl_Radio_Button *G_radio3 = 0;
Fl_Choice       *G_choice = 0;
Fl_Browser      *G_brow_hold = 0;
Fl_Browser      *G_brow_mult = 0;

void Widget_CB(Fl_Widget*w,void*v) {
    const char *msg = (const char*)v;
    if (strcmp(msg,"MULTI BROWSER")==0|| strcmp(msg,"HOLD BROWSER")==0) {
        Fl_Browser *b = (Fl_Browser*)w;
        printf("%s Callback, changed()=%d value()=%d text()='%s'\n", msg, 
w->changed(),b->value(),b->text(b->value()));
    } else {
        printf("%s Callback, changed()=%d\n", msg, w->changed());
    }
}

void When_CB(Fl_Widget*w,void*) {
    int when = 0;
    const char *s = G_choice->text();
    if ( strcmp(s,"NEVER"              )==0) when = FL_WHEN_NEVER;
    if ( strcmp(s,"CHANGED"            )==0) when = FL_WHEN_CHANGED;
    if ( strcmp(s,"NOT_CHANGED"        )==0) when = FL_WHEN_NOT_CHANGED;
    if ( strcmp(s,"RELEASE"            )==0) when = FL_WHEN_RELEASE;
    if ( strcmp(s,"CHANGED+NOT_CHANGED")==0) when = 
FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED;
    if ( strcmp(s,"RELEASE+CHANGED"    )==0) when = 
FL_WHEN_RELEASE|FL_WHEN_CHANGED;
    if ( strcmp(s,"RELEASE+NOT_CHANGED")==0) when = 
FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED;
    if ( strcmp(s,"RELEASE+CHANGED+NOT_CHANGED")==0) when = 
FL_WHEN_RELEASE|FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED;
    // Apply new when value to radio button and tabs widget..
    G_radio1->when(when);
    G_radio2->when(when);
    G_radio3->when(when);
    G_tabs->when(when);
    G_brow_hold->when(when);
    G_brow_mult->when(when);
    printf("\n*** WHEN IS NOW %d (%s)\n", when, s);
}

int main(int argc, char *argv[]) {
    Fl_Window *win = new Fl_Window(720,200,"Tabs Example");
    {
        G_tabs = new Fl_Tabs(10,10,500-20-110,200-20);
        {
            // Aaa tab
            Fl_Group *aaa = new Fl_Group(10,35,500-20-110,200-45,"Aaa");
            {
                new Fl_Box(50,40,aaa->w()-100,20,"These buttons do nothing");
                Fl_Button *b1 = new Fl_Button(50, 60,90,25,"Button A1"); 
b1->color(88+1);
                Fl_Button *b2 = new Fl_Button(50, 90,90,25,"Button A2"); 
b2->color(88+2);
                Fl_Button *b3 = new Fl_Button(50,120,90,25,"Button A3"); 
b3->color(88+3);
            }
            aaa->end();
            // Bbb tab
            Fl_Group *bbb = new Fl_Group(10,35,500-10,200-35,"Bbb");
            {
                new Fl_Box(50,40,aaa->w()-100,20,"These buttons do nothing");
                Fl_Button *b1 = new Fl_Button( 50,60,90,25,"Button B1"); 
b1->color(88+1);
                Fl_Button *b2 = new Fl_Button(150,60,90,25,"Button B2"); 
b2->color(88+3);
                Fl_Button *b3 = new Fl_Button(250,60,90,25,"Button B3"); 
b3->color(88+5);
                Fl_Button *b4 = new Fl_Button( 50,90,90,25,"Button B4"); 
b4->color(88+2);
                Fl_Button *b5 = new Fl_Button(150,90,90,25,"Button B5"); 
b5->color(88+4);
                Fl_Button *b6 = new Fl_Button(250,90,90,25,"Button B6"); 
b6->color(88+6);
            }
            bbb->end();
        }
        G_tabs->end();
        G_tabs->callback(Widget_CB, (void*)"TABS");

        G_choice = new Fl_Choice(500-100-10,30,100,25,"when()");
        G_choice->align(FL_ALIGN_TOP);
        G_choice->add("NEVER");
        G_choice->add("CHANGED");
        G_choice->add("NOT_CHANGED");
        G_choice->add("RELEASE");
        G_choice->add("CHANGED+NOT_CHANGED");
        G_choice->add("RELEASE+CHANGED");
        G_choice->add("RELEASE+NOT_CHANGED");
        G_choice->add("RELEASE+CHANGED+NOT_CHANGED");
        G_choice->callback(When_CB);
        G_choice->textsize(9);

        Fl_Group *rg = new Fl_Group(G_choice->x(), G_choice->y()+35, 100,100);
        rg->color(50);
        rg->begin();
            G_radio1 = new Fl_Radio_Button(rg->x(),rg->y()+00,rg->w(),25,"Radio 
&1");
            G_radio1->callback(Widget_CB,(void*)"RADIO1");
            G_radio2 = new Fl_Radio_Button(rg->x(),rg->y()+30,rg->w(),25,"Radio 
&2");
            G_radio2->callback(Widget_CB,(void*)"RADIO2");
            G_radio3 = new Fl_Radio_Button(rg->x(),rg->y()+60,rg->w(),25,"Radio 
&3");
            G_radio3->callback(Widget_CB,(void*)"RADIO3");
        rg->end();

        G_brow_hold = new Fl_Browser(510,10,100,160,"Hold");
        G_brow_hold->type(FL_HOLD_BROWSER);
        G_brow_hold->add("Aaa");
        G_brow_hold->add("Bbb");
        G_brow_hold->add("Ccc");
        G_brow_hold->add("Ddd");
        G_brow_hold->callback(Widget_CB,(void*)"HOLD BROWSER");

        G_brow_mult = new Fl_Browser(610,10,100,160,"Multi");
        G_brow_mult->type(FL_MULTI_BROWSER);
        G_brow_mult->add("Aaa");
        G_brow_mult->add("Bbb");
        G_brow_mult->add("Ccc");
        G_brow_mult->add("Ddd");
        G_brow_mult->callback(Widget_CB,(void*)"MULTI BROWSER");
    }
    win->end();
    win->show();
    return(Fl::run());
}
_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to