Initialization
#include <FL/Fl.H>

Unlike every other toolkit I have ever seen, you do not need to "initialize" fltk. The constructors for fltk widgets do not require or create a connection to the X display. You can in fact create a whole hierarchy of widgets without opening the display or setting any global state of fltk. Calling redraw() on widgets or Fl::flush() does nothing as long as the display is not open. This is useful if your program has a "non-gui" mode, as you can avoid putting "if" statements around all the gui parts.

Fltk will open the X display when the first Fl_Window::show() is called. There are certain calls that do not work after this is done (such as Fl::display()). There are also other calls that must be done before the first show() which have a side effect of opening the display (such as Fl::visual()). It is important to call these in the correct order.

The argument parsers provided by fltk are optional. You don't have to call them if you don't like them! Everything they can do can be done with other calls to fltk.

int Fl::args(int argc, char** argv, int &i, int (*callback)(int,char**,int&)=0)

int Fl::arg(int argc, char** argv, int &i)

void Fl::args(int argc, char** argv)

int Fl_Window::show(int argc, char** argv)

const char* const Fl::help;

int Fl::display(const char *)

int Fl::visual(int)

int Fl::gl_visual(int)

void Fl::foreground(short, short, short);

void Fl::background(short, short, short);

void Fl::background2(short, short, short);

#include <FL/x.H>

These calls are only supported on the X version. The normal fltk header files do not include Xlib.h or any calls depending on them. But the <FL/x.H> header file does include them. You must include this header file to call these:

extern Display* fl_display;

void fl_open_display();

void fl_close_display();

extern int fl_screen;
extern XVisualInfo* fl_visual;
extern Colormap fl_colormap;

(back to contents)