YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
About.cpp
浏览该文件的文档.
1 /*
2  © 2013 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 (btnClose
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 
54  : Form({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, btnClose)
63  DeclDynWidgetNode(Button, btnExit)
64 
65  AddWidgets(*this, AccessWidget<Panel>(node)),
66  lblTitle.Font.SetSize(20),
67  yunseq(
68  lblTitle.Background = nullptr,
69  lblTitle.Text = G_APP_NAME,
70  lblTitle.HorizontalAlignment = TextAlignment::Left,
71  lblTitle.VerticalAlignment = TextAlignment::Down,
72  lblTitle.ForeColor = ColorSpace::Blue,
73  lblVersion.Background = nullptr,
74  lblVersion.AutoWrapLine = true,
75  lblVersion.Text = G_APP_VER + String(" @ " __DATE__ ", " __TIME__),
76  lblVersion.ForeColor = ColorSpace::Green,
77  lblCopyright.Background = nullptr,
78  lblCopyright.Text = String("(C)2009-2013 by ") + G_COMP_NAME,
79  lblCopyright.ForeColor = ColorSpace::Maroon,
80  btnClose.Text = u"关闭",
81  btnExit.Text = u"退出",
82  root.Background = SolidBrush({248, 120, 120}),
83  btnClose.Background = SolidBrush({176, 184, 192}),
84  FetchEvent<TouchDown>(root) += [&](CursorEventArgs&& e){
85  root.Background = SolidBrush(GenerateRandomColor());
86  SetInvalidationOf(root);
87  if(e.Strategy == RoutedEventArgs::Direct)
88  e.Handled = true;
89  },
90  FetchEvent<TouchHeld>(root) += std::bind(OnTouchHeld_DraggingRaw,
91  std::placeholders::_1, std::ref(*this)),
92  FetchEvent<Click>(btnClose) += [this]{
93  Hide(*this);
94  },
95  FetchEvent<Click>(btnExit) += []{
97  }
98  );
99  SetInvalidationOf(*this);
100 }
101 
102 } // namespace YReader;
103 
#define G_APP_NAME
Definition: Shells.h:58
bool return true
Definition: DSMain.cpp:177
Color GenerateRandomColor()
Definition: ShellHelper.h:293
YF_API void PostQuitMessage(int nExitCode, Messaging::Priority p=0xF0)
以优先级 p 发起 Shell 终止请求,返回 nExitCode。
Definition: yapp.cpp:83
void SetInvalidationOf(IWidget &wgt)
Definition: ywidget.cpp:60
YF_API void OnTouchHeld_DraggingRaw(CursorEventArgs &&, IWidget &)
处理屏幕接触移动事件:拖放指定部件。
Definition: ycontrol.cpp:151
#define G_APP_VER
Definition: Shells.h:59
面板。
Definition: ypanel.h:45
窗口。
Definition: ywindow.h:44
按钮。
Definition: button.h:116
YF_API void Hide(IWidget &)
隐藏部件。
Definition: ywidget.cpp:103
关于界面。
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
Definition: yuicont.h:400
YSLib 标准字符串(使用 UCS-2 作为内部编码)。
Definition: ystring.h:47
sizeof(AlphaType)*GetAreaOf(GetSize())) using CompactPixmap void SetSize(const Size &) override
重新设置缓冲区大小。
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:748
WidgetLoader & FetchWidgetLoader()
Definition: Shells.cpp:130
直接事件:仅当遍历至目标控件时触发。
Definition: ywgtevt.h:104
标签。
Definition: label.h:104
IWidget & AccessWidget(const ValueNode &node, const string &name, _tParams &&...args)
Definition: Loader.h:135
#define DeclDynWidget(_t, _n,...)
声明动态部件。
Definition: Loader.h:263
TextAlignment
Definition: label.h:44
单色画刷。
Definition: YBrush.h:46
字体:字模,包含字型、样式和大小。
Definition: Font.h:546
#define G_COMP_NAME
Definition: Shells.h:57
#define DeclDynWidgetNode(_t, _n)
声明名称为 node 的节点下的按相同名称访问的动态部件。
Definition: Loader.h:276