00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_CSLAYOUT_H__
00021 #define __CS_CSLAYOUT_H__
00022
00027 #include "csws/csdialog.h"
00028 #include "csgeom/cspoint.h"
00029
00034 class csLayoutConstraint
00035 {
00036 public:
00038 csComponent *comp;
00039 public:
00041 csLayoutConstraint ()
00042 { comp = NULL; }
00044 csLayoutConstraint (csComponent *comp)
00045 { this->comp = comp; }
00047 virtual ~csLayoutConstraint () {}
00049 virtual csLayoutConstraint *Clone ();
00050 };
00051
00057 class csConstraintVector : public csVector
00058 {
00059 public:
00061 virtual int Compare (void* Item1, void* Item2, int Mode = 0) const
00062 {
00063 (void)Mode;
00064 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00065 csLayoutConstraint *c2 = (csLayoutConstraint *)Item2;
00066 return (c1->comp < c2->comp ? -1 : c1->comp > c2->comp ? 1 : 0);
00067 }
00069 virtual int CompareKey (void* Item1, const void* Item2, int Mode = 0) const
00070 {
00071 (void)Mode;
00072 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00073 csComponent *c2 = (csComponent *)Item2;
00074 return (c1->comp < c2 ? -1 : c1->comp > c2 ? 1 : 0);
00075 }
00077 virtual bool FreeItem (void* Item)
00078 { if (Item) delete (csLayoutConstraint *)Item; return true; }
00080 csLayoutConstraint *Get (int idx)
00081 { return (csLayoutConstraint *)csVector::Get (idx); }
00082 };
00083
00110 class csLayout : public csDialog
00111 {
00112 protected:
00119 static bool mUseTwoPhaseLayoutingGlobally;
00120 static int mCurrentLayoutingPhase;
00122 bool bRecalcLayout;
00124 csConstraintVector vConstraints;
00126 csLayoutConstraint *lc;
00127
00128 public:
00130 csRect insets;
00131 enum LAYOUTING_PHASES {PHASE_0 = 0, PHASE_1 = 1};
00137 csLayoutConstraint c;
00138
00139 public:
00140 csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle = csdfsNone);
00141
00153 virtual csLayoutConstraint *AddLayoutComponent (csComponent *comp);
00155 virtual void RemoveLayoutComponent (csComponent *comp);
00157 virtual void SuggestSize (int &sugw, int& sugh) = 0;
00159 virtual void LayoutContainer () = 0;
00162 virtual void InvalidateLayout ();
00163
00165 virtual int GetLayoutingPhase ();
00167 virtual void SetLayoutingPhase (int phase);
00169 virtual csPoint GetPhase0Size ();
00171 virtual bool TwoPhaseLayoutingEnabled ();
00173 static void SetTwoPhaseLayoutingGlobally (bool on);
00174
00176 virtual void Insert (csComponent *child);
00177 virtual bool HandleEvent (iEvent &Event);
00178 virtual void Draw ();
00179 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00180 virtual void FixSize (int &newWidth, int &newHeight);
00181 };
00182
00187 class csLayout2 : public csLayout
00188 {
00189 public:
00190 csLayout2 (csComponent *pParent);
00191
00192 virtual void MaximumLayoutSize (int &w, int &h) = 0;
00193 virtual float GetLayoutAlignmentX () = 0;
00194 virtual float GetLayoutAlignmentY () = 0;
00195 };
00196
00199 #endif // __CS_CSLAYOUT_H__