CrystalSpace

Public API Reference

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

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 #include "csutil/parray.h"
00030 
00035 class csLayoutConstraint
00036 {
00037 public:
00039   csComponent *comp;
00040 public:
00042   csLayoutConstraint ()
00043   { comp = 0; }
00045   csLayoutConstraint (csComponent *comp)
00046   { this->comp = comp; }
00048   virtual ~csLayoutConstraint () {}
00050   virtual csLayoutConstraint *Clone ();
00051 };
00052 
00058 class csConstraintVector : public csPDelArray<csLayoutConstraint>
00059 {
00060 public:
00062   static int CompareKey (csLayoutConstraint* const& Item1, void* Item2)
00063   {
00064     csComponent *c2 = (csComponent *)Item2;
00065     return (Item1->comp < c2 ? -1 : Item1->comp > c2 ? 1 : 0);
00066   }
00067 };
00068 
00095 class csLayout : public csDialog
00096 {
00097 protected:
00104   static bool mUseTwoPhaseLayoutingGlobally;
00105   static int mCurrentLayoutingPhase;
00107   bool bRecalcLayout;
00109   csConstraintVector vConstraints;
00111   csLayoutConstraint *lc;
00112 
00113 public:
00115   csRect insets;
00116   enum LAYOUTING_PHASES {PHASE_0 = 0, PHASE_1 = 1};
00122   csLayoutConstraint c;
00123 
00124 public:
00125   csLayout (csComponent *iParent, csDialogFrameStyle iFrameStyle = csdfsNone);
00126 
00138   virtual csLayoutConstraint *AddLayoutComponent (csComponent *comp);
00140   virtual void RemoveLayoutComponent (csComponent *comp);
00142   virtual void SuggestSize (int &sugw, int& sugh) = 0;
00144   virtual void LayoutContainer () = 0;
00147   virtual void InvalidateLayout ();
00148 
00150   virtual int GetLayoutingPhase ();
00152   virtual void SetLayoutingPhase (int phase);
00154   virtual csPoint GetPhase0Size ();
00156   virtual bool TwoPhaseLayoutingEnabled ();
00158   static void SetTwoPhaseLayoutingGlobally (bool on);
00159 
00161   virtual void Insert (csComponent *child);
00162   virtual bool HandleEvent (iEvent &Event);
00163   virtual void Draw ();
00164   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00165   virtual void FixSize (int &newWidth, int &newHeight);
00166 };
00167 
00172 class csLayout2 : public csLayout
00173 {
00174  public:
00175   csLayout2 (csComponent *pParent);
00176 
00177   virtual void MaximumLayoutSize (int &w, int &h) = 0;
00178   virtual float GetLayoutAlignmentX () = 0;
00179   virtual float GetLayoutAlignmentY () = 0;
00180 };
00181 
00184 #endif // __CS_CSLAYOUT_H__

Generated for Crystal Space by doxygen 1.2.14