YSTest: HostWindow.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

HostWindow.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
28 #include "Helper/YModules.h"
29 #include YFM_Helper_Environment // for Host::Window, ::RAWINPUT, WM_*,
30 // ystdex::pun_storage_t, ystdex::replace_cast;
31 #include YFM_Helper_GUIApplication // for FetchGUIHost;
32 #include YFM_YCLib_Input // for platform::ClearKeyStates;
33 #if YCL_Win32
34 # include YFM_YSLib_UI_YUIContainer // for UI::FetchTopLevel;
35 #endif
36
37 namespace YSLib
38 {
39
40 using namespace Drawing;
41 using namespace UI;
42
43 #if YF_Hosted
44 namespace Host
45 {
46
47 Window::Window(NativeWindowHandle h_wnd)
48 : Window(h_wnd, FetchGUIHost())
49 {}
50 Window::Window(NativeWindowHandle h_wnd, GUIHost& h)
51 : HostWindow(h_wnd), host(h)
52 #if YCL_Win32
53 , InputHost(*this)
54 #endif
55 {
56 h.AddMappedItem(h_wnd, make_observer(this));
57 }
58 Window::~Window()
59 {
60 host.get().RemoveMappedItem(GetNativeHandle());
61 }
62
63 void
64 Window::UpdateFrom(Drawing::ConstBitmapPtr p, ScreenBuffer& buf)
65 {
66 const auto h_wnd(Nonnull(GetNativeHandle()));
67
68 # if YCL_Win32
69 if(UseOpacity)
70 {
71 buf.Premultiply(p);
72 buf.UpdatePremultipliedTo(h_wnd, Opacity);
73 }
74 else
75 # endif
76 {
77 buf.UpdateFrom(p);
78 buf.UpdateTo(h_wnd);
79 }
80 }
81
82 # if YCL_Win32
83 void
84 Window::UpdateFromBounds(Drawing::ConstBitmapPtr p, ScreenBuffer& buf,
85 const Rect& r, const Point& sp)
86 {
87 const auto h_wnd(Nonnull(GetNativeHandle()));
88
89 if(UseOpacity)
90 {
91 buf.Premultiply(p);
92 buf.UpdatePremultipliedTo(h_wnd, Opacity);
93 }
94 else
95 {
96 buf.UpdateFromBounds(p, r);
97 buf.UpdateToBounds(h_wnd, r, sp);
98 }
99 }
100
101 void
102 Window::UpdateTextInputFocus(IWidget& wgt, const Point& pt)
103 {
104 auto loc(pt);
105 auto& top_level(FetchTopLevel(wgt, loc));
106
107 yunused(top_level);
108 InputHost.UpdateCandidateWindowLocation(loc);
109 }
110 # endif
111
112 } // namespace Host;
113 #endif
114
115 } // namespace YSLib;
116
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
UI
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:326
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
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
YSLib::Text::buf
const char * buf
Definition: TextFile.h:81
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::UI::FetchTopLevel
YF_API IWidget & FetchTopLevel(IWidget &)
取指定部件的顶层部件。
Definition: YUIContainer.cpp:41
platform::if
if(!p) p
Drawing
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:968
YSLib::UI::Styles::Window
窗口背景。
Definition: YStyle.h:311
YModules.h
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
YSLib::UI::Window::Window
Window(const Rect &={}, unique_ptr< Renderer >=make_unique< BufferedRenderer >())
构造：使用指定边界并设置渲染器。
Definition: YWindow.cpp:40
YSLib::FetchGUIHost
FetchGUIHost
Definition: GUIApplication.h:296
YSLib::Drawing::ConstBitmapPtr
const Pixel * ConstBitmapPtr
Definition: YGraphics.h:44
CHRLib::p
const auto p(d)