To execute any drawing operation the ImagePainter relies on a class hierarchy based on a class named TFigure. This class contains methods and properties common to most kinds of drawings. From TFigure the different tools are derived: TRectangle, TEllipse, TLine, TPencil, and so on.
A drawing operation is carried out in three steps:
BeginDraw: The initializing step that creates the draw object and makes it ready for use.
Draw: The executing step where the actual drawing takes place
EndDraw: The finalizing step that concludes the operation and “commits” the drawing
Each tool is associated with a description of how to respond to user input. When a tool is selected it starts listening to mouse- and keyboard events and responds when it detects an event that matches its input description.
The input specification tells which one of these steps should be carried out in response to an input event. For instance, the TRectangle tool has the following description:
MouseDown: BeginDraw, MouseMove: Draw, MouseUp: EndDraw.