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