]> git.saurik.com Git - wxWidgets.git/blob - src/common/layout.cpp
No changes, just use wxRecursionGuard instead of manual boolean flag.
[wxWidgets.git] / src / common / layout.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/layout.cpp
3 // Purpose: Constraint layout system classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // =============================================================================
12 // declarations
13 // =============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #if wxUSE_CONSTRAINTS
27
28 #include "wx/layout.h"
29
30 #ifndef WX_PRECOMP
31 #include "wx/window.h"
32 #include "wx/utils.h"
33 #include "wx/dialog.h"
34 #include "wx/msgdlg.h"
35 #include "wx/intl.h"
36 #endif
37
38
39 IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
40 IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
41
42
43 inline void wxGetAsIs(wxWindowBase* win, int* w, int* h)
44 {
45 #if 1
46 // The old way. Works for me.
47 win->GetSize(w, h);
48 #endif
49
50 #if 0
51 // Vadim's change. Breaks wxPython's LayoutAnchors
52 win->GetBestSize(w, h);
53 #endif
54
55 #if 0
56 // Proposed compromise. Doesn't work.
57 int sw, sh, bw, bh;
58 win->GetSize(&sw, &sh);
59 win->GetBestSize(&bw, &bh);
60 if (w)
61 *w = wxMax(sw, bw);
62 if (h)
63 *h = wxMax(sh, bh);
64 #endif
65 }
66
67
68 wxIndividualLayoutConstraint::wxIndividualLayoutConstraint()
69 {
70 myEdge = wxTop;
71 relationship = wxUnconstrained;
72 margin = 0;
73 value = 0;
74 percent = 0;
75 otherEdge = wxTop;
76 done = false;
77 otherWin = NULL;
78 }
79
80 void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val, int marg)
81 {
82 if (rel == wxSameAs)
83 {
84 // If Set is called by the user with wxSameAs then call SameAs to do
85 // it since it will actually use wxPercent instead.
86 SameAs(otherW, otherE, marg);
87 return;
88 }
89
90 relationship = rel;
91 otherWin = otherW;
92 otherEdge = otherE;
93
94 if ( rel == wxPercentOf )
95 {
96 percent = val;
97 }
98 else
99 {
100 value = val;
101 }
102
103 margin = marg;
104 }
105
106 void wxIndividualLayoutConstraint::LeftOf(wxWindowBase *sibling, int marg)
107 {
108 Set(wxLeftOf, sibling, wxLeft, 0, marg);
109 }
110
111 void wxIndividualLayoutConstraint::RightOf(wxWindowBase *sibling, int marg)
112 {
113 Set(wxRightOf, sibling, wxRight, 0, marg);
114 }
115
116 void wxIndividualLayoutConstraint::Above(wxWindowBase *sibling, int marg)
117 {
118 Set(wxAbove, sibling, wxTop, 0, marg);
119 }
120
121 void wxIndividualLayoutConstraint::Below(wxWindowBase *sibling, int marg)
122 {
123 Set(wxBelow, sibling, wxBottom, 0, marg);
124 }
125
126 //
127 // 'Same edge' alignment
128 //
129 void wxIndividualLayoutConstraint::SameAs(wxWindowBase *otherW, wxEdge edge, int marg)
130 {
131 Set(wxPercentOf, otherW, edge, 100, marg);
132 }
133
134 // The edge is a percentage of the other window's edge
135 void wxIndividualLayoutConstraint::PercentOf(wxWindowBase *otherW, wxEdge wh, int per)
136 {
137 Set(wxPercentOf, otherW, wh, per);
138 }
139
140 //
141 // Edge has absolute value
142 //
143 void wxIndividualLayoutConstraint::Absolute(int val)
144 {
145 value = val;
146 relationship = wxAbsolute;
147 }
148
149 // Reset constraint if it mentions otherWin
150 bool wxIndividualLayoutConstraint::ResetIfWin(wxWindowBase *otherW)
151 {
152 if (otherW == otherWin)
153 {
154 myEdge = wxTop;
155 relationship = wxAsIs;
156 margin = 0;
157 value = 0;
158 percent = 0;
159 otherEdge = wxTop;
160 otherWin = NULL;
161 return true;
162 }
163
164 return false;
165 }
166
167 // Try to satisfy constraint
168 bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win)
169 {
170 if (relationship == wxAbsolute)
171 {
172 done = true;
173 return true;
174 }
175
176 switch (myEdge)
177 {
178 case wxLeft:
179 {
180 switch (relationship)
181 {
182 case wxLeftOf:
183 {
184 // We can know this edge if: otherWin is win's
185 // parent, or otherWin has a satisfied constraint,
186 // or otherWin has no constraint.
187 int edgePos = GetEdge(otherEdge, win, otherWin);
188 if (edgePos != -1)
189 {
190 value = edgePos - margin;
191 done = true;
192 return true;
193 }
194 else
195 return false;
196 }
197 case wxRightOf:
198 {
199 int edgePos = GetEdge(otherEdge, win, otherWin);
200 if (edgePos != -1)
201 {
202 value = edgePos + margin;
203 done = true;
204 return true;
205 }
206 else
207 return false;
208 }
209 case wxPercentOf:
210 {
211 int edgePos = GetEdge(otherEdge, win, otherWin);
212 if (edgePos != -1)
213 {
214 value = (int)(edgePos*(((float)percent)*0.01) + margin);
215 done = true;
216 return true;
217 }
218 else
219 return false;
220 }
221 case wxUnconstrained:
222 {
223 // We know the left-hand edge position if we know
224 // the right-hand edge and we know the width; OR if
225 // we know the centre and the width.
226 if (constraints->right.GetDone() && constraints->width.GetDone())
227 {
228 value = (constraints->right.GetValue() - constraints->width.GetValue() + margin);
229 done = true;
230 return true;
231 }
232 else if (constraints->centreX.GetDone() && constraints->width.GetDone())
233 {
234 value = (int)(constraints->centreX.GetValue() - (constraints->width.GetValue()/2) + margin);
235 done = true;
236 return true;
237 }
238 else
239 return false;
240 }
241 case wxAsIs:
242 {
243 int y;
244 win->GetPosition(&value, &y);
245 done = true;
246 return true;
247 }
248 default:
249 break;
250 }
251 break;
252 }
253 case wxRight:
254 {
255 switch (relationship)
256 {
257 case wxLeftOf:
258 {
259 // We can know this edge if: otherWin is win's
260 // parent, or otherWin has a satisfied constraint,
261 // or otherWin has no constraint.
262 int edgePos = GetEdge(otherEdge, win, otherWin);
263 if (edgePos != -1)
264 {
265 value = edgePos - margin;
266 done = true;
267 return true;
268 }
269 else
270 return false;
271 }
272 case wxRightOf:
273 {
274 int edgePos = GetEdge(otherEdge, win, otherWin);
275 if (edgePos != -1)
276 {
277 value = edgePos + margin;
278 done = true;
279 return true;
280 }
281 else
282 return false;
283 }
284 case wxPercentOf:
285 {
286 int edgePos = GetEdge(otherEdge, win, otherWin);
287 if (edgePos != -1)
288 {
289 value = (int)(edgePos*(((float)percent)*0.01) - margin);
290 done = true;
291 return true;
292 }
293 else
294 return false;
295 }
296 case wxUnconstrained:
297 {
298 // We know the right-hand edge position if we know the
299 // left-hand edge and we know the width, OR if we know the
300 // centre edge and the width.
301 if (constraints->left.GetDone() && constraints->width.GetDone())
302 {
303 value = (constraints->left.GetValue() + constraints->width.GetValue() - margin);
304 done = true;
305 return true;
306 }
307 else if (constraints->centreX.GetDone() && constraints->width.GetDone())
308 {
309 value = (int)(constraints->centreX.GetValue() + (constraints->width.GetValue()/2) - margin);
310 done = true;
311 return true;
312 }
313 else
314 return false;
315 }
316 case wxAsIs:
317 {
318 int x, y;
319 int w, h;
320 wxGetAsIs(win, &w, &h);
321 win->GetPosition(&x, &y);
322 value = x + w;
323 done = true;
324 return true;
325 }
326 default:
327 break;
328 }
329 break;
330 }
331 case wxTop:
332 {
333 switch (relationship)
334 {
335 case wxAbove:
336 {
337 // We can know this edge if: otherWin is win's
338 // parent, or otherWin has a satisfied constraint,
339 // or otherWin has no constraint.
340 int edgePos = GetEdge(otherEdge, win, otherWin);
341 if (edgePos != -1)
342 {
343 value = edgePos - margin;
344 done = true;
345 return true;
346 }
347 else
348 return false;
349 }
350 case wxBelow:
351 {
352 int edgePos = GetEdge(otherEdge, win, otherWin);
353 if (edgePos != -1)
354 {
355 value = edgePos + margin;
356 done = true;
357 return true;
358 }
359 else
360 return false;
361 }
362 case wxPercentOf:
363 {
364 int edgePos = GetEdge(otherEdge, win, otherWin);
365 if (edgePos != -1)
366 {
367 value = (int)(edgePos*(((float)percent)*0.01) + margin);
368 done = true;
369 return true;
370 }
371 else
372 return false;
373 }
374 case wxUnconstrained:
375 {
376 // We know the top edge position if we know the bottom edge
377 // and we know the height; OR if we know the centre edge and
378 // the height.
379 if (constraints->bottom.GetDone() && constraints->height.GetDone())
380 {
381 value = (constraints->bottom.GetValue() - constraints->height.GetValue() + margin);
382 done = true;
383 return true;
384 }
385 else if (constraints->centreY.GetDone() && constraints->height.GetDone())
386 {
387 value = (constraints->centreY.GetValue() - (constraints->height.GetValue()/2) + margin);
388 done = true;
389 return true;
390 }
391 else
392 return false;
393 }
394 case wxAsIs:
395 {
396 int x;
397 win->GetPosition(&x, &value);
398 done = true;
399 return true;
400 }
401 default:
402 break;
403 }
404 break;
405 }
406 case wxBottom:
407 {
408 switch (relationship)
409 {
410 case wxAbove:
411 {
412 // We can know this edge if: otherWin is win's parent,
413 // or otherWin has a satisfied constraint, or
414 // otherWin has no constraint.
415 int edgePos = GetEdge(otherEdge, win, otherWin);
416 if (edgePos != -1)
417 {
418 value = edgePos + margin;
419 done = true;
420 return true;
421 }
422 else
423 return false;
424 }
425 case wxBelow:
426 {
427 int edgePos = GetEdge(otherEdge, win, otherWin);
428 if (edgePos != -1)
429 {
430 value = edgePos - margin;
431 done = true;
432 return true;
433 }
434 else
435 return false;
436 }
437 case wxPercentOf:
438 {
439 int edgePos = GetEdge(otherEdge, win, otherWin);
440 if (edgePos != -1)
441 {
442 value = (int)(edgePos*(((float)percent)*0.01) - margin);
443 done = true;
444 return true;
445 }
446 else
447 return false;
448 }
449 case wxUnconstrained:
450 {
451 // We know the bottom edge position if we know the top edge
452 // and we know the height; OR if we know the centre edge and
453 // the height.
454 if (constraints->top.GetDone() && constraints->height.GetDone())
455 {
456 value = (constraints->top.GetValue() + constraints->height.GetValue() - margin);
457 done = true;
458 return true;
459 }
460 else if (constraints->centreY.GetDone() && constraints->height.GetDone())
461 {
462 value = (constraints->centreY.GetValue() + (constraints->height.GetValue()/2) - margin);
463 done = true;
464 return true;
465 }
466 else
467 return false;
468 }
469 case wxAsIs:
470 {
471 int x, y;
472 int w, h;
473 wxGetAsIs(win, &w, &h);
474 win->GetPosition(&x, &y);
475 value = h + y;
476 done = true;
477 return true;
478 }
479 default:
480 break;
481 }
482 break;
483 }
484 case wxCentreX:
485 {
486 switch (relationship)
487 {
488 case wxLeftOf:
489 {
490 // We can know this edge if: otherWin is win's parent, or
491 // otherWin has a satisfied constraint, or otherWin has no
492 // constraint.
493 int edgePos = GetEdge(otherEdge, win, otherWin);
494 if (edgePos != -1)
495 {
496 value = edgePos - margin;
497 done = true;
498 return true;
499 }
500 else
501 return false;
502 }
503 case wxRightOf:
504 {
505 int edgePos = GetEdge(otherEdge, win, otherWin);
506 if (edgePos != -1)
507 {
508 value = edgePos + margin;
509 done = true;
510 return true;
511 }
512 else
513 return false;
514 }
515 case wxPercentOf:
516 {
517 int edgePos = GetEdge(otherEdge, win, otherWin);
518 if (edgePos != -1)
519 {
520 value = (int)(edgePos*(((float)percent)*0.01) + margin);
521 done = true;
522 return true;
523 }
524 else
525 return false;
526 }
527 case wxUnconstrained:
528 {
529 // We know the centre position if we know
530 // the left-hand edge and we know the width, OR
531 // the right-hand edge and the width
532 if (constraints->left.GetDone() && constraints->width.GetDone())
533 {
534 value = (int)(constraints->left.GetValue() + (constraints->width.GetValue()/2) + margin);
535 done = true;
536 return true;
537 }
538 else if (constraints->right.GetDone() && constraints->width.GetDone())
539 {
540 value = (int)(constraints->left.GetValue() - (constraints->width.GetValue()/2) + margin);
541 done = true;
542 return true;
543 }
544 else
545 return false;
546 }
547 default:
548 break;
549 }
550 break;
551 }
552 case wxCentreY:
553 {
554 switch (relationship)
555 {
556 case wxAbove:
557 {
558 // We can know this edge if: otherWin is win's parent,
559 // or otherWin has a satisfied constraint, or otherWin
560 // has no constraint.
561 int edgePos = GetEdge(otherEdge, win, otherWin);
562 if (edgePos != -1)
563 {
564 value = edgePos - margin;
565 done = true;
566 return true;
567 }
568 else
569 return false;
570 }
571 case wxBelow:
572 {
573 int edgePos = GetEdge(otherEdge, win, otherWin);
574 if (edgePos != -1)
575 {
576 value = edgePos + margin;
577 done = true;
578 return true;
579 }
580 else
581 return false;
582 }
583 case wxPercentOf:
584 {
585 int edgePos = GetEdge(otherEdge, win, otherWin);
586 if (edgePos != -1)
587 {
588 value = (int)(edgePos*(((float)percent)*0.01) + margin);
589 done = true;
590 return true;
591 }
592 else
593 return false;
594 }
595 case wxUnconstrained:
596 {
597 // We know the centre position if we know
598 // the top edge and we know the height, OR
599 // the bottom edge and the height.
600 if (constraints->bottom.GetDone() && constraints->height.GetDone())
601 {
602 value = (int)(constraints->bottom.GetValue() - (constraints->height.GetValue()/2) + margin);
603 done = true;
604 return true;
605 }
606 else if (constraints->top.GetDone() && constraints->height.GetDone())
607 {
608 value = (int)(constraints->top.GetValue() + (constraints->height.GetValue()/2) + margin);
609 done = true;
610 return true;
611 }
612 else
613 return false;
614 }
615 default:
616 break;
617 }
618 break;
619 }
620 case wxWidth:
621 {
622 switch (relationship)
623 {
624 case wxPercentOf:
625 {
626 int edgePos = GetEdge(otherEdge, win, otherWin);
627 if (edgePos != -1)
628 {
629 value = (int)(edgePos*(((float)percent)*0.01));
630 done = true;
631 return true;
632 }
633 else
634 return false;
635 }
636 case wxAsIs:
637 {
638 if (win)
639 {
640 int h;
641 wxGetAsIs(win, &value, &h);
642 done = true;
643 return true;
644 }
645 else return false;
646 }
647 case wxUnconstrained:
648 {
649 // We know the width if we know the left edge and the right edge, OR
650 // if we know the left edge and the centre, OR
651 // if we know the right edge and the centre
652 if (constraints->left.GetDone() && constraints->right.GetDone())
653 {
654 value = constraints->right.GetValue() - constraints->left.GetValue();
655 done = true;
656 return true;
657 }
658 else if (constraints->centreX.GetDone() && constraints->left.GetDone())
659 {
660 value = (int)(2*(constraints->centreX.GetValue() - constraints->left.GetValue()));
661 done = true;
662 return true;
663 }
664 else if (constraints->centreX.GetDone() && constraints->right.GetDone())
665 {
666 value = (int)(2*(constraints->right.GetValue() - constraints->centreX.GetValue()));
667 done = true;
668 return true;
669 }
670 else
671 return false;
672 }
673 default:
674 break;
675 }
676 break;
677 }
678 case wxHeight:
679 {
680 switch (relationship)
681 {
682 case wxPercentOf:
683 {
684 int edgePos = GetEdge(otherEdge, win, otherWin);
685 if (edgePos != -1)
686 {
687 value = (int)(edgePos*(((float)percent)*0.01));
688 done = true;
689 return true;
690 }
691 else
692 return false;
693 }
694 case wxAsIs:
695 {
696 if (win)
697 {
698 int w;
699 wxGetAsIs(win, &w, &value);
700 done = true;
701 return true;
702 }
703 else return false;
704 }
705 case wxUnconstrained:
706 {
707 // We know the height if we know the top edge and the bottom edge, OR
708 // if we know the top edge and the centre, OR
709 // if we know the bottom edge and the centre
710 if (constraints->top.GetDone() && constraints->bottom.GetDone())
711 {
712 value = constraints->bottom.GetValue() - constraints->top.GetValue();
713 done = true;
714 return true;
715 }
716 else if (constraints->top.GetDone() && constraints->centreY.GetDone())
717 {
718 value = (int)(2*(constraints->centreY.GetValue() - constraints->top.GetValue()));
719 done = true;
720 return true;
721 }
722 else if (constraints->bottom.GetDone() && constraints->centreY.GetDone())
723 {
724 value = (int)(2*(constraints->bottom.GetValue() - constraints->centreY.GetValue()));
725 done = true;
726 return true;
727 }
728 else
729 return false;
730 }
731 default:
732 break;
733 }
734 break;
735 }
736 default:
737 break;
738 }
739 return false;
740 }
741
742 // Get the value of this edge or dimension, or if this is not determinable, -1.
743 int wxIndividualLayoutConstraint::GetEdge(wxEdge which,
744 wxWindowBase *thisWin,
745 wxWindowBase *other) const
746 {
747 // If the edge or dimension belongs to the parent, then we know the
748 // dimension is obtainable immediately. E.g. a wxExpandSizer may contain a
749 // button (but the button's true parent is a panel, not the sizer)
750 if (other->GetChildren().Find((wxWindow*)thisWin))
751 {
752 switch (which)
753 {
754 case wxLeft:
755 {
756 return 0;
757 }
758 case wxTop:
759 {
760 return 0;
761 }
762 case wxRight:
763 {
764 int w, h;
765 other->GetClientSizeConstraint(&w, &h);
766 return w;
767 }
768 case wxBottom:
769 {
770 int w, h;
771 other->GetClientSizeConstraint(&w, &h);
772 return h;
773 }
774 case wxWidth:
775 {
776 int w, h;
777 other->GetClientSizeConstraint(&w, &h);
778 return w;
779 }
780 case wxHeight:
781 {
782 int w, h;
783 other->GetClientSizeConstraint(&w, &h);
784 return h;
785 }
786 case wxCentreX:
787 case wxCentreY:
788 {
789 int w, h;
790 other->GetClientSizeConstraint(&w, &h);
791 if (which == wxCentreX)
792 return (int)(w/2);
793 else
794 return (int)(h/2);
795 }
796 default:
797 return -1;
798 }
799 }
800 switch (which)
801 {
802 case wxLeft:
803 {
804 wxLayoutConstraints *constr = other->GetConstraints();
805 // If no constraints, it means the window is not dependent
806 // on anything, and therefore we know its value immediately
807 if (constr)
808 {
809 if (constr->left.GetDone())
810 return constr->left.GetValue();
811 else
812 return -1;
813 }
814 else
815 {
816 int x, y;
817 other->GetPosition(&x, &y);
818 return x;
819 }
820 }
821 case wxTop:
822 {
823 wxLayoutConstraints *constr = other->GetConstraints();
824 // If no constraints, it means the window is not dependent
825 // on anything, and therefore we know its value immediately
826 if (constr)
827 {
828 if (constr->top.GetDone())
829 return constr->top.GetValue();
830 else
831 return -1;
832 }
833 else
834 {
835 int x, y;
836 other->GetPosition(&x, &y);
837 return y;
838 }
839 }
840 case wxRight:
841 {
842 wxLayoutConstraints *constr = other->GetConstraints();
843 // If no constraints, it means the window is not dependent
844 // on anything, and therefore we know its value immediately
845 if (constr)
846 {
847 if (constr->right.GetDone())
848 return constr->right.GetValue();
849 else
850 return -1;
851 }
852 else
853 {
854 int x, y, w, h;
855 other->GetPosition(&x, &y);
856 other->GetSize(&w, &h);
857 return (int)(x + w);
858 }
859 }
860 case wxBottom:
861 {
862 wxLayoutConstraints *constr = other->GetConstraints();
863 // If no constraints, it means the window is not dependent
864 // on anything, and therefore we know its value immediately
865 if (constr)
866 {
867 if (constr->bottom.GetDone())
868 return constr->bottom.GetValue();
869 else
870 return -1;
871 }
872 else
873 {
874 int x, y, w, h;
875 other->GetPosition(&x, &y);
876 other->GetSize(&w, &h);
877 return (int)(y + h);
878 }
879 }
880 case wxWidth:
881 {
882 wxLayoutConstraints *constr = other->GetConstraints();
883 // If no constraints, it means the window is not dependent
884 // on anything, and therefore we know its value immediately
885 if (constr)
886 {
887 if (constr->width.GetDone())
888 return constr->width.GetValue();
889 else
890 return -1;
891 }
892 else
893 {
894 int w, h;
895 other->GetSize(&w, &h);
896 return w;
897 }
898 }
899 case wxHeight:
900 {
901 wxLayoutConstraints *constr = other->GetConstraints();
902 // If no constraints, it means the window is not dependent
903 // on anything, and therefore we know its value immediately
904 if (constr)
905 {
906 if (constr->height.GetDone())
907 return constr->height.GetValue();
908 else
909 return -1;
910 }
911 else
912 {
913 int w, h;
914 other->GetSize(&w, &h);
915 return h;
916 }
917 }
918 case wxCentreX:
919 {
920 wxLayoutConstraints *constr = other->GetConstraints();
921 // If no constraints, it means the window is not dependent
922 // on anything, and therefore we know its value immediately
923 if (constr)
924 {
925 if (constr->centreX.GetDone())
926 return constr->centreX.GetValue();
927 else
928 return -1;
929 }
930 else
931 {
932 int x, y, w, h;
933 other->GetPosition(&x, &y);
934 other->GetSize(&w, &h);
935 return (int)(x + (w/2));
936 }
937 }
938 case wxCentreY:
939 {
940 wxLayoutConstraints *constr = other->GetConstraints();
941 // If no constraints, it means the window is not dependent
942 // on anything, and therefore we know its value immediately
943 if (constr)
944 {
945 if (constr->centreY.GetDone())
946 return constr->centreY.GetValue();
947 else
948 return -1;
949 }
950 else
951 {
952 int x, y, w, h;
953 other->GetPosition(&x, &y);
954 other->GetSize(&w, &h);
955 return (int)(y + (h/2));
956 }
957 }
958 default:
959 break;
960 }
961 return -1;
962 }
963
964 wxLayoutConstraints::wxLayoutConstraints()
965 {
966 left.SetEdge(wxLeft);
967 top.SetEdge(wxTop);
968 right.SetEdge(wxRight);
969 bottom.SetEdge(wxBottom);
970 centreX.SetEdge(wxCentreX);
971 centreY.SetEdge(wxCentreY);
972 width.SetEdge(wxWidth);
973 height.SetEdge(wxHeight);
974 }
975
976 bool wxLayoutConstraints::SatisfyConstraints(wxWindowBase *win, int *nChanges)
977 {
978 int noChanges = 0;
979
980 bool done = width.GetDone();
981 bool newDone = (done ? true : width.SatisfyConstraint(this, win));
982 if (newDone != done)
983 noChanges ++;
984
985 done = height.GetDone();
986 newDone = (done ? true : height.SatisfyConstraint(this, win));
987 if (newDone != done)
988 noChanges ++;
989
990 done = left.GetDone();
991 newDone = (done ? true : left.SatisfyConstraint(this, win));
992 if (newDone != done)
993 noChanges ++;
994
995 done = top.GetDone();
996 newDone = (done ? true : top.SatisfyConstraint(this, win));
997 if (newDone != done)
998 noChanges ++;
999
1000 done = right.GetDone();
1001 newDone = (done ? true : right.SatisfyConstraint(this, win));
1002 if (newDone != done)
1003 noChanges ++;
1004
1005 done = bottom.GetDone();
1006 newDone = (done ? true : bottom.SatisfyConstraint(this, win));
1007 if (newDone != done)
1008 noChanges ++;
1009
1010 done = centreX.GetDone();
1011 newDone = (done ? true : centreX.SatisfyConstraint(this, win));
1012 if (newDone != done)
1013 noChanges ++;
1014
1015 done = centreY.GetDone();
1016 newDone = (done ? true : centreY.SatisfyConstraint(this, win));
1017 if (newDone != done)
1018 noChanges ++;
1019
1020 *nChanges = noChanges;
1021
1022 return AreSatisfied();
1023 }
1024
1025 #endif // wxUSE_CONSTRAINTS