YSTest: ComboList.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

ComboList.h
浏览该文件的文档.
1 /*
2 © 2011-2015 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_ComboList_h_
29 #define YSL_INC_UI_ComboList_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_UI_ListControl
33 #include YFM_YSLib_UI_Scroll
34 #include YFM_YSLib_Service_FileSystem
35 //#include YFM_YSLib_UI_YStyle
36
37 namespace YSLib
38 {
39
40 namespace UI
41 {
42
49 class YF_API ListBox : public ScrollableContainer
50 {
51 public:
52 using ListType = TextList::ListType;
53 using ViewArgs = TextList::ViewArgs;
55 using IndexType = TextList::IndexType;
57 using ItemType = TextList::ItemType;
59 using iterator = ystdex::subscriptive_iterator<ListBox, IWidget>;
60
61 protected:
66 unique_ptr<TextList> pTextList;
67
69 explicit
70 ListBox(const Rect&, unique_ptr<TextList>);
71
72 public:
74 explicit
75 ListBox(const Rect& = {}, const shared_ptr<ListType>& = {});
76 DefDeMoveCtor(ListBox)
81 ~ListBox() override;
82
84 DefWidgetMemberIterationBase(ScrollableContainer, GetTextListRef())
85
86
87 PDefH(bool, Contains, ListType::size_type i) const ynothrow
88 ImplRet(GetTextListRef().Contains(i))
89 DefPredMem(const ynothrow, Selected, GetTextListRef())
90
92
93 DefGetter(, GEvent<void(IndexEventArgs)>&, Confirmed,
95 GetTextListRef().Confirmed)
96 DefGetterMem(const, ListType::size_type, HeadIndex, GetTextListRef())
97 DefGetterMem(const, ListType::size_type, SelectedIndex, GetTextListRef())
98 DefGetterMem(const, const ListType&, List, GetTextListRef())
99 DefGetterMem(, ListType&, ListRef, GetTextListRef())
101 DefGetter(, GEvent<void(IndexEventArgs)>&, Selected,
102 GetTextListRef().Selected)
104 DefGetter(const, TextList&, TextListRef, Deref(pTextList))
106 DefGetter(, GEvent<void(ViewArgs)>&, ViewChanged,
107 GetTextListRef().ViewChanged)
109
114 DefSetterMem(, const shared_ptr<ListType>&, List, GetTextListRef())
120 PDefH(void, SetSelected, ListType::size_type i)
121 ImplExpr(GetTextListRef().SetSelected(i))
122
129 PDefH(void, AdjustViewForContent, )
130 ImplExpr(GetTextListRef().AdjustViewForContent())
131
137 PDefH(void, AdjustViewLength, )
138 ImplExpr(GetTextListRef().AdjustViewLength())
139
145 PDefH(void, ClearSelected, )
146 ImplExpr(GetTextListRef().ClearSelected())
147
148 PDefH(void, ResetView, )
149 ImplExpr(GetTextListRef().ResetView())
150
157 void
158 ResizeForPreferred(const Size& sup, Size s = {});
159
160 PDefH(void, UpdateView, )
161 ImplExpr(UI::UpdateView(GetTextListRef()))
162 };
163
164
169 class YF_API FileBox : public ListBox
170 {
171 protected:
176 IO::Path pthDirectory;
177
178 public:
180 explicit
181 FileBox(const Rect& = {});
182 DefDeMoveCtor(FileBox)
187 ~FileBox() override;
188
193 bool
194 operator=(const IO::Path&);
195
200 bool
201 operator/=(const String&);
206 bool
207 operator/=(const IO::Path&);
208
213 DefGetter(const ynothrow, const IO::Path&, Directory, pthDirectory)
217 IO::Path
218 GetPath() const;
224 IO::Path
225 GetPath(typename ListType::size_type i) const;
226
232 bool
233 SetPath(const IO::Path&);
234
239 ListType
240 ListItems() const;
241 };
242
243
249 class YF_API DropDownList : public Button
250 {
251 public:
252 using ListType = ListBox::ListType;
258 using ViewArgs = ListBox::ViewArgs;
260 using iterator = ystdex::subscriptive_iterator<DropDownList, IWidget>;
261
262 protected:
264 ListBox lbContent;
265
266 public:
268 explicit
269 DropDownList(const Rect& = {}, const shared_ptr<ListType>& = {});
270 DefDeMoveCtor(DropDownList)
275 ~DropDownList() override;
276
278 DefWidgetMemberIteration(lbContent)
279
280
281 DefGetterMem(const ynothrow, const ListType&, List, lbContent)
283 DefGetterMem(ynothrow, ListType&, ListRef, lbContent)
288 DefGetterMem(ynothrow, GEvent<void(ViewArgs)>&, ViewChanged, lbContent)
293 DefGetterMem(ynothrow, GEvent<void(IndexEventArgs)>&, Selected, lbContent)
298 DefGetterMem(ynothrow, GEvent<void(IndexEventArgs)>&, Confirmed, lbContent)
299
304 DefSetterMem(, const shared_ptr<ListType>&, List, lbContent)
305
312 PDefH(void, AdjustViewForContent, )
313 ImplExpr(lbContent.AdjustViewForContent())
314
315 private:
320 void
321 DetachTopWidget();
322
323 public:
328 void
329 Refresh(PaintEventArgs&&) override;
330 };
331
332 } // namespace UI;
333
334 } // namespace YSLib;
335
336 #endif
337
YSLib::UI::ImplExpr
IWidget bool b ImplExpr(wgt.GetController().SetEnabled(b)) YF_API bool Enable(IWidget &
设置部件可用性，且当可用性改变时无效化部件区域。
DefPredMem
#define DefPredMem(_q, _n, _m)
Definition: YBaseMacro.h:237
YSLib::GEvent
事件模板。
Definition: YEvent.hpp:312
DefWidgetMemberIteration
#define DefWidgetMemberIteration(...)
定义部件成员下标及部件成员迭代器起始、终止和范围操作。
Definition: WidgetIteration.h:131
YSLib::UI::ListBox::pTextList
unique_ptr< TextList > pTextList
文本列表指针。
Definition: ComboList.h:66
YSLib::UI::FileBox
文件列表框。
Definition: ComboList.h:169
YSLib::UI::DropDownList::ListType
ListBox::ListType ListType
Definition: ComboList.h:252
YSLib::UI::MTextList::ListType
vector< ItemType > ListType
列表类型。
Definition: ListControl.h:142
YSLib::UI::UpdateView
void UpdateView(TextList &tl, bool is_active)
Definition: ListControl.cpp:425
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::UI::ListBox::ListType
TextList::ListType ListType
Definition: ComboList.h:52
YSLib::UI::Button
按钮。
Definition: Button.h:127
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
YSLib::UI::DropDownList::lbContent
ListBox lbContent
Definition: ComboList.h:264
YSLib::UI::AMUnitControlList::ViewArgs
GValueEventArgs< bool > ViewArgs
视图参数类型。
Definition: ListControl.h:63
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:246
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:240
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
DefSetterMem
#define DefSetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:267
YSLib::UI::MTextList::ItemType
String ItemType
项目类型：字符串。
Definition: ListControl.h:141
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:440
IO
YSLib::UI::DropDownList
下拉列表。
Definition: ComboList.h:249
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::UI::ScrollableContainer
带滚动条的容器。
Definition: Scroll.h:407
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:166
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
YSLib::UI::MTextList::IndexType
typename ListType::size_type IndexType
索引类型。
Definition: ListControl.h:143
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1243
YSLib::UI::FileBox::pthDirectory
IO::Path pthDirectory
目录的完整路径。
Definition: ComboList.h:176
UI
YSLib::i
return i
Definition: YCoreUtilities.h:176
YModules.h
YSLib::UI::TextList
文本列表。
Definition: ListControl.h:201
YSLib::UI::ListBox::IndexType
TextList::IndexType IndexType
Definition: ComboList.h:55
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:109
YSLib::UI::PaintEventArgs
部件绘制参数。
Definition: YWidgetEvent.h:323
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::UI::PDefH
PDefH(void, DisplayFor, IWidget &wgt, Timers::TimeSpan delay) ImplExpr(Show(wgt)
在一定时间内显示部件。
DefWidgetMemberIterationBase
#define DefWidgetMemberIterationBase(_tBase,...)
定义基于基类的部件成员下标及部件成员迭代器起始、终止和范围操作。
Definition: WidgetIteration.h:139
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
YSLib::UI::ListBox
带滚动条的文本列表框。
Definition: ComboList.h:49
YSLib::UI::GValueEventArgs
简单 UI 事件参数类。
Definition: YWidgetEvent.h:299
YSLib::UI::ListBox::ViewArgs
TextList::ViewArgs ViewArgs
Definition: ComboList.h:53