Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
GridLayoutContainer.h
1/***********************************************************************
2 created: 01/8/2010
3 author: Martin Preisler
4
5 purpose: Interface to a vertical layout container
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUIGridLayoutContainer_h_
30#define _CEGUIGridLayoutContainer_h_
31
32#include "./LayoutContainer.h"
33#include "../WindowFactory.h"
34
35#if defined(_MSC_VER)
36# pragma warning(push)
37# pragma warning(disable : 4251)
38#endif
39
40// Start of CEGUI namespace section
41namespace CEGUI
42{
47class CEGUIEXPORT GridLayoutContainer : public LayoutContainer
48{
49public:
56 {
70 AP_TopToBottom
71 };
72
73 /*************************************************************************
74 Constants
75 *************************************************************************/
77 static const String WidgetTypeName;
78
79 /*************************************************************************
80 Child Widget name suffix constants
81 *************************************************************************/
83 static const String DummyName;
84
85 /*************************************************************************
86 Event name constants
87 *************************************************************************/
89 static const String EventNamespace;
90
93
94 /*************************************************************************
95 Construction and Destruction
96 *************************************************************************/
101 GridLayoutContainer(const String& type, const String& name);
102
107 virtual ~GridLayoutContainer(void);
108
113 void setGridDimensions(size_t width, size_t height);
118 void setGrid(const Sizef &size);
119
124 size_t getGridWidth() const;
125
130 size_t getGridHeight() const;
131
136 Sizef getGrid() const;
137
138
148
154
161
168
173 void autoPositioningSkipCells(size_t cells);
174
192 void addChildToPosition(Window* window, size_t gridX, size_t gridY);
193
198 Window* getChildAtPosition(size_t gridX, size_t gridY);
199
207 void removeChildFromPosition(size_t gridX, size_t gridY);
208
216 virtual void swapChildPositions(size_t wnd1, size_t wnd2);
217
222 void swapChildPositions(size_t gridX1, size_t gridY1,
223 size_t gridX2, size_t gridY2);
224
229 void swapChildren(Window* wnd1, Window* wnd2);
230
235 void swapChildren(Window* wnd1, const String& wnd2);
236
241 void swapChildren(const String& wnd1, Window* wnd2);
242
247 void moveChildToPosition(Window* wnd, size_t gridX, size_t gridY);
248
254 size_t gridX, size_t gridY);
255
257 virtual void layout();
258
259protected:
269
271 size_t mapFromGridToIdx(size_t gridX, size_t gridY,
272 size_t gridWidth, size_t gridHeight) const;
274 void mapFromIdxToGrid(size_t idx, size_t& gridX, size_t& gridY,
275 size_t gridWidth, size_t gridHeight) const;
276
280 UVector2 getGridCellOffset(const std::vector<UDim>& colSizes,
281 const std::vector<UDim>& rowSizes,
282 size_t gridX, size_t gridY) const;
284 USize getGridSize(const std::vector<UDim>& colSizes,
285 const std::vector<UDim>& rowSizes) const;
286
288 size_t translateAPToGridIdx(size_t APIdx) const;
289
294
301
310
315
319 bool isDummy(Window* wnd) const;
320
322 virtual void addChild_impl(Element* element);
324 virtual void removeChild_impl(Element* element);
325
326private:
327 void addGridLayoutContainerProperties(void);
328};
329
330template<>
331class PropertyHelper<GridLayoutContainer::AutoPositioning>
332{
333public:
338
339 static const String& getDataTypeName()
340 {
341 static String type("AutoPositioning");
342
343 return type;
344 }
345
346 static return_type fromString(const String& str)
347 {
348 if (str == "Disabled")
349 {
351 }
352 else if (str == "Top to Bottom")
353 {
355 }
356 else
357 {
359 }
360 }
361
362 static string_return_type toString(pass_type val)
363 {
365 {
366 return "Left to Right";
367 }
368 else if (val == GridLayoutContainer::AP_Disabled)
369 {
370 return "Disabled";
371 }
373 {
374 return "Top to Bottom";
375 }
376 else
377 {
378 assert(false && "Invalid Auto Positioning");
379 return "Left to Right";
380 }
381 }
382};
383
384} // End of CEGUI namespace section
385
386#if defined(_MSC_VER)
387# pragma warning(pop)
388#endif
389
390#endif // end of guard _CEGUIGridLayoutContainer_h_
A positioned and sized rectangular node in a tree graph.
Definition Element.h:246
A Layout Container window layouting it's children into a grid.
Definition GridLayoutContainer.h:48
size_t getNextAutoPositioningIdx() const
Retrieves auto positioning "sequence position", this will be used next time when addChild is called.
void moveChildToPosition(Window *wnd, size_t gridX, size_t gridY)
Moves given child window to given grid position.
USize getGridSize(const std::vector< UDim > &colSizes, const std::vector< UDim > &rowSizes) const
calculates total grid size
void removeChildFromPosition(size_t gridX, size_t gridY)
Removes the child window that is currently at given grid position.
size_t d_gridHeight
stores grid height - amount of rows
Definition GridLayoutContainer.h:293
Sizef getGrid() const
Retrieves grid width, the amount of cells in one row.
void autoPositioningSkipCells(size_t cells)
Skips given number of cells in the auto positioning sequence.
void setGridDimensions(size_t width, size_t height)
Sets grid's dimensions.
bool isDummy(Window *wnd) const
checks whether given window is a dummy
virtual void addChild_impl(Element *element)
Add given element to child list at an appropriate position.
size_t d_nextGridY
Definition GridLayoutContainer.h:309
virtual void swapChildPositions(size_t wnd1, size_t wnd2)
Swaps positions of 2 windows given by their index.
static const String EventNamespace
Namespace for global events.
Definition GridLayoutContainer.h:89
size_t d_nextDummyIdx
Definition GridLayoutContainer.h:314
AutoPositioning d_autoPositioning
stores currently used auto positioning method
Definition GridLayoutContainer.h:296
void swapChildren(Window *wnd1, const String &wnd2)
Swaps positions of given windows.
void swapChildren(Window *wnd1, Window *wnd2)
Swaps positions of given windows.
AutoPositioning
Definition GridLayoutContainer.h:56
@ AP_TopToBottom
Definition GridLayoutContainer.h:70
@ AP_Disabled
no auto positioning!
Definition GridLayoutContainer.h:58
@ AP_LeftToRight
Definition GridLayoutContainer.h:64
void setNextAutoPositioningIdx(size_t idx)
Sets the next auto positioning "sequence position", this will be used next time when addChild is call...
UVector2 getGridCellOffset(const std::vector< UDim > &colSizes, const std::vector< UDim > &rowSizes, size_t gridX, size_t gridY) const
void setGrid(const Sizef &size)
Sets grid's dimensions.
size_t mapFromGridToIdx(size_t gridX, size_t gridY, size_t gridWidth, size_t gridHeight) const
converts from grid cell position to idx
void mapFromIdxToGrid(size_t idx, size_t &gridX, size_t &gridY, size_t gridWidth, size_t gridHeight) const
converts from idx to grid cell position
Window * createDummy()
creates a dummy window
virtual ~GridLayoutContainer(void)
Destructor for GUISheet windows.
size_t d_nextGridX
Definition GridLayoutContainer.h:305
void addChildToPosition(Window *window, size_t gridX, size_t gridY)
Add the specified Window to specified grid position as a child of this Grid Layout Container....
size_t getGridHeight() const
Retrieves grid height, the amount of rows in the grid.
virtual void layout()
(re)layouts all windows inside this layout container immediately
size_t d_nextAutoPositioningIdx
Definition GridLayoutContainer.h:300
static const String WidgetTypeName
The unique typename of this widget.
Definition GridLayoutContainer.h:77
AutoPositioning getAutoPositioning() const
Retrieves current auto positioning method.
virtual void onChildOrderChanged(WindowEventArgs &e)
Handler called when children of this window gets rearranged in any way.
size_t d_gridWidth
stores grid width - amount of columns
Definition GridLayoutContainer.h:291
static const String EventChildOrderChanged
fired when child windows get rearranged
Definition GridLayoutContainer.h:92
GridLayoutContainer(const String &type, const String &name)
Constructor for GUISheet windows.
Window * getChildAtPosition(size_t gridX, size_t gridY)
Retrieves child window that is currently at given grid position.
void swapChildPositions(size_t gridX1, size_t gridY1, size_t gridX2, size_t gridY2)
Swaps positions of 2 windows given by grid positions.
size_t translateAPToGridIdx(size_t APIdx) const
translates auto positioning index to absolute grid index
size_t getGridWidth() const
Retrieves grid width, the amount of cells in one row.
void swapChildren(const String &wnd1, Window *wnd2)
Swaps positions of given windows.
static const String DummyName
Widget name for dummies.
Definition GridLayoutContainer.h:83
void setAutoPositioning(AutoPositioning positioning)
Sets new auto positioning method.
void moveChildToPosition(const String &wnd, size_t gridX, size_t gridY)
Moves named child window to given grid position.
virtual void removeChild_impl(Element *element)
Remove given element from child list.
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition LayoutContainer.h:54
Helper class used to convert various data types to and from the format expected in Property strings.
Definition PropertyHelper.h:84
String class used within the GUI system.
Definition String.h:64
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition InputEvent.h:252
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1