YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
uicontx.cpp
浏览该文件的文档.
1 /*
2  © 2011-2014 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 
40  : Control(r, MakeBlankBrush()),
41  btnClose(Rect(GetWidth() - 20, 4, 16, 16), 330)
42 {
43  const auto invalidator([this]{
44  Invalidate(*this);
45  });
46 
48  SetContainerPtrOf(btnClose, this),
49  yunseq(
50  FetchEvent<Paint>(*this).Add(BorderBrush(), BackgroundPriority),
51  FetchEvent<GotFocus>(*this) += invalidator,
52  FetchEvent<LostFocus>(*this) += invalidator
53  );
54 }
55 
56 
58  : Panel(r),
59  btnClose(Rect(GetWidth() - 20, 4, 16, 16), 330),
60  btnOK(Rect(GetWidth() - 40, 4, 16, 16), 120)
61 {
62  const auto invalidator([this]{
63  Invalidate(*this);
64  });
65 
66  AddWidgets(*this, btnClose, btnOK),
68  yunseq(
69  FetchEvent<Paint>(*this).Add(BorderBrush(), BackgroundPriority),
70  FetchEvent<Click>(btnOK) += [this]{
71  Close(*this);
72  },
73  FetchEvent<Paint>(btnOK) += [this](PaintEventArgs&& e){
74  DrawCircle(e.Target, e.ClipArea, {e.Location.X + 8, e.Location.Y + 8},
76  : FetchGUIState().Colors[Styles::Workspace]);
77  },
78  FetchEvent<GotFocus>(*this) += invalidator,
79  FetchEvent<LostFocus>(*this) += invalidator
80  );
81 }
82 
83 } // namespace UI;
84 
85 } // namespace YSLib;
86 
DialogBox(const Rect &={})
Definition: uicontx.cpp:39
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
YF_API void Invalidate(IWidget &, const Rect &)
无效化:使相对于部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: ywidget.cpp:111
DialogPanel(const Rect &={})
Definition: uicontx.cpp:57
部件绘制参数。
Definition: ywgtevt.h:276
面板。
Definition: ypanel.h:45
Thumb btnClose
关闭按钮。
Definition: uicontx.h:57
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
Definition: yuicont.h:400
控件。
Definition: ycontrol.h:275
边框画刷。
Definition: Border.h:59
bounds c YF_API void DrawCircle(const Graphics &, const Rect &, const Point &, SDst, Color c)
描画圆形。
Definition: ydraw.cpp:173
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:748
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
Thumb btnOK
确定按钮。
Definition: uicontx.h:85
bool IsEnabled(const IWidget &wgt)
判断部件是否为可用的控件。
Definition: ycontrol.h:86
应用程序工作区背景。
Definition: ystyle.h:185
bounds & r
Definition: ydraw.h:220
Color ForeColor
默认前景色。
Definition: ywidget.h:375
void DecorateAsCloseButton(Thumb &tmb)
Definition: button.cpp:127
void Close(IWidget &wgt)
Definition: ywidget.cpp:95
Thumb btnClose
关闭按钮。
Definition: uicontx.h:80
yconstexpr EventPriority BackgroundPriority(0xC0)
用户界面绘制优先级。