]> git.saurik.com Git - wxWidgets.git/blame - contrib/docs/latex/ogl/topics.tex
Rework modal dialog code to not depend on now obsolete wxDIALOG_MODAL flag.
[wxWidgets.git] / contrib / docs / latex / ogl / topics.tex
CommitLineData
2d08140f
JS
1\chapter{Topic overviews}
2\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
3\setfooter{\thepage}{}{}{}{}{\thepage}
4
5The following sections describe particular topics.
6
7\section{OGL overview}\label{ogloverview}
8
9\helpref{wxShapeCanvas}{wxshapecanvas}, derived from {\bf wxCanvas}, is the drawing area
10for a number of \helpref{wxShape}{wxshape} instances. Everything drawn on a
11wxShapeCanvas is derived from wxShape, which provides virtual
12member functions for redrawing, creating and destroying
13resize/selection `handles', movement and erasing behaviour, mouse
14click behaviour, calculating the bounding box of the shape, linking
15nodes with arcs, and so on.
16
17The way a client application copes with `damage' to the canvas is to
18erase (white out) anything should no longer be displayed, redraw the shape,
19and then redraw everything on the canvas to repair any damage. If quick edit
20mode is on for the canvas, the complete should be omitted by OGL and the
21application.
22
23Selection handles (called control points in the code) are implemented as
24wxRectangleShapes.
25
26Events are passed to shapes by the canvas in a high-level form, for example {\bf OnLeftClick},
27{\bf OnBeginDragLeft}, {\bf OnDragLeft}, {\bf OnEndDragLeft}. The canvas decides
28what is a click and what is a drag, whether it is on a shape or the canvas itself,
29and (by interrogating the shape) which attachment point the click is associated with.
30
31In order to provide event-handling flexibility, each shapes has an `event handler' associated with it,
32which by default is the shape itself (all shapes derive from wxShapeEvtHandler).
33An application can modify the event-handling behaviour simply by plugging a new
34event handler into the shape. This can avoid the need for multiple inheritance when
35new properties and behaviour are required for a number of different shape classes: instead
36of overriding each class, one new event handler class can be defined and used for all
37existing shape classes.
38
39A range of shapes have been predefined in the library, including rectangles, ellipses,
40polygons. A client application can derive from these shapes and/or derive entirely
41new shapes from wxShape.
42
43Instances of a class called \helpref{wxDiagram}{wxdiagram} organise collections of
44shapes, providing default file input and output behaviour.
45
46\section{wxDividedShape overview}\label{dividedshapeoverview}
47
48Classes: \helpref{wxDividedShape}{wxdividedshape}
49
50A wxDividedShape is a rectangle with a number of vertical divisions. Each
51division may have its text formatted with independent characteristics, and
52the size of each division relative to the whole image may be specified.
53
54Once a wxDividedShape has been created, the user may move the divisions with the
55mouse. By pressing Ctrl while right-clicking, the region attributes can be edited.
56
57Here are examples of creating wxDividedShape objects:
58
59{\small
60\begin{verbatim}
61 /*
62 * Divided rectangle with 3 regions
63 *
64 */
65
66 wxDividedShape *dividedRect = new wxDividedShape(50, 60);
67
68 wxShapeRegion *region = new wxShapeRegion;
69 region->SetProportions(0.0, 0.25);
70 dividedRect->AddRegion(region);
71
72 region = new wxShapeRegion;
73 region->SetProportions(0.0, 0.5);
74 dividedRect->AddRegion(region);
75
76 region = new wxShapeRegion;
77 region->SetProportions(0.0, 0.25);
78 dividedRect->AddRegion(region);
79
80 dividedRect->SetSize(50, 60); // Allow it to calculate region sizes
81 dividedRect->SetPen(wxBLACK_PEN);
82 dividedRect->SetBrush(wxWHITE_BRUSH);
83 dividedRect->Show(TRUE);
84 dividedRect->NameRegions();
85
86 /*
87 * Divided rectangle with 3 regions, rounded
88 *
89 */
90
91 wxDividedShape *dividedRect3 = new wxDividedShape(50, 60);
92 dividedRect3->SetCornerRadius(-0.4);
93
94 region = new wxShapeRegion;
95 region->SetProportions(0.0, 0.25);
96 dividedRect3->AddRegion(region);
97
98 region = new wxShapeRegion;
99 region->SetProportions(0.0, 0.5);
100 dividedRect3->AddRegion(region);
101
102 region = new wxShapeRegion;
103 region->SetProportions(0.0, 0.25);
104 dividedRect3->AddRegion(region);
105
106 dividedRect3->SetSize(50, 60); // Allow it to calculate region sizes
107 dividedRect3->SetPen(wxBLACK_PEN);
108 dividedRect3->SetBrush(wxWHITE_BRUSH);
109 dividedRect3->Show(TRUE);
110 dividedRect3->NameRegions();
111\end{verbatim}
112}
113
114\section{wxCompositeShape overview}\label{compositeshapeoverview}
115
116Classes: \helpref{wxCompositeShape}{wxcompositeshape}, \helpref{wxOGLConstraint}{wxoglconstraint}
117
118The wxCompositeShape allows fairly complex shapes to be created, and maintains
119a set of constraints which specify the layout and proportions of child shapes.
120
121Add child shapes to a wxCompositeShape using \helpref{AddChild}{wxcompositeshapeaddchild}, and
122add constraints using \helpref{AddConstraint}{wxcompositeshapeaddconstraint}.
123
124After children and shapes have been added, call \helpref{Recompute}{wxcompositeshaperecompute} which
125will return TRUE is the constraints could be satisfied, FALSE otherwise. If
126constraints have been correctly and consistently specified, this call will succeed.
127
128If there is more than one child, constraints must be specified: OGL cannot calculate
129the size and position of children otherwise. Don't assume that children will simply
130move relative to the parent without the use of constraints.
131
132To specify a constraint, you need three things:
133
134\begin{enumerate}\itemsep=0pt
135\item a constraint type, such as gyCONSTRAINT\_CENTRED\_VERTICALLY;
136\item a reference shape, with respect to which other shapes are going to be positioned - the\rtfsp
137{\it constraining} shape;
138\item a list of one or more shapes to be constrained: the {\it constrained} shapes.
139\end{enumerate}
140
141The constraining shape can be either the parent of the constrained shapes, or a sibling. The
142constrained shapes must all be siblings of each other.
143
144For an exhaustive list and description of the available constraint types, see the \helpref{wxOGLConstraint constructor}{wxoglconstraintconstr}.
145Note that most constraints operate in one dimension only (vertically or horizontally), so you will
146usually need to specify constraints in pairs.
147
148You can set the spacing between constraining and constrained shapes by
149calling \helpref{wxOGLConstraint::SetSpacing}{wxoglconstraintsetspacing}.
150
151Finally, a wxCompositeShape can have {\it divisions}, which are special child shapes of class
152wxDivisionShape (not to be confused with wxDividedShape). The purpose of this is to allow
153the composite to be divided into user-adjustable regions (divisions) into which other shapes
154can be dropped dynamically, given suitable application code. Divisons allow the child
155shapes to have an identity of their own - they can be manipulated independently of their container -
156but to behave as if they are contained with the division, moving with the parent shape.
157Divisions boundaries can themselves be moved using the mouse.
158
159To create an initial division, call \helpref{wxCompositeShape::MakeContainer}{wxcompositeshapemakecontainer}.
160Make further divisions by calling \helpref{wxDivisionShape::Divide}{wxdivisionshapedivide}.
161