YSTest  PreAlpha_b380_20130211
The YSLib Test Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
YSLib::Components::TextList Class Reference

文本列表。 More...

#include <textlist.h>

Inheritance diagram for YSLib::Components::TextList:
Collaboration diagram for YSLib::Components::TextList:

Public Types

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

Public Member Functions

 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 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 ()
 选择最后一个项目。
 
void UpdateView (bool is_active=false, bool need_invalidation=true)
 更新视图。
 
- Public Member Functions inherited from YSLib::Components::Control
 Control (const Rect &={})
 构造:使用指定边界,默认背景(同 Widget 默认构造)。
 
 Control (const Rect &, NoBackgroundTag)
 构造:使用指定边界,无背景。
 
 Control (const Control &)
 复制构造:除容器为空外深复制。
 
 Control (Control &&)=default
 
virtual IWidgetGetBoundControlPtr (const KeyInput &)
 取按键-指针设备输入默认事件组映射。
 
void OnTouch_Close (TouchEventArgs &&)
 处理屏幕事件:关闭显示。
 
- Public Member Functions inherited from YSLib::Components::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 Member Functions inherited from YSLib::Components::IWidget
virtual ~IWidget ()
 

Public Attributes

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

Protected Member Functions

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 Member Functions inherited from YSLib::Components::MTextList
ListTypeGetList () const ynothrow
 取文本列表。
 
ItemTypeGetItemPtr (IndexType) 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 Member Functions

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

Private Attributes

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

Additional Inherited Members

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

Detailed Description

文本列表。

Since
build 212

Definition at line 51 of file textlist.h.

Member Typedef Documentation

视图事件委托类型。

Since
build 268

Definition at line 68 of file textlist.h.

typedef ListType::size_type YSLib::Components::MTextList::IndexType

索引类型。

Definition at line 137 of file label.h.

项目类型:字符串。

Definition at line 135 of file label.h.

列表类型。

Definition at line 136 of file label.h.

视图参数类型。

Parameters
表示主动定位视图。
Since
build 268

Definition at line 63 of file textlist.h.

视图类型。

Definition at line 57 of file textlist.h.

Constructor & Destructor Documentation

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

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

Since
build 337
YSLib::Components::TextList::TextList ( TextList &&  )
inlinedefault

Member Function Documentation

SDst TextList::AdjustOffset ( bool  is_top)
private

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

Returns
返回调整前的偏移量值(取值区间 [0, GetItemHeight()) )。
Postcondition
若调整则 top_offset == 0
Note
若没有底项目则不调整,返回 0 。

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

Definition at line 181 of file textlist.cpp.

void TextList::AdjustViewLength ( )

调整视图长度。

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

Definition at line 215 of file textlist.cpp.

void TextList::CallSelected ( )
private

调用选中事件处理器。

Definition at line 398 of file textlist.cpp.

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

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

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

Reimplemented in YSLib::Components::Menu.

Definition at line 228 of file textlist.cpp.

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

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

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

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

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

Definition at line 210 of file textlist.h.

References YSLib::Drawing::GBinaryGroup< _type >::X, and YSLib::Drawing::GBinaryGroup< _type >::Y.

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

Definition at line 215 of file textlist.h.

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

Definition at line 113 of file textlist.h.

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

绘制列表项。

Since
build 346

Reimplemented in YSLib::Components::Menu.

Definition at line 286 of file textlist.cpp.

References YSLib::Drawing::DrawClippedText().

Here is the call graph for this function:

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

项目选中确定事件。

Definition at line 120 of file textlist.h.

SDst TextList::GetFullViewHeight ( ) const

取完整视图高。

Note
依赖于 GetItemHeight 方法的结果。

Definition at line 139 of file textlist.cpp.

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

Definition at line 123 of file textlist.h.

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

项目选择状态变更事件。

Definition at line 118 of file textlist.h.

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

Definition at line 128 of file textlist.h.

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

视图变更事件。

Definition at line 116 of file textlist.h.

SDst TextList::GetViewPosition ( ) const

取视图顶端竖直位置。

Note
依赖于 GetItemHeight 方法的结果。

Definition at line 144 of file textlist.cpp.

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

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

Parameters
offset起始偏移量。
diff终止偏移量相对于起始偏移量的距离偏移量。
Since
build 318

Definition at line 241 of file textlist.cpp.

References YSLib::Drawing::Size::Height, YSLib::Components::Invalidate(), YSLib::RestrictUnsignedStrict(), and YSLib::Drawing::GBinaryGroup< _type >::Y.

Here is the call graph for this function:

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

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

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

Definition at line 259 of file textlist.cpp.

References YSLib::IO::swap().

Here is the call graph for this function:

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

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

Definition at line 404 of file textlist.cpp.

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

Definition at line 112 of file textlist.h.

void TextList::LocateViewPosition ( SDst  h)

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

Definition at line 268 of file textlist.cpp.

References YSLib::RestrictInInterval().

Here is the call graph for this function:

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

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

Since
build 294

Reimplemented from YSLib::Components::Widget.

Definition at line 356 of file textlist.cpp.

References YSLib::Components::GetSizeOf().

Here is the call graph for this function:

void TextList::ResetView ( )

复位视图。

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

Definition at line 363 of file textlist.cpp.

void TextList::SelectFirst ( )

选择第一个项目。

Note
仅操作 viewer ,不更新视图。

Definition at line 375 of file textlist.cpp.

void TextList::SelectLast ( )

选择最后一个项目。

Note
仅操作 viewer ,不更新视图。

Definition at line 382 of file textlist.cpp.

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

设置文本列表。

Note
若参数为空则忽略,否则设置列表并重置视图。
Since
build 292

Definition at line 150 of file textlist.cpp.

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

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

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

按接触点设置选中项目。

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

按接触点设置选中项目。

Definition at line 163 of file textlist.h.

void TextList::UpdateView ( bool  is_active = false,
bool  need_invalidation = true 
)

更新视图。

Parameters
is_active是否确定仅变更视图位置。
need_invalidation更新后无效化自身。
Since
build 318

调用视图变更事件并调整视图长度。

Definition at line 389 of file textlist.cpp.

References YSLib::Components::Invalidate().

Here is the call graph for this function:

Member Data Documentation

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

项目选中确认事件。

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

Definition at line 99 of file textlist.h.

bool YSLib::Components::TextList::CyclicTraverse

循环选择遍历。

Definition at line 77 of file textlist.h.

Color YSLib::Components::TextList::HilightBackColor

高亮背景色。

Definition at line 75 of file textlist.h.

Color YSLib::Components::TextList::HilightTextColor

高亮文本色。

Definition at line 76 of file textlist.h.

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

项目选择状态变更事件。

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

Definition at line 93 of file textlist.h.

SDst YSLib::Components::TextList::top_offset
private

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

Definition at line 81 of file textlist.h.

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

视图变更事件。

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

Definition at line 87 of file textlist.h.

ViewerType YSLib::Components::TextList::viewer
private

列表视图。

Definition at line 80 of file textlist.h.


The documentation for this class was generated from the following files: