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 CS_DECLARE_STATIC_CLASSVAR (CENTER, GetCenter, csBorderConstraint)
00128 CS_DECLARE_STATIC_CLASSVAR (EAST, GetEast, csBorderConstraint)
00129 CS_DECLARE_STATIC_CLASSVAR (NORTH, GetNorth, csBorderConstraint)
00130 CS_DECLARE_STATIC_CLASSVAR (SOUTH, GetSouth, csBorderConstraint)
00131 CS_DECLARE_STATIC_CLASSVAR (WEST, GetWest, csBorderConstraint)
00132 CS_DECLARE_STATIC_CLASSVAR (AFTER_LAST_LINE, GetAfterLastLine, csBorderConstraint)
00133 CS_DECLARE_STATIC_CLASSVAR (AFTER_LINE_ENDS, GetAfterLineEnds, csBorderConstraint)
00134 CS_DECLARE_STATIC_CLASSVAR (BEFORE_FIRST_LINE, GetBeforeFirstLine, csBorderConstraint)
00135 CS_DECLARE_STATIC_CLASSVAR (BEFORE_LINE_BEGINS, GetBeforeLineBegins, csBorderConstraint)
00136
00137 protected:
00138
00139 enum ALIGNMENT_ENUM_INTERNAL
00140 {
00141 _CENTER = 0,
00142 _EAST = 1,
00143 _NORTH = 2,
00144 _SOUTH = 3,
00145 _WEST = 4,
00146
00147
00148
00149 _AFTER_LAST_LINE = _SOUTH,
00150 _AFTER_LINE_ENDS = _EAST,
00151 _BEFORE_FIRST_LINE = _NORTH,
00152 _BEFORE_LINE_BEGINS = _WEST
00153 };
00154
00155 protected:
00156 void DistributeSizes( int& left, int& center,
00157 int& right, int totalWidth, int gap,
00158 bool hasLeft, bool hasCenter, bool hasRight );
00159
00160 int GetWidthSum( int left, int center, int right, int gap,
00161 bool hasLeft, bool hasCenter, bool hasRight );
00162
00163 int Hgap (csComponent* pComp);
00164 int Vgap (csComponent* pComp);
00165
00166 protected:
00167 int mHgap;
00168 int mVgap;
00169
00170 };
00171
00172 #endif // __BORDERLAYOUT_G__