Google

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   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     // for Western, top-to-bottom, left-to-right orientations
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__

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