YSTest: WidgetIteration.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
WidgetIteration.h
浏览该文件的文档.
1 /*
2 © 2012-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_WidgetIteration_h_
29 #define YSL_INC_UI_WidgetIteration_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YWidget
33
34 namespace YSLib
35 {
36
42 #define DefSubscriptor(_q, _type, ...) \
43 _type& \
44 operator[](size_t idx) _q \
45 { \
46 return ystdex::forward_as_array<std::reference_wrapper<_type>>( \
47 __VA_ARGS__).begin()[idx]; \
48 }
49
54 #define DefSubscriptorBase(_q, _type, _tBase, _vBaseN, ...) \
55 _type& \
56 operator[](size_t idx) _q \
57 { \
58 return idx < _vBaseN ? _tBase::operator[](idx) \
59 : ystdex::forward_as_array<std::reference_wrapper<_type>>( \
60 __VA_ARGS__).begin()[idx - _vBaseN].get(); \
61 }
62
63
64 namespace UI
65 {
66
72 #define DefWidgetSubscriptor(...) \
73 DefSubscriptor(ynoexcept, IWidget, __VA_ARGS__) \
74 DefGetter(const ynothrow, size_t, ChildrenCount, \
75 ystdex::sizeof_params(__VA_ARGS__))
76
82 #define DefWidgetSubscriptorBase(_tBase, ...) \
83 DefSubscriptorBase(ynoexcept, IWidget, _tBase, _tBase::GetChildrenCount(), \
84 __VA_ARGS__) \
85 DefGetter(const ynothrow, size_t, ChildrenCount, \
86 _tBase::GetChildrenCount() + ystdex::sizeof_params(__VA_ARGS__))
87
93 #define DefWidgetBegin(_tIter) \
94 PDefH(_tIter, begin, ) \
95 ImplRet(_tIter(*this, 0))
96
102 #define DefWidgetEnd(_tIter) \
103 PDefH(_tIter, end, ) \
104 ImplRet(_tIter(*this, GetChildrenCount()))
105
113 #define DefWidgetChildrenGetter \
114 DefGetter(override, WidgetRange, Children, WidgetRange(begin(), end()))
115
121 #define DefWidgetMemberIterationOperations(_tIter) \
122 DefWidgetBegin(_tIter) \
123 DefWidgetEnd(_tIter) \
124 DefWidgetChildrenGetter
125
131 #define DefWidgetMemberIteration(...) \
132 DefWidgetMemberIterationOperations(iterator) \
133 DefWidgetSubscriptor(__VA_ARGS__)
134
139 #define DefWidgetMemberIterationBase(_tBase, ...) \
140 DefWidgetMemberIterationOperations(iterator) \
141 DefWidgetSubscriptorBase(_tBase, __VA_ARGS__)
142
143 } // namespace UI;
144
145 } // namespace YSLib;
146
147 #endif
148
YModules.h