]>
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 | |
9 | // Licence: wxWindows licence | |
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 | ||
163 | // Return TRUE if anything changed | |
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 | |
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 | { | |
217 | constrainedObject->Move(dc, constrainedObject->GetX(), startY, FALSE); | |
218 | changed = TRUE; | |
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 | |
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 | { | |
265 | constrainedObject->Move(dc, startX, constrainedObject->GetY(), FALSE); | |
266 | changed = TRUE; | |
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 | |
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()))) | |
332 | { | |
333 | constrainedObject->Move(dc, startX, startY, FALSE); | |
334 | changed = TRUE; | |
335 | } | |
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 | { | |
346 | bool changed = FALSE; | |
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())) | |
358 | { | |
359 | changed = TRUE; | |
360 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
361 | } | |
362 | ||
b9ac87bc | 363 | node = node->GetNext(); |
1fc25a89 JS |
364 | } |
365 | return changed; | |
366 | } | |
367 | case gyCONSTRAINT_RIGHT_OF: | |
368 | { | |
369 | bool changed = FALSE; | |
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())) | |
381 | { | |
382 | changed = TRUE; | |
383 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
384 | } | |
385 | ||
b9ac87bc | 386 | node = node->GetNext(); |
1fc25a89 JS |
387 | } |
388 | return changed; | |
389 | ||
390 | return FALSE; | |
391 | } | |
392 | case gyCONSTRAINT_ABOVE: | |
393 | { | |
394 | bool changed = FALSE; | |
395 | ||
b9ac87bc | 396 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
397 | while (node) |
398 | { | |
b9ac87bc | 399 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
400 | |
401 | double width2, height2; | |
402 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
403 | ||
404 | double y3 = (double)(y - (minHeight/2.0) - (height2/2.0) - m_ySpacing); | |
405 | if (!Equals(y3, constrainedObject->GetY())) | |
406 | { | |
407 | changed = TRUE; | |
408 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
409 | } | |
410 | ||
b9ac87bc | 411 | node = node->GetNext(); |
1fc25a89 JS |
412 | } |
413 | return changed; | |
414 | } | |
415 | case gyCONSTRAINT_BELOW: | |
416 | { | |
417 | bool changed = FALSE; | |
418 | ||
b9ac87bc | 419 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
420 | while (node) |
421 | { | |
b9ac87bc | 422 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
423 | |
424 | double width2, height2; | |
425 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
426 | ||
427 | double y3 = (double)(y + (minHeight/2.0) + (height2/2.0) + m_ySpacing); | |
428 | if (!Equals(y3, constrainedObject->GetY())) | |
429 | { | |
430 | changed = TRUE; | |
431 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
432 | } | |
433 | ||
b9ac87bc | 434 | node = node->GetNext(); |
1fc25a89 JS |
435 | } |
436 | return changed; | |
437 | } | |
438 | case gyCONSTRAINT_ALIGNED_LEFT: | |
439 | { | |
440 | bool changed = FALSE; | |
441 | ||
b9ac87bc | 442 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
443 | while (node) |
444 | { | |
b9ac87bc | 445 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
446 | |
447 | double width2, height2; | |
448 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
449 | ||
450 | double x3 = (double)(x - (minWidth/2.0) + (width2/2.0) + m_xSpacing); | |
451 | if (!Equals(x3, constrainedObject->GetX())) | |
452 | { | |
453 | changed = TRUE; | |
454 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
455 | } | |
456 | ||
b9ac87bc | 457 | node = node->GetNext(); |
1fc25a89 JS |
458 | } |
459 | return changed; | |
460 | } | |
461 | case gyCONSTRAINT_ALIGNED_RIGHT: | |
462 | { | |
463 | bool changed = FALSE; | |
464 | ||
b9ac87bc | 465 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
466 | while (node) |
467 | { | |
b9ac87bc | 468 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
469 | |
470 | double width2, height2; | |
471 | constrainedObject->GetBoundingBoxMax(&width2, &height2); | |
472 | ||
473 | double x3 = (double)(x + (minWidth/2.0) - (width2/2.0) - m_xSpacing); | |
474 | if (!Equals(x3, constrainedObject->GetX())) | |
475 | { | |
476 | changed = TRUE; | |
477 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
478 | } | |
479 | ||
b9ac87bc | 480 | node = node->GetNext(); |
1fc25a89 JS |
481 | } |
482 | return changed; | |
483 | ||
484 | return FALSE; | |
485 | } | |
486 | case gyCONSTRAINT_ALIGNED_TOP: | |
487 | { | |
488 | bool changed = FALSE; | |
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())) | |
500 | { | |
501 | changed = TRUE; | |
502 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
503 | } | |
504 | ||
b9ac87bc | 505 | node = node->GetNext(); |
1fc25a89 JS |
506 | } |
507 | return changed; | |
508 | } | |
509 | case gyCONSTRAINT_ALIGNED_BOTTOM: | |
510 | { | |
511 | bool changed = FALSE; | |
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())) | |
523 | { | |
524 | changed = TRUE; | |
525 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
526 | } | |
527 | ||
b9ac87bc | 528 | node = node->GetNext(); |
1fc25a89 JS |
529 | } |
530 | return changed; | |
531 | } | |
532 | case gyCONSTRAINT_MIDALIGNED_LEFT: | |
533 | { | |
534 | bool changed = FALSE; | |
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())) | |
543 | { | |
544 | changed = TRUE; | |
545 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
546 | } | |
547 | ||
b9ac87bc | 548 | node = node->GetNext(); |
1fc25a89 JS |
549 | } |
550 | return changed; | |
551 | } | |
552 | case gyCONSTRAINT_MIDALIGNED_RIGHT: | |
553 | { | |
554 | bool changed = FALSE; | |
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())) | |
563 | { | |
564 | changed = TRUE; | |
565 | constrainedObject->Move(dc, x3, constrainedObject->GetY(), FALSE); | |
566 | } | |
567 | ||
b9ac87bc | 568 | node = node->GetNext(); |
1fc25a89 JS |
569 | } |
570 | return changed; | |
571 | ||
572 | return FALSE; | |
573 | } | |
574 | case gyCONSTRAINT_MIDALIGNED_TOP: | |
575 | { | |
576 | bool changed = FALSE; | |
577 | ||
b9ac87bc | 578 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
579 | while (node) |
580 | { | |
b9ac87bc | 581 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
582 | |
583 | double y3 = (double)(y - (minHeight/2.0)); | |
584 | if (!Equals(y3, constrainedObject->GetY())) | |
585 | { | |
586 | changed = TRUE; | |
587 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
588 | } | |
589 | ||
b9ac87bc | 590 | node = node->GetNext(); |
1fc25a89 JS |
591 | } |
592 | return changed; | |
593 | } | |
594 | case gyCONSTRAINT_MIDALIGNED_BOTTOM: | |
595 | { | |
596 | bool changed = FALSE; | |
597 | ||
b9ac87bc | 598 | wxNode *node = m_constrainedObjects.GetFirst(); |
1fc25a89 JS |
599 | while (node) |
600 | { | |
b9ac87bc | 601 | wxShape *constrainedObject = (wxShape *)node->GetData(); |
1fc25a89 JS |
602 | |
603 | double y3 = (double)(y + (minHeight/2.0)); | |
604 | if (!Equals(y3, constrainedObject->GetY())) | |
605 | { | |
606 | changed = TRUE; | |
607 | constrainedObject->Move(dc, constrainedObject->GetX(), y3, FALSE); | |
608 | } | |
609 | ||
b9ac87bc | 610 | node = node->GetNext(); |
1fc25a89 JS |
611 | } |
612 | return changed; | |
613 | } | |
614 | ||
615 | default: | |
616 | return FALSE; | |
617 | } | |
618 | return FALSE; | |
619 | } | |
620 |