#include <FL/Fl.H>

You will have to include at least this header file in your main code so that you can call the methods described here.

Initialization

You can construct all your widgets (and menus and boxtypes and images and other fltk types) without "initializing". The constructors do not require a connection to the X display. This makes it a lot easier, especially if your program has a mode where it does not use a gui, and guarantees that code you don't use is not linked in.

Fltk is usually "initialized" when you show() the first window. At this time the X display is opened and everything is set up so the calls described in the rest of this document work. A few other calls can open the X display, amoung them are fl_width() to measure the size of a font. Be careful that the following calls are done before the display is opened, if not you will get lots of strange X errors.

Most of these "initialization" calls are to get around stupid X things. I have tried to make these as simple to call as possible and they have no effect on systems which aren't as badly designed as X. But you should call them to make your program as portable as possible.

int Fl::visual(int)

int Fl::gl_visual(int)

void Fl::own_colormap();

void Fl::get_system_colors();

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

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

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

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)

const char* const Fl::help;

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

Running

After fltk is "initialized" by calling show() on some window, you get fltk to wait for and respond to events by calling the following methods:

int Fl::run()

int Fl::wait()

float Fl::wait(float time)

int Fl::check()

int Fl::ready();

void Fl::add_timeout(float t,void (*cb)(void*),void* v=0);
void Fl::remove_timeout(void (*cb)(void*), void* = 0);

void Fl::set_idle(void (*cb)());

void Fl::flush()

int Fl::damage()

Fl_Widget *Fl::readqueue();

Listening to other file descriptors (Unix only)

void Fl::add_fd(int fd, void (*cb)(int, void*), void* = 0);
void Fl::add_fd(int fd, int when, void (*cb)(int, void*), void* = 0);
void Fl::remove_fd(int);

Exiting

When all windows are closed Fl::wait() and Fl::run() return zero. If your main() routine then returns the program exits. You can also call exit(0) at any time in your program. You do not need to do any cleanup code for fltk. In particular you do not have to destroy any widgets you have created. Fltk also does not sneak any atexit functions in on you either. You will need to do #include <stdlib.h> to call exit().

To stop a window from closing, or conversely to make the closing of a particular window exit the program you must change the callback() function. Here is a typical use:

void (*Fl::warning)(const char*,...);
void (*Fl::error)(const char*,...);
void (*Fl::fatal)(const char*,...);

(back to contents)