CrystalSpace

Public API Reference

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

cslayout.h

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_CSLAYOUT_H__
00021 #define __CS_CSLAYOUT_H__
00022 
00027 #include "csextern.h"
00028  
00029 #include "csws/csdialog.h"
00030 #include "csgeom/cspoint.h"
00031 #include "csutil/parray.h"
00032 
00037 class CS_CSWS_EXPORT csLayoutConstraint
00038 {
00039 public:
00041   csComponent *comp;
00042 public:
00044   csLayoutConstraint ()
00045   { comp = 0; }
00047   csLayoutConstraint (csComponent *comp)
00048   { this->comp = comp; }
00050   virtual ~csLayoutConstraint () {}
00052   virtual csLayoutConstraint *Clone ();
00053 };
00054 
00060 class CS_CSWS_EXPORT csConstraintVector :
00061   public csPDelArray<csLayoutConstraint>
00062 {
00063 public:
00065   static int CompareKey (csLayoutConstraint* const& Item1,
00066                          csComponent* const& Item2)
00067   {
00068     return (Item1->comp < Item2 ? -1 : Item1->comp > Item2 ? 1 : 0);
00069   }
00071   static csArrayCmp<csLayoutConstraint*,csComponent*> KeyCmp(csComponent* c)
00072   {
00073     return csArrayCmp<csLayoutConstraint*,csComponent*>(c, CompareKey);
00074   }
00075 };
00076 
00103 class CS_CSWS_EXPORT csLayout : public csDialog
00104 {
00105 protected:
00112   static bool mUseTwoPhaseLayoutingGlobally;
00113   static int mCurrentLayoutingPhase;
00115   bool bRecalcLayout;
00117   csConstraintVector vConstraints;
00119   csLayoutConstraint *lc;
00120 
00121 public:
00123   csRect insets;
00124   enum LAYOUTING_PHASES {PHASE_0 = 0, PHASE_1 = 1};
00130   csLayoutConstraint c;
00131 
00132 public:
00133   csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle = csdfsNone);
00134 
00146   virtual csLayoutConstraint *AddLayoutComponent (csComponent *comp);
00148   virtual void RemoveLayoutComponent (csComponent *comp);
00150   virtual void SuggestSize (int &sugw, int& sugh) = 0;
00152   virtual void LayoutContainer () = 0;
00155   virtual void InvalidateLayout ();
00156 
00158   virtual int GetLayoutingPhase ();
00160   virtual void SetLayoutingPhase (int phase);
00162   virtual csPoint GetPhase0Size ();
00164   virtual bool TwoPhaseLayoutingEnabled ();
00166   static void SetTwoPhaseLayoutingGlobally (bool on);
00167 
00169   virtual void Insert (csComponent *child);
00170   virtual bool HandleEvent (iEvent &Event);
00171   virtual void Draw ();
00172   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00173   virtual void FixSize (int &newWidth, int &newHeight);
00174 };
00175 
00180 class CS_CSWS_EXPORT csLayout2 : public csLayout
00181 {
00182  public:
00183   csLayout2 (csComponent *pParent);
00184 
00185   virtual void MaximumLayoutSize (int &w, int &h) = 0;
00186   virtual float GetLayoutAlignmentX () = 0;
00187   virtual float GetLayoutAlignmentY () = 0;
00188 };
00189 
00192 #endif // __CS_CSLAYOUT_H__

Generated for Crystal Space by doxygen 1.3.9.1