FLTK - Basic Example of Fl_Tabs


One of the common ways people learn fltk is through the examples in the test folder, as opposed to the documentation which is auto generated using doxygen. However there is no example for Fl_Tabs. So I provided one below.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Group.H>
 
int main(int argc, char ** argv)
{
    Fl_Window *window = new Fl_Window(550, 300);
    {
       Fl_Tabs* o = new Fl_Tabs(0, 0, 545, 150);
       { Fl_Group* o = new Fl_Group(0, 20, 540, 125, "tab1");
         {
            Fl_Box *box1 = new Fl_Box(50, 40, 70, 20,"box1");//x,y,w,h
         }
         o->end();
       }
 
       { Fl_Group* o = new Fl_Group(0, 20, 540, 125, "tab2");
         o->hide();
         {
           Fl_Box *box2 = new Fl_Box(50, 40, 70, 20,"box2");//x,y,w,h
         }
         o->end();
       }
       o->end();
 
    }
    window->end();
    window->show(argc, argv);
 
    return(Fl::run());
}

code snippets are licensed under Creative Commons CC-By-SA 3.0 (unless otherwise specified)