YSTest: TabControl.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

TabControl.h
浏览该文件的文档.
1 /*
2 © 2014-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_UI_TabControl_h_
29 #define YSL_INC_UI_TabControl_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YPanel
33 #include YFM_YSLib_UI_WidgetIteration
34
35 namespace YSLib
36 {
37
38 namespace UI
39 {
40
45 class YF_API TabBar : public Control, protected MLinearUIContainer
46 {
47 public:
48 using TabPtrType = unique_ptr<Control>;
49
51 SPos Offset = 0;
53 SDst MinWidth = 12;
58 std::function<void(PaintEventArgs&&)> PaintTabBackground{};
63 std::function<void(PaintEventArgs&&)>
64 PaintTabForeground{DefaultPaintTabBorder};
65
66 explicit
67 TabBar(const Rect& = {});
68
69 virtual void
70 operator+=(IWidget&);
71
72 virtual bool
73 operator-=(IWidget&);
74
75 DefWidgetChildrenGetter
76
77 using MLinearUIContainer::Contains;
78
80 using MLinearUIContainer::GetCount;
81
83 static void
84 DefaultPaintTabBorder(PaintEventArgs&&);
85
87 using MLinearUIContainer::Find;
88
93 SPos
94 PerformLayout();
95
96 void
97 Refresh(PaintEventArgs&&) override;
98
103 bool
104 SwitchPage(Control&);
105 };
106
107
112 class YF_API TabControl : public Control
113 {
114 public:
115 using iterator = ystdex::subscriptive_iterator<TabControl, IWidget>;
116
118 SDst BarHeight = 24;
119
120 private:
125 unique_ptr<TabBar> p_bar;
127 observer_ptr<Panel> p_page{};
129 vector<observer_ptr<Panel>> tab_pages{};
130
131 public:
132 explicit
133 TabControl(const Rect& = {});
134 DefDeMoveCtor(TabControl)
139 ~TabControl() override;
140
141 DefWidgetMemberIterationOperations(iterator)
142
143 PDefHOp(IWidget&, [], size_t idx) ynoexcept
144 ImplRet(YAssertNonnull(idx == 0 || p_page),
145 *ystdex::forward_as_array<observer_ptr<IWidget>>(
146 make_observer(p_bar.get()), p_page).begin()[idx])
147
153 void
154 operator+=(IWidget&);
155
156 DefGetter(const ynothrow, size_t, ChildrenCount, p_page ? 2 : 1)
158 Rect
159 GetPageBounds() const ynothrow;
161 DefGetter(const ynothrow, TabBar&, TabBarRef, Deref(p_bar))
166 DefGetter(const ynothrow, size_t, TabCount, GetTabBarRef().GetCount())
168 DefGetter(const ynothrow, const vector<observer_ptr<Panel>>&, Pages, tab_pages)
169
170
172 void
173 Attach(Control&);
174
180 size_t
181 Find(IWidget&) const;
182
187 bool
188 SwitchTab(Control&);
189
196 bool
197 SwitchPage(size_t);
199 bool
200 SwitchPage(Control&);
202
211 void
212 UpdateTabPages();
213 };
214
215 } // namespace UI;
216
217 } // namespace YSLib;
218
219 #endif
220
YSLib::UI::Control
控件。
Definition: YControl.h:275
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
DefWidgetMemberIterationOperations
#define DefWidgetMemberIterationOperations(_tIter)
定义部件成员迭代器起始、终止和范围操作。
Definition: WidgetIteration.h:121
YSLib::UI::TabBar::TabPtrType
unique_ptr< Control > TabPtrType
Definition: TabControl.h:48
ystdex::forward_as_array
common_array_t< _type, _tParams... > forward_as_array(_tParams &&...args)
转移指定参数至 std::array 对象。
Definition: array.hpp:66
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:240
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
YSLib::UI::TabControl::p_bar
unique_ptr< TabBar > p_bar
标签栏。
Definition: TabControl.h:125
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:440
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:114
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:42
YSLib::UI::MLinearUIContainer::Contains
Index is out of vWidgets[idx] Index is out of vWidgets[idx] bool Contains(IWidget &) const
判断是否包含指定部件。
Definition: YUIContainer.cpp:196
platform_ex::Attach
void Attach(COMPtr< _iCOM > &ptr, typename COMPtr< _iCOM >::InterfaceType *p) ynothrow
Definition: COM.h:384
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
ystdex
特性测试宏。
Definition: ydef.h:796
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:166
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1243
UI
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:720
YSLib::UI::MLinearUIContainer
线性部件容器模块。
Definition: YUIContainer.h:201
YModules.h
YSLib::UI::Panel
面板。
Definition: ypanel.h:45
YSLib::UI::TabBar
标签栏控件。
Definition: TabControl.h:45
DefWidgetChildrenGetter
#define DefWidgetChildrenGetter
定义部件成员迭代器范围操作。
Definition: WidgetIteration.h:113
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: memory.hpp:1042
YSLib::UI::PaintEventArgs
部件绘制参数。
Definition: YWidgetEvent.h:323
YF_API
#define YF_API
Definition: Platform.h:56
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
YSLib::UI::TabControl
标签容器控件。
Definition: TabControl.h:112
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:43