Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csbdrlay.h

00001 /*
00002     Copyright (C) Aleksandras Gluchovas
00003     CS port by Norman Krämer <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 __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     // for Western, top-to-bottom, left-to-right orientations
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__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000