|
cslayout.h00001 /* 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 __CSLAYOUT_H__ 00021 #define __CSLAYOUT_H__ 00022 00023 #include "csws/csdialog.h" 00024 #include "csgeom/cspoint.h" 00025 00030 class csLayoutConstraint 00031 { 00032 public: 00034 csComponent *comp; 00035 public: 00037 csLayoutConstraint () 00038 { comp = NULL; } 00040 csLayoutConstraint (csComponent *comp) 00041 { this->comp = comp; } 00043 virtual ~csLayoutConstraint () {} 00045 virtual csLayoutConstraint *Clone (); 00046 }; 00047 00053 class csConstraintVector : public csVector 00054 { 00055 public: 00057 virtual int Compare (csSome Item1, csSome Item2, int Mode = 0) const 00058 { 00059 (void)Mode; 00060 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1; 00061 csLayoutConstraint *c2 = (csLayoutConstraint *)Item2; 00062 return (c1->comp < c2->comp ? -1 : c1->comp > c2->comp ? 1 : 0); 00063 } 00065 virtual int CompareKey (csSome Item1, csConstSome Item2, int Mode = 0) const 00066 { 00067 (void)Mode; 00068 csLayoutConstraint *c1 = (csLayoutConstraint *)Item1; 00069 csComponent *c2 = (csComponent *)Item2; 00070 return (c1->comp < c2 ? -1 : c1->comp > c2 ? 1 : 0); 00071 } 00073 virtual bool FreeItem (csSome Item) 00074 { if (Item) delete (csLayoutConstraint *)Item; return true; } 00076 csLayoutConstraint *Get (int idx) 00077 { return (csLayoutConstraint *)csVector::Get (idx); } 00078 }; 00079 00105 class csLayout : public csDialog 00106 { 00107 protected: 00114 static bool mUseTwoPhaseLayoutingGlobally; 00115 static int mCurrentLayoutingPhase; 00117 bool bRecalcLayout; 00119 csConstraintVector vConstraints; 00121 csLayoutConstraint *lc; 00122 00123 public: 00125 csRect insets; 00126 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 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 00190 #endif // __CSLAYOUT_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |