|Century Embedded Technologies Nano-X SDK and Developer's Guide|
|Prev||Chapter 13. Extending and Adding Widgets||Next|
The draw() virtual method is called when FLTK wants you to redraw your widget. It will be called if and only if damage() is non-zero, and damage() will be cleared to zero after it returns. draw() should be declared protected, so that it can't 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 on the FL_DAMAGE_ALL bit if it thinks the entire widget must be redrawn (e.g. for 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 cases by testing fl_not_clipped(x,y,w,h) or fl_clip_box(...) and skipping invisible parts.
Besides the protected methods described above, FLTK provides a large number of basic drawing functions, which are described below.