CrystalSpace

Public API Reference

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

cslayout.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 __CS_CSLAYOUT_H__
00021 #define __CS_CSLAYOUT_H__
00022 
00027 #include "csws/csdialog.h"
00028 #include "csgeom/cspoint.h"
00029 
00034 class csLayoutConstraint
00035 {
00036 public:
00038   csComponent *comp;
00039 public:
00041   csLayoutConstraint ()
00042   { comp = NULL; }
00044   csLayoutConstraint (csComponent *comp)
00045   { this->comp = comp; }
00047   virtual ~csLayoutConstraint () {}
00049   virtual csLayoutConstraint *Clone ();
00050 };
00051 
00057 class csConstraintVector : public csVector
00058 {
00059 public:
00061   virtual int Compare (void* Item1, void* Item2, int Mode = 0) const
00062   {
00063     (void)Mode;
00064     csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00065     csLayoutConstraint *c2 = (csLayoutConstraint *)Item2;
00066     return (c1->comp < c2->comp ? -1 : c1->comp > c2->comp ? 1 : 0);
00067   }
00069   virtual int CompareKey (void* Item1, const void* Item2, int Mode = 0) const
00070   {
00071     (void)Mode;
00072     csLayoutConstraint *c1 = (csLayoutConstraint *)Item1;
00073     csComponent *c2 = (csComponent *)Item2;
00074     return (c1->comp < c2 ? -1 : c1->comp > c2 ? 1 : 0);
00075   }
00077   virtual bool FreeItem (void* Item)
00078   { if (Item) delete (csLayoutConstraint *)Item; return true; }
00080   csLayoutConstraint *Get (int idx)
00081   { return (csLayoutConstraint *)csVector::Get (idx); }
00082 };
00083 
00110 class csLayout : public csDialog
00111 {
00112 protected:
00119   static bool mUseTwoPhaseLayoutingGlobally;
00120   static int mCurrentLayoutingPhase;
00122   bool bRecalcLayout;
00124   csConstraintVector vConstraints;
00126   csLayoutConstraint *lc;
00127 
00128 public:
00130   csRect insets;
00131   enum LAYOUTING_PHASES {PHASE_0 = 0, PHASE_1 = 1};
00137   csLayoutConstraint c;
00138 
00139 public:
00140   csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle = csdfsNone);
00141 
00153   virtual csLayoutConstraint *AddLayoutComponent (csComponent *comp);
00155   virtual void RemoveLayoutComponent (csComponent *comp);
00157   virtual void SuggestSize (int &sugw, int& sugh) = 0;
00159   virtual void LayoutContainer () = 0;
00162   virtual void InvalidateLayout ();
00163 
00165   virtual int GetLayoutingPhase ();
00167   virtual void SetLayoutingPhase (int phase);
00169   virtual csPoint GetPhase0Size ();
00171   virtual bool TwoPhaseLayoutingEnabled ();
00173   static void SetTwoPhaseLayoutingGlobally (bool on);
00174 
00176   virtual void Insert (csComponent *child);
00177   virtual bool HandleEvent (iEvent &Event);
00178   virtual void Draw ();
00179   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00180   virtual void FixSize (int &newWidth, int &newHeight);
00181 };
00182 
00187 class csLayout2 : public csLayout
00188 {
00189  public:
00190   csLayout2 (csComponent *pParent);
00191 
00192   virtual void MaximumLayoutSize (int &w, int &h) = 0;
00193   virtual float GetLayoutAlignmentX () = 0;
00194   virtual float GetLayoutAlignmentY () = 0;
00195 };
00196 
00199 #endif // __CS_CSLAYOUT_H__

Generated for Crystal Space by doxygen 1.2.14