csws/csbaglay.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) Aleksandras Gluchovas 00003 CS port by Norman Kraemer <norman@users.sourceforge.net> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_CSGRIDBAGLAYOUT_H__ 00021 #define __CS_CSGRIDBAGLAYOUT_H__ 00022 00030 #include "cslayout.h" 00031 #include "csutil/parray.h" 00032 00036 class csGridBagConstraint : public csLayoutConstraint 00037 { 00038 public: 00039 csGridBagConstraint (csComponent *comp); 00040 csGridBagConstraint (const csGridBagConstraint &c); 00041 csGridBagConstraint (csComponent *comp, int _gridx, int _gridy, 00042 int _gridwidth, int _gridheight, float _weightx, 00043 float _weighty, int _anchor, int _fill, 00044 csRect _insets, int _ipadx, int _ipady); 00045 csLayoutConstraint *Clone (); 00046 public: 00052 int gridx; 00059 int gridy; 00064 int gridwidth; 00069 int gridheight; 00076 float weightx; 00083 float weighty; 00098 int anchor; 00105 int fill; 00109 csRect insets; 00114 int ipadx; 00119 int ipady; 00120 00121 #undef RELATIVE 00122 #undef _LEFT 00123 #undef _CENTER 00124 00125 enum GRID_BAG_CONSTANTS 00126 { 00127 RELATIVE = -1, 00128 REMAINDER = 0, 00129 00130 NONE = 0, 00131 BOTH = 1, 00132 HORIZONTAL = 2, 00133 VERTICAL = 3, 00134 00135 CENTER = 10, 00136 NORTH = 11, 00137 NORTHEAST = 12, 00138 EAST = 13, 00139 SOUTHEAST = 14, 00140 SOUTH = 15, 00141 SOUTHWEST = 16, 00142 WEST = 17, 00143 NORTHWEST = 18 00144 }; 00145 00147 enum GRID_BAG_CONSTANTS_INTERNAL 00148 { 00149 _LEFT = 20, 00150 _CENTER = 21, 00151 _RIGHT = 22 00152 }; 00153 00155 bool bSized; 00157 csPoint mPrefCompSize; 00158 }; 00159 00281 class csGridBagLayout : public csLayout2 00282 { 00283 struct CellInfo 00284 { 00285 csComponent* comp; 00286 00287 int prefSize; // actually, it can be calculated on-the-fly 00288 int prefCompSize; 00289 00290 int cellSpan; 00291 int leftInset; 00292 int rightInset; 00293 int pad; 00294 int fill; 00295 int anchor; 00296 00297 float extraSpace; 00298 float weight; 00299 00300 int finalSize; 00301 int finalPos; 00302 int finalCompSize; 00303 int finalCompPos; 00304 }; 00305 00306 struct CellHolder 00307 { 00308 csGridBagConstraint* constr; 00309 float weightx; 00310 float weighty; 00311 00312 int gridwidth; 00313 int gridheight; 00314 int actualWidth; 00315 int actualHeight; 00316 00317 bool isFirstCellForComp; 00318 int x, y; 00319 }; 00320 00321 typedef csPDelArray<CellHolder> CellHolderArrayT; 00322 00323 public: 00324 csGridBagLayout (csComponent *pParent); 00325 ~csGridBagLayout (); 00326 00327 virtual void RemoveLayoutComponent (csComponent* comp); 00328 virtual void SuggestSize (int &sugw, int &sugh); 00329 virtual void LayoutContainer (); 00330 00331 virtual void MaximumLayoutSize (int &w, int &h); 00332 virtual float GetLayoutAlignmentX (); 00333 virtual float GetLayoutAlignmentY (); 00334 00335 csGridBagConstraint c; 00336 00337 protected: 00338 int CalcPrefSize (CellInfo* cells, int xCnt, int yCnt, int _arrayWidth); 00339 void LayoutCells (CellInfo* cells, int xCnt, int yCnt, 00340 int outterSize, int outterPos, int _arrayWidth ); 00341 00342 void InitializeCellArray (CellInfo* cells, int size); 00343 void InitCellFromHolder (CellHolder& holder); 00344 void CreateMatrix (); 00345 long GetCellCode (int x, int y); 00346 void CleanupConstraints (); 00347 void ClearCachedData (); 00348 bool HasCashedInfo (); 00349 void SetComponentLocations (); 00350 00351 protected: 00352 CellInfo* mpHorizCellInfos; 00353 CellInfo* mpVertCellInfos; 00354 int mColCount; 00355 int mRowCount; 00356 }; 00357 00360 #endif // __CS_CSGRIDBAGLAYOUT_H__
Generated for Crystal Space by doxygen 1.2.18