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