YSTest: YSLib::Components::MenuHost Class Reference

YSTest PreAlpha_b380_20130211 The YSLib Test Project

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
YSLib::Components::MenuHost Class Reference

菜单宿主。 More...

`#include <menu.h>`

Inheritance diagram for YSLib::Components::MenuHost:
[legend]
Collaboration diagram for YSLib::Components::MenuHost:
[legend]

## Public Types

typedef Menu * | ItemType
| 菜单组项目类型：记录菜单控件指针。
typedef map< Menu::ID, ItemType > | MenuMap
| 菜单组类型。
typedef MenuMap::value_type | ValueType

## Public Member Functions

| MenuHost (Window &)
virtual | ~MenuHost ()
| 析构。
void | operator+= (const ValueType &)
| 向菜单组添加标识和指针指定的菜单。
void | operator+= (Menu &)
| 向菜单组添加菜单。
bool | operator-= (Menu::ID)
| 从菜单组移除菜单标识指定的菜单。
Menu & | operator[] (Menu::ID id)

访问菜单标识指定的菜单。

Exceptions

  std::out_of_range | 异常中立：由 at 抛出。

bool | IsShowing (Menu::ID)
| 判断框架窗口中是否正在显示菜单标识指定的菜单。
bool | Contains (Menu::ID id)
| 判断菜单组中是否存在菜单标识指定的菜单。
bool | Contains (Menu &)
| 判断菜单组中是否存在指定的菜单。
void | Clear ()
| 清除菜单组。
void | Show (Menu::ID, ZOrderType=DefaultMenuZOrder)
| 按指定 Z 顺序显示菜单组中菜单标识指定的菜单。
void | Show (Menu &mnu, ZOrderType z=DefaultMenuZOrder)
| 按指定 Z 顺序显示指定菜单 mnu 。
void | ShowAll (ZOrderType=DefaultMenuZOrder)
| 按指定 Z 顺序显示菜单组中的所有菜单。
void | Hide (Menu::ID)
| 隐藏菜单组中菜单标识指定的菜单。
void | Hide (Menu &mnu)
| 隐藏指定菜单 mnu。
void | HideAll ()
| 隐藏菜单组中的所有菜单。
void | HideUnrelated (Menu &mnu, Menu &mnuParent)
| 隐藏从 mnu 起向上层遍历菜单树的过程中不相关的菜单。

## Public Attributes

Window & | Frame
| 框架窗口。
map< IWidget *, Menu::ID > | Roots
| 根菜单关联映射。

## Protected Attributes

MenuMap | mMenus
| 菜单组：存储非空菜单指针。

## Private Member Functions

void | ShowRaw (Menu &mnu, ZOrderType=DefaultMenuZOrder)
| 按指定 Z 顺序显示指定菜单 mnu 。
void | HideRaw (Menu &mnu)
| 隐藏指定菜单 mnu。
Private Member Functions inherited from ystdex::noncopyable
| noncopyable (const noncopyable &)=delete
| 禁止复制构造。
noncopyable & | operator= (const noncopyable &)=delete
| 禁止赋值复制。
| noncopyable ()=default
| `protected` 构造：默认实现。
| ~noncopyable ()=default
| `protected` 析构：默认实现。

## Detailed Description

菜单宿主。

Since
  build 252

Definition at line 181 of file menu.h.

## Member Typedef Documentation

typedef Menu* YSLib::Components::MenuHost::ItemType

菜单组项目类型：记录菜单控件指针。

Definition at line 184 of file menu.h.

typedef map<Menu::ID, ItemType> YSLib::Components::MenuHost::MenuMap

菜单组类型。

Definition at line 185 of file menu.h.

typedef MenuMap::value_type YSLib::Components::MenuHost::ValueType

Definition at line 186 of file menu.h.

## Constructor & Destructor Documentation

MenuHost::MenuHost | ( | Window & | frm | ) |

Definition at line 236 of file menu.cpp.

MenuHost::~MenuHost | ( |  | ) |

virtual

析构。

Note
  隐藏菜单组中的所有菜单并清理菜单组。

Definition at line 239 of file menu.cpp.

References Clear(), and HideAll().

Here is the call graph for this function:

## Member Function Documentation

void MenuHost::Clear | ( |  | ) |

清除菜单组。

Note
  释放所有的菜单对象。

Definition at line 295 of file menu.cpp.

References delete_second_mem, and mMenus.

Referenced by ~MenuHost().

Here is the caller graph for this function:

bool YSLib::Components::MenuHost::Contains | ( | Menu::ID | id | ) |

inline

判断菜单组中是否存在菜单标识指定的菜单。

Definition at line 246 of file menu.h.

Referenced by HideUnrelated().

Here is the caller graph for this function:

bool YSLib::Components::MenuHost::Contains | ( | Menu & |  | ) |

判断菜单组中是否存在指定的菜单。

void YSLib::Components::MenuHost::Hide | ( | Menu::ID |  | ) |

隐藏菜单组中菜单标识指定的菜单。

void YSLib::Components::MenuHost::Hide | ( | Menu & | mnu | ) |

inline

隐藏指定菜单 mnu。

Precondition
  断言： Contains(mnu) 。

Definition at line 302 of file menu.h.

References Contains(), and YAssert.

Here is the call graph for this function:

void MenuHost::HideAll | ( |  | ) |

隐藏菜单组中的所有菜单。

Definition at line 341 of file menu.cpp.

References ystdex::get_value, HideRaw(), and mMenus.

Referenced by HideUnrelated(), and ~MenuHost().

Here is the call graph for this function:

Here is the caller graph for this function:

void MenuHost::HideRaw | ( | Menu & | mnu | ) |

private

隐藏指定菜单 mnu。

Definition at line 353 of file menu.cpp.

References Frame, YSLib::Components::Invalidate(), YSLib::Components::IsVisible(), and YSLib::Components::ReleaseFocus().

Referenced by HideAll(), and HideUnrelated().

Here is the call graph for this function:

Here is the caller graph for this function:

void MenuHost::HideUnrelated | ( | Menu & | mnu,
|  | Menu & | mnuParent
| ) |  |

隐藏从 mnu 起向上层遍历菜单树的过程中不相关的菜单。

Note
  相关菜单指 mnu 的父菜单中的 mnuParent 及其直接或间接父菜单。
  若 `!Contains(mnuParent)` 或 mnuParent 不是 mnu 的直接或间接父菜单，则隐藏所有菜单。

Definition at line 362 of file menu.cpp.

References Contains(), HideAll(), HideRaw(), and mMenus.

Here is the call graph for this function:

bool MenuHost::IsShowing | ( | Menu::ID | id | ) |

判断框架窗口中是否正在显示菜单标识指定的菜单。

Definition at line 278 of file menu.cpp.

References YSLib::Components::MUIContainer::Contains(), Frame, and mMenus.

Here is the call graph for this function:

void YSLib::Components::MenuHost::operator+= | ( | const ValueType & |  | ) |

向菜单组添加标识和指针指定的菜单。

Note
  覆盖菜单对象的菜单标识成员；若菜单项已存在则覆盖旧菜单项。

void YSLib::Components::MenuHost::operator+= | ( | Menu & |  | ) |

向菜单组添加菜单。

Note
  标识由菜单对象的菜单标识成员指定；若菜单项已存在则覆盖旧菜单项。

bool MenuHost::operator-= | ( | Menu::ID | id | ) |

从菜单组移除菜单标识指定的菜单。

Note
  同时置菜单宿主指针为空。

Definition at line 262 of file menu.cpp.

References mMenus.

Menu& YSLib::Components::MenuHost::operator[] | ( | Menu::ID | id | ) |

inline

访问菜单标识指定的菜单。

Exceptions

  std::out_of_range | 异常中立：由 at 抛出。

Definition at line 234 of file menu.h.

void YSLib::Components::MenuHost::Show | ( | Menu::ID | ,
|  | ZOrderType | = `DefaultMenuZOrder`
| ) |  |

按指定 Z 顺序显示菜单组中菜单标识指定的菜单。

void YSLib::Components::MenuHost::Show | ( | Menu & | mnu,
|  | ZOrderType | z = `DefaultMenuZOrder`
| ) |  |

inline

按指定 Z 顺序显示指定菜单 mnu 。

Precondition
  断言： Contains(mnu) 。

Definition at line 271 of file menu.h.

References Contains(), and YAssert.

Here is the call graph for this function:

void MenuHost::ShowAll | ( | ZOrderType | z = `DefaultMenuZOrder` | ) |

按指定 Z 顺序显示菜单组中的所有菜单。

Definition at line 311 of file menu.cpp.

References ystdex::get_value, mMenus, and ShowRaw().

Here is the call graph for this function:

void MenuHost::ShowRaw | ( | Menu & | mnu,
|  | ZOrderType | z = `DefaultMenuZOrder`
| ) |  |

private

按指定 Z 顺序显示指定菜单 mnu 。

Definition at line 323 of file menu.cpp.

References YSLib::Components::Window::Add(), Frame, and YSLib::Components::RequestFocus().

Referenced by ShowAll().

Here is the call graph for this function:

Here is the caller graph for this function:

## Member Data Documentation

Window& YSLib::Components::MenuHost::Frame

框架窗口。

Definition at line 188 of file menu.h.

Referenced by HideRaw(), IsShowing(), and ShowRaw().

MenuMap YSLib::Components::MenuHost::mMenus

protected

菜单组：存储非空菜单指针。

Definition at line 191 of file menu.h.

Referenced by Clear(), HideAll(), HideUnrelated(), IsShowing(), operator-=(), and ShowAll().

map<IWidget*, Menu::ID> YSLib::Components::MenuHost::Roots

根菜单关联映射。

Since
  build 363 指定向指定部件转移焦点时不进行隐藏的菜单的映射。

Definition at line 200 of file menu.h.

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

- menu.h
- menu.cpp