CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 "csextern.h"
00031  
00032 #include "cslayout.h"
00033 #include "csutil/parray.h"
00034 
00038 class CS_CSWS_EXPORT csGridBagConstraint : public csLayoutConstraint
00039 {
00040 public:
00041   csGridBagConstraint (csComponent *comp);
00042   csGridBagConstraint (const csGridBagConstraint &c);
00043   csGridBagConstraint (csComponent *comp, int _gridx, int _gridy,
00044                        int _gridwidth, int _gridheight, float _weightx,
00045                        float _weighty, int _anchor, int _fill,
00046                        csRect _insets, int _ipadx, int _ipady);
00047   csLayoutConstraint *Clone ();
00048 public:
00054   int gridx;
00061   int gridy;
00066   int gridwidth;
00071   int gridheight;
00078   float weightx;
00085   float weighty;
00100   int anchor;
00107   int fill;
00111   csRect insets;
00116   int ipadx;
00121   int ipady;
00122 
00123 #undef RELATIVE
00124 #undef _LEFT
00125 #undef _CENTER
00126 
00127   enum GRID_BAG_CONSTANTS
00128   {
00129     RELATIVE   = -1,
00130     REMAINDER  = 0,
00131 
00132     NONE       = 0,
00133     BOTH       = 1,
00134     HORIZONTAL = 2,
00135     VERTICAL   = 3,
00136 
00137     CENTER    = 10,
00138     NORTH     = 11,
00139     NORTHEAST = 12,
00140     EAST      = 13,
00141     SOUTHEAST = 14,
00142     SOUTH     = 15,
00143     SOUTHWEST = 16,
00144     WEST      = 17,
00145     NORTHWEST = 18
00146   };
00147 
00149   enum  GRID_BAG_CONSTANTS_INTERNAL
00150   {
00151     _LEFT     = 20,
00152     _CENTER   = 21,
00153     _RIGHT    = 22
00154   };
00155 
00157   bool bSized;
00159   csPoint mPrefCompSize;
00160 };
00161 
00283 class CS_CSWS_EXPORT csGridBagLayout : public csLayout2
00284 {
00285   struct CellInfo
00286   {
00287     csComponent* comp;
00288 
00289     int prefSize;        // actually, it can be calculated on-the-fly
00290     int prefCompSize;
00291 
00292     int cellSpan;
00293     int leftInset;
00294     int rightInset;
00295     int pad;
00296     int fill;
00297     int anchor;
00298 
00299     float extraSpace;
00300     float weight;
00301 
00302     int finalSize;
00303     int finalPos;
00304     int finalCompSize;
00305     int finalCompPos;
00306   };
00307 
00308   struct CellHolder
00309   {
00310     csGridBagConstraint* constr;
00311     float weightx;
00312     float weighty;
00313 
00314     int gridwidth;
00315     int gridheight;
00316     int actualWidth;
00317     int actualHeight;
00318 
00319     bool isFirstCellForComp;
00320     int x, y;
00321   };
00322 
00323   typedef csPDelArray<CellHolder> CellHolderArrayT;
00324 
00325  public:
00326   csGridBagLayout (csComponent *pParent);
00327   ~csGridBagLayout ();
00328 
00329   virtual void RemoveLayoutComponent (csComponent* comp);
00330   virtual void SuggestSize (int &sugw, int &sugh);
00331   virtual void LayoutContainer ();
00332 
00333   virtual void MaximumLayoutSize (int &w, int &h);
00334   virtual float GetLayoutAlignmentX ();
00335   virtual float GetLayoutAlignmentY ();
00336 
00337   csGridBagConstraint c;
00338 
00339 protected:
00340   int CalcPrefSize (CellInfo* cells, int xCnt, int yCnt, int _arrayWidth);
00341   void LayoutCells (CellInfo* cells, int xCnt, int yCnt,
00342                     int outterSize, int outterPos, int _arrayWidth );
00343 
00344   void InitializeCellArray (CellInfo* cells, int size);
00345   void InitCellFromHolder (CellHolder& holder);
00346   void CreateMatrix ();
00347   long GetCellCode (int x, int y);
00348   void CleanupConstraints ();
00349   void ClearCachedData ();
00350   bool HasCashedInfo ();
00351   void SetComponentLocations ();
00352 
00353 protected:
00354   CellInfo* mpHorizCellInfos;
00355   CellInfo* mpVertCellInfos;
00356   int mColCount;
00357   int mRowCount;
00358 };
00359 
00362 #endif // __CS_CSGRIDBAGLAYOUT_H__

Generated for Crystal Space by doxygen 1.2.18