00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __BORDERLAYOUT_G__
00021 #define __BORDERLAYOUT_G__
00022
00023 #include "cslayout.h"
00024
00065 class csBorderConstraint : public csLayoutConstraint
00066 {
00067 public:
00068 int mAlign;
00069 public:
00078 csBorderConstraint (int align): mAlign( align ) {}
00080 csBorderConstraint (const csBorderConstraint &c) :
00081 csLayoutConstraint (c.comp)
00082 { mAlign = c.mAlign; }
00083 virtual csLayoutConstraint *Clone ();
00084 };
00085
00086 class csBorderLayout : public csLayout2
00087 {
00088 public:
00089 csBorderLayout (csComponent *pParent);
00094 csBorderLayout (csComponent *pParent, int hgap, int vgap);
00095
00096 ~csBorderLayout();
00097
00109 virtual csLayoutConstraint *AddLayoutComponent (csComponent* comp);
00111 virtual void RemoveLayoutComponent (csComponent* comp);
00112
00113 virtual void SuggestSize (int &w, int &h);
00114
00116 virtual void LayoutContainer ();
00117
00118 virtual void MaximumLayoutSize (int &w, int &h);
00119 virtual float GetLayoutAlignmentX ();
00120 virtual float GetLayoutAlignmentY ();
00121
00122 public:
00123
00124 csBorderConstraint c;
00125
00127 static csBorderConstraint* CENTER;
00128 static csBorderConstraint* EAST;
00129 static csBorderConstraint* NORTH;
00130 static csBorderConstraint* SOUTH;
00131 static csBorderConstraint* WEST;
00132 static csBorderConstraint* AFTER_LAST_LINE;
00133 static csBorderConstraint* AFTER_LINE_ENDS;
00134 static csBorderConstraint* BEFORE_FIRST_LINE;
00135 static csBorderConstraint* BEFORE_LINE_BEGINS;
00136
00137 protected:
00138
00139 static csBorderConstraint mCENTER;
00140 static csBorderConstraint mEAST;
00141 static csBorderConstraint mNORTH;
00142 static csBorderConstraint mSOUTH;
00143 static csBorderConstraint mWEST;
00144 static csBorderConstraint mAFTER_LAST_LINE;
00145 static csBorderConstraint mAFTER_LINE_ENDS;
00146 static csBorderConstraint mBEFORE_FIRST_LINE;
00147 static csBorderConstraint mBEFORE_LINE_BEGINS;
00148
00149 protected:
00150
00151 enum ALIGNMENT_ENUM_INTERNAL
00152 {
00153 _CENTER = 0,
00154 _EAST = 1,
00155 _NORTH = 2,
00156 _SOUTH = 3,
00157 _WEST = 4,
00158
00159
00160
00161 _AFTER_LAST_LINE = _SOUTH,
00162 _AFTER_LINE_ENDS = _EAST,
00163 _BEFORE_FIRST_LINE = _NORTH,
00164 _BEFORE_LINE_BEGINS = _WEST
00165 };
00166
00167 protected:
00168 void DistributeSizes( int& left, int& center,
00169 int& right, int totalWidth, int gap,
00170 bool hasLeft, bool hasCenter, bool hasRight );
00171
00172 int GetWidthSum( int left, int center, int right, int gap,
00173 bool hasLeft, bool hasCenter, bool hasRight );
00174
00175 int Hgap (csComponent* pComp);
00176 int Vgap (csComponent* pComp);
00177
00178 protected:
00179 int mHgap;
00180 int mVgap;
00181
00182 };
00183
00184 #endif // __BORDERLAYOUT_G__