Damage and Redrawing


uchar fltk::Widget::damage () const
void fltk::Widget::set_damage (uchar c)
void fltk::Widget::redraw ()
void fltk::Widget::redraw (uchar c)
void fltk::Widget::redraw_label ()
void fltk::Widget::redraw_highlight ()
virtual void fltk::Widget::draw ()

Detailed Description

When redrawing your widgets you should look at the damage bits to see what parts of your widget need redrawing. The handle() method can then set individual damage bits to limit the amount of drawing that needs to be done:

MyClass::handle(int event) {
  if (change_to_part1) damage(1);
  if (change_to_part2) damage(2);
  if (change_to_part3) damage(4);

MyClass::draw() {
  if (damage() & fltk::DAMAGE_ALL) {
    ... draw frame/box and other static stuff ...
  if (damage() & (fltk::DAMAGE_ALL | 1)) draw_part1();
  if (damage() & (fltk::DAMAGE_ALL | 2)) draw_part2();
  if (damage() & (fltk::DAMAGE_ALL | 4)) draw_part3();

Except for DAMAGE_ALL, each widget is allowed to assign any meaning to any of the bits it wants. The enumerations are just to provide suggested meanings.

Function Documentation

uchar Widget::damage  )  const [inline, inherited]

The 'or' of all the calls to redraw() done since the last draw(). Cleared to zero after draw() is called.

void Widget::draw  )  [virtual, inherited]

Fltk calls this virtual function to draw the widget, after setting up the graphics (current window, xy translation, etc) so that any drawing functions will go into this widget.

User code should not call this! You probably want to call redraw().

The default version calls draw_box() and draw_label(), thus drawing the box() to fill the widget and putting the label() and image() inside it to fill it, unless the align() flags are set to put it outside.

Information on how to write your own version is here.

Reimplemented in fltk::Divider, fltk::Group, fltk::Window, fltk::DockHolder, fltk::GripperBar, fltk::RegionHolder, fltk::ToolDivider, fltk::ToolWindow, and fltk::WindowHolder.

void Widget::redraw uchar  flags  )  [inherited]

Indicates that draw() should be called, and turns on the given bits in damage(). At least these bits, and possibly others, will still be on when draw() is called.

void Widget::redraw  )  [inherited]

Same as redraw(DAMAGE_ALL). This bit is used by most widgets to indicate that they should not attempt any incremental update, and should instead completely draw themselves.

void Widget::redraw_highlight  )  [inherited]

Causes a redraw if highlighting changes.

Calls redraw(DAMAGE_HIGHLIGHT) if this widget has a non-zero highlight_color(). This is designed to be called in response to ENTER and EXIT events and not redraw the widget if the no highlight color is being used.

void Widget::redraw_label  )  [inherited]

Indicates that the label() should be redrawn. This does nothing if there is no label. If it is an outside label (see align()) then the parent() is told to redraw it. Otherwise redraw() is called.

void Widget::set_damage uchar  c  )  [inline, inherited]

Directly change the value returned by damage(). Note that this replaces the value, it does not turn bits on. Use redraw() to turn bits on.

Tue Jun 27 02:19:43 2006. FLTK Dock is copyright © 2006 by MD. Z. Hossain