There are two reasons to make a subclass of Fl_Window. First, you may want to make a widget that is an entire window. In that case, just override the draw() and handle() routines exactly like you would do for a subclass of Fl_Object.
The other reason for making a subclass of Fl_Window is to change X stuff, such as the visual or background pixel or any of the other complexities that X sometimes requires. There are then several virtual functions you must override to change how your window is created, destroyed, and drawn. This entire section is very subject to change! It is also X-specific and your code will not be portable to other systems.
You almost certainly need to use this header file in order to override any of these virtual functions.
virtual void show()
// these variables are often static and filled in only once by a class: static XVisualInfo *vis; static Colormap colormap_; void MyWindow::show() { if (shown()) {Fl_Window::show(); return;} // you must do this! fl_open_display(); // necessary if this is first window if (!vis) { vis = figure_out_visual(); colormap_ = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen), vis->visual, AllocNone); } make_xid(vis); }
virtual void flush()
void MyWindow::flush() { set_up_to_draw_into(xid()); if (damage()==2) { // do minimal update inside the damage_box.x, .y, .r, .b } else { // draw everything } damage_box.r = 0; // reset incremental damage clear_damage(0); }
virtual void hide()
void MyWindow::hide() { if (mypixmap) { XFreePixmap(fl_display,mypixmap); mypixmap = 0; } Fl_Window::hide(); // you must call this } MyWindow::~MyWindow() { hide(); }
virtual ulong colormap()
ulong MyWindow::colormap() {return colormap_;}
void Fl_Window::make_xid(XVisualInfo *);
void Fl_Window::make_current(ulong xid);
Fl_Window::current()
to this
window.