Fltk X-specific interface

#include <FL/x.H>

On Unix/X you can include this file to access fltk's X-specific functions. Be warned that some of the structures and calls in it are subject to change in future version of fltk. Try to avoid doing this so your code is portable.


Handling other X events

void Fl::add_handler(int (*f)(int));

extern XEvent* fl_xvent;

extern ulong fl_event_time;

Window fl_xid(const Fl_Window*);

Fl_Window* fl_find(ulong xid);

int fl_handle(const XEvent&);


Drawing using Xlib

extern Display* fl_display;
extern Window fl_window;
extern GC fl_gc;
extern int fl_screen;
extern XVisualInfo* fl_visual;
extern Colormap fl_colormap;

unsigned long fl_xpixel(Fl_Color i);

unsigned long fl_xpixel(uchar r, uchar g, uchar b);


Changing the display, screen, or X visual

Fltk uses only a single display, screen, X visual, and X colormap. This greatly simplifies it's internal structure and makes it much smaller and faster. You can change which it uses by setting global variables before the first Fl_Window::show() is called. You may also want to call Fl::visual(int), which is a portable interface to get a full color and/or double buffered visual.

int Fl::display(const char *)

extern Display* fl_display;

void fl_open_display();

void fl_close_display();

extern int fl_screen;

extern XVisualInfo* fl_visual;
extern Colormap fl_colormap;


Using a subclass of Fl_Window for special X stuff

Fltk can manage an X window on a different screen, visual and/or colormap, you just can't use fltk's drawing routines to draw into it. But you can write your own draw() method that uses Xlib calls only.

Fltk can also manage xid's provided by other libraries or programs, and call those libraries when the window needs to be redrawn.

To do this, you need to make a subclass of Fl_Window and override some of these virtual functions:

virtual void Fl_Window::show()

virtual void Fl_Window::flush()

virtual void Fl_Window::hide()

virtual void Fl_Window::~Fl_Window()

(back to contents)