]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/ogl/composit.h
include iostream headers before using iostream classes (might fix HP-UX native compil...
[wxWidgets.git] / contrib / include / wx / ogl / composit.h
CommitLineData
1fc25a89
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: composit.h
3// Purpose: wxCompositeShape
4// Author: Julian Smart
5// Modified by:
6// Created: 12/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
2ba06d5a 9// Licence: wxWindows licence
1fc25a89
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _OGL_COMPOSIT_H_
13#define _OGL_COMPOSIT_H_
14
ab7ce33c 15#if defined(__GNUG__) && !defined(__APPLE__)
1fc25a89
JS
16#pragma interface "composit.h"
17#endif
18
5f331691
RD
19
20class WXDLLIMPEXP_OGL wxDivisionShape;
21class WXDLLIMPEXP_OGL wxOGLConstraint;
1fc25a89
JS
22
23/*
24 * A composite object is an invisible rectangle surrounding all children
25 *
26 */
27
5f331691 28class WXDLLIMPEXP_OGL wxCompositeShape: public wxRectangleShape
1fc25a89
JS
29{
30 DECLARE_DYNAMIC_CLASS(wxCompositeShape)
31public:
32
33 wxCompositeShape();
34 ~wxCompositeShape();
35
36 void OnDraw(wxDC& dc);
37 void OnDrawContents(wxDC& dc);
38 void OnErase(wxDC& dc);
2ba06d5a 39 bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = true);
1fc25a89
JS
40 void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
41 void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
42 void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
43
44 void OnRightClick(double x, double y, int keys, int attachment = 0);
45
2ba06d5a 46 void SetSize(double w, double h, bool recursive = true);
1fc25a89 47
2ba06d5a 48 // Returns true if it settled down
1fc25a89
JS
49 bool Recompute();
50
51 // New members
52 void AddChild(wxShape *child, wxShape *addAfter = NULL);
53 void RemoveChild(wxShape *child);
54
55 wxOGLConstraint *AddConstraint(wxOGLConstraint *constraint);
56 wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxList& constrained);
57 wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxShape *constrained);
58
59 void DeleteConstraint(wxOGLConstraint *constraint);
60
61 // Delete constraints that involve this child.
62 void DeleteConstraintsInvolvingChild(wxShape *child);
63
64 // Remove the image from any constraints involving it, but DON'T
65 // remove any constraints.
66 void RemoveChildFromConstraints(wxShape *child);
67
68 // Find constraint, also returning actual composite the constraint was in,
69 // in case it had to find it recursively.
70 wxOGLConstraint *FindConstraint(long id, wxCompositeShape **actualComposite = NULL);
71
2ba06d5a 72 // Returns true if something changed
1fc25a89
JS
73 bool Constrain();
74
75 // Make this composite into a container by creating one wxDivisionShape
76 void MakeContainer();
77
78 // Calculates size and position of composite object based on children
79 void CalculateSize();
80
2b5f62a0 81#if wxUSE_PROLOGIO
1fc25a89
JS
82 void WriteAttributes(wxExpr *clause);
83 void ReadAttributes(wxExpr *clause);
84 // In case the object has constraints it needs to read in in a different pass
85 void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
86#endif
87 // Does the copying for this object
88 void Copy(wxShape& copy);
89
90 virtual wxDivisionShape *OnCreateDivision();
91
92 // Finds the image used to visualize a container. This is any child
93 // of the composite that is not in the divisions list.
94 wxShape *FindContainerImage();
95
2ba06d5a 96 // Returns true if division is a descendant of this container
1fc25a89
JS
97 bool ContainsDivision(wxDivisionShape *division);
98
99 inline wxList& GetDivisions() const { return (wxList&) m_divisions; }
100 inline wxList& GetConstraints() const { return (wxList&) m_constraints; }
101
102protected:
103 double m_oldX;
104 double m_oldY;
105 wxList m_constraints;
106 wxList m_divisions; // In case it's a container
107};
108
109/*
110 * A division object is a composite with special properties,
111 * to be used for containment. It's a subdivision of a container.
112 * A containing node image consists of a composite with a main child shape
113 * such as rounded rectangle, plus a list of division objects.
114 * It needs to be a composite because a division contains pieces
115 * of diagram.
116 * NOTE a container has at least one wxDivisionShape for consistency.
117 * This can be subdivided, so it turns into two objects, then each of
118 * these can be subdivided, etc.
119 */
120#define DIVISION_SIDE_NONE 0
121#define DIVISION_SIDE_LEFT 1
122#define DIVISION_SIDE_TOP 2
123#define DIVISION_SIDE_RIGHT 3
124#define DIVISION_SIDE_BOTTOM 4
125
5f331691 126class WXDLLIMPEXP_OGL wxDivisionShape: public wxCompositeShape
1fc25a89
JS
127{
128 DECLARE_DYNAMIC_CLASS(wxDivisionShape)
129 public:
130
131 wxDivisionShape();
132 ~wxDivisionShape();
133
134 void OnDraw(wxDC& dc);
135 void OnDrawContents(wxDC& dc);
2ba06d5a 136 bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = true);
1fc25a89
JS
137 void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
138 void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
139 void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
140
141 void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
142
143 // Don't want this kind of composite to resize its subdiagrams, so
144 // override composite's SetSize.
2ba06d5a 145 void SetSize(double w, double h, bool recursive = true);
1fc25a89
JS
146
147 // Similarly for calculating size: it's fixed at whatever SetSize
148 // set it to, not in terms of children.
149 void CalculateSize();
150
151 void MakeControlPoints();
152 void ResetControlPoints();
153 void MakeMandatoryControlPoints();
154 void ResetMandatoryControlPoints();
155
2b5f62a0 156#if wxUSE_PROLOGIO
1fc25a89
JS
157 void WriteAttributes(wxExpr *clause);
158 void ReadAttributes(wxExpr *clause);
159#endif
160 // Does the copying for this object
161 void Copy(wxShape& copy);
162
163 // Divide horizontally (wxHORIZONTAL) or vertically (wxVERTICAL)
164 bool Divide(int direction);
165
2ba06d5a 166 // Resize adjoining divisions at the given side. If test is true,
1fc25a89 167 // just see whether it's possible for each adjoining region,
2ba06d5a 168 // returning false if it's not.
1fc25a89
JS
169 bool ResizeAdjoining(int side, double newPos, bool test);
170
2ba06d5a 171 // Adjust a side, returning false if it's not physically possible.
1fc25a89
JS
172 bool AdjustLeft(double left, bool test);
173 bool AdjustTop(double top, bool test);
174 bool AdjustRight(double right, bool test);
175 bool AdjustBottom(double bottom, bool test);
176
177 // Edit style of left or top side
178 void EditEdge(int side);
179
180 // Popup menu
181 void PopupMenu(double x, double y);
182
183 inline void SetLeftSide(wxDivisionShape *shape) { m_leftSide = shape; }
184 inline void SetTopSide(wxDivisionShape *shape) { m_topSide = shape; }
185 inline void SetRightSide(wxDivisionShape *shape) { m_rightSide = shape; }
186 inline void SetBottomSide(wxDivisionShape *shape) { m_bottomSide = shape; }
187 inline wxDivisionShape *GetLeftSide() const { return m_leftSide; }
188 inline wxDivisionShape *GetTopSide() const { return m_topSide; }
189 inline wxDivisionShape *GetRightSide() const { return m_rightSide; }
190 inline wxDivisionShape *GetBottomSide() const { return m_bottomSide; }
191
192 inline void SetHandleSide(int side) { m_handleSide = side; }
193 inline int GetHandleSide() const { return m_handleSide; }
194
195 inline void SetLeftSidePen(wxPen *pen) { m_leftSidePen = pen; }
196 inline wxPen *GetLeftSidePen() const { return m_leftSidePen; }
197 inline void SetTopSidePen(wxPen *pen) { m_topSidePen = pen; }
198 inline wxPen *GetTopSidePen() const { return m_topSidePen; }
199
200 void SetLeftSideColour(const wxString& colour);
201 void SetTopSideColour(const wxString& colour);
202 void SetLeftSideStyle(const wxString& style);
203 void SetTopSideStyle(const wxString& style);
204
205 inline wxString GetLeftSideColour() const { return m_leftSideColour; }
206 inline wxString GetTopSideColour() const { return m_topSideColour; }
207 inline wxString GetLeftSideStyle() const { return m_leftSideStyle; }
208 inline wxString GetTopSideStyle() const { return m_topSideStyle; }
209
210 protected:
211 // Adjoining divisions. NULL indicates edge
212 // of container, and that side shouldn't be
213 // drawn.
214 wxDivisionShape* m_leftSide;
215 wxDivisionShape* m_rightSide;
216 wxDivisionShape* m_topSide;
217 wxDivisionShape* m_bottomSide;
218
219 int m_handleSide; // Side at which handle is legal
220
221 wxPen* m_leftSidePen;
222 wxPen* m_topSidePen;
223 wxString m_leftSideColour;
224 wxString m_topSideColour;
225 wxString m_leftSideStyle;
226 wxString m_topSideStyle;
227};
228
229
230#define DIVISION_MENU_SPLIT_HORIZONTALLY 1
231#define DIVISION_MENU_SPLIT_VERTICALLY 2
232#define DIVISION_MENU_EDIT_LEFT_EDGE 3
233#define DIVISION_MENU_EDIT_TOP_EDGE 4
234#define DIVISION_MENU_EDIT_RIGHT_EDGE 5
235#define DIVISION_MENU_EDIT_BOTTOM_EDGE 6
236#define DIVISION_MENU_DELETE_ALL 7
237
238#endif
239 // _OGL_COMPOSIT_H_