Drawing Controls

OBJECTS

  typedef void (*drawfn)(control c, rect r);

FUNCTIONS

  void  setredraw(control c, drawfn fn);

  void  clear(control c);
  void  draw(control c);
  void  redraw(control c);

NOTES

The setredraw function is used to attach a call-back function to a control which will be called every time that control needs to be redrawn. There is no need for this call-back to clear the control since this will automatically be done by the window manager. The call-back function should use drawing operations (see later sections) to draw the entire contents of the control.

Build-in controls such as buttons, scrollbars, etc have their own redrawing functions, so it is unwise to use the functions in this section on anything but controls defined by yourself.

The clear function causes a control's rectangle to be filled with its background colour. This can be used to totally clear a control's contents.

The draw function calls the control's redraw call-back, as set using setredraw (see above). The redraw call-back, which is supplied by the programmer, is passed two parameters: the control which needs to be redrawn, and that control's rectangle (in local co-ordinates).

Calling redraw is equivalent to calling clear followed by draw and is used to completely redraw a control.