next up previous contents
Next: Supporting menu bars Up: Adding a new GUI Previous: vgui_Foo_window

vgui_Foo

There may be some setup for the widget system that should take place in this class in the vgui::init_impl function. The only other features to worry about are providing the singleton methods/data

from vgui_Xm.h


class vgui_Xm : public vgui { ... static vgui_Xm* instance_; };

from vgui_Xm.C


vgui\_Xm* vgui\_Xm::instance\_ = 0;... instance\_ = new vgui\_Xm; return instance\_; \}

The line containing vgui_Xm_instantiation causes the (sole) instance of vgui_Xm to be created and due to the ctor vgui::vgui being called, vgui_Xm is then registered with VGUI under the name given in the virtual function ::name e.g. string vgui_Fl::name() const { return "fltk"; }

The other important function to override is vgui::run_impl which basically calls the main event loop for the interface e.g.


void vgui\_Xm::run\_impl() { ... }
The other functions to override are the factory methods returning vgui_window subclasses of the correct type. e.g.


vgui_window* vgui_Fl::produce_window_impl()...  { return new vgui_Fl_window(width, height, title); }



Target Junior User
2000-10-31