Otclient  14/8/2020
uilayout.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 UILAYOUT_H
24 #define UILAYOUT_H
25 
26 #include "declarations.h"
28 #include <framework/otml/otml.h>
29 
30 // @bindclass
31 class UILayout : public LuaObject
32 {
33 public:
34  UILayout(UIWidgetPtr parentWidget) : m_parentWidget(parentWidget) { m_updateDisabled = 0; }
35 
36  void update();
37  void updateLater();
38 
39  virtual void applyStyle(const OTMLNodePtr& /*styleNode*/) { }
40  virtual void addWidget(const UIWidgetPtr& /*widget*/) { }
41  virtual void removeWidget(const UIWidgetPtr& /*widget*/) { }
43  void enableUpdates() { m_updateDisabled = std::max<int>(m_updateDisabled-1,0); }
44 
45  void setParent(UIWidgetPtr parentWidget) { m_parentWidget = parentWidget; }
47 
48  bool isUpdateDisabled() { return m_updateDisabled > 0; }
49  bool isUpdating() { return m_updating; }
50 
51  virtual bool isUIAnchorLayout() { return false; }
52  virtual bool isUIBoxLayout() { return false; }
53  virtual bool isUIHorizontalLayout() { return false; }
54  virtual bool isUIVerticalLayout() { return false; }
55  virtual bool isUIGridLayout() { return false; }
56 
57 protected:
58  virtual bool internalUpdate() { return false; }
59 
64 };
65 
66 #endif
UILayout
Definition: uilayout.h:31
UILayout::UILayout
UILayout(UIWidgetPtr parentWidget)
Definition: uilayout.h:34
UILayout::updateLater
void updateLater()
Definition: uilayout.cpp:58
otml.h
UILayout::isUpdating
bool isUpdating()
Definition: uilayout.h:49
UILayout::removeWidget
virtual void removeWidget(const UIWidgetPtr &)
Definition: uilayout.h:41
UILayout::isUIVerticalLayout
virtual bool isUIVerticalLayout()
Definition: uilayout.h:54
UILayout::enableUpdates
void enableUpdates()
Definition: uilayout.h:43
UILayout::isUIAnchorLayout
virtual bool isUIAnchorLayout()
Definition: uilayout.h:51
UILayout::m_updating
stdext::boolean< false > m_updating
Definition: uilayout.h:61
UILayout::isUIBoxLayout
virtual bool isUIBoxLayout()
Definition: uilayout.h:52
UILayout::m_parentWidget
UIWidgetPtr m_parentWidget
Definition: uilayout.h:63
stdext::boolean< false >
UILayout::isUIGridLayout
virtual bool isUIGridLayout()
Definition: uilayout.h:55
UILayout::setParent
void setParent(UIWidgetPtr parentWidget)
Definition: uilayout.h:45
luaobject.h
UILayout::addWidget
virtual void addWidget(const UIWidgetPtr &)
Definition: uilayout.h:40
declarations.h
UILayout::m_updateScheduled
stdext::boolean< false > m_updateScheduled
Definition: uilayout.h:62
UILayout::update
void update()
Definition: uilayout.cpp:28
UILayout::internalUpdate
virtual bool internalUpdate()
Definition: uilayout.h:58
UILayout::getParentWidget
UIWidgetPtr getParentWidget()
Definition: uilayout.h:46
UILayout::isUpdateDisabled
bool isUpdateDisabled()
Definition: uilayout.h:48
UILayout::disableUpdates
void disableUpdates()
Definition: uilayout.h:42
stdext::shared_object_ptr< UIWidget >
UILayout::m_updateDisabled
int m_updateDisabled
Definition: uilayout.h:60
UILayout::isUIHorizontalLayout
virtual bool isUIHorizontalLayout()
Definition: uilayout.h:53
LuaObject
LuaObject, all script-able classes have it as base.
Definition: luaobject.h:30
UILayout::applyStyle
virtual void applyStyle(const OTMLNodePtr &)
Definition: uilayout.h:39