Otclient  14/8/2020
uigridlayout.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef UIGRIDLAYOUT_H
24 #define UIGRIDLAYOUT_H
25 
26 #include "uilayout.h"
27 
28 // @bindclass
29 class UIGridLayout : public UILayout
30 {
31 public:
32  UIGridLayout(UIWidgetPtr parentWidget);
33 
34  void applyStyle(const OTMLNodePtr& styleNode);
35  void removeWidget(const UIWidgetPtr& widget);
36  void addWidget(const UIWidgetPtr& widget);
37 
38  void setCellSize(const Size& size) { m_cellSize = size; update(); }
39  void setCellWidth(int width) { m_cellSize.setWidth(width); update(); }
40  void setCellHeight(int height) { m_cellSize.setHeight(height); update(); }
41  void setCellSpacing(int spacing) { m_cellSpacing = spacing; update(); }
42  void setNumColumns(int columns) { m_numColumns = columns; update(); }
43  void setNumLines(int lines) { m_numLines = lines; update(); }
44  void setAutoSpacing(bool enable) { m_autoSpacing = enable; update(); }
45  void setFitChildren(bool enable) { m_fitChildren = enable; update(); }
46  void setFlow(bool enable) { m_flow = enable; update(); }
47 
48  Size getCellSize() { return m_cellSize; }
49  int getCellSpacing() { return m_cellSpacing; }
50  int getNumColumns() { return m_numColumns; }
51  int getNumLines() { return m_numLines; }
52 
53  virtual bool isUIGridLayout() { return true; }
54 
55 protected:
56  bool internalUpdate();
57 
58 private:
59  Size m_cellSize;
60  int m_cellSpacing;
61  int m_numColumns;
62  int m_numLines;
63  stdext::boolean<false> m_autoSpacing;
64  stdext::boolean<false> m_fitChildren;
66 };
67 
68 #endif
UILayout
Definition: uilayout.h:31
UIGridLayout::getCellSpacing
int getCellSpacing()
Definition: uigridlayout.h:49
UIGridLayout::addWidget
void addWidget(const UIWidgetPtr &widget)
Definition: uigridlayout.cpp:67
TSize::setWidth
void setWidth(T w)
Definition: size.h:47
UIGridLayout::getCellSize
Size getCellSize()
Definition: uigridlayout.h:48
UIGridLayout::setCellSize
void setCellSize(const Size &size)
Definition: uigridlayout.h:38
UIGridLayout::setCellHeight
void setCellHeight(int height)
Definition: uigridlayout.h:40
UIGridLayout::internalUpdate
bool internalUpdate()
Definition: uigridlayout.cpp:72
UIGridLayout::setFlow
void setFlow(bool enable)
Definition: uigridlayout.h:46
stdext::boolean< false >
UIGridLayout::isUIGridLayout
virtual bool isUIGridLayout()
Definition: uigridlayout.h:53
UIGridLayout::setFitChildren
void setFitChildren(bool enable)
Definition: uigridlayout.h:45
UIGridLayout::setCellSpacing
void setCellSpacing(int spacing)
Definition: uigridlayout.h:41
TSize::setHeight
void setHeight(T h)
Definition: size.h:48
UIGridLayout::getNumLines
int getNumLines()
Definition: uigridlayout.h:51
UIGridLayout
Definition: uigridlayout.h:29
UIGridLayout::UIGridLayout
UIGridLayout(UIWidgetPtr parentWidget)
Definition: uigridlayout.cpp:28
UIGridLayout::setAutoSpacing
void setAutoSpacing(bool enable)
Definition: uigridlayout.h:44
UILayout::update
void update()
Definition: uilayout.cpp:28
UIGridLayout::setNumColumns
void setNumColumns(int columns)
Definition: uigridlayout.h:42
stdext::shared_object_ptr< UIWidget >
UIGridLayout::setNumLines
void setNumLines(int lines)
Definition: uigridlayout.h:43
uilayout.h
UIGridLayout::getNumColumns
int getNumColumns()
Definition: uigridlayout.h:50
UIGridLayout::applyStyle
void applyStyle(const OTMLNodePtr &styleNode)
Definition: uigridlayout.cpp:36
TSize< int >
UIGridLayout::setCellWidth
void setCellWidth(int width)
Definition: uigridlayout.h:39
UIGridLayout::removeWidget
void removeWidget(const UIWidgetPtr &widget)
Definition: uigridlayout.cpp:62