## OGL overview

wxShapeCanvas, derived from wxCanvas, is the drawing area for a number of wxShape instances. Everything drawn on a wxShapeCanvas is derived from wxShape, which provides virtual member functions for redrawing, creating and destroying resize/selection 'handles', movement and erasing behaviour, mouse click behaviour, calculating the bounding box of the shape, linking nodes with arcs, and so on.

The way a client application copes with 'damage' to the canvas is to erase (white out) anything should no longer be displayed, redraw the shape, and then redraw everything on the canvas to repair any damage. If quick edit mode is on for the canvas, the complete should be omitted by OGL and the application.

Selection handles (called control points in the code) are implemented as wxRectangleShapes.

Events are passed to shapes by the canvas in a high-level form, for example OnLeftClick, OnBeginDragLeft, OnDragLeft, OnEndDragLeft. The canvas decides what is a click and what is a drag, whether it is on a shape or the canvas itself, and (by interrogating the shape) which attachment point the click is associated with.

In order to provide event-handling flexibility, each shapes has an 'event handler' associated with it, which by default is the shape itself (all shapes derive from wxShapeEvtHandler). An application can modify the event-handling behaviour simply by plugging a new event handler into the shape. This can avoid the need for multiple inheritance when new properties and behaviour are required for a number of different shape classes: instead of overriding each class, one new event handler class can be defined and used for all existing shape classes.

A range of shapes have been predefined in the library, including rectangles, ellipses, polygons. A client application can derive from these shapes and/or derive entirely new shapes from wxShape.

Instances of a class called wxDiagram organise collections of shapes, providing default file input and output behaviour.