All widgets inherits Fl_Widget class in the FLTK.
In the Fl_Widget, drawing function draw(), event handling function
handle() and resizing function resize() are defined as virtual function.
Moreover, draw() is defined as abstract function.
So we can make these functions suit to each user defined widget.
Ruby/FLTK also has this feature. See the MyCanvas class in the sample
The MyCanvas inherits FLTK::Widget and has handle and draw method.
draw method is defined as follows:
In this method, we first call the draw method defined in super class, and
then clear the widget. After that, we draw lines with the color FLTK::BLACK.
When the widget is redrawed by redraw method, the draw method is invoked.
Similarly$B!$(Bthe handle method is defined as follows:
All events created inside the MyCanvas are passed to the handle.
It accepts FLTK::PUSH and FLTK::DRAG events. When it accepts drag event,
change the position of the child widget @cur, and redraw.
We must return true, if accepting an event. If we reject an event and
return the false, the event is passed to the handle method defined in
if( @cur )
Likewise, we can change behavior of the widget by overloading methods
such as Widget#resize, Window#flush, Window#show and Window#hide.
FLTK has basic drawing functions. We must specify the absolute position.
Its base is the left top of a window. So we must calculate the offset to
draw inside of the widget. Ruby/FLTK has FLTK::Drawable module.
The offset is automatically caluculated, if the widget does include the
module. For example, since foregoing MyCanvas class includes FLTK::Drawable,
MyCanvas has color, line and clear methods.
PDA -- Agenda VR3
Ruby/FLTK can works on PDA called "Agenda VR3". As I don't have it now,
I can't write the details here. See also ralated links which is apears
on the top page.
Agenda Computing seems to have gone.