YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
TabControl.h
浏览该文件的文档.
1 /*
2  © 2014 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 
76 
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:
116 
118  SDst BarHeight = 24;
119 
120 private:
125  unique_ptr<TabBar> p_bar;
126  Panel* p_page{};
127  vector<Panel*> tab_pages{};
128 
129 public:
130  explicit
131  TabControl(const Rect& = {});
133 
135 
136  PDefHOp(IWidget&, [], size_t idx) ynoexcept
137  ImplRet(YAssertNonnull(idx == 0 || p_page), *ystdex::forward_as_array<
138  IWidget*>(p_bar.get(), p_page).begin()[idx])
139 
145  void
146  operator+=(IWidget&);
147 
148  DefGetter(const ynothrow, size_t, ChildrenCount, p_page ? 2 : 1)
150  Rect
151  GetPageBounds() const ynothrow;
153  DefGetter(const ynothrow, TabBar&, TabBarRef,
154  (YAssertNonnull(p_bar), *p_bar))
159  DefGetter(const ynothrow, size_t, TabCount, GetTabBarRef().GetCount())
160  DefGetter(const ynothrow, const vector<Panel*>&, Pages, tab_pages)
161 
162 
164  void
165  Attach(Control&);
166 
172  size_t
173  Find(IWidget&) const;
174 
179  bool
180  SwitchTab(Control&);
181 
188  bool
189  SwitchPage(size_t);
191  bool
192  SwitchPage(Control&);
194 
203  void
204  UpdateTabPages();
205 };
206 
207 } // namespace UI;
208 
209 } // namespace YSLib;
210 
211 #endif
212 
unique_ptr< Control > TabPtrType
Definition: TabControl.h:48
#define DefWidgetMemberIterationOperations(_tIter)
定义部件成员迭代器起始、终止和范围操作。
void Refresh(PaintEventArgs &&) override
刷新:按指定参数绘制界面并更新状态。
unique_ptr< TabBar > p_bar
标签栏。
Definition: TabControl.h:125
部件绘制参数。
Definition: ywgtevt.h:276
#define YF_API
Definition: Platform.h:64
成员下标迭代器。
Definition: iterator.hpp:1380
面板。
Definition: ypanel.h:45
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
控件。
Definition: ycontrol.h:275
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
*vWidgets[idx]*vWidgets[idx] bool Contains(IWidget &) const
判断是否包含指定部件。
Definition: yuicont.cpp:176
const IWidget &wgt SPos
Definition: ywidget.h:104
#define YAssertNonnull(_expr)
Definition: cassert.h:81
线性部件容器模块。
Definition: yuicont.h:176
std::array< _type, sizeof...(_tParams)> forward_as_array(_tParams &&...args)
取指定参数转移至 std::array 对象。
Definition: container.hpp:501
void Attach(COMPtr< _iCOM > &ptr, typename COMPtr< _iCOM >::InterfaceType *p) ynothrow
#define DefWidgetChildrenGetter
定义部件成员迭代器范围操作。
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
标签栏控件。
Definition: TabControl.h:45
Selected const shared_ptr< ListType > const pair< Color, Color > & DefDeMoveCtor(TextList) DefPredMem(const ynothrow
#define ynoexcept(...)
YSLib 无异常抛出保证:指定特定的异常规范。
Definition: ydef.h:526
标签容器控件。
Definition: TabControl.h:112