YSTest: shlds.cpp 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
shlds.cpp
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2010 - 2013.
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
29 #include "Helper/shlds.h"
30 #include "Helper/DSMain.h"
31 #include "Helper/ShellHelper.h"
32 #include "YSLib/UI/ydesktop.h"
33 #include "YSLib/UI/ygui.h"
34 #include "Host.h"
35
36 YSL_BEGIN
37
38 YSL_BEGIN_NAMESPACE(Shells)
39
40 using namespace Messaging;
41
42 int
43 ShlCLI::ExecuteCommand(const ucs2_t*)
44 {
45 // TODO: Implementation.
46 return 0;
47 }
48
49
50 YSL_END_NAMESPACE(Shells)
51
52
53 YSL_BEGIN_NAMESPACE(DS)
54
55 void
56 ResetDSDesktops(Desktop& dsk_up, Desktop& dsk_dn)
57 {
58 auto& app(FetchGlobalInstance<DSApplication>());
59
60 ResetDesktop(dsk_up, app.GetScreenUp()),
61 ResetDesktop(dsk_dn, app.GetScreenDown());
62 }
63
64
65 ShlDS::ShlDS(const shared_ptr<Desktop>& hUp, const shared_ptr<Desktop>& hDn)
66 : GUIShell(),
67 desktop_up_ptr(hUp ? hUp : make_shared<Desktop>(
68 FetchGlobalInstance<DSApplication>().GetScreenUp())),
69 desktop_down_ptr(hDn ? hDn : make_shared<Desktop>(
70 FetchGlobalInstance<DSApplication>().GetScreenDown())),
71 bUpdateUp(), bUpdateDown()
72 {
73 YAssert(bool(desktop_up_ptr), "Null pointer found.");
74 YAssert(bool(desktop_down_ptr), "Null pointer found.");
75 }
76
77 void
78 ShlDS::OnGotMessage(const Message& msg)
79 {
80 switch(msg.GetMessageID())
81 {
82 case SM_PAINT:
83 ShlDS::OnInput();
84 return;
85 case SM_INPUT:
86 #if YCL_HOSTED
87 if(auto p_wgt = imMain.Update())
88 imMain.DispatchInput(*p_wgt);
89 else
90 imMain.DispatchInput(*desktop_down_ptr);
91 #else
92 imMain.Update();
93 imMain.DispatchInput(*desktop_down_ptr);
94 #endif
95 OnInput();
96 return;
97 default:
98 break;
99 }
100 GUIShell::OnGotMessage(msg);
101 }
102
103 void
104 ShlDS::OnInput()
105 {
106 using Drawing::Rect;
107
108 yunseq(bUpdateUp = bool(desktop_up_ptr->Validate()),
109 bUpdateDown = bool(desktop_down_ptr->Validate()));
110 OnPaint();
111 if(bUpdateUp)
112 desktop_up_ptr->Update();
113 if(bUpdateDown)
114 desktop_down_ptr->Update();
115 #if YCL_HOSTED
116 GUIShell::OnInput();
117 #endif
118 }
119
120 YSL_END_NAMESPACE(DS)
121
122 YSL_END
123