YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
textlist.h
浏览该文件的文档.
1 /*
2  © 2011-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_textlist_h_
29 #define YSL_INC_UI_textlist_h_ 1
30 
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YControl
33 #include YFM_YSLib_UI_YGUI
34 #include YFM_YSLib_UI_Label
35 #include YFM_YSLib_UI_Viewer
36 
37 namespace YSLib
38 {
39 
40 namespace UI
41 {
42 
48 DeclDelegate(HIndexEvent, IndexEventArgs)
49 
50 
54 class YF_API TextList
55  : public Control, protected MTextList, protected MHilightText
56 {
57 public:
58  using MTextList::ItemType;
59  using MTextList::ListType;
62 
72  DeclDelegate(HViewEvent, ViewArgs)
73 
74  using MTextList::Font;
75  using MTextList::Margin;
76  using MTextList::HorizontalAlignment;
77  using MTextList::VerticalAlignment;
78  using MTextList::Text;
80  using MHilightText::HilightBackColor;
82  using MHilightText::HilightTextColor;
84 
85 private:
88 
89 public:
96  DeclEvent(HViewEvent, ViewChanged)
103  DeclEvent(HIndexEvent, Selected)
110  DeclEvent(HIndexEvent, Confirmed)
111 
116  explicit
117  TextList(const Rect& = {}, const shared_ptr<ListType>& = {},
118  const pair<Color, Color>& = FetchGUIState().Colors.GetPair(
120  DefDeMoveCtor(TextList)
121 
123  PDefH(bool, Contains, ListType::size_type i)
124  ImplBodyMem(viewer, Contains, i)
125 
126  DefGetterMem(const ynothrow, ListType::size_type, HeadIndex, viewer)
127  using MTextList::GetItemHeight;
128  using MTextList::GetItemPtr;
129  using MTextList::GetList;
131  using MTextList::GetListRef;
132  using MTextList::GetMaxTextWidth;
133  DefGetterMem(const ynothrow, ListType::size_type, SelectedIndex, viewer)
138  SDst
139  GetFullViewHeight() const;
144  SDst
145  GetViewPosition() const;
146 
152  void
153  SetList(const shared_ptr<ListType>&);
157  void
158  SetSelected(ListType::size_type);
162  void
163  SetSelected(SPos, SPos);
167  void
168  SetSelected(const Point& pt)
169  {
170  SetSelected(pt.X, pt.Y);
171  }
172 
173 private:
183  SDst
184  AdjustOffset(bool);
185 
186 public:
192  void
194 
202  void
204 
209  virtual bool
210  CheckConfirmed(ListType::size_type) const;
211 
216  ListType::size_type
217  CheckPoint(SPos, SPos);
222  ListType::size_type
223  CheckPoint(const Point& pt)
224  {
225  return CheckPoint(pt.X, pt.Y);
226  }
227 
228  PDefH(void, ClearSelected, )
230 
232  using MTextList::Find;
233 
234 protected:
241  void
242  InvalidateSelected(ListType::difference_type offset,
243  ListType::size_type diff = 1);
244 
251  void
252  InvalidateSelected2(ListType::difference_type, ListType::difference_type);
253 
254 public:
258  void
260 
261 protected:
266  virtual void
267  DrawItem(const Graphics&, const Rect& mask, const Rect&,
268  ListType::size_type);
269 
275  virtual void
276  DrawItemBackground(const PaintContext&, const Rect& r);
277 
282  virtual void
283  DrawItems(const PaintContext&);
284 
285 public:
290  void
291  Refresh(PaintEventArgs&&) override;
292 
293  using MTextList::RefreshTextState;
294 
299  void
300  ResetView();
301 
306  void
307  SelectFirst();
308 
313  void
314  SelectLast();
315 
316 private:
320  void
321  CallSelected();
322 
326  void
327  InvokeConfirmed(ListType::size_type);
328 };
329 
331 
332 
336 YF_API void
337 ResizeForContent(TextList&);
338 
346 YF_API void
347 UpdateView(TextList&, bool is_active = {});
349 
350 } // namespace UI;
351 
352 } // namespace YSLib;
353 
354 #endif
355 
void InvalidateSelected(ListType::difference_type offset, ListType::size_type diff=1)
无效化偏移量对应的列表项区域。
Definition: textlist.cpp:261
ViewerType viewer
列表视图。
Definition: textlist.h:86
#define ImplBodyMem(_m, _n,...)
Definition: YBaseMacro.h:116
SDst GetViewPosition() const
取视图顶端竖直位置。
Definition: textlist.cpp:149
typename ListType::size_type IndexType
索引类型。
Definition: label.h:149
void Refresh(PaintEventArgs &&) override
刷新:按指定参数绘制界面并更新状态。
文本列表模块。
Definition: label.h:144
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
SDst AdjustOffset(bool)
调整列表视图底项目的竖直偏移量为零。
Definition: textlist.cpp:186
DeclEvent(HViewEvent, ViewChanged) DeclEvent(HIndexEvent
视图变更事件。
String ItemType
项目类型:字符串。
Definition: label.h:147
部件绘制参数。
Definition: ywgtevt.h:276
void UpdateView(TextList &tl, bool is_active)
Definition: textlist.cpp:431
#define YF_API
Definition: Platform.h:64
void InvalidateSelected2(ListType::difference_type, ListType::difference_type)
无效化偏移量对应的列表项区域。
Definition: textlist.cpp:279
void SelectLast()
选择最后一个项目。
Definition: textlist.cpp:402
void ResetView()
复位视图。
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
virtual bool CheckConfirmed(ListType::size_type) const
检查列表中的指定项是否有效。
控件。
Definition: ycontrol.h:275
PDefH(void, Activate, Console &console, Drawing::Color fc=Drawing::ColorSpace::White) ImplExpr(Activate(console
激活:使用指定屏幕、有效性、前景色和默认背景色。
序列视图类模板。
Definition: viewer.hpp:46
virtual void DrawItemBackground(const PaintContext &, const Rect &r)
描画列表项背景。
Definition: textlist.cpp:314
bool CyclicTraverse
循环选择遍历。
Definition: textlist.h:83
void SetSelected(ListType::size_type)
按指定项目索引设置选中项目。
void SetList(const shared_ptr< ListType > &)
设置文本列表。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
void SelectFirst()
选择第一个项目。
Definition: textlist.cpp:395
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
高亮背景。
Definition: ystyle.h:190
DeclDelegate(HScrollEvent, ScrollEventArgs) class YF_API ATrack
轨道。
Definition: scroll.h:118
const IWidget &wgt SPos
Definition: ywidget.h:104
vector< ItemType > ListType
列表类型。
Definition: label.h:148
void LocateViewPosition(SDst)
定位视图顶端至指定竖直位置。
Styles::Palette Colors
调色板。
Definition: ygui.h:124
virtual void DrawItem(const Graphics &, const Rect &mask, const Rect &, ListType::size_type)
绘制列表项。
二维图形接口上下文。
Definition: ygdibase.h:721
void AdjustViewForContent()
按内容大小依次调整视图中选中和首个项目的索引,然后按需调整竖直偏移量。
SDst top_offset
列表视图首项目超出上边界的竖直偏移量。
Definition: textlist.h:87
简单 UI 事件参数类。
Definition: ywgtevt.h:252
Selected const shared_ptr< ListType > const pair< Color, Color > viewer Contains
Definition: textlist.h:124
高亮文本模块。
Definition: label.h:243
DefGetterMem(const ynothrow, ListType::size_type, SelectedIndex, viewer) SDst GetFullViewHeight() const
取完整视图高。
Selected const shared_ptr< ListType > const pair< Color, Color > & DefDeMoveCtor(TextList) DefPredMem(const ynothrow
bounds & r
Definition: ydraw.h:220
ListType::size_type CheckPoint(SPos, SPos)
检查点(相对于所在缓冲区的控件坐标)是否在选择范围内,
Definition: textlist.cpp:254
void InvokeConfirmed(ListType::size_type)
检查和调用确认事件处理器。
Definition: textlist.cpp:415
void AdjustViewLength()
调整视图长度。
字体:字模,包含字型、样式和大小。
Definition: Font.h:546
void CallSelected()
调用选中事件处理器。
Definition: textlist.cpp:409
#define DefPredMem(_q, _n, _m)
Definition: YBaseMacro.h:177
void ResizeForContent(TextList &tl)
Definition: textlist.cpp:423
virtual void DrawItems(const PaintContext &)
绘制列表。
Definition: textlist.cpp:322
Selected const shared_ptr< ListType > const pair< Color, Color > Selected
Definition: textlist.h:122