MyGUI: MyGUI_TabControl.h Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_TabControl.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_TAB_CONTROL_H_
8#define MYGUI_TAB_CONTROL_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Widget.h"
12#include "MyGUI_Any.h"
13#include "MyGUI_EventPair.h"
14#include "MyGUI_ControllerFadeAlpha.h"
15#include "MyGUI_IItem.h"
16#include "MyGUI_IItemContainer.h"
17
18namespace MyGUI
19{
20
21 typedef delegates::CMultiDelegate2<TabControl*, size_t> EventHandle_TabPtrSizeT;
22
26 class MYGUI_EXPORT TabControl :
27 public Widget,
28 public IItemContainer,
29 public MemberObsolete<TabControl>
30 {
31 // для уведобления об удалении
32 //FIXME
33 friend class TabItem;
34
35 MYGUI_RTTI_DERIVED( TabControl )
36
37 public:
38 TabControl();
39
40 struct TabItemInfo
41 {
42 TabItemInfo(int _width, const UString& _name, TabItem* _item, Any _data) :
43 width(_width),
44 name(_name),
45 item(_item),
46 data(_data)
47 {
48 }
49
50 int width;
51 UString name;
52 TabItem* item;
53 Any data;
54 };
55
56 typedef std::vector<TabItemInfo> VectorTabItemInfo;
57
59 void setPosition(const IntPoint& _value) override;
61 void setSize(const IntSize& _value) override;
63 void setCoord(const IntCoord& _value) override;
64
65 using Widget::setPosition;
66 using Widget::setSize;
67 using Widget::setCoord;
68
69 //------------------------------------------------------------------------------//
70 // манипуляции айтемами
71
73 size_t getItemCount() const;
74
76 TabItem* insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
78 TabItem* insertItem(TabItem* _to, const UString& _name, Any _data = Any::Null);
79
81 TabItem* addItem(const UString& _name, Any _data = Any::Null);
82
84 void removeItemAt(size_t _index);
86 void removeItem(TabItem* _item);
87
89 void removeAllItems();
90
91
93 TabItem* getItemAt(size_t _index) const;
94
96 size_t getItemIndex(const TabItem* _item) const;
97
99 size_t findItemIndex(const TabItem* _item);
100
102 size_t findItemIndexWith(const UString& _name);
103
105 TabItem* findItemWith(const UString& _name);
106
107 void swapItems(size_t _index1, size_t _index2);
108
109 //------------------------------------------------------------------------------//
110 // манипуляции выделениями
111
113 size_t getIndexSelected() const;
114
116 TabItem* getItemSelected() const;
117
119 void setIndexSelected(size_t _index);
120
122 void setItemSelected(TabItem* _item);
123
124
125 //------------------------------------------------------------------------------//
126 // манипуляции данными
127
129 void setItemDataAt(size_t _index, Any _data);
131 void setItemData(TabItem* _item, Any _data);
132
134 void clearItemDataAt(size_t _index);
136 void clearItemData(TabItem* _item);
137
139 template <typename ValueType>
140 ValueType* getItemDataAt(size_t _index, bool _throw = true)
141 {
142 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "TabControl::getItemDataAt");
143 return mItemsInfo[_index].data.castType<ValueType>(_throw);
144 }
146 template <typename ValueType>
147 ValueType* getItemData(TabItem* _item, bool _throw = true)
148 {
149 return getItemDataAt<ValueType>(getItemIndex(_item), _throw);
150 }
151
152
153 //------------------------------------------------------------------------------//
154 // манипуляции отображением
155
157 void setItemNameAt(size_t _index, const UString& _name);
158
160 void setItemName(TabItem* _item, const UString& _name);
161
163 const UString& getItemNameAt(size_t _index) const;
164
166 const UString& getItemName(const TabItem* _item) const;
167
168
169 //------------------------------------------------------------------------------//
170 // манипуляции выдимостью
171
173 void beginToItemAt(size_t _index);
174
176 void beginToItem(const TabItem* _item);
178 void beginToItemFirst();
180 void beginToItemLast();
182 void beginToItemSelected();
183
184
185 //------------------------------------------------------------------------------//
186 // остальные манипуляции
187
189 void setButtonWidthAt(size_t _index, int _width = DEFAULT);
191 void setButtonWidth(TabItem* _item, int _width = DEFAULT);
192
194 int getButtonWidthAt(size_t _index) const;
196 int getButtonWidth(TabItem* _item) const;
197
198 //------------------------------------------------------------------------------//
199
201 void setButtonDefaultWidth(int _value);
203 int getButtonDefaultWidth() const;
204
206 void setButtonAutoWidth(bool _value);
208 bool getButtonAutoWidth() const;
209
211 void setSmoothShow(bool _value);
213 bool getSmoothShow() const;
214
215 /*events:*/
221 EventPair<EventHandle_WidgetSizeT, EventHandle_TabPtrSizeT> eventTabChangeSelect;
222
223 /*internal:*/
224 // IItemContainer impl
225 size_t _getItemCount() const override;
226 void _addItem(const MyGUI::UString& _name) override;
227 void _removeItemAt(size_t _index) override;
228 Widget* _getItemAt(size_t _index) const override;
229 void _setItemNameAt(size_t _index, const UString& _name) override;
230 const UString& _getItemNameAt(size_t _index) const override;
231
232 protected:
233 void initialiseOverride() override;
234 void shutdownOverride() override;
235
236 void updateBar();
237
238 void notifyPressedButtonEvent(MyGUI::Widget* _sender);
239 void notifyPressedBarButtonEvent(MyGUI::Widget* _sender);
240
241 int _getTextWidth(const UString& _text);
242
243 void _showItem(TabItem* _sheet, bool _show, bool _smooth);
244
245 void _createItemButton();
246
247 void _insertItem(size_t _index, const UString& _name, TabItem* _sheet, Any _data);
248
249 // вкладка при удалении уведомляет таб
250 void _notifyDeleteItem(TabItem* _item);
251
252 void onWidgetCreated(Widget* _widget) override;
253
254 void setPropertyOverride(const std::string& _key, const std::string& _value) override;
255
256 private:
257 void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
258
259 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
260
261 Widget* _getWidgetTemplate();
262 Widget* _getWidgetBar();
263
264 Button* createButton();
265 void updateBarOld();
266 void updateBarNew();
267
268 private:
269 int mOffsetTab; // смещение бара при показе кнопок
270 bool mButtonShow;
271 int mWidthBar; // ширина в которую помещаються все кнопки
272 std::vector<Button*> mItemButton; // список кнопок, не должно равно списку страниц
273 std::string mButtonSkinName;
274 std::string mEmptySkinName;
275
276 Widget* mWidgetBar;
277 Button* mButtonLeft;
278 Button* mButtonRight;
279 Widget* mButtonDecor;
280 VectorWidgetPtr mWidgetsPatch; // список виджетов которые нужно показать при показе кнопки
281 Widget* mEmptyBarWidget;
282 Widget* mItemTemplate;
283
284 // информация о вкладках
285 VectorTabItemInfo mItemsInfo;
286 size_t mStartIndex;
287 size_t mIndexSelect;
288
289 int mButtonDefaultWidth;
290 bool mSmoothShow;
291 bool mButtonAutoWidth;
292
293 // флаг, чтобы отсеч уведомления от вкладок, при общем шутдауне виджета
294 bool mShutdown;
295
296 Widget* mHeaderPlace;
297 Widget* mControls;
298 Widget* mEmpty;
299 };
300
301} // namespace MyGUI
302
303#endif // MYGUI_TAB_CONTROL_H_
MyGUI_Any.h
MyGUI_ControllerFadeAlpha.h
MYGUI_ASSERT_RANGE
#define MYGUI_ASSERT_RANGE(index, size, owner)
Definition MyGUI_Diagnostic.h:40
MyGUI_EventPair.h
MyGUI_IItem.h
MyGUI_IItemContainer.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:48
MyGUI_Widget.h
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:22
MyGUI::ControllerFadeAlpha
Definition MyGUI_ControllerFadeAlpha.h:20
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:27
MyGUI::EventPair
Definition MyGUI_EventPair.h:17
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::TabControl
widget description should be here.
Definition MyGUI_TabControl.h:30
MyGUI::TabControl::eventTabChangeSelect
EventPair< EventHandle_WidgetSizeT, EventHandle_TabPtrSizeT > eventTabChangeSelect
Definition MyGUI_TabControl.h:221
MyGUI::TabControl::VectorTabItemInfo
std::vector< TabItemInfo > VectorTabItemInfo
Definition MyGUI_TabControl.h:56
MyGUI::TabControl::getItemData
ValueType * getItemData(TabItem *_item, bool _throw=true)
Get item data.
Definition MyGUI_TabControl.h:147
MyGUI::TabControl::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_TabControl.h:140
MyGUI::TabItem
widget description should be here.
Definition MyGUI_TabItem.h:22
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:145
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:200
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::EventHandle_TabPtrSizeT
delegates::CMultiDelegate2< TabControl *, size_t > EventHandle_TabPtrSizeT
Definition MyGUI_TabControl.h:21
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::TabControl::TabItemInfo
Definition MyGUI_TabControl.h:41
MyGUI::TabControl::TabItemInfo::width
int width
Definition MyGUI_TabControl.h:50
MyGUI::TabControl::TabItemInfo::TabItemInfo
TabItemInfo(int _width, const UString &_name, TabItem *_item, Any _data)
Definition MyGUI_TabControl.h:42
MyGUI::TabControl::TabItemInfo::name
UString name
Definition MyGUI_TabControl.h:51
MyGUI::TabControl::TabItemInfo::item
TabItem * item
Definition MyGUI_TabControl.h:52
MyGUI::TabControl::TabItemInfo::data
Any data
Definition MyGUI_TabControl.h:53
MyGUI::types::TCoord< int >
MyGUI::types::TPoint< int >
MyGUI::types::TSize< int >