YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
GUIShell.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 "Helper/YModules.h"
29 #include YFM_Helper_GUIShell
30 #include YFM_Helper_GUIApplication // for FetchEnvironent;
31 #include YFM_Helper_Host
32 #include <thread> // for std::this_thread::sleep_for;
33 
34 namespace YSLib
35 {
36 
37 namespace Shells
38 {
39 
40 using namespace Messaging;
41 
43  : Shell(),
44  imMain()
45 {
47 }
48 
49 void
51 {
52  switch(msg.GetMessageID())
53  {
54  case SM_Paint:
56  return;
57  case SM_Input:
58  if(const auto p_wgt = imMain.Update())
59  imMain.DispatchInput(*p_wgt);
60  OnInput();
61  return;
62  default:
63  break;
64  }
65  Shell::OnGotMessage(msg);
66 }
67 
68 void
70 {
71  OnPaint();
72 #if YF_Hosted
73  // TODO: Use host reference stored by shell.
74  Host::FetchEnvironment().UpdateRenderWindows();
75  std::this_thread::sleep_for(IdleSleep);
76 #endif
77  // NOTE: Use code below if non-hosted delay is needed.
78 // Timers::Delay(std::chrono::duration_cast<Timers::TimeSpan>(IdleSleep));
79  // NOTE: Use code below instead if asynchronous posting is necessary.
80 // PostMessage<SM_PAINT>(0xE0, nullptr);
81 }
82 
83 void
85 {}
86 
87 } // namespace Shells;
88 
89 } // namespace YSLib;
90 
外壳程序:实现运行期控制流映像语义。
Definition: yshell.h:42
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
void DispatchInput(UI::IWidget &)
向指定部件分发响应输入状态。
#define SM_Paint
Definition: ymsgdef.h:66
Devices::InputManager imMain
输入管理器。
Definition: GUIShell.h:52
virtual void OnPaint()
处理绘制消息:默认为空实现。
Definition: GUIShell.cpp:84
GUIShell()
无参数构造:复位 GUI 状态。
Definition: GUIShell.cpp:42
virtual void OnInput()
处理输入消息:发送绘制消息。
Definition: GUIShell.cpp:69
std::chrono::nanoseconds IdleSleep
挂起延时时间。
Definition: GUIShell.h:59
#define SM_Input
Definition: ymsgdef.h:67
UI::IWidget * Update()
更新输入状态。
void Reset()
复位图形用户界面状态。
Definition: ygui.cpp:185
void OnGotMessage(const Message &) override
消息处理函数。
Definition: GUIShell.cpp:50