From dc70b69502de6769c8fe109161f984494a0c00b8 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 19 Jan 1999 20:53:39 +0000 Subject: Updated documentation with changes from Bill. Added new image files for buttons. git-svn-id: file:///fltk/svn/fltk/trunk@237 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/subclassing.html | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'documentation/subclassing.html') diff --git a/documentation/subclassing.html b/documentation/subclassing.html index d15f691e2..5951f0305 100644 --- a/documentation/subclassing.html +++ b/documentation/subclassing.html @@ -74,20 +74,19 @@ flags(ACTIVE|VISIBLE);

void Fl_Widget::damage(uchar mask)
void Fl_Widget::damage(uchar mask, int x, int y, int w, int h)
uchar Fl_Widget::damage()

- The first form indicates that a partial update of the object is +The first form indicates that a partial update of the object is needed. The bits in mask are OR'd into damage(). Your -draw() routine can examine these bits to limit what it is drawing. - The public method Fl_Widget::redraw() simply does -Fl_Widget::damage(FL_DAMAGE_ALL). +draw() routine can examine these bits to limit what it is +drawing. The public method Fl_Widget::redraw() simply does + Fl_Widget::damage(FL_DAMAGE_ALL), but the implementation of +your widget can call the private damage(n).

The second form indicates that a region is damaged. If only these calls are done in a window (no calls to damage(n)) then FLTK will clip to the union of all these calls before drawing anything. This can greatly speed up incremental displays. The mask bits are or'd into damage() unless this is a Fl_Window widget.

The third form returns the bitwise-OR of all damage(n) - calls done since the last draw(). The public method -redraw() does damage(FL_DAMAGE_ALL), but the -implementation of your widget can call the private damage(n).

+calls done since the last draw().

void Fl_Widget::draw_box() const
void Fl_Widget::draw_box(Fl_Boxtype b, ulong c) const

The first form draws this widget's box(), using the @@ -110,7 +109,7 @@ the passed bounding box. This is designed for parent groups to draw labels with.

void Fl_Widget::set_flag(SHORTCUT_LABEL)

If your constructor calls this it modifies draw_label() so -that ''characters cause an underscore to be printed under the next +that '&' characters cause an underscore to be printed under the next letter.

void Fl_Widget::set_visible()
void Fl_Widget::clear_visible()

@@ -121,10 +120,10 @@ FL_SHOW events to the widget.
static int Fl_Widget::test_shortcut(const char *s) The first version tests Fl_Widget::label() against the current event (which should be a FL_SHORTCUT event). If the -label contains a ''character and the character after it matches the key +label contains a '&' character and the character after it matches the key press, this returns true. This returns false if the SHORTCUT_LABEL - flag is off, if the label is NULL or does not have a -''character in it, or if the keypress does not match the character. +flag is off, if the label is NULL or does not have a +'&' character in it, or if the keypress does not match the character.

The second version lets you do this test against an arbitrary string.

uchar Fl_Widget::type() const @@ -140,11 +139,10 @@ standard everywhere.

If you don't have RTTI you can use the clumsy FLTK mechanisim, by having type() have a unique value. These unique values must be greater than the symbol FL_RESERVED_TYPE (which is 100). - Look through the header files for FL_RESERVED_TYPE to find an -unused number. If you make a subclass of Fl_Group you must -use FL_GROUP + n, and if you make a subclass of Fl_Window -you must use FL_WINDOW + n (in both cases n is in the -range 1 to 7).

+Look through the header files for FL_RESERVED_TYPE to find an +unused number. If you make a subclass of Fl_Window +you must use FL_WINDOW + n (n must be in the +range 1 to 7).

Handling Events

The virtual method int Fl_Widget::handle(int event) is called to handle each event passed to the widget. It can: @@ -216,8 +214,8 @@ be called from non-drawing code.

damage() contains the bitwise-OR of all the damage(n) calls to this widget since it was last drawn. This can be used for minimal update, by only redrawing the parts whose bits are set. FLTK -will turn all the bits on if it thinks the entire widget must be -redrawn (for instance due to an expose event).

+will turn on the FL_DAMAGE_ALL bit if it thinks the entire widget +must be redrawn (for instance due to an expose event).

Expose events (and the above damage(b,x,y,w,h)) will cause draw() to be called with FLTK's clipping turned on. You can greatly speed up redrawing in some @@ -285,8 +283,8 @@ void MyClass::slider_cb() { // normal method If you make the handle() method, you can quickly pass all the events to the children using the Fl_Group::handle() method. -Note that you don't need to override handle() if your -composite widget does nothing other than pass events to the children: +You don't need to override handle() if your composite widget +does nothing other than pass events to the children: