]>
Commit | Line | Data |
---|---|---|
1fc25a89 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: constrnt.cpp | |
3 | // Purpose: OGL Constraint classes | |
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 | #ifdef __GNUG__ | |
13 | #pragma implementation "constrnt.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
92a19c2e | 17 | #include "wx/wxprec.h" |
1fc25a89 JS |
18 | |
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include <wx/wx.h> | |
25 | #endif | |
26 | ||
5f331691 | 27 | #if wxUSE_PROLOGIO |
7c9955d1 | 28 | #include <wx/deprecated/wxexpr.h> |
fd657b8a | 29 | #endif |
1fc25a89 | 30 | |
5f331691 RD |
31 | #include "wx/ogl/ogl.h" |
32 | ||
1fc25a89 JS |
33 | |
34 | wxList *wxOGLConstraintTypes = NULL; | |
35 | ||
36 | /* | |
37 | * Constraint type | |
38 | * | |
39 | */ | |
40 | ||
41 | IMPLEMENT_DYNAMIC_CLASS(wxOGLConstraintType, wxObject) | |
42 | ||
43 | wxOGLConstraintType::wxOGLConstraintType(int theType, const wxString& theName, const wxString& thePhrase) | |
44 | { | |
45 | m_type = theType; | |
46 | m_name = theName; | |
47 | m_phrase = thePhrase; | |
48 | } | |
49 | ||
50 | wxOGLConstraintType::~wxOGLConstraintType() | |
51 | { | |
52 | } | |
53 | ||
54 | void OGLInitializeConstraintTypes() | |
55 | { | |
56 | if (!wxOGLConstraintTypes) | |
57 | return; | |
58 | ||
59 | wxOGLConstraintTypes = new wxList(wxKEY_INTEGER); | |
60 | ||
61 | wxOGLConstraintTypes->Append(gyCONSTRAINT_CENTRED_VERTICALLY, | |
9e053640 | 62 | new wxOGLConstraintType(gyCONSTRAINT_CENTRED_VERTICALLY, wxT("Centre vertically"), wxT("centred vertically w.r.t."))); |
1fc25a89 JS |
63 | |
64 | wxOGLConstraintTypes->Append(gyCONSTRAINT_CENTRED_HORIZONTALLY, | |
9e053640 | 65 | new wxOGLConstraintType(gyCONSTRAINT_CENTRED_HORIZONTALLY, wxT("Centre horizontally"), wxT("centred horizontally w.r.t."))); |
1fc25a89 JS |
66 | |
67 | wxOGLConstraintTypes->Append(gyCONSTRAINT_CENTRED_BOTH, | |
9e053640 | 68 | new wxOGLConstraintType(gyCONSTRAINT_CENTRED_BOTH, wxT("Centre"), wxT("centred w.r.t."))); |
1fc25a89 JS |
69 | |
70 | wxOGLConstraintTypes->Append(gyCONSTRAINT_LEFT_OF, | |
9e053640 | 71 | new wxOGLConstraintType(gyCONSTRAINT_LEFT_OF, wxT("Left of"), wxT("left of"))); |
1fc25a89 JS |
72 | |
73 | wxOGLConstraintTypes->Append(gyCONSTRAINT_RIGHT_OF, | |
9e053640 | 74 | new wxOGLConstraintType(gyCONSTRAINT_RIGHT_OF, wxT("Right of"), wxT("right of"))); |
1fc25a89 JS |
75 | |
76 | wxOGLConstraintTypes->Append(gyCONSTRAINT_ABOVE, | |
9e053640 | 77 | new wxOGLConstraintType(gyCONSTRAINT_ABOVE, wxT("Above"), wxT("above"))); |
1fc25a89 JS |
78 | |
79 | wxOGLConstraintTypes->Append(gyCONSTRAINT_BELOW, | |
9e053640 | 80 | new wxOGLConstraintType(gyCONSTRAINT_BELOW, wxT("Below"), wxT("below"))); |
1fc25a89 JS |
81 | |
82 | // Alignment | |
83 | wxOGLConstraintTypes->Append(gyCONSTRAINT_ALIGNED_TOP, | |
9e053640 | 84 | new wxOGLConstraintType(gyCONSTRAINT_ALIGNED_TOP, wxT("Top-aligned"), wxT("aligned to the top of"))); |
1fc25a89 JS |
85 | |
86 | wxOGLConstraintTypes->Append(gyCONSTRAINT_ALIGNED_BOTTOM, | |
9e053640 | 87 | new wxOGLConstraintType(gyCONSTRAINT_ALIGNED_BOTTOM, wxT("Bottom-aligned"), wxT("aligned to the bottom of"))); |
1fc25a89 JS |
88 | |
89 | wxOGLConstraintTypes->Append(gyCONSTRAINT_ALIGNED_LEFT, | |
9e053640 | 90 | new wxOGLConstraintType(gyCONSTRAINT_ALIGNED_LEFT, wxT("Left-aligned"), wxT("aligned to the left of"))); |
1fc25a89 JS |
91 | |
92 | wxOGLConstraintTypes->Append(gyCONSTRAINT_ALIGNED_RIGHT, | |
9e053640 | 93 | new wxOGLConstraintType(gyCONSTRAINT_ALIGNED_RIGHT, wxT("Right-aligned"), wxT("aligned to the right of"))); |
1fc25a89 JS |
94 | |
95 | // Mid-alignment | |
96 | wxOGLConstraintTypes->Append(gyCONSTRAINT_MIDALIGNED_TOP, | |
9e053640 | 97 | new wxOGLConstraintType(gyCONSTRAINT_MIDALIGNED_TOP, wxT("Top-midaligned"), wxT("centred on the top of"))); |
1fc25a89 JS |
98 | |
99 | wxOGLConstraintTypes->Append(gyCONSTRAINT_MIDALIGNED_BOTTOM, | |
9e053640 | 100 | new wxOGLConstraintType(gyCONSTRAINT_MIDALIGNED_BOTTOM, wxT("Bottom-midaligned"), wxT("centred on the bottom of"))); |
1fc25a89 JS |
101 | |
102 | wxOGLConstraintTypes->Append(gyCONSTRAINT_MIDALIGNED_LEFT, | |
9e053640 | 103 | new wxOGLConstraintType(gyCONSTRAINT_MIDALIGNED_LEFT, wxT("Left-midaligned"), wxT("centred on the left of"))); |
1fc25a89 JS |
104 | |
105 | wxOGLConstraintTypes->Append(gyCONSTRAINT_MIDALIGNED_RIGHT, | |
9e053640 | 106 | new wxOGLConstraintType(gyCONSTRAINT_MIDALIGNED_RIGHT, wxT("Right-midaligned"), wxT("centred on the right of"))); |
1fc25a89 JS |
107 | } |
108 | ||
109 | void OGLCleanUpConstraintTypes() | |
110 | { | |
111 | if (!wxOGLConstraintTypes) | |
112 | return; | |
113 | ||
b9ac87bc | 114 | wxNode* node = wxOGLConstraintTypes->GetFirst(); |
1fc25a89 JS |
115 | while (node) |
116 | { | |
b9ac87bc | 117 | wxOGLConstraintType* ct = (wxOGLConstraintType*) node->GetData(); |
1fc25a89 | 118 | delete ct; |
b9ac87bc | 119 | node = node->GetNext(); |
1fc25a89 JS |
120 | } |
121 | delete wxOGLConstraintTypes; | |
122 | wxOGLConstraintTypes = NULL; | |
123 | } | |
124 | ||
125 | /* | |
126 | * Constraint Stuff | |
127 | * | |
128 | */ | |
129 | ||
130 | IMPLEMENT_DYNAMIC_CLASS(wxOGLConstraint, wxObject) | |
131 | ||
132 | wxOGLConstraint::wxOGLConstraint(int type, wxShape *constraining, wxList& constrained) | |
133 | { | |
134 | m_xSpacing = 0.0; | |
135 | m_ySpacing = 0.0; | |
136 | ||
137 | m_constraintType = type; | |
138 | m_constrainingObject = constraining; | |
139 | ||
140 | m_constraintId = 0; | |
9e053640 | 141 | m_constraintName = wxT("noname"); |
1fc25a89 | 142 | |
b9ac87bc | 143 | wxNode *node = constrained.GetFirst(); |
1fc25a89 JS |
144 | while (node) |
145 | { | |
b9ac87bc RD |
146 | m_constrainedObjects.Append(node->GetData()); |
147 | node = node->GetNext(); | |
1fc25a89 JS |
148 | } |
149 | } | |
150 | ||
151 | wxOGLConstraint::~wxOGLConstraint() | |
152 | { | |
153 | } | |
154 | ||
155 | bool wxOGLConstraint::Equals(double a, double b) | |
156 | { | |
157 | double marg = 0.5; | |
158 | ||
159 | bool eq = ((b <= a + marg) && (b >= a - marg)); | |
160 | return eq; | |
161 | } | |
162 | ||
2ba06d5a | 163 | // Return true if anything changed |
1fc25a89 JS |
164 | bool wxOGLConstraint::Evaluate() |
165 | { | |
166 | double maxWidth, maxHeight, minWidth, minHeight, x, y; | |
167 | m_constrainingObject->GetBoundingBoxMax(&maxWidth, &maxHeight); | |
168 | m_constrainingObject->GetBoundingBoxMin(&minWidth, &minHeight); | |
169 | x = m_constrainingObject->GetX(); | |
170 | y = m_constrainingObject->GetY(); | |
171 | ||
172 | wxClientDC dc(m_constrainingObject->GetCanvas()); | |
173 | m_constrainingObject->GetCanvas()->PrepareDC(dc); | |
174 | ||
175 | switch (m_constraintType) | |
176 | { | |
177 | case gyCONSTRAINT_CENTRED_VERTICALLY: | |
178 | { | |
b9ac87bc | 179 | int n = m_constrainedObjects.GetCount(); |
1fc25a89 | 180 | double totalObjectHeight = 0.0; |
b9ac87bc | 181 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
182 | while (node) |
183 | { | |
b9ac87bc | 184 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
185 | |
186 | double width2, height2; | |
187 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
188 | totalObjectHeight += height2; | |
b9ac87bc | 189 | node = node->GetNext(); |
1fc25a89 JS |
190 | } |
191 | double startY; | |
192 | double spacingY; | |
193 | // Check if within the constraining object... | |
194 | if ((totalObjectHeight + (n + 1)*m_ySpacing) <= minHeight) | |
195 | { | |
196 | spacingY = (double)((minHeight - totalObjectHeight)/(n + 1)); | |
197 | startY = (double)(y - (minHeight/2.0)); | |
198 | } | |
199 | // Otherwise, use default spacing | |
200 | else | |
201 | { | |
202 | spacingY = m_ySpacing; | |
203 | startY = (double)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0)); | |
204 | } | |
205 | ||
206 | // Now position the objects | |
2ba06d5a | 207 | bool changed = false; |
b9ac87bc | 208 | node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
209 | while (node) |
210 | { | |
b9ac87bc | 211 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
212 | double width2, height2; |
213 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
214 | startY += (double)(spacingY + (height2/2.0)); | |
215 | if (!Equals(startY, constrainedObject->GetY())) | |
216 | { | |
2ba06d5a WS |
217 | constrainedObject->Move(dc, constrainedObject->GetX(), startY, false); |
218 | changed = true; | |
1fc25a89 JS |
219 | } |
220 | startY += (double)(height2/2.0); | |
b9ac87bc | 221 | node = node->GetNext(); |
1fc25a89 JS |
222 | } |
223 | return changed; | |
224 | } | |
225 | case gyCONSTRAINT_CENTRED_HORIZONTALLY: | |
226 | { | |
b9ac87bc | 227 | int n = m_constrainedObjects.GetCount(); |
1fc25a89 | 228 | double totalObjectWidth = 0.0; |
b9ac87bc | 229 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
230 | while (node) |
231 | { | |
b9ac87bc | 232 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
233 | |
234 | double width2, height2; | |
235 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
236 | totalObjectWidth += width2; | |
b9ac87bc | 237 | node = node->GetNext(); |
1fc25a89 JS |
238 | } |
239 | double startX; | |
240 | double spacingX; | |
241 | // Check if within the constraining object... | |
242 | if ((totalObjectWidth + (n + 1)*m_xSpacing) <= minWidth) | |
243 | { | |
244 | spacingX = (double)((minWidth - totalObjectWidth)/(n + 1)); | |
245 | startX = (double)(x - (minWidth/2.0)); | |
246 | } | |
247 | // Otherwise, use default spacing | |
248 | else | |
249 | { | |
250 | spacingX = m_xSpacing; | |
251 | startX = (double)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0)); | |
252 | } | |
253 | ||
254 | // Now position the objects | |
2ba06d5a | 255 | bool changed = false; |
b9ac87bc | 256 | node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
257 | while (node) |
258 | { | |
b9ac87bc | 259 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
260 | double width2, height2; |
261 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
262 | startX += (double)(spacingX + (width2/2.0)); | |
263 | if (!Equals(startX, constrainedObject->GetX())) | |
264 | { | |
2ba06d5a WS |
265 | constrainedObject->Move(dc, startX, constrainedObject->GetY(), false); |
266 | changed = true; | |
1fc25a89 JS |
267 | } |
268 | startX += (double)(width2/2.0); | |
b9ac87bc | 269 | node = node->GetNext(); |
1fc25a89 JS |
270 | } |
271 | return changed; | |
272 | } | |
273 | case gyCONSTRAINT_CENTRED_BOTH: | |
274 | { | |
b9ac87bc | 275 | int n = m_constrainedObjects.GetCount(); |
1fc25a89 JS |
276 | double totalObjectWidth = 0.0; |
277 | double totalObjectHeight = 0.0; | |
b9ac87bc | 278 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
279 | while (node) |
280 | { | |
b9ac87bc | 281 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
282 | |
283 | double width2, height2; | |
284 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
285 | totalObjectWidth += width2; | |
286 | totalObjectHeight += height2; | |
b9ac87bc | 287 | node = node->GetNext(); |
1fc25a89 JS |
288 | } |
289 | double startX; | |
290 | double spacingX; | |
291 | double startY; | |
292 | double spacingY; | |
293 | ||
294 | // Check if within the constraining object... | |
295 | if ((totalObjectWidth + (n + 1)*m_xSpacing) <= minWidth) | |
296 | { | |
297 | spacingX = (double)((minWidth - totalObjectWidth)/(n + 1)); | |
298 | startX = (double)(x - (minWidth/2.0)); | |
299 | } | |
300 | // Otherwise, use default spacing | |
301 | else | |
302 | { | |
303 | spacingX = m_xSpacing; | |
304 | startX = (double)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0)); | |
305 | } | |
306 | ||
307 | // Check if within the constraining object... | |
308 | if ((totalObjectHeight + (n + 1)*m_ySpacing) <= minHeight) | |
309 | { | |
310 | spacingY = (double)((minHeight - totalObjectHeight)/(n + 1)); | |
311 | startY = (double)(y - (minHeight/2.0)); | |
312 | } | |
313 | // Otherwise, use default spacing | |
314 | else | |
315 | { | |
316 | spacingY = m_ySpacing; | |
317 | startY = (double)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0)); | |
318 | } | |
319 | ||
320 | // Now position the objects | |
2ba06d5a | 321 | bool changed = false; |
b9ac87bc | 322 | node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
323 | while (node) |
324 | { | |
b9ac87bc | 325 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
326 | double width2, height2; |
327 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
328 | startX += (double)(spacingX + (width2/2.0)); | |
329 | startY += (double)(spacingY + (height2/2.0)); | |
330 | ||
331 | if ((!Equals(startX, constrainedObject->GetX())) || (!Equals(startY, constrainedObject->GetY()))) | |
2ba06d5a WS |
332 | { |
333 | constrainedObject->Move(dc, startX, startY, false); | |
334 | changed = true; | |
335 | } | |
1fc25a89 JS |
336 | |
337 | startX += (double)(width2/2.0); | |
338 | startY += (double)(height2/2.0); | |
339 | ||
b9ac87bc | 340 | node = node->GetNext(); |
1fc25a89 JS |
341 | } |
342 | return changed; | |
343 | } | |
344 | case gyCONSTRAINT_LEFT_OF: | |
345 | { | |
2ba06d5a | 346 | bool changed = false; |
1fc25a89 | 347 | |
b9ac87bc | 348 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
349 | while (node) |
350 | { | |
b9ac87bc | 351 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
352 | |
353 | double width2, height2; | |
354 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
355 | ||
356 | double x3 = (double)(x - (minWidth/2.0) - (width2/2.0) - m_xSpacing); | |
357 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
358 | { |
359 | changed = true; | |
360 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
361 | } | |
1fc25a89 | 362 | |
b9ac87bc | 363 | node = node->GetNext(); |
1fc25a89 JS |
364 | } |
365 | return changed; | |
366 | } | |
367 | case gyCONSTRAINT_RIGHT_OF: | |
368 | { | |
2ba06d5a | 369 | bool changed = false; |
1fc25a89 | 370 | |
b9ac87bc | 371 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
372 | while (node) |
373 | { | |
b9ac87bc | 374 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
375 | |
376 | double width2, height2; | |
377 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
378 | ||
379 | double x3 = (double)(x + (minWidth/2.0) + (width2/2.0) + m_xSpacing); | |
380 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
381 | { |
382 | changed = true; | |
383 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
384 | } | |
1fc25a89 | 385 | |
b9ac87bc | 386 | node = node->GetNext(); |
1fc25a89 JS |
387 | } |
388 | return changed; | |
1fc25a89 JS |
389 | } |
390 | case gyCONSTRAINT_ABOVE: | |
391 | { | |
2ba06d5a | 392 | bool changed = false; |
1fc25a89 | 393 | |
b9ac87bc | 394 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
395 | while (node) |
396 | { | |
b9ac87bc | 397 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
398 | |
399 | double width2, height2; | |
400 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
401 | ||
402 | double y3 = (double)(y - (minHeight/2.0) - (height2/2.0) - m_ySpacing); | |
403 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
404 | { |
405 | changed = true; | |
406 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
407 | } | |
1fc25a89 | 408 | |
b9ac87bc | 409 | node = node->GetNext(); |
1fc25a89 JS |
410 | } |
411 | return changed; | |
412 | } | |
413 | case gyCONSTRAINT_BELOW: | |
414 | { | |
2ba06d5a | 415 | bool changed = false; |
1fc25a89 | 416 | |
b9ac87bc | 417 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
418 | while (node) |
419 | { | |
b9ac87bc | 420 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
421 | |
422 | double width2, height2; | |
423 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
424 | ||
425 | double y3 = (double)(y + (minHeight/2.0) + (height2/2.0) + m_ySpacing); | |
426 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
427 | { |
428 | changed = true; | |
429 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
430 | } | |
1fc25a89 | 431 | |
b9ac87bc | 432 | node = node->GetNext(); |
1fc25a89 JS |
433 | } |
434 | return changed; | |
435 | } | |
436 | case gyCONSTRAINT_ALIGNED_LEFT: | |
437 | { | |
2ba06d5a | 438 | bool changed = false; |
1fc25a89 | 439 | |
b9ac87bc | 440 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
441 | while (node) |
442 | { | |
b9ac87bc | 443 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
444 | |
445 | double width2, height2; | |
446 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
447 | ||
448 | double x3 = (double)(x - (minWidth/2.0) + (width2/2.0) + m_xSpacing); | |
449 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
450 | { |
451 | changed = true; | |
452 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
453 | } | |
1fc25a89 | 454 | |
b9ac87bc | 455 | node = node->GetNext(); |
1fc25a89 JS |
456 | } |
457 | return changed; | |
458 | } | |
459 | case gyCONSTRAINT_ALIGNED_RIGHT: | |
460 | { | |
2ba06d5a | 461 | bool changed = false; |
1fc25a89 | 462 | |
b9ac87bc | 463 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
464 | while (node) |
465 | { | |
b9ac87bc | 466 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
467 | |
468 | double width2, height2; | |
469 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
470 | ||
471 | double x3 = (double)(x + (minWidth/2.0) - (width2/2.0) - m_xSpacing); | |
472 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
473 | { |
474 | changed = true; | |
475 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
476 | } | |
1fc25a89 | 477 | |
b9ac87bc | 478 | node = node->GetNext(); |
1fc25a89 JS |
479 | } |
480 | return changed; | |
1484b5cc VS |
481 | #if 0 |
482 | // two returned values ? | |
2ba06d5a | 483 | return false; |
1484b5cc | 484 | #endif |
1fc25a89 JS |
485 | } |
486 | case gyCONSTRAINT_ALIGNED_TOP: | |
487 | { | |
2ba06d5a | 488 | bool changed = false; |
1fc25a89 | 489 | |
b9ac87bc | 490 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
491 | while (node) |
492 | { | |
b9ac87bc | 493 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
494 | |
495 | double width2, height2; | |
496 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
497 | ||
498 | double y3 = (double)(y - (minHeight/2.0) + (height2/2.0) + m_ySpacing); | |
499 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
500 | { |
501 | changed = true; | |
502 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
503 | } | |
1fc25a89 | 504 | |
b9ac87bc | 505 | node = node->GetNext(); |
1fc25a89 JS |
506 | } |
507 | return changed; | |
508 | } | |
509 | case gyCONSTRAINT_ALIGNED_BOTTOM: | |
510 | { | |
2ba06d5a | 511 | bool changed = false; |
1fc25a89 | 512 | |
b9ac87bc | 513 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
514 | while (node) |
515 | { | |
b9ac87bc | 516 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
517 | |
518 | double width2, height2; | |
519 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
520 | ||
521 | double y3 = (double)(y + (minHeight/2.0) - (height2/2.0) - m_ySpacing); | |
522 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
523 | { |
524 | changed = true; | |
525 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
526 | } | |
1fc25a89 | 527 | |
b9ac87bc | 528 | node = node->GetNext(); |
1fc25a89 JS |
529 | } |
530 | return changed; | |
531 | } | |
532 | case gyCONSTRAINT_MIDALIGNED_LEFT: | |
533 | { | |
2ba06d5a | 534 | bool changed = false; |
1fc25a89 | 535 | |
b9ac87bc | 536 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
537 | while (node) |
538 | { | |
b9ac87bc | 539 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
540 | |
541 | double x3 = (double)(x - (minWidth/2.0)); | |
542 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
543 | { |
544 | changed = true; | |
545 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
546 | } | |
1fc25a89 | 547 | |
b9ac87bc | 548 | node = node->GetNext(); |
1fc25a89 JS |
549 | } |
550 | return changed; | |
551 | } | |
552 | case gyCONSTRAINT_MIDALIGNED_RIGHT: | |
553 | { | |
2ba06d5a | 554 | bool changed = false; |
1fc25a89 | 555 | |
b9ac87bc | 556 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
557 | while (node) |
558 | { | |
b9ac87bc | 559 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
560 | |
561 | double x3 = (double)(x + (minWidth/2.0)); | |
562 | if (!Equals(x3, constrainedObject->GetX())) | |
2ba06d5a WS |
563 | { |
564 | changed = true; | |
565 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); | |
566 | } | |
1fc25a89 | 567 | |
b9ac87bc | 568 | node = node->GetNext(); |
1fc25a89 JS |
569 | } |
570 | return changed; | |
1484b5cc VS |
571 | #if 0 |
572 | // two returned values ? | |
2ba06d5a | 573 | return false; |
1484b5cc | 574 | #endif |
1fc25a89 JS |
575 | } |
576 | case gyCONSTRAINT_MIDALIGNED_TOP: | |
577 | { | |
2ba06d5a | 578 | bool changed = false; |
1fc25a89 | 579 | |
b9ac87bc | 580 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
581 | while (node) |
582 | { | |
b9ac87bc | 583 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
584 | |
585 | double y3 = (double)(y - (minHeight/2.0)); | |
586 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
587 | { |
588 | changed = true; | |
589 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
590 | } | |
1fc25a89 | 591 | |
b9ac87bc | 592 | node = node->GetNext(); |
1fc25a89 JS |
593 | } |
594 | return changed; | |
595 | } | |
596 | case gyCONSTRAINT_MIDALIGNED_BOTTOM: | |
597 | { | |
2ba06d5a | 598 | bool changed = false; |
1fc25a89 | 599 | |
b9ac87bc | 600 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
601 | while (node) |
602 | { | |
b9ac87bc | 603 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
604 | |
605 | double y3 = (double)(y + (minHeight/2.0)); | |
606 | if (!Equals(y3, constrainedObject->GetY())) | |
2ba06d5a WS |
607 | { |
608 | changed = true; | |
609 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); | |
610 | } | |
1fc25a89 | 611 | |
b9ac87bc | 612 | node = node->GetNext(); |
1fc25a89 JS |
613 | } |
614 | return changed; | |
615 | } | |
1484b5cc VS |
616 | #if 0 |
617 | // default value handled in main function body | |
1fc25a89 | 618 | default: |
2ba06d5a | 619 | return false; |
1484b5cc | 620 | #endif |
1fc25a89 | 621 | } |
2ba06d5a | 622 | return false; |
1fc25a89 JS |
623 | } |
624 |