YSTest: ypanel.cpp 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
ypanel.cpp
浏览该文件的文档.
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 #include "YSLib/UI/ypanel.h"
29
30 YSL_BEGIN
31
32 YSL_BEGIN_NAMESPACE(UI)
33
34 Panel::Panel(const Rect& r)
35 : Control(r), MUIContainer()
36 {}
37
38 void
39 Panel::operator+=(IWidget& wgt)
40 {
41 MUIContainer::operator+=(wgt);
42 SetContainerPtrOf(wgt, this);
43 }
44
45 bool
46 Panel::operator-=(IWidget& wgt)
47 {
48 if(FetchContainerPtr(wgt) == this)
49 {
50 SetContainerPtrOf(wgt);
51 if(FetchFocusingPtr(*this) == &wgt)
52 GetView().FocusingPtr = nullptr;
53 return MUIContainer::operator-=(wgt);
54 }
55 return false;
56 }
57
58 void
59 Panel::Add(IWidget& wgt, ZOrderType z)
60 {
61 MUIContainer::Add(wgt, z);
62 SetContainerPtrOf(wgt, this);
63 }
64
65 void
66 Panel::ClearContents()
67 {
68 ClearFocusingOf(*this);
69 mWidgets.clear();
70 SetInvalidationOf(*this);
71 }
72
73 bool
74 Panel::MoveToTop(IWidget& wgt)
75 {
76 using ystdex::get_value;
77
78 auto i(std::find(mWidgets.begin() | get_value, mWidgets.end() | get_value,
79 &wgt));
80
81 if(i != mWidgets.end())
82 {
83 const ZOrderType z(i.get()->first);
84
85 mWidgets.erase(i);
86 mWidgets.insert(make_pair(z, static_cast<IWidget*>(&wgt)));
87 Invalidate(wgt);
88 return true;
89 }
90 return false;
91 }
92
93 void
94 Panel::Refresh(PaintEventArgs&& e)
95 {
96 if(!e.ClipArea.IsUnstrictlyEmpty())
97 PaintVisibleChildren(e);
98 }
99
100 YSL_END_NAMESPACE(UI)
101
102 YSL_END
103