Domingo Alvarez Duarte wrote:
> Here you are pointing one of problems of Fl_Tabs "Guess work", When adding  
> a group to Fl_Tabs the label of the group isn't adapted to the labelsize  
> of Fl_Tabs resulting in strange tabs.

    I see, this is handy.

    So the proposed client_area() makes it easier to procedurally
    create the child groups without having to mentally calculate
    their sizes, and hard code 'magic numbers' for the group's XYWH. eg:

         Fl_Tab *tab = new Fl_Tab(20,20,400,350);

         // Create child groups based on client_area()'s return values
         int X,Y,W,H; tab->client_area(X,Y,W,H);
         Fl_Group *g1 = new Fl_Group(X,Y,W,H,"Tab 1");  // no magic numbers for 
xywh
         Fl_Group *g2 = new Fl_Group(X,Y,W,H,"Tab 2");  // no magic numbers for 
xywh

    I tried this, and this works nicely..

    Except: client_area() uses Fl_Tabs::labelsize() to do its calculations
    when no children exist yet.

    Trouble is, Fl_Tabs::labelsize() has nothing to do with the size of the
    tab's labels; each child's labelsize() is what defines each tab's label 
size.

    If the child group's label sizes are different, then client_area()
    won't give a correct answer.

    However, if it accepted an optional font size, then the app
    could pass the maximum font size for more accurate xywh values.

    +1 for adding this method, or something like it.
    I'd suggest changing the name of the parameter "top_if_first"
    to "tabs_on_top", which I think might be clearer.

    Here's a small test program I used to play with client_area();
    (a modified version of the examples/tabs-simple)
    It currently shows the problem defined above (different sized
    child labels) which could be solved if client_area() accepted
    an optional size parameter. However, it works fine if the children
    label sizes are all the same (which is the more common case).

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
int main(int argc, char *argv[]) {
  Fl::scheme("gtk+");
  Fl_Window *win = new Fl_Window(500,200,"Tabs Example");
  {
    // Create the tab widget
    Fl_Tabs *tabs = new Fl_Tabs(10,10,500-20,200-20);
    {
      int X,Y,W,H;
      tabs->client_area(X,Y,W,H,true);                  // TABS ON TOP
      //tabs->client_area(X,Y,W,H,false);               // TABS ON BOTTOM

      Fl_Group *aaa = new Fl_Group(X,Y,W,H,"Aaa");      // no magic #'s
      aaa->labelsize(20);
      {
        Fl_Button *b1 = new Fl_Button(X+20, Y+20,90,25,"Button A1"); 
b1->color(88+1);
        Fl_Button *b2 = new Fl_Button(X+20, Y+50,90,25,"Button A2"); 
b2->color(88+2);
        Fl_Button *b3 = new Fl_Button(X+20, Y+80,90,25,"Button A3"); 
b3->color(88+3);
      }
      aaa->end();

      Fl_Group *bbb = new Fl_Group(X,Y,W,H,"Bbb");      // no magic #'s
      bbb->labelsize(30);
      {
        Fl_Button *b1 = new Fl_Button( X+20,Y+20,90,25,"Button B1"); 
b1->color(88+1);
        Fl_Button *b2 = new Fl_Button(X+120,Y+20,90,25,"Button B2"); 
b2->color(88+3);
        Fl_Button *b3 = new Fl_Button(X+220,Y+20,90,25,"Button B3"); 
b3->color(88+5);
        Fl_Button *b4 = new Fl_Button( X+20,Y+50,90,25,"Button B4"); 
b4->color(88+2);
        Fl_Button *b5 = new Fl_Button(X+120,Y+50,90,25,"Button B5"); 
b5->color(88+4);
        Fl_Button *b6 = new Fl_Button(X+220,Y+50,90,25,"Button B6"); 
b6->color(88+6);
      }
      bbb->end();
      Fl_Group *ccc = new Fl_Group(X,Y,W,H,"Ccc");      // no magic #'s
      ccc->labelsize(35);
      {
        Fl_Button *b1 = new Fl_Button( X+20,Y+20,90,25,"Button C1"); 
b1->color(88+1);
      }
      ccc->end();
    }
    tabs->end();
  }
  win->end();
  win->show(argc, argv);
  return(Fl::run());
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to