YSTest: ComboList.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

ComboList.h
浏览该文件的文档.
1 /*
2 © 2011-2016, 2020 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>& = {});
80 ~ListBox() override;
81
83 DefWidgetMemberIterationBase(ScrollableContainer, GetTextListRef())
84
85
86 PDefH(bool, Contains, ListType::size_type i) const ynothrow
87 ImplRet(GetTextListRef().Contains(i))
88 DefPredMem(const ynothrow, Selected, GetTextListRef())
89
91
92 DefGetter(, GEvent<void(IndexEventArgs)>&, Confirmed,
94 GetTextListRef().Confirmed)
95 DefGetterMem(const, ListType::size_type, HeadIndex, GetTextListRef())
96 DefGetterMem(const, ListType::size_type, SelectedIndex, GetTextListRef())
97 DefGetterMem(const, const ListType&, List, GetTextListRef())
98 DefGetterMem(, ListType&, ListRef, GetTextListRef())
100 DefGetter(, GEvent<void(IndexEventArgs)>&, Selected,
101 GetTextListRef().Selected)
103 DefGetter(const, TextList&, TextListRef, Deref(pTextList))
105 DefGetter(, GEvent<void(ViewArgs)>&, ViewChanged,
106 GetTextListRef().ViewChanged)
108
113 DefSetterMem(, const shared_ptr<ListType>&, List, GetTextListRef())
119 PDefH(void, SetSelected, ListType::size_type i)
120 ImplExpr(GetTextListRef().SetSelected(i))
121
128 PDefH(void, AdjustViewForContent, )
129 ImplExpr(GetTextListRef().AdjustViewForContent())
130
136 PDefH(void, AdjustViewLength, )
137 ImplExpr(GetTextListRef().AdjustViewLength())
138
144 PDefH(void, ClearSelected, )
145 ImplExpr(GetTextListRef().ClearSelected())
146
147 PDefH(void, ResetView, )
148 ImplExpr(GetTextListRef().ResetView())
149
156 void
157 ResizeForPreferred(const Size& sup, Size s = {});
158
159 PDefH(void, UpdateView, )
160 ImplExpr(UI::UpdateView(GetTextListRef()))
161 };
162
163
168 class YF_API FileBox : public ListBox
169 {
170 protected:
175 IO::Path pthDirectory;
176
177 public:
179 explicit
180 FileBox(const Rect& = {});
185 ~FileBox() override;
186
191 bool
192 operator=(const IO::Path&);
193
198 bool
199 operator/=(const String&);
204 bool
205 operator/=(const IO::Path&);
206
211 DefGetter(const ynothrow, const IO::Path&, Directory, pthDirectory)
215 IO::Path
216 GetPath() const;
222 IO::Path
223 GetPath(typename ListType::size_type i) const;
224
230 bool
231 SetPath(const IO::Path&);
232
238 ListType
239 ListItems() const;
240 };
241
242
248 class YF_API DropDownList : public Button
249 {
250 public:
251 using ListType = ListBox::ListType;
257 using ViewArgs = ListBox::ViewArgs;
259 using iterator = ystdex::subscriptive_iterator<DropDownList, IWidget>;
260
261 protected:
263 ListBox lbContent;
264
265 public:
267 explicit
268 DropDownList(const Rect& = {}, const shared_ptr<ListType>& = {});
273 ~DropDownList() override;
274
276 DefWidgetMemberIteration(lbContent)
277
278
279 DefGetterMem(const ynothrow, const ListType&, List, lbContent)
281 DefGetterMem(ynothrow, ListType&, ListRef, lbContent)
286 DefGetterMem(ynothrow, GEvent<void(ViewArgs)>&, ViewChanged, lbContent)
291 DefGetterMem(ynothrow, GEvent<void(IndexEventArgs)>&, Selected, lbContent)
296 DefGetterMem(ynothrow, GEvent<void(IndexEventArgs)>&, Confirmed, lbContent)
297
302 DefSetterMem(, const shared_ptr<ListType>&, List, lbContent)
303
310 PDefH(void, AdjustViewForContent, )
311 ImplExpr(lbContent.AdjustViewForContent())
312
313 private:
318 void
319 DetachTopWidget();
320
321 public:
326 void
327 Refresh(PaintEventArgs&&) override;
328 };
329
330 } // namespace UI;
331
332 } // namespace YSLib;
333
334 #endif
335
YSLib::UI::ListBox::IndexType
TextList::IndexType IndexType
Definition: ComboList.h:55
YSLib::UI::ListBox::pTextList
unique_ptr< TextList > pTextList
文本列表指针。
Definition: ComboList.h:66
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:217
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:247
YSLib::UI::UpdateView
YF_API void UpdateView(TextList &, bool is_active={})
更新文本列表视图。
Definition: ListControl.cpp:425
YSLib::UI::ynothrow
AView &y ynothrow
Definition: YWidgetView.cpp:47
YSLib::GEvent
事件模板。
Definition: YEvent.hpp:488
YSLib::UI::DropDownList::DefWidgetMemberIteration
DefWidgetMemberIteration(lbContent) DefGetterMem(const ynothrow
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:536
YSLib::UI::FileBox::pthDirectory
IO::Path pthDirectory
目录的完整路径。
Definition: ComboList.h:175
YSLib::UI::GValueEventArgs
简单 UI 事件参数类。
Definition: YWidgetEvent.h:306
YSLib::UI::Button
按钮。
Definition: Button.h:127
YSLib::UI::PDefH
PDefH(void, DisplayFor, IWidget &wgt, Timers::TimeSpan delay) ImplExpr(Show(wgt)
在一定时间内显示部件。
YSLib::UI::AMUnitControlList::ViewArgs
GValueEventArgs< bool > ViewArgs
视图参数类型。
Definition: ListControl.h:63
YSLib::UI::FileBox
文件列表框。
Definition: ComboList.h:169
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::UI::FileBox::operator=
bool operator=(const IO::Path &)
导航至绝对路径。
DefPredMem
#define DefPredMem(_q, _n, _m)
Definition: YBaseMacro.h:238
YSLib::UI::FileBox::GetPath
DefGetter(const ynothrow, const IO::Path &, Directory, pthDirectory) IO IO::Path GetPath(typename ListType::size_type i) const
取目录的完整路径。
Definition: ComboList.h:223
YSLib::UI::MTextList::ItemType
String ItemType
项目类型：字符串。
Definition: ListControl.h:141
YSLib::UI::ScrollableContainer
带滚动条的容器。
Definition: Scroll.h:404
YSLib::UI::ListBox::~ListBox
~ListBox() override
虚析构：类定义外默认实现。
YSLib::UI::ListBox::DefWidgetMemberIterationBase
DefWidgetMemberIterationBase(ScrollableContainer, GetTextListRef()) PDefH(bool
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:47
YSLib::UI::MTextList::ListType
vector< ItemType > ListType
列表类型。
Definition: ListControl.h:143
YSLib::i
return i
Definition: YCoreUtilities.h:177
YSLib::UI::DropDownList::ListType
ListBox::ListType ListType
Definition: ComboList.h:251
YSLib::UI::FileBox::~FileBox
~FileBox() override
虚析构：类定义外默认实现。
YSLib::UI::ListBox::ViewArgs
TextList::ViewArgs ViewArgs
Definition: ComboList.h:53
YSLib::UI::DropDownList::lbContent
ListBox lbContent
Definition: ComboList.h:263
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:788
YSLib::UI::ListBox
带滚动条的文本列表框。
Definition: ComboList.h:50
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:143
YModules.h
YSLib 用户界面模块配置文件。
YSLib::UI::TextList
文本列表。
Definition: ListControl.h:205
YSLib::UI::MTextList::IndexType
typename ListType::size_type IndexType
索引类型。
Definition: ListControl.h:145
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
YSLib::UI::PaintEventArgs
部件绘制参数。
Definition: YWidgetEvent.h:330
YSLib::UI::DropDownList
下拉列表。
Definition: ComboList.h:249
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
YSLib::UI::ImplExpr
IWidget bool b ImplExpr(wgt.GetController().SetEnabled(b)) YF_API bool Enable(IWidget &
设置部件可用性，且当可用性改变时无效化部件区域。
YSLib::UI::ListBox::ListType
TextList::ListType ListType
Definition: ComboList.h:52
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ystdex::subscriptive_iterator
成员下标迭代器。
Definition: iterator.hpp:1193
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) YB_ATTR_nodiscard YB_PURE bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
DefSetterMem
#define DefSetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:268