CrystalSpace

Public API Reference

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

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 
00148   enum GRID_BAG_CONSTANTS_INTERNAL
00149   {
00150     _LEFT     = 20,
00151     _CENTER   = 21,
00152     _RIGHT    = 22
00153   };
00154 
00155   bool bSized;
00156   csPoint mPrefCompSize;
00157 };
00158 
00280 class CS_CSWS_EXPORT csGridBagLayout : public csLayout2
00281 {
00282   struct CellInfo
00283   {
00284     csComponent* comp;
00285 
00286     int prefSize;        // actually, it can be calculated on-the-fly
00287     int prefCompSize;
00288 
00289     int cellSpan;
00290     int leftInset;
00291     int rightInset;
00292     int pad;
00293     int fill;
00294     int anchor;
00295 
00296     float extraSpace;
00297     float weight;
00298 
00299     int finalSize;
00300     int finalPos;
00301     int finalCompSize;
00302     int finalCompPos;
00303   };
00304 
00305   struct CellHolder
00306   {
00307     csGridBagConstraint* constr;
00308     float weightx;
00309     float weighty;
00310 
00311     int gridwidth;
00312     int gridheight;
00313     int actualWidth;
00314     int actualHeight;
00315 
00316     bool isFirstCellForComp;
00317     int x, y;
00318   };
00319 
00320   typedef csPDelArray<CellHolder> CellHolderArrayT;
00321 
00322  public:
00323   csGridBagLayout (csComponent *pParent);
00324   ~csGridBagLayout ();
00325 
00326   virtual void RemoveLayoutComponent (csComponent* comp);
00327   virtual void SuggestSize (int &sugw, int &sugh);
00328   virtual void LayoutContainer ();
00329 
00330   virtual void MaximumLayoutSize (int &w, int &h);
00331   virtual float GetLayoutAlignmentX ();
00332   virtual float GetLayoutAlignmentY ();
00333 
00334   csGridBagConstraint c;
00335 
00336 protected:
00337   int CalcPrefSize (CellInfo* cells, int xCnt, int yCnt, int _arrayWidth);
00338   void LayoutCells (CellInfo* cells, int xCnt, int yCnt,
00339                     int outterSize, int outterPos, int _arrayWidth );
00340 
00341   void InitializeCellArray (CellInfo* cells, int size);
00342   void InitCellFromHolder (CellHolder& holder);
00343   void CreateMatrix ();
00344   long GetCellCode (int x, int y);
00345   void CleanupConstraints ();
00346   void ClearCachedData ();
00347   bool HasCashedInfo ();
00348   void SetComponentLocations ();
00349 
00350 protected:
00351   CellInfo* mpHorizCellInfos;
00352   CellInfo* mpVertCellInfos;
00353   int mColCount;
00354   int mRowCount;
00355 };
00356 
00359 #endif // __CS_CSGRIDBAGLAYOUT_H__

Generated for Crystal Space by doxygen 1.3.9.1