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