YSTest: About.cpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

About.cpp
浏览该文件的文档.
1 /*
2 © 2012-2016, 2019 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[]{R"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-2019 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(bad_any_cast&)
126 return n;
127 };
128 view.GetTreeRootRef() = FetchRoot();
129 view.BindView();
130 }
131
132 } // namespace YReader;
133
YSLib::UI::TextAlignment::Down
@ Down
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:112
YSLib::Drawing::SolidBrush
单色画刷。
Definition: YBrush.h:59
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
YSLib::PostQuitMessage
YF_API void PostQuitMessage(int=0, Messaging::Priority p=DefaultQuitPriority)
以指定错误码和优先级发起 Shell 终止请求。
Definition: YApplication.cpp:87
YSLib::UI::Panel
面板。
Definition: YPanel.h:46
YReader::AboutPanel
关于窗体。
Definition: About.h:41
About.h
关于界面。
YReader
Definition: About.h:34
YSLib::UI::Button
按钮。
Definition: Button.h:127
YReader::SystemInformationPanel::SystemInformationPanel
SystemInformationPanel()
YReader::ImplDeDtor
ImplDeDtor(AboutPanel) SystemInformationPanel
Definition: About.cpp:103
ImplDeDtor
#define ImplDeDtor(_t)
Definition: YBaseMacro.h:183
G_APP_NAME
#define G_APP_NAME
Definition: Shells.h:56
YSLib::Consoles::Blue
@ Blue
Definition: YConsole.h:62
YSLib::UI::Label
标签。
Definition: Label.h:143
YSLib::UI::OnTouchHeld_DraggingRaw
YF_API void OnTouchHeld_DraggingRaw(CursorEventArgs &&, IWidget &)
处理屏幕接触移动事件：拖放指定部件。
Definition: YControl.cpp:152
ystdex::bad_any_cast
动态泛型转换失败异常。
Definition: any.h:1091
YReader::FetchWidgetLoader
YB_ATTR_nodiscard YB_PURE WidgetLoader & FetchWidgetLoader()
Definition: Shells.cpp:125
YSLib::UI::AddWidgets
void AddWidgets(_tCon &con, _tWidgets &... wgts)
向部件容器添加子部件。
Definition: YUIContainer.h:446
G_APP_VER
#define G_APP_VER
Definition: Shells.h:57
YSLib::UI::RoutedEventArgs::Direct
@ Direct
直接事件：仅当遍历至目标控件时触发。
Definition: YWidgetEvent.h:113
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:47
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:73
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1535
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:816
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: YWidget.cpp:92
YReader::SystemInformationPanel
系统信息面板。
Definition: About.h:70
YSLib::UI::DialogPanel
对话面板。
Definition: UIContainerEx.h:79
YSLib::UI::TextAlignment::Left
@ Left
YReader::AboutPanel::AboutPanel
AboutPanel()
Definition: About.cpp:53
DeclDynWidgetNode
#define DeclDynWidgetNode(_t, _n)
声明名称为 node 的节点下的按相同名称访问的动态部件。
Definition: Loader.h:315
DeclDynWidget
#define DeclDynWidget(_t, _n,...)
声明动态部件。
Definition: Loader.h:302
YSLib::UI::AddWidgetsZ
void AddWidgetsZ(_tCon &con, ZOrder z, _tWidgets &... wgts)
向部件容器添加指定 Z 顺序的子部件。
Definition: YUIContainer.h:460
YSLib::UI::SetInvalidationOf
void SetInvalidationOf(IWidget &wgt)
Definition: YWidget.cpp:63
YSLib::UI::RequestFocusCascade
YF_API void RequestFocusCascade(IWidget &)
级联请求部件及上层容器焦点。
Definition: YFocus.cpp:137
YSLib::Consoles::Green
@ Green
Definition: YConsole.h:63
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
G_COMP_NAME
#define G_COMP_NAME
Definition: Shells.h:55
ystdex::ref
void ref(const _type &&)=delete
YSLib::Drawing::ColorSpace::Maroon
@ Maroon
Definition: YGDIBase.h:268