YSTest: About.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

About.cpp
浏览该文件的文档.
1 /*
2 © 2012-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 "About.h"
29
30 namespace YReader
31 {
32
34 namespace
35 {
36
37 const char TU_About[]{u8R"NPL(root
38 ($type "Panel")($bounds "0 0 208 144")
39 (lblTitle
40 ($type "Label")($bounds "8 4 192 28"))
41 (lblVersion
42 ($type "Label")($bounds "8 36 192 40"))
43 (lblCopyright
44 ($type "Label")($bounds "8 80 192 20"))
45 (btnSysInfo
46 ($type "Button")($bounds "12 106 60 22"))
47 (btnExit
48 ($type "Button")($bounds "84 106 60 22"))
49 )NPL"};
50
51 } // unnamed namespace;
52
53 AboutPanel::AboutPanel()
54 : DialogPanel({8, 24, 208, 144}),
55 dynWgts(FetchWidgetLoader(), TU_About)
56 {
57 auto& node(dynWgts.WidgetNode);
58 DeclDynWidget(Panel, root, node)
59 DeclDynWidgetNode(Label, lblTitle)
60 DeclDynWidgetNode(Label, lblVersion)
61 DeclDynWidgetNode(Label, lblCopyright)
62 DeclDynWidgetNode(Button, btnSysInfo)
63 DeclDynWidgetNode(Button, btnExit)
64
65 AddWidgetsZ(*this, 32, root),
66 lblTitle.Font.SetSize(20),
67 lblTitle.Font.SetStyle(FontStyle::Bold),
68 yunseq(
69 lblTitle.Background = nullptr,
70 lblTitle.Text = G_APP_NAME,
71 lblTitle.HorizontalAlignment = TextAlignment::Left,
72 lblTitle.VerticalAlignment = TextAlignment::Down,
73 lblTitle.ForeColor = ColorSpace::Blue,
74 lblVersion.Background = nullptr,
75 lblVersion.AutoWrapLine = true,
76 lblVersion.Text = G_APP_VER + String(u" 0.6"),
77 lblVersion.ForeColor = ColorSpace::Green,
78 lblCopyright.Background = nullptr,
79 lblCopyright.Text = String("(C)2009-2015 by ") + G_COMP_NAME,
80 lblCopyright.ForeColor = ColorSpace::Maroon,
81 btnSysInfo.Text = u"系统信息",
82 btnExit.Text = u"退出",
83 root.Background = SolidBrush({248, 120, 120}),
84 FetchEvent<TouchDown>(root) += [&](CursorEventArgs&& e){
85 root.Background = SolidBrush(GenerateRandomColor());
86 SetInvalidationOf(root);
87 if(e.Strategy == RoutedEventArgs::Direct)
88 {
89 e.Handled = true;
90 RequestFocusCascade(*this);
91 }
92 },
93 FetchEvent<TouchHeld>(root) += std::bind(OnTouchHeld_DraggingRaw,
94 std::placeholders::_1, std::ref(*this)),
95 FetchEvent<Click>(btnSysInfo) += std::bind(std::ref(OnCommand),
96 Command::SystemInfo),
97 FetchEvent<Click>(btnSysInfo) += std::bind(Close, std::ref(*this)),
98 FetchEvent<Click>(btnExit)
99 += std::bind(YSLib::PostQuitMessage, 0, DefaultQuitPriority)
100 );
101 SetInvalidationOf(*this);
102 }
103 ImplDeDtor(AboutPanel)
104
105
106 SystemInformationPanel::SystemInformationPanel()
107 : DialogPanel({0, 0, 256, 170}),
108 view({0, 24, 256, 170}), lbl_title({3, 2, 80, 20})
109 {
110 AddWidgets(*this, view, lbl_title),
111 yunseq(
112 lbl_title.Background = nullptr,
113 lbl_title.Text = u"系统信息"
114 );
115 }
116 ImplDeDtor(SystemInformationPanel)
117
118 void
119 SystemInformationPanel::UpdateContents()
120 {
121 view.GetExtractText() = [](const ValueNode& nd) -> String{
122 const String& n(nd.GetName());
123
124 TryRet(n + u": " + TreeList::DefaultExtractText(nd))
125 CatchIgnore(ystdex::bad_any_cast&)
126 return n;
127 };
128 view.GetTreeRootRef() = FetchRoot();
129 view.BindView();
130 }
131
132 } // namespace YReader;
133
YSLib::UI::RequestFocusCascade
YF_API void RequestFocusCascade(IWidget &)
级联请求部件及上层容器焦点。
Definition: YFocus.cpp:137
YSLib::Drawing::Font
字体：字模，包含字型、样式和大小。
Definition: Font.h:583
YSLib::Consoles::Blue
Definition: YConsole.h:62
YSLib::Consoles::Green
Definition: YConsole.h:63
G_COMP_NAME
#define G_COMP_NAME
Definition: Shells.h:55
G_APP_NAME
#define G_APP_NAME
Definition: Shells.h:56
YSLib::PostQuitMessage
YF_API void PostQuitMessage(int=0, Messaging::Priority p=DefaultQuitPriority)
以指定错误码和优先级发起 Shell 终止请求。
Definition: YApplication.cpp:85
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: YWidget.cpp:92
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YReader::SystemInformationPanel
系统信息面板。
Definition: About.h:69
YSLib::UI::Button
按钮。
Definition: Button.h:127
YSLib::UI::DialogPanel
对话面板。
Definition: UIContainerEx.h:78
YReader
Definition: About.h:33
YSLib::UI::RoutedEventArgs::Direct
直接事件：仅当遍历至目标控件时触发。
Definition: YWidgetEvent.h:109
YSLib::UI::AddWidgets
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
Definition: YUIContainer.h:443
YSLib::UI::TextAlignment
TextAlignment
Definition: Label.h:45
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46
YSLib::Drawing::FontStyle
FontStyle
字体样式。
Definition: Font.h:95
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
ystdex::bad_any_cast
动态泛型转换失败异常。
Definition: any.h:636
YReader::ImplDeDtor
ImplDeDtor(AboutPanel) SystemInformationPanel
Definition: About.cpp:103
DeclDynWidget
#define DeclDynWidget(_t, _n,...)
声明动态部件。
Definition: Loader.h:300
YSLib::UI::SetInvalidationOf
void SetInvalidationOf(IWidget &wgt)
Definition: YWidget.cpp:63
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
YSLib::Drawing::SolidBrush
单色画刷。
Definition: YBrush.h:58
YReader::AboutPanel::AboutPanel
AboutPanel()
Definition: About.cpp:53
YSLib::UI::AddWidgetsZ
void AddWidgetsZ(_tCon &con, ZOrder z, _tWidgets &...wgts)
向部件容器添加指定 Z 顺序的子部件。
Definition: YUIContainer.h:457
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:487
YReader::FetchWidgetLoader
WidgetLoader & FetchWidgetLoader()
Definition: Shells.cpp:127
YSLib::UI::OnTouchHeld_DraggingRaw
YF_API void OnTouchHeld_DraggingRaw(CursorEventArgs &&, IWidget &)
处理屏幕接触移动事件：拖放指定部件。
Definition: YControl.cpp:152
About.h
关于界面。
YSLib::UI::Panel
面板。
Definition: ypanel.h:45
Text
ColorSpace
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:57
G_APP_VER
#define G_APP_VER
Definition: Shells.h:57
YSLib::UI::Label
标签。
Definition: Label.h:143
DeclDynWidgetNode
#define DeclDynWidgetNode(_t, _n)
声明名称为 node 的节点下的按相同名称访问的动态部件。
Definition: Loader.h:313
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
ystdex::ref
lref< _type > ref(_type &t)
构造引用包装。
Definition: ref.hpp:120
YReader::AboutPanel
关于窗体。
Definition: About.h:40