YSTest: textlist.h 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
textlist.h
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2011 - 2013.
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_textlist_h_
29 #define YSL_INC_UI_textlist_h_ 1
30
31 #include "ycontrol.h"
32 #include "ygui.h"
33 #include "label.h"
34 #include "viewer.hpp"
35
36 YSL_BEGIN
37
38 YSL_BEGIN_NAMESPACE(UI)
39
40
44 typedef GValueEventArgs<MTextList::IndexType> IndexEventArgs;
45 DeclDelegate(HIndexEvent, IndexEventArgs)
46
51 class YF_API TextList : public Control, protected MTextList
52 {
53 public:
54 using MTextList::ItemType;
55 using MTextList::ListType;
56 using MTextList::IndexType;
57 typedef GSequenceViewer<ListType> ViewerType;
58
63 typedef GValueEventArgs<bool> ViewArgs;
68 DeclDelegate(HViewEvent, ViewArgs)
69
70 using MTextList::Font;
71 using MTextList::Margin;
72 using MTextList::HorizontalAlignment;
73 using MTextList::VerticalAlignment;
74 using MTextList::Text;
75 Color HilightBackColor;
76 Color HilightTextColor;
77 bool CyclicTraverse;
78
79 private:
80 ViewerType viewer;
81 SDst top_offset;
82
87 DeclEvent(HViewEvent, ViewChanged)
93 DeclEvent(HIndexEvent, Selected)
99 DeclEvent(HIndexEvent, Confirmed)
100
101 public:
106 explicit
107 TextList(const Rect& = {}, const shared_ptr<ListType>& = {},
108 pair<Color, Color> = FetchGUIState().Colors.GetPair(Styles::Highlight,
109 Styles::HighlightText));
110 inline DefDeMoveCtor(TextList)
111
112 DefPredMem(const ynothrow, Selected, viewer)
113 PDefH(bool, Contains, ListType::size_type i)
114 ImplBodyMem(viewer, Contains, i)
115
116 DefEventGetter(ynothrow, HViewEvent, ViewChanged, ViewChanged) \
118 DefEventGetter(ynothrow, HIndexEvent, Selected, Selected) \
120 DefEventGetter(ynothrow, HIndexEvent, Confirmed, Confirmed) \
122
123 DefGetterMem(const ynothrow, ListType::size_type, HeadIndex, viewer)
124 using MTextList::GetItemHeight;
125 using MTextList::GetItemPtr;
126 using MTextList::GetList;
128 using MTextList::GetListRef;
129 using MTextList::GetMaxTextWidth;
130 DefGetterMem(const ynothrow, ListType::size_type, SelectedIndex, viewer)
135 SDst
136 GetFullViewHeight() const;
141 SDst
142 GetViewPosition() const;
143
149 void
150 SetList(const shared_ptr<ListType>&);
154 void
155 SetSelected(ListType::size_type);
159 void
160 SetSelected(SPos, SPos);
164 void
165 SetSelected(const Point& pt)
166 {
167 SetSelected(pt.X, pt.Y);
168 }
169
170 private:
180 SDst
181 AdjustOffset(bool);
182
183 public:
189 void
190 AdjustViewForContent();
191
199 void
200 AdjustViewLength();
201
206 virtual bool
207 CheckConfirmed(ListType::size_type) const;
208
213 ListType::size_type
214 CheckPoint(SPos, SPos);
219 ListType::size_type
220 CheckPoint(const Point& pt)
221 {
222 return CheckPoint(pt.X, pt.Y);
223 }
224
225 PDefH(void, ClearSelected, )
226 ImplBodyMem(viewer, ClearSelected, )
227
229 using MTextList::Find;
230
231 protected:
238 void
239 InvalidateSelected(ListType::difference_type offset,
240 ListType::size_type diff = 1);
241
248 void
249 InvalidateSelected2(ListType::difference_type, ListType::difference_type);
250
251 public:
255 void
256 LocateViewPosition(SDst);
257
258 protected:
263 virtual void
264 DrawItem(const Graphics&, const Rect& mask, const Rect&,
265 ListType::size_type);
266
272 virtual void
273 DrawItemBackground(const PaintContext&, const Rect& r);
274
279 virtual void
280 DrawItems(const PaintContext&);
281
282 public:
287 void
288 Refresh(PaintEventArgs&&) override;
289
290 using MTextList::RefreshTextState;
291
296 void
297 ResetView();
298
303 void
304 SelectFirst();
305
310 void
311 SelectLast();
312
313 private:
317 void
318 CallSelected();
319
323 void
324 InvokeConfirmed(ListType::size_type);
325 };
326
327
332 YF_API void
333 ResizeForContent(TextList&);
334
342 YF_API void
343 UpdateView(TextList&, bool is_active = false);
344
345 YSL_END_NAMESPACE(UI)
346
347 YSL_END
348
349 #endif
350