Crazy Eddies GUI System: CEGUIGridLayoutContainer.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIGridLayoutContainer.h

    00001 /***********************************************************************
    00002     filename:   CEGUIGridLayoutContainer.h
    00003     created:    01/8/2010
    00004     author:     Martin Preisler
    00005
    00006     purpose:    Interface to a vertical layout container
    00007 *************************************************************************/
    00008 /***************************************************************************
    00009  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
    00010  *
    00011  *   Permission is hereby granted, free of charge, to any person obtaining
    00012  *   a copy of this software and associated documentation files (the
    00013  *   "Software"), to deal in the Software without restriction, including
    00014  *   without limitation the rights to use, copy, modify, merge, publish,
    00015  *   distribute, sublicense, and/or sell copies of the Software, and to
    00016  *   permit persons to whom the Software is furnished to do so, subject to
    00017  *   the following conditions:
    00018  *
    00019  *   The above copyright notice and this permission notice shall be
    00020  *   included in all copies or substantial portions of the Software.
    00021  *
    00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00028  *   OTHER DEALINGS IN THE SOFTWARE.
    00029  ***************************************************************************/
    00030 #ifndef _CEGUIGridLayoutContainer_h_
    00031 #define _CEGUIGridLayoutContainer_h_
    00032
    00033 #include "CEGUILayoutContainer.h"
    00034 #include "../CEGUIWindowFactory.h"
    00035 #include "CEGUIGridLayoutContainerProperties.h"
    00036
    00037 #if defined(_MSC_VER)
    00038 #   pragma warning(push)
    00039 #   pragma warning(disable : 4251)
    00040 #endif
    00041
    00042 // Start of CEGUI namespace section
    00043 namespace CEGUI
    00044 {
    00049 class CEGUIEXPORT GridLayoutContainer : public LayoutContainer
    00050 {
    00051 public:
    00057     enum AutoPositioning
    00058     {
    00060         AP_Disabled,
    00066         AP_LeftToRight,
    00072         AP_TopToBottom
    00073     };
    00074
    00075     /*************************************************************************
    00076         Constants
    00077     *************************************************************************/
    00079     static const String WidgetTypeName;
    00080
    00081     /*************************************************************************
    00082         Child Widget name suffix constants
    00083     *************************************************************************/
    00085     static const String DummyNameSuffix;
    00086
    00087     /*************************************************************************
    00088         Event name constants
    00089     *************************************************************************/
    00091     static const String EventNamespace;
    00092
    00094     static const String EventChildWindowOrderChanged;
    00095
    00096     /*************************************************************************
    00097         Construction and Destruction
    00098     *************************************************************************/
    00103     GridLayoutContainer(const String& type, const String& name);
    00104
    00109     virtual ~GridLayoutContainer(void);
    00110
    00115     void setGridDimensions(size_t width, size_t height);
    00116
    00121     size_t getGridWidth() const;
    00122
    00127     size_t getGridHeight() const;
    00128
    00137     void setAutoPositioning(AutoPositioning positioning);
    00138
    00143     AutoPositioning getAutoPositioning() const;
    00144
    00150     void setNextAutoPositioningIdx(size_t idx);
    00151
    00157     size_t getNextAutoPositioningIdx() const;
    00158
    00163     void autoPositioningSkipCells(size_t cells);
    00164
    00182     void addChildWindowToPosition(Window* window, size_t gridX, size_t gridY);
    00183
    00201     void addChildWindowToPosition(const String& name, size_t gridX, size_t gridY);
    00202
    00207     Window* getChildWindowAtPosition(size_t gridX, size_t gridY);
    00208
    00216     void removeChildWindowFromPosition(size_t gridX, size_t gridY);
    00217
    00225     virtual void swapChildWindowPositions(size_t wnd1, size_t wnd2);
    00226
    00231     void swapChildWindowPositions(size_t gridX1, size_t gridY1,
    00232                                   size_t gridX2, size_t gridY2);
    00233
    00238     void swapChildWindows(Window* wnd1, Window* wnd2);
    00239
    00244     void swapChildWindows(Window* wnd1, const String& wnd2);
    00245
    00250     void swapChildWindows(const String& wnd1, Window* wnd2);
    00251
    00256     void moveChildWindowToPosition(Window* wnd, size_t gridX, size_t gridY);
    00257
    00262     void moveChildWindowToPosition(const String& wnd,
    00263                                    size_t gridX, size_t gridY);
    00264
    00266     virtual void layout();
    00267
    00268 protected:
    00277     virtual void onChildWindowOrderChanged(WindowEventArgs& e);
    00278
    00280     size_t mapFromGridToIdx(size_t gridX, size_t gridY,
    00281                             size_t gridWidth, size_t gridHeight) const;
    00283     void mapFromIdxToGrid(size_t idx, size_t& gridX, size_t& gridY,
    00284                           size_t gridWidth, size_t gridHeight) const;
    00285
    00289     UVector2 getGridCellOffset(const std::vector<UDim>& colSizes,
    00290                                const std::vector<UDim>& rowSizes,
    00291                                size_t gridX, size_t gridY) const;
    00293     UVector2 getGridSize(const std::vector<UDim>& colSizes,
    00294                          const std::vector<UDim>& rowSizes) const;
    00295
    00297     size_t translateAPToGridIdx(size_t APIdx) const;
    00298
    00300     size_t d_gridWidth;
    00302     size_t d_gridHeight;
    00303
    00305     AutoPositioning d_autoPositioning;
    00309     size_t d_nextAutoPositioningIdx;
    00310
    00314     size_t d_nextGridX;
    00318     size_t d_nextGridY;
    00319
    00323     size_t d_nextDummyIdx;
    00324
    00326     Window* createDummy();
    00328     bool isDummy(Window* wnd) const;
    00329
    00331     virtual void addChild_impl(Window* wnd);
    00333     virtual void removeChild_impl(Window* wnd);
    00334
    00346     virtual bool    testClassName_impl(const String& class_name) const
    00347     {
    00348         if (class_name == "GridLayoutContainer")  return true;
    00349
    00350         return LayoutContainer::testClassName_impl(class_name);
    00351     }
    00352
    00353 private:
    00354     /*************************************************************************
    00355         Properties for GridLayoutContainer class
    00356     *************************************************************************/
    00357     static GridLayoutContainerProperties::GridSize d_gridSizeProperty;
    00358     static GridLayoutContainerProperties::AutoPositioning d_autoPositioningProperty;
    00359
    00360     void addGridLayoutContainerProperties(void);
    00361 };
    00362
    00363 } // End of  CEGUI namespace section
    00364
    00365 #if defined(_MSC_VER)
    00366 #   pragma warning(pop)
    00367 #endif
    00368
    00369 #endif  // end of guard _CEGUIGridLayoutContainer_h_
    00370