Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes

CEGUI::GridLayoutContainer Class Reference

A Layout Container window layouting it's children into a grid. More...

Inheritance diagram for CEGUI::GridLayoutContainer:
Collaboration diagram for CEGUI::GridLayoutContainer:

List of all members.

Public Types

enum  AutoPositioning { AP_Disabled, AP_LeftToRight, AP_TopToBottom }

Public Member Functions

 GridLayoutContainer (const String &type, const String &name)
 Constructor for GUISheet windows.
virtual ~GridLayoutContainer (void)
 Destructor for GUISheet windows.
void setGridDimensions (size_t width, size_t height)
 Sets grid's dimensions.
size_t getGridWidth () const
 Retrieves grid width, the amount of cells in one row.
size_t getGridHeight () const
 Retrieves grid height, the amount of rows in the grid.
void setAutoPositioning (AutoPositioning positioning)
 Sets new auto positioning method.
AutoPositioning getAutoPositioning () const
 Retrieves current auto positioning method.
void setNextAutoPositioningIdx (size_t idx)
 Sets the next auto positioning "sequence position", this will be used next time when addChildWindow is called.
size_t getNextAutoPositioningIdx () const
 Retrieves auto positioning "sequence position", this will be used next time when addChildWindow is called.
void autoPositioningSkipCells (size_t cells)
 Skips given number of cells in the auto positioning sequence.
void addChildWindowToPosition (Window *window, size_t gridX, size_t gridY)
 Add the specified Window to specified grid position as a child of this Grid Layout Container. If the Window window is already attached to a Window, it is detached before being added to this Window.
void addChildWindowToPosition (const String &name, size_t gridX, size_t gridY)
 Add the named Window to specified grid position as a child of this Grid Layout Container. If the Window window is already attached to a Window, it is detached before being added to this Window.
WindowgetChildWindowAtPosition (size_t gridX, size_t gridY)
 Retrieves child window that is currently at given grid position.
void removeChildWindowFromPosition (size_t gridX, size_t gridY)
 Removes the child window that is currently at given grid position.
virtual void swapChildWindowPositions (size_t wnd1, size_t wnd2)
 Swaps positions of 2 windows given by their index.
void swapChildWindowPositions (size_t gridX1, size_t gridY1, size_t gridX2, size_t gridY2)
 Swaps positions of 2 windows given by grid positions.
void swapChildWindows (Window *wnd1, Window *wnd2)
 Swaps positions of given windows.
void swapChildWindows (Window *wnd1, const String &wnd2)
 Swaps positions of given windows.
void swapChildWindows (const String &wnd1, Window *wnd2)
 Swaps positions of given windows.
void moveChildWindowToPosition (Window *wnd, size_t gridX, size_t gridY)
 Moves given child window to given grid position.
void moveChildWindowToPosition (const String &wnd, size_t gridX, size_t gridY)
 Moves named child window to given grid position.
virtual void layout ()

Static Public Attributes

static const String WidgetTypeName
 The unique typename of this widget.
static const String DummyNameSuffix
 Widget name suffix for dummies.
static const String EventNamespace
 Namespace for global events.
static const String EventChildWindowOrderChanged
 fired when child windows get rearranged

Protected Member Functions

virtual void onChildWindowOrderChanged (WindowEventArgs &e)
 Handler called when children of this window gets rearranged in any way.
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
UVector2 getGridCellOffset (const std::vector< UDim > &colSizes, const std::vector< UDim > &rowSizes, size_t gridX, size_t gridY) const
UVector2 getGridSize (const std::vector< UDim > &colSizes, const std::vector< UDim > &rowSizes) const
 calculates total grid size
size_t translateAPToGridIdx (size_t APIdx) const
 translates auto positioning index to absolute grid index
WindowcreateDummy ()
 creates a dummy window
bool isDummy (Window *wnd) const
 checks whether given window is a dummy
virtual void addChild_impl (Window *wnd)
virtual void removeChild_impl (Window *wnd)
virtual bool testClassName_impl (const String &class_name) const
 Return whether this window was inherited from the given class name at some point in the inheritance hierarchy.

Protected Attributes

size_t d_gridWidth
 stores grid width - amount of columns
size_t d_gridHeight
 stores grid height - amount of rows
AutoPositioning d_autoPositioning
 stores currently used auto positioning method
size_t d_nextAutoPositioningIdx
size_t d_nextGridX
size_t d_nextGridY
size_t d_nextDummyIdx

Detailed Description

A Layout Container window layouting it's children into a grid.


Member Enumeration Documentation

enumerates auto positioning methods for the grid - these allow you to fill the grid without specifying gridX and gridY positions for each addChildWindow.

Enumerator:
AP_Disabled 

no auto positioning!

AP_LeftToRight 

Left to right positioning:

  • 1 2 3
  • 4 5 6
AP_TopToBottom 

Top to bottom positioning

  • 1 3 5
  • 2 4 6

Member Function Documentation

virtual void CEGUI::GridLayoutContainer::addChild_impl ( Window wnd  )  [protected, virtual]

Add given window to child list at an appropriate position.

Reimplemented from CEGUI::LayoutContainer.

void CEGUI::GridLayoutContainer::addChildWindowToPosition ( const String name,
size_t  gridX,
size_t  gridY 
)

Add the named Window to specified grid position as a child of this Grid Layout Container. If the Window window is already attached to a Window, it is detached before being added to this Window.

If something is already in given grid cell, it gets removed!
This disabled auto positioning from further usage! You need to call setAutoPositioning(..) to set it back to your desired value and use setAutoPositioningIdx(..) to set it's starting point back
See also:
Window::addChildWindow
void CEGUI::GridLayoutContainer::addChildWindowToPosition ( Window window,
size_t  gridX,
size_t  gridY 
)

Add the specified Window to specified grid position as a child of this Grid Layout Container. If the Window window is already attached to a Window, it is detached before being added to this Window.

If something is already in given grid cell, it gets removed!
This disabled auto positioning from further usage! You need to call setAutoPositioning(..) to set it back to your desired value and use setAutoPositioningIdx(..) to set it's starting point back
See also:
Window::addChildWindow
UVector2 CEGUI::GridLayoutContainer::getGridCellOffset ( const std::vector< UDim > &  colSizes,
const std::vector< UDim > &  rowSizes,
size_t  gridX,
size_t  gridY 
) const [protected]

calculates grid cell offset (relative to position of this layout container)

virtual void CEGUI::GridLayoutContainer::layout (  )  [virtual]

(re)layouts all windows inside this layout container immediately

Implements CEGUI::LayoutContainer.

virtual void CEGUI::GridLayoutContainer::onChildWindowOrderChanged ( WindowEventArgs e  )  [protected, virtual]

Handler called when children of this window gets rearranged in any way.

Parameters:
e WindowEventArgs object whose 'window' field is set this layout container.
virtual void CEGUI::GridLayoutContainer::removeChild_impl ( Window wnd  )  [protected, virtual]

Remove given window from child list.

Reimplemented from CEGUI::LayoutContainer.

void CEGUI::GridLayoutContainer::removeChildWindowFromPosition ( size_t  gridX,
size_t  gridY 
)

Removes the child window that is currently at given grid position.

See also:
Window::removeChildWindow
void CEGUI::GridLayoutContainer::setAutoPositioning ( AutoPositioning  positioning  ) 

Sets new auto positioning method.

The newly set auto positioning sequence will start over! Use setAutoPositioningIdx to set it's starting point
virtual void CEGUI::GridLayoutContainer::swapChildWindowPositions ( size_t  wnd1,
size_t  wnd2 
) [virtual]

Swaps positions of 2 windows given by their index.

For advanced users only!
virtual bool CEGUI::GridLayoutContainer::testClassName_impl ( const String class_name  )  const [inline, protected, virtual]

Return whether this window was inherited from the given class name at some point in the inheritance hierarchy.

Parameters:
class_name The class name that is to be checked.
Returns:
true if this window was inherited from class_name. false if not.

Reimplemented from CEGUI::LayoutContainer.

References CEGUI::LayoutContainer::testClassName_impl().


Member Data Documentation

stores next auto positioning index (will be used for next added window if d_autoPositioning != AP_Disabled)

stores next used dummy suffix index (used to generate unique dummy names)

stores next used grid X position (only used if d_autoPositioning == AP_Disabled)

stores next used grid Y position (only used if d_autoPositioning == AP_Disabled)