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