00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CSLAYOUT_H__
00021 #define __CSLAYOUT_H__
00022
00023 #include "csws/csdialog.h"
00024 #include "csgeom/cspoint.h"
00025
00030 class csLayoutConstraint
00031 {
00032 public:
00034 csComponent *comp;
00035 public:
00037 csLayoutConstraint ()
00038 { comp = NULL; }
00040 csLayoutConstraint (csComponent *comp)
00041 { this->comp = comp; }
00043 virtual ~csLayoutConstraint () {}
00045 virtual csLayoutConstraint *Clone ();
00046 };
00047
00053 class csConstraintVector : public csVector
00054 {
00055 public:
00057 virtual int Compare (csSome Item1, csSome Item2, int Mode = 0) const
00058 {
00059 (void)Mode;
00060 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00061 csLayoutConstraint *c2 = (csLayoutConstraint *)Item2;
00062 return (c1->comp < c2->comp ? -1 : c1->comp > c2->comp ? 1 : 0);
00063 }
00065 virtual int CompareKey (csSome Item1, csConstSome Item2, int Mode = 0) const
00066 {
00067 (void)Mode;
00068 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00069 csComponent *c2 = (csComponent *)Item2;
00070 return (c1->comp < c2 ? -1 : c1->comp > c2 ? 1 : 0);
00071 }
00073 virtual bool FreeItem (csSome Item)
00074 { if (Item) delete (csLayoutConstraint *)Item; return true; }
00076 csLayoutConstraint *Get (int idx)
00077 { return (csLayoutConstraint *)csVector::Get (idx); }
00078 };
00079
00105 class csLayout : public csDialog
00106 {
00107 protected:
00114 static bool mUseTwoPhaseLayoutingGlobally;
00115 static int mCurrentLayoutingPhase;
00117 bool bRecalcLayout;
00119 csConstraintVector vConstraints;
00121 csLayoutConstraint *lc;
00122
00123 public:
00125 csRect insets;
00126 enum LAYOUTING_PHASES {PHASE_0 = 0, PHASE_1 = 1};
00130 csLayoutConstraint c;
00131
00132 public:
00133 csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle = csdfsNone);
00134
00146 virtual csLayoutConstraint *AddLayoutComponent (csComponent *comp);
00148 virtual void RemoveLayoutComponent (csComponent *comp);
00150 virtual void SuggestSize (int &sugw, int& sugh) = 0;
00152 virtual void LayoutContainer () = 0;
00155 virtual void InvalidateLayout ();
00156
00158 virtual int GetLayoutingPhase ();
00160 virtual void SetLayoutingPhase (int phase);
00162 virtual csPoint GetPhase0Size ();
00164 virtual bool TwoPhaseLayoutingEnabled ();
00166 static void SetTwoPhaseLayoutingGlobally (bool on);
00167
00169 virtual void Insert (csComponent *child);
00170 virtual bool HandleEvent (iEvent &Event);
00171 virtual void Draw ();
00172 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00173 virtual void FixSize (int &newWidth, int &newHeight);
00174 };
00175
00180 class csLayout2 : public csLayout
00181 {
00182 public:
00183 csLayout2 (csComponent *pParent);
00184
00185 virtual void MaximumLayoutSize (int &w, int &h) = 0;
00186 virtual float GetLayoutAlignmentX () = 0;
00187 virtual float GetLayoutAlignmentY () = 0;
00188 };
00189
00190 #endif // __CSLAYOUT_H__