YSTest: DSWindow.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

DSWindow.cpp
浏览该文件的文档.
1 /*
2 © 2013-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
29 #include "DSWindow.h"
30 #include "DSScreen.h" // for GSurface;
31 #if YCL_Win32
32 # include YFM_YSLib_UI_YDesktop // for UI::Desktop;
33 # include <ystdex/cast.hpp> // for ystdex::polymorphic_downcast;
34 #endif
35
36 namespace YSLib
37 {
38
39 #if YF_Hosted
40 using Devices::DSScreen;
41 using namespace Drawing;
42
43 namespace Host
44 {
45
46 DSWindow::DSWindow(NativeWindowHandle h_wnd, DSScreen& s_up, DSScreen& s_dn,
47 GUIHost& h)
48 : Window(h_wnd, h), scr_up(s_up), scr_dn(s_dn)
49 {
50 # if YCL_Win32
51 yunseq(
52 MessageMap[WM_DESTROY] += []{
53 YSLib::PostQuitMessage(0);
54 // NOTE: Try to make sure all shells are released before destructing the
55 // instance of %DSApplication.
56 },
57 MessageMap[WM_PAINT] += [this]{
58 GSurface<WindowRegionDeviceContext> sf(GetNativeHandle());
59 const auto& r(sf.GetInvalidatedArea());
60
61 UpdateScreen(sf, scr_up, r);
62 UpdateScreen(sf, scr_dn, r);
63 }
64 );
65 Show();
66 # endif
67 }
68
69 # if YCL_Win32
70 Point
71 DSWindow::MapPoint(const Point& pt) const
72 {
73 const Rect
74 bounds(0, MainScreenHeight, MainScreenWidth, MainScreenHeight << 1);
75
76 return bounds.Contains(pt) ? pt - bounds.GetPoint() : Point::Invalid;
77 }
78
79 void
80 DSWindow::UpdateTextInputFocus(UI::IWidget& wgt, const Point& pt)
81 {
82 auto loc(pt);
83 auto& top_level(UI::FetchTopLevel(wgt, loc));
84
85 YAssert(&ystdex::polymorphic_downcast<const DSScreen&>(
86 ystdex::polymorphic_downcast<Desktop&>(top_level)
87 .GetScreen()) == &scr_dn, "Wrong screen of text input found");
88 yunused(top_level);
89 InputHost.UpdateCandidateWindowLocation(loc + Point(0, MainScreenHeight));
90 }
91 # endif
92
93 } // namespace Host;
94 #endif
95
96 } // namespace YSLib;
97
DSWindow.h
DS 宿主窗口。
YSLib::Drawing::Rect::Contains
bool Contains(SPos px, SPos py) const ynothrow
判断点 (px, py) 是否在矩形内或边上。
Definition: YGDIBase.cpp:92
YSLib::PostQuitMessage
YF_API void PostQuitMessage(int=0, Messaging::Priority p=DefaultQuitPriority)
以指定错误码和优先级发起 Shell 终止请求。
Definition: YApplication.cpp:85
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::Drawing::bounds
The boundary is out of the const Rect & bounds
Definition: YDraw.h:127
YSLib::UI::Styles::Window
窗口背景。
Definition: YStyle.h:311
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:942
DSScreen.h
DS 屏幕。
cast.hpp
C++ 转换模板。
YSLib::YAssert
YAssert(!(v< Deref(a)),"Value less than lower bound found.")
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
Drawing
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: YWidget.cpp:202
YSLib::Drawing::GBinaryGroup< SPos >::Invalid
static const GBinaryGroup Invalid
无效（不在屏幕坐标系中）对象。
Definition: YGDIBase.h:58
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::UI::FetchTopLevel
YF_API IWidget & FetchTopLevel(IWidget &)
取指定部件的顶层部件。
Definition: YUIContainer.cpp:41