YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
YSLib::UI::TextList类 参考

文本列表。 更多...

#include <textlist.h>

类 YSLib::UI::TextList 继承关系图:
YSLib::UI::TextList 的协作图:

Public 类型

typedef GSequenceViewer< ListTypeViewerType
 视图类型。
 
typedef GValueEventArgs< bool > ViewArgs
 视图参数类型。
 
typedef GHEvent< void(ViewArgs)> HViewEvent
 视图事件委托类型。
 
typedef String ItemType
 项目类型:字符串。
 
typedef vector< ItemTypeListType
 列表类型。
 
typedef ListType::size_type IndexType
 索引类型。
 

Public 成员函数

 TextList (const Rect &={}, const shared_ptr< ListType > &={}, pair< Color, Color >=FetchGUIState().Colors.GetPair(Styles::Highlight, Styles::HighlightText))
 构造:使用指定边界、文本列表和高亮背景色/文本色对。
 
 TextList (TextList &&)=default
 
bool IsSelected () const ynothrow
 
bool Contains (ListType::size_type i)
 
GEvent< void(HViewEvent::EventArgsType)> & GetViewChanged () ynothrow
 视图变更事件。
 
GEvent< void(HIndexEvent::EventArgsType)> & GetSelected () ynothrow
 项目选择状态变更事件。
 
GEvent< void(HIndexEvent::EventArgsType)> & GetConfirmed () ynothrow
 项目选中确定事件。
 
ListType::size_type GetHeadIndex () const ynothrow
 
ListType::size_type GetSelectedIndex () const ynothrow
 
SDst GetFullViewHeight () const
 取完整视图高。
 
SDst GetViewPosition () const
 取视图顶端竖直位置。
 
void SetList (const shared_ptr< ListType > &)
 设置文本列表。
 
void SetSelected (ListType::size_type)
 按指定项目索引设置选中项目。
 
void SetSelected (SPos, SPos)
 按接触点设置选中项目。
 
void SetSelected (const Point &pt)
 按接触点设置选中项目。
 
void AdjustViewForContent ()
 按内容大小依次调整视图中选中和首个项目的索引,然后按需调整竖直偏移量。
 
void AdjustViewLength ()
 调整视图长度。
 
virtual bool CheckConfirmed (ListType::size_type) const
 检查列表中的指定项是否有效。
 
ListType::size_type CheckPoint (SPos, SPos)
 检查点(相对于所在缓冲区的控件坐标)是否在选择范围内,
 
ListType::size_type CheckPoint (const Point &pt)
 检查点(相对于所在缓冲区的控件坐标)是否在选择范围内,
 
void ClearSelected ()
 
void LocateViewPosition (SDst)
 定位视图顶端至指定竖直位置。
 
void Refresh (PaintEventArgs &&) override
 刷新:按指定参数绘制界面并更新状态。
 
void ResetView ()
 复位视图。
 
void SelectFirst ()
 选择第一个项目。
 
void SelectLast ()
 选择最后一个项目。
 
- Public 成员函数 继承自 YSLib::UI::Control
 Control (const Rect &={})
 构造:使用指定边界,默认背景(同 Widget 默认构造)。
 
 Control (const Rect &, NoBackgroundTag)
 构造:使用指定边界,无背景。
 
 Control (const Control &)
 复制构造:除容器为空外深复制。
 
 Control (Control &&)=default
 
virtual IWidgetGetBoundControlPtr (const KeyInput &)
 取按键-指针设备输入默认事件组映射。
 
void OnTouch_Close (TouchEventArgs &&)
 处理屏幕事件:关闭显示。
 
- Public 成员函数 继承自 YSLib::UI::Widget
 Widget (const Rect &={}, Color=Drawing::ColorSpace::White, Color=Drawing::ColorSpace::Black)
 
template<typename _tView , typename _tRenderer , typename _tController >
 Widget (_tView &&pView_=make_unique< View >(), _tRenderer &&pRenderer_=make_unique< Renderer >(), _tController &&pController_={})
 构造:使用视图指针、渲染器指针和控制器指针,无背景。
 
 Widget (const Widget &)
 复制构造:除容器指针为空外深复制。
 
 Widget (Widget &&)=default
 
virtual ~Widget ()
 析构:虚实现。
 
SPos GetX () const ynothrow
 
SPos GetY () const ynothrow
 
SDst GetWidth () const ynothrow
 
SDst GetHeight () const ynothrow
 
virtual RendererGetRenderer () const ynothrow
 取渲染器。
 
virtual ViewGetView () const ynothrow
 取部件视图。
 
virtual AControllerGetController () const override
 取控制器。
 
virtual WidgetRange GetChildren () override
 
void SetX (SDst _tempArgName)
 
void SetY (SDst _tempArgName)
 
void SetWidth (SDst _tempArgName)
 
void SetHeight (SDst _tempArgName)
 
void SetRenderer (unique_ptr< Renderer > &&)
 设置渲染器为指定指针指向的对象,同时更新渲染器状态。
 
void SetView (unique_ptr< View > &&)
 设置渲染器为指定指针指向的对象,同时更新渲染器状态。
 
- Public 成员函数 继承自 YSLib::UI::IWidget
virtual ~IWidget ()
 

Public 属性

Color HilightBackColor
 高亮背景色。
 
Color HilightTextColor
 高亮文本色。
 
bool CyclicTraverse
 循环选择遍历。
 
- Public 属性 继承自 YSLib::UI::Control
std::function< IWidget *(const
KeyInput &)> 
BoundControlPtr
 按键-指针设备输入事件组映射。
 
- Public 属性 继承自 YSLib::UI::Widget
HBrush Background
 背景。
 
Color ForeColor
 默认前景色。
 

Protected 成员函数

void InvalidateSelected (ListType::difference_type offset, ListType::size_type diff=1)
 无效化偏移量对应的列表项区域。
 
void InvalidateSelected2 (ListType::difference_type, ListType::difference_type)
 无效化偏移量对应的列表项区域。
 
virtual void DrawItem (const Graphics &, const Rect &mask, const Rect &, ListType::size_type)
 绘制列表项。
 
virtual void DrawItemBackground (const PaintContext &, const Rect &r)
 描画列表项背景。
 
virtual void DrawItems (const PaintContext &)
 绘制列表。
 
- Protected 成员函数 继承自 YSLib::UI::MTextList
const ListTypeGetList () const ynothrow
 取文本列表。
 
ListTypeGetListRef () ynothrow
 取文本列表引用。
 
ItemTypeGetItemPtr (const IndexType &)
 取指定项目索引的项目指针。
 
const ItemTypeGetItemPtr (const IndexType &) const
 取指定项目索引的项目 const 指针。
 
SDst GetItemHeight () const ynothrow
 取项目行高。
 
SDst GetMaxTextWidth () const
 取文本列表中的最大文本宽度。
 
void SetList (const shared_ptr< ListType > &h)
 设置文本列表。
 
IndexType Find (const ItemType &) const
 查找项。
 
void RefreshTextState ()
 刷新文本状态。
 
 MTextList (const shared_ptr< ListType > &={}, const Drawing::Font &={})
 构造:使用文本列表句柄和字体指针。
 
 MTextList (MTextList &&)=default
 

Private 成员函数

SDst AdjustOffset (bool)
 调整列表视图底项目的竖直偏移量为零。
 
void CallSelected ()
 调用选中事件处理器。
 
void InvokeConfirmed (ListType::size_type)
 检查和调用确认事件处理器。
 

Private 属性

ViewerType viewer
 列表视图。
 
SDst top_offset
 列表视图首项目超出上边界的竖直偏移量。
 
GEvent< void(HViewEvent::EventArgsType)> ViewChanged
 视图变更事件。
 
GEvent< void(HIndexEvent::EventArgsType)> Selected
 项目选择状态变更事件。
 
GEvent< void(HIndexEvent::EventArgsType)> Confirmed
 项目选中确认事件。
 

额外继承的成员函数

- Protected 类型 继承自 YSLib::UI::MTextList
typedef String ItemType
 项目类型:字符串。
 
typedef vector< ItemTypeListType
 列表类型。
 
typedef ListType::size_type IndexType
 索引类型。
 
- Protected 属性 继承自 YSLib::UI::MLabel
Drawing::Font Font
 字体。
 
Drawing::Padding Margin
 文本和容器的间距。
 
TextAlignment HorizontalAlignment
 文本水平和竖直对齐属性。
 
TextAlignment VerticalAlignment
 
bool AutoWrapLine
 启用自动换行。
 
String Text
 标签文本。
 

详细描述

文本列表。

自从
build 212

在文件 textlist.h51 行定义.

成员类型定义说明

视图事件委托类型。

自从
build 268

在文件 textlist.h68 行定义.

typedef ListType::size_type YSLib::UI::MTextList::IndexType

索引类型。

在文件 label.h137 行定义.

项目类型:字符串。

在文件 label.h135 行定义.

列表类型。

在文件 label.h136 行定义.

视图参数类型。

参数
表示主动定位视图。
自从
build 268

在文件 textlist.h63 行定义.

视图类型。

在文件 textlist.h57 行定义.

构造及析构函数说明

YSLib::UI::TextList::TextList ( const Rect = {},
const shared_ptr< ListType > &  = {},
pair< Color, Color >  = FetchGUIState().Colors.GetPair(Styles::HighlightStyles::HighlightText) 
)
explicit

构造:使用指定边界、文本列表和高亮背景色/文本色对。

自从
build 337
YSLib::UI::TextList::TextList ( TextList &&  )
inlinedefault

成员函数说明

SDst TextList::AdjustOffset ( bool  is_top)
private

调整列表视图底项目的竖直偏移量为零。

后置条件
若调整则 top_offset == 0
返回
返回调整前的偏移量值(取值区间 [0, GetItemHeight()) )。
注解
若没有底项目则不调整,返回 0 。

参数为 true 时,调整列表视图底项目(可能不完全)超出下边界以上的竖直 偏移量为零;否则,调整列表视图首项目(可能不完全)超出上边界以上的竖直偏移量为零。

在文件 textlist.cpp181 行定义.

void TextList::AdjustViewForContent ( )

按内容大小依次调整视图中选中和首个项目的索引,然后按需调整竖直偏移量。

警告
若视图大小变化后不调用此方法调整视图,可能导致选择项越界而行为未定义。
自从
build 392

在文件 textlist.cpp215 行定义.

void TextList::AdjustViewLength ( )

调整视图长度。

注解
视图长为当项目数足够时所有在视图中显示的(可能不完全)项目总数。
当部件高为 0 时忽略。
警告
设置大小或列表内容后不调用此方法可能导致显示错误。
自从
build 285

在文件 textlist.cpp230 行定义.

参考 h.

void TextList::CallSelected ( )
private

调用选中事件处理器。

在文件 textlist.cpp404 行定义.

bool TextList::CheckConfirmed ( ListType::size_type  idx) const
virtual

检查列表中的指定项是否有效。

注解
当且仅当有效时响应 Confirmed 事件。

YSLib::UI::Menu 重载.

在文件 textlist.cpp243 行定义.

ListType::size_type YSLib::UI::TextList::CheckPoint ( SPos  ,
SPos   
)

检查点(相对于所在缓冲区的控件坐标)是否在选择范围内,

返回
选择的项目索引。
ListType::size_type YSLib::UI::TextList::CheckPoint ( const Point pt)
inline

检查点(相对于所在缓冲区的控件坐标)是否在选择范围内,

返回
选择的项目索引,若无效则为 static_cast<Viewer::IndexType>(-1) 。

在文件 textlist.h220 行定义.

参考 YSLib::Drawing::GBinaryGroup< _type >::X , 以及 YSLib::Drawing::GBinaryGroup< _type >::Y.

void YSLib::UI::TextList::ClearSelected ( )
inline

在文件 textlist.h225 行定义.

bool YSLib::UI::TextList::Contains ( ListType::size_type  i)
inline

在文件 textlist.h113 行定义.

void TextList::DrawItem ( const Graphics g,
const Rect mask,
const Rect unit,
ListType::size_type  i 
)
protectedvirtual

绘制列表项。

自从
build 346

YSLib::UI::Menu 重载.

在文件 textlist.cpp301 行定义.

参考 YSLib::Drawing::DrawClippedText().

函数调用图:

void TextList::DrawItemBackground ( const PaintContext pc,
const Rect r 
)
protectedvirtual
GEvent<void( HIndexEvent ::EventArgsType)>& YSLib::UI::TextList::GetConfirmed ( )
inline

项目选中确定事件。

在文件 textlist.h120 行定义.

SDst TextList::GetFullViewHeight ( ) const

取完整视图高。

注解
依赖于 GetItemHeight 方法的结果。

在文件 textlist.cpp139 行定义.

ListType::size_type YSLib::UI::TextList::GetHeadIndex ( ) const
inline

在文件 textlist.h123 行定义.

GEvent<void( HIndexEvent ::EventArgsType)>& YSLib::UI::TextList::GetSelected ( )
inline

项目选择状态变更事件。

在文件 textlist.h118 行定义.

ListType::size_type YSLib::UI::TextList::GetSelectedIndex ( ) const
inline

在文件 textlist.h130 行定义.

GEvent<void( HViewEvent ::EventArgsType)>& YSLib::UI::TextList::GetViewChanged ( )
inline

视图变更事件。

在文件 textlist.h116 行定义.

SDst TextList::GetViewPosition ( ) const

取视图顶端竖直位置。

注解
依赖于 GetItemHeight 方法的结果。

在文件 textlist.cpp144 行定义.

void TextList::InvalidateSelected ( ListType::difference_type  offset,
ListType::size_type  diff = 1 
)
protected

无效化偏移量对应的列表项区域。

参数
offset起始偏移量。
diff终止偏移量相对于起始偏移量的距离偏移量。
自从
build 318

在文件 textlist.cpp256 行定义.

参考 YSLib::Drawing::Size::Height,YSLib::UI::Invalidate(),YSLib::RestrictUnsignedStrict() , 以及 YSLib::Drawing::GBinaryGroup< _type >::Y.

函数调用图:

void TextList::InvalidateSelected2 ( ListType::difference_type  x,
ListType::difference_type  y 
)
protected

无效化偏移量对应的列表项区域。

注解
若第二参数小于第一参数则交换它们的值。
区域由参数组成的闭区间指定,若区间左端小于 0 则视为 0 。
自从
build 318

在文件 textlist.cpp274 行定义.

参考 std::swap().

函数调用图:

void TextList::InvokeConfirmed ( ListType::size_type  idx)
private

检查和调用确认事件处理器。

在文件 textlist.cpp410 行定义.

bool YSLib::UI::TextList::IsSelected ( ) const
inline

在文件 textlist.h112 行定义.

void TextList::LocateViewPosition ( SDst  h)

定位视图顶端至指定竖直位置。

在文件 textlist.cpp283 行定义.

参考 YSLib::RestrictInInterval() , 以及 UpdateView().

函数调用图:

void TextList::Refresh ( PaintEventArgs &&  e)
overridevirtual

刷新:按指定参数绘制界面并更新状态。

自从
build 294

重载 YSLib::UI::Widget .

在文件 textlist.cpp371 行定义.

参考 YSLib::UI::GetSizeOf().

函数调用图:

void TextList::ResetView ( )

复位视图。

注解
若项目列表非空则选择首个项目。

在文件 textlist.cpp378 行定义.

参考 UpdateView().

函数调用图:

void TextList::SelectFirst ( )

选择第一个项目。

注解
仅操作 viewer ,不更新视图。

在文件 textlist.cpp390 行定义.

void TextList::SelectLast ( )

选择最后一个项目。

注解
仅操作 viewer ,不更新视图。

在文件 textlist.cpp397 行定义.

void TextList::SetList ( const shared_ptr< ListType > &  h)

设置文本列表。

注解
若参数为空则忽略,否则设置列表并重置视图。
自从
build 292

在文件 textlist.cpp150 行定义.

void YSLib::UI::TextList::SetSelected ( ListType::size_type  )

按指定项目索引设置选中项目。

void YSLib::UI::TextList::SetSelected ( SPos  ,
SPos   
)

按接触点设置选中项目。

void YSLib::UI::TextList::SetSelected ( const Point pt)
inline

按接触点设置选中项目。

在文件 textlist.h165 行定义.

类成员变量说明

GEvent<void( HIndexEvent ::EventArgsType)> YSLib::UI::TextList::Confirmed
private

项目选中确认事件。

当前选中项目被确定时触发的事件。

在文件 textlist.h99 行定义.

bool YSLib::UI::TextList::CyclicTraverse

循环选择遍历。

在文件 textlist.h77 行定义.

Color YSLib::UI::TextList::HilightBackColor

高亮背景色。

在文件 textlist.h75 行定义.

Color YSLib::UI::TextList::HilightTextColor

高亮文本色。

在文件 textlist.h76 行定义.

GEvent<void( HIndexEvent ::EventArgsType)> YSLib::UI::TextList::Selected
private

项目选择状态变更事件。

当项目被选中或取消选中时触发的事件。

在文件 textlist.h93 行定义.

SDst YSLib::UI::TextList::top_offset
private

列表视图首项目超出上边界的竖直偏移量。

在文件 textlist.h81 行定义.

GEvent<void( HViewEvent ::EventArgsType)> YSLib::UI::TextList::ViewChanged
private

视图变更事件。

当视图长度或位置发生改变时触发的事件。

在文件 textlist.h87 行定义.

ViewerType YSLib::UI::TextList::viewer
private

列表视图。

在文件 textlist.h80 行定义.


该类的文档由以下文件生成: