damage.h File Reference


Enumerations

enum  {
  DAMAGE_VALUE, DAMAGE_PUSHED, DAMAGE_SCROLL, DAMAGE_OVERLAY,
  DAMAGE_HIGHLIGHT, DAMAGE_CHILD, DAMAGE_CHILD_LABEL, DAMAGE_EXPOSE,
  DAMAGE_CONTENTS, DAMAGE_ALL
}

Detailed Description

Values of the bits stored in Widget::damage().

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

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() & DAMAGE_ALL) {
    ... draw frame/box and other static stuff ...
  }
  if (damage() & (DAMAGE_ALL | 1)) draw_part1();
  if (damage() & (DAMAGE_ALL | 2)) draw_part2();
  if (damage() & (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.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
DAMAGE_VALUE  A widget may use this to indicate that the displayed value has changed.
DAMAGE_PUSHED  A widget may use this to indicate that the user has pushed or released a button.
DAMAGE_SCROLL  A widget may use this to indicate that the displayed data has scrolled moved horizontally and/or vertically.
DAMAGE_OVERLAY  Same value as DAMAGE_SCROLL.
DAMAGE_HIGHLIGHT  A widget may use this to indicate that the mouse has entered/exited part of the widget.
DAMAGE_CHILD  A child of this group widget needs to be redrawn (non-group widgets can use this bit for their own purposes).
DAMAGE_CHILD_LABEL  An outside label of this widget needs to be redrawn. This is handled (and this bit is cleared) by the parent group.

Because anti-aliasing cannot be redrawn atop itself, this is not used anymore. Instead if an outside label needs to change the entire parent widget is redrawn.

DAMAGE_EXPOSE  Damage caused by damage() or by expose events from the operating system. If this and DAMAGE_ALL is on the widget should draw every pixel inside it's region.
DAMAGE_CONTENTS  Same as DAMAGE_EXPOSE but if DAMAGE_ALL is off a widget can use this for it's own purposes.
DAMAGE_ALL  This bit is set by redraw() and indicates that all of the widget (but not "holes" where the background shows through) needs to be redraw.


Sun Jan 7 00:55:16 2007. FLTK ©2006 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.