YSTest: UIContainerEx.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

UIContainerEx.cpp
浏览该文件的文档.
1 /*
2 © 2011-2016 FrankHB.
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/YModules.h"
29 #include YFM_YSLib_UI_UIContainerEx
30 #include YFM_YSLib_UI_YGUI
31 #include YFM_YSLib_UI_Border
32
33 namespace YSLib
34 {
35
36 namespace UI
37 {
38
39 DialogBox::DialogBox(const Rect& r)
40 : Control(r, MakeBlankBrush()),
41 // XXX: Conversion to 'SPos' might be implementation-defined.
42 btnClose(Rect(SPos(GetWidth()) - 20, 4, 16, 16), 330)
43 {
44 const auto invalidator([this]{
45 Invalidate(*this);
46 });
47
48 DecorateAsCloseButton(btnClose),
49 SetContainerPtrOf(btnClose, make_observer(this)),
50 yunseq(
51 FetchEvent<Paint>(*this).Add(BorderBrush(), BackgroundPriority),
52 FetchEvent<GotFocus>(*this) += invalidator,
53 FetchEvent<LostFocus>(*this) += invalidator
54 );
55 }
56 ImplDeDtor(DialogBox)
57
58
59 DialogPanel::DialogPanel(const Rect& r)
60 : Panel(r),
61 // XXX: Conversion to 'SPos' might be implementation-defined.
62 btnClose(Rect(SPos(GetWidth()) - 20, 4, 16, 16), 330),
63 btnOK(Rect(SPos(GetWidth()) - 40, 4, 16, 16), 120)
64 {
65 const auto invalidator([this]{
66 Invalidate(*this);
67 });
68
69 AddWidgets(*this, btnClose, btnOK),
70 DecorateAsCloseButton(btnClose),
71 yunseq(
72 FetchEvent<Paint>(*this).Add(BorderBrush(), BackgroundPriority),
73 FetchEvent<Click>(btnOK) += [this]{
74 Close(*this);
75 },
76 FetchEvent<Paint>(btnOK) += [this](PaintEventArgs&& e){
77 DrawCircle(e.Target, e.ClipArea, {e.Location.X + 8, e.Location.Y + 8},
78 4, IsEnabled(btnOK) ? btnOK.ForeColor
79 : FetchGUIConfiguration().Colors[Styles::Workspace]);
80 },
81 FetchEvent<GotFocus>(*this) += invalidator,
82 FetchEvent<LostFocus>(*this) += invalidator
83 );
84 }
85 ImplDeDtor(DialogPanel)
86
87 } // namespace UI;
88
89 } // namespace YSLib;
90
YSLib::UI::FetchGUIConfiguration
GUIConfiguration & FetchGUIConfiguration()
Definition: YGUI.cpp:519
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
UI
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:326
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
YSLib::UI::Panel
面板。
Definition: ypanel.h:45
YSLib::UI::BorderBrush
边框画刷。
Definition: Border.h:68
YSLib::UI::DialogBox::DialogBox
DialogBox(const Rect &={})
Definition: UIContainerEx.cpp:39
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: YWidget.cpp:92
YSLib::UI::Styles::Workspace
应用程序工作区背景。
Definition: YStyle.h:314
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.cpp:108
YSLib::UI::BackgroundPriority
yconstexpr const EventPriority BackgroundPriority(0xC0)
用户界面绘制优先级。
YSLib::UI::DialogBox::btnClose
Thumb btnClose
关闭按钮。
Definition: UIContainerEx.h:57
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:43
YSLib::UI::PaintEventArgs
部件绘制参数。
Definition: YWidgetEvent.h:323
YSLib::UI::DialogBox
对话框。
Definition: UIContainerEx.h:46
YSLib::UI::e
void e
Definition: YWidget.h:352
YSLib::UI::AddWidgets
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
Definition: YUIContainer.h:443
YModules.h
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::UI::Control
控件。
Definition: YControl.h:275
YSLib::Drawing::DrawCircle
bounds c YF_API void DrawCircle(const Graphics &g, const Rect &bounds, const Point &, SDst, Color)
描画圆形。
Definition: YDraw.cpp:180
YSLib::UI::SPos
const IWidget &wgt SPos
Definition: YWidget.h:109
YSLib::UI::DialogPanel
对话面板。
Definition: UIContainerEx.h:78
YSLib::UI::ImplDeDtor
ImplDeDtor(Thumb) void DecorateAsCloseButton(Thumb &tmb)
Definition: Button.cpp:125