YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
yuicont.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_yuicont_h_
29 #define YSL_INC_UI_yuicont_h_ 1
30 
31 #include "ywidget.h"
32 #include <ystdex/iterator.hpp>
33 
35 
37 
38 
43 YF_API IWidget&
44 FetchTopLevel(IWidget&);
51 YF_API IWidget&
52 FetchTopLevel(IWidget&, Point&);
53 
54 
59 YF_API Point
60 LocateOffset(const IWidget* pEnd, Point, const IWidget* pWgt);
61 
66 inline Point
67 LocateContainerOffset(const IWidget& wgt, const Point& pt)
68 {
69  return pt + GetLocationOf(wgt);
70 }
71 
77 LocateForWidget(IWidget& a, IWidget& b);
78 
85 template<class _tWidget, typename _fFetcher>
86 Point
87 LocateForWidgetNode(IWidget& wgt, _fFetcher fetch_ptr)
88 {
89  if(YB_LIKELY(dynamic_cast<_tWidget*>(&wgt)))
90  return Point();
91 
92  _tWidget* const pNode(fetch_ptr(wgt));
93 
94  return pNode ? LocateOffset(pNode, Point(), &wgt) : Point::Invalid;
95 }
96 
103 LocateForParentContainer(const IWidget&);
104 
105 
111 YF_API void
112 MoveToLeft(IWidget& wgt);
113 
119 YF_API void
120 MoveToRight(IWidget& wgt);
121 
127 YF_API void
128 MoveToTop(IWidget& wgt);
129 
135 YF_API void
136 MoveToBottom(IWidget& wgt);
137 
138 
139 /*
140 \brief Z 顺序类型:覆盖顺序,值越大表示越接近顶层。
141 \since build 212
142 */
143 typedef u8 ZOrderType;
148 const ZOrderType DefaultZOrder(64);
154 
155 
162 {
163 public:
164  typedef IWidget* ItemType;
165  typedef multimap<ZOrderType, ItemType> WidgetMap; \
167  typedef WidgetMap::value_type PairType;
170 
171 protected:
172  /*
173  \brief 部件映射:存储 Z 顺序映射至非空部件指针。
174  \since build 279
175  */
177 
183 
190  PDefHOp(void, +=, IWidget& wgt)
191  ImplRet(Add(wgt))
192 
199  bool
200  operator-=(IWidget&);
201 
202 public:
206  bool
207  Contains(IWidget&);
208 
210  Iterator
211  GetBegin();
213  Iterator
214  GetEnd();
215 
222  void
223  Add(IWidget&, ZOrderType = DefaultZOrder);
224 
225 protected:
230  void
231  PaintVisibleChildren(PaintEventArgs&);
232 };
233 
234 
240 template<class _tContainer, class... _tWidgets>
241 inline void
242 AddWidgets(_tContainer& con, _tWidgets&... wgts)
243 {
244  unseq_apply(std::bind(static_cast<void(_tContainer::*)(IWidget&)>(
245  &_tContainer::operator+=), std::ref(con), std::placeholders::_1),
246  std::forward<IWidget&>(wgts)...);
247 }
248 
254 template<class _tContainer, class... _tWidgets>
255 inline void
256 AddWidgetsZ(_tContainer& con, ZOrderType z, _tWidgets&... wgts)
257 {
258  unseq_apply(std::bind(static_cast<void(_tContainer::*)(IWidget&, ZOrderType)
259  >(&_tContainer::Add), std::ref(con), std::placeholders::_1, z),
260  std::forward<IWidget&>(wgts)...);
261 }
262 
268 template<class _tContainer, class... _tWidgets>
269 inline void
270 RemoveWidgets(_tContainer& con, _tWidgets&... wgts)
271 {
272  unseq_apply(std::bind(static_cast<bool(_tContainer::*)(IWidget&)>(
273  &_tContainer::operator-=), std::ref(con), std::placeholders::_1),
274  std::forward<IWidget&>(wgts)...);
275 }
276 
278 
279 YSL_END
280 
281 #endif
282