When your user interface can not be completely built with the standard toolbox gadgets you will need to be able to draw your own graphics in a Window.
The WIMP informs an application when part of its window needs drawing by sending it a messages and then providing it with one or more non overlapping rectangles to draw within. The WIMP also sets the clipping rectangle to the rectangle it gives so standard graphic commands will not draw outside of it.
A flag on the Window resource tells the WIMP that it wants to draw part or all of the window itself. Unless this flag is set the WIMP will not send the messages.
In the TBX library the rectangles to redraw are passed to one or more
redraw listeners derived from class tbx::RedrawListener
via the redraw
method. The information about
what needs to be redrawn is handed to the method in a tbx::RedrawEvent
object.
The tbx::RedrawEvent
has two members, the visible_area and the clip
box. The visible_area return a tbx::VisibleArea
object which gives
information about the visible area of the Window. It also contains useful functions to
convert between work area co-ordinates and screen co-ordinates. The clip box gives
the area that needs to be redrawn in screen co-ordinates. By using the clip box
you can reduce the amount you need to redraw.