Crazy Eddies GUI System  0.7.2
CEGUIGridLayoutContainer.h
1 /***********************************************************************
2  filename: CEGUIGridLayoutContainer.h
3  created: 01/8/2010
4  author: Martin Preisler
5 
6  purpose: Interface to a vertical layout container
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIGridLayoutContainer_h_
31 #define _CEGUIGridLayoutContainer_h_
32 
33 #include "CEGUILayoutContainer.h"
34 #include "../CEGUIWindowFactory.h"
35 #include "CEGUIGridLayoutContainerProperties.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
49 class CEGUIEXPORT GridLayoutContainer : public LayoutContainer
50 {
51 public:
58  {
72  AP_TopToBottom
73  };
74 
75  /*************************************************************************
76  Constants
77  *************************************************************************/
79  static const String WidgetTypeName;
80 
81  /*************************************************************************
82  Child Widget name suffix constants
83  *************************************************************************/
85  static const String DummyNameSuffix;
86 
87  /*************************************************************************
88  Event name constants
89  *************************************************************************/
91  static const String EventNamespace;
92 
95 
96  /*************************************************************************
97  Construction and Destruction
98  *************************************************************************/
103  GridLayoutContainer(const String& type, const String& name);
104 
109  virtual ~GridLayoutContainer(void);
110 
115  void setGridDimensions(size_t width, size_t height);
116 
121  size_t getGridWidth() const;
122 
127  size_t getGridHeight() const;
128 
137  void setAutoPositioning(AutoPositioning positioning);
138 
143  AutoPositioning getAutoPositioning() const;
144 
150  void setNextAutoPositioningIdx(size_t idx);
151 
157  size_t getNextAutoPositioningIdx() const;
158 
163  void autoPositioningSkipCells(size_t cells);
164 
182  void addChildWindowToPosition(Window* window, size_t gridX, size_t gridY);
183 
201  void addChildWindowToPosition(const String& name, size_t gridX, size_t gridY);
202 
207  Window* getChildWindowAtPosition(size_t gridX, size_t gridY);
208 
216  void removeChildWindowFromPosition(size_t gridX, size_t gridY);
217 
225  virtual void swapChildWindowPositions(size_t wnd1, size_t wnd2);
226 
231  void swapChildWindowPositions(size_t gridX1, size_t gridY1,
232  size_t gridX2, size_t gridY2);
233 
238  void swapChildWindows(Window* wnd1, Window* wnd2);
239 
244  void swapChildWindows(Window* wnd1, const String& wnd2);
245 
250  void swapChildWindows(const String& wnd1, Window* wnd2);
251 
256  void moveChildWindowToPosition(Window* wnd, size_t gridX, size_t gridY);
257 
262  void moveChildWindowToPosition(const String& wnd,
263  size_t gridX, size_t gridY);
264 
266  virtual void layout();
267 
268 protected:
277  virtual void onChildWindowOrderChanged(WindowEventArgs& e);
278 
280  size_t mapFromGridToIdx(size_t gridX, size_t gridY,
281  size_t gridWidth, size_t gridHeight) const;
283  void mapFromIdxToGrid(size_t idx, size_t& gridX, size_t& gridY,
284  size_t gridWidth, size_t gridHeight) const;
285 
289  UVector2 getGridCellOffset(const std::vector<UDim>& colSizes,
290  const std::vector<UDim>& rowSizes,
291  size_t gridX, size_t gridY) const;
293  UVector2 getGridSize(const std::vector<UDim>& colSizes,
294  const std::vector<UDim>& rowSizes) const;
295 
297  size_t translateAPToGridIdx(size_t APIdx) const;
298 
300  size_t d_gridWidth;
302  size_t d_gridHeight;
303 
310 
314  size_t d_nextGridX;
318  size_t d_nextGridY;
319 
324 
326  Window* createDummy();
328  bool isDummy(Window* wnd) const;
329 
331  virtual void addChild_impl(Window* wnd);
333  virtual void removeChild_impl(Window* wnd);
334 
346  virtual bool testClassName_impl(const String& class_name) const
347  {
348  if (class_name == "GridLayoutContainer") return true;
349 
350  return LayoutContainer::testClassName_impl(class_name);
351  }
352 
353 private:
354  /*************************************************************************
355  Properties for GridLayoutContainer class
356  *************************************************************************/
357  static GridLayoutContainerProperties::GridSize d_gridSizeProperty;
358  static GridLayoutContainerProperties::AutoPositioning d_autoPositioningProperty;
359 
360  void addGridLayoutContainerProperties(void);
361 };
362 
363 } // End of CEGUI namespace section
364 
365 #if defined(_MSC_VER)
366 # pragma warning(pop)
367 #endif
368 
369 #endif // end of guard _CEGUIGridLayoutContainer_h_
370