YSTest: Win32GUI.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
include/YCLib/Win32GUI.h
浏览该文件的文档.
1 /*
2 © 2013-2014 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 #ifndef YCL_MinGW32_INC_Win32GUI_h_
30 #define YCL_MinGW32_INC_Win32GUI_h_ 1
31
32 #include "YCLib/YModules.h"
33 #include YFM_MinGW32_YCLib_MinGW32
34 #include YFM_YSLib_Core_YGDIBase
35 #include YFM_YSLib_Core_YEvent
36 #include <mutex> // for std::mutex;
37 #include <atomic>
38
39 namespace platform_ex
40 {
41
43 using NativeWindowHandle = ::HWND;
44
45 inline namespace Windows
46 {
47
54 class YF_API WindowReference
55 {
56 protected:
57 NativeWindowHandle hWindow;
58
59 public:
60 WindowReference(NativeWindowHandle h = {})
61 : hWindow(h)
62 {}
64 DefDeCopyCtor(WindowReference)
66 WindowReference(WindowReference&& r) ynothrow
67 : hWindow(r.hWindow)
68 {
69 r.hWindow = {};
70 }
71
73
74 YSLib::Drawing::Rect
75 GetClientBounds() const;
76 YSLib::Drawing::Point
77 GetClientLocation() const;
78 YSLib::Drawing::Size
79 GetClientSize() const;
81 YSLib::Drawing::Point
82 GetLocation() const;
83 DefGetter(const ynothrow, NativeWindowHandle, NativeHandle, hWindow)
90 YSLib::Drawing::AlphaType
91 GetOpacity() const;
92 YSLib::Drawing::Size
93 GetSize() const;
94
96 void
97 SetClientBounds(const YSLib::Drawing::Rect&);
103 void
104 SetOpacity(YSLib::Drawing::AlphaType);
109 void
110 SetText(const wchar_t*);
111
113 void
114 Close();
115
120 void
121 Invalidate();
122
127 void
128 Move(const YSLib::Drawing::Point&);
129
134 void
135 Resize(const YSLib::Drawing::Size&);
136
141 void
142 ResizeClient(const YSLib::Drawing::Size&);
143
148 bool
149 Show() ynothrow;
150 };
151
152
157 YF_API NativeWindowHandle
158 CreateNativeWindow(const wchar_t*, const YSLib::Drawing::Size&,
159 const wchar_t* = L"", ::DWORD = WS_POPUP, ::DWORD = WS_EX_LTRREADING);
160
161
163
164
169 class YF_API ScreenBuffer
170 {
171 private:
173 YSLib::Drawing::Size size;
174
175 protected:
176 YSLib::Drawing::BitmapPtr pBuffer;
177 ::HBITMAP hBitmap;
178
179 public:
180 ScreenBuffer(const YSLib::Drawing::Size&);
182 ScreenBuffer(ScreenBuffer&&) ynothrow;
183 ~ScreenBuffer();
184
186 ScreenBuffer&
187 operator=(ScreenBuffer&&);
188
190
191 DefGetter(const ynothrow, YSLib::Drawing::BitmapPtr, BufferPtr, pBuffer)
192 DefGetter(const ynothrow, ::HBITMAP, NativeHandle, hBitmap)
193 DefGetter(const ynothrow, const YSLib::Drawing::Size&, Size, size)
194
201 void
202 Premultiply(YSLib::Drawing::BitmapPtr) ynothrow;
203
209 void
210 Resize(const YSLib::Drawing::Size&);
211
218 void
219 UpdateFrom(YSLib::Drawing::BitmapPtr) ynothrow;
221
222 /*
223 \brief 交换。
224 \since build 430
225 */
226 void
227 swap(ScreenBuffer&) ynothrow;
228 };
229
234 inline DefSwap(ynothrow, ScreenBuffer)
235
236
242 class YF_API ScreenRegionBuffer : private ScreenBuffer
243 {
244 private:
245 std::mutex mtx;
246
247 public:
248 ScreenRegionBuffer(const YSLib::Drawing::Size& s)
249 : ScreenBuffer(s), mtx()
250 {}
251
252 using ScreenBuffer::GetBufferPtr;
253 using ScreenBuffer::GetNativeHandle;
254 using ScreenBuffer::GetSize;
255 DefGetter(ynothrow, ScreenBuffer&, ScreenBufferRef, *this)
256
257
258 using ScreenBuffer::Premultiply;
260 using ScreenBuffer::Resize;
261
263 void
264 UpdateFrom(YSLib::Drawing::BitmapPtr) ynothrow;
265
267 void
268 UpdatePremultipliedTo(NativeWindowHandle, YSLib::Drawing::AlphaType = 0xFF,
269 const YSLib::Drawing::Point& = {}) ynothrow;
270
271 void
272 UpdateTo(NativeWindowHandle, const YSLib::Drawing::Point& = {}) ynothrow;
273 };
275
276
278
279
283 class YF_API WindowMemorySurface
284 {
285 private:
286 ::HDC h_owner_dc, h_mem_dc;
287
288 public:
289 WindowMemorySurface(::HDC h_dc)
290 : h_owner_dc(h_dc), h_mem_dc(::CreateCompatibleDC(h_dc))
291 {}
292 ~WindowMemorySurface()
293 {
294 ::DeleteDC(h_mem_dc);
295 }
296
297 DefGetter(const ynothrow, ::HDC, OwnerHandle, h_owner_dc)
298 DefGetter(const ynothrow, ::HDC, NativeHandle, h_mem_dc)
299
301 void
302 Update(ScreenBuffer&, const YSLib::Drawing::Point& = {}) ynothrow;
304 PDefH(void, Update, ScreenRegionBuffer& rbuf,
305 const YSLib::Drawing::Point& pt = {}) ynothrow
306 ImplExpr(Update(rbuf.GetScreenBufferRef(), pt))
307
308
309 void
310 UpdatePremultiplied(ScreenBuffer&, NativeWindowHandle,
311 YSLib::Drawing::AlphaType = 0xFF, const YSLib::Drawing::Point& = {})
312 ynothrow;
314 void
315 UpdatePremultiplied(ScreenRegionBuffer& rbuf, NativeWindowHandle h_wnd,
316 YSLib::Drawing::AlphaType a = 0xFF,
317 const YSLib::Drawing::Point& pt = {}) ynothrow
318 {
319 UpdatePremultiplied(rbuf.GetScreenBufferRef(), h_wnd, a, pt);
320 }
321 };
322
323
324 class YF_API WindowDeviceContextBase
325 {
326 protected:
327 NativeWindowHandle hWindow;
328 ::HDC hDC;
329
330 WindowDeviceContextBase(NativeWindowHandle h_wnd, ::HDC h_dc)
331 : hWindow(h_wnd), hDC(h_dc)
332 {}
333 DefDeDtor(WindowDeviceContextBase)
334
335 public:
336 DefGetter(const ynothrow, ::HDC, DeviceContextHandle, hDC)
337 DefGetter(const ynothrow, NativeWindowHandle, WindowHandle, hWindow)
338 };
339
340
345 class YF_API WindowDeviceContext : public WindowDeviceContextBase
346 {
347 protected:
348 WindowDeviceContext(NativeWindowHandle h_wnd)
349 : WindowDeviceContextBase(h_wnd, ::GetDC(h_wnd))
350 {}
351 ~WindowDeviceContext()
352 {
353 ::ReleaseDC(hWindow, hDC);
354 }
355 };
356
357
362 class YF_API WindowRegionDeviceContext : public WindowDeviceContextBase
363 {
364 private:
365 ::PAINTSTRUCT ps;
366
367 protected:
368 WindowRegionDeviceContext(NativeWindowHandle h_wnd)
369 : WindowDeviceContextBase(h_wnd, ::BeginPaint(h_wnd, &ps))
370 {}
371 ~WindowRegionDeviceContext()
372 {
373 ::EndPaint(hWindow, &ps);
374 }
375 };
377
378
384 template<typename _type = WindowDeviceContext>
385 class GSurface : public _type, public WindowMemorySurface
386 {
387 public:
389 GSurface(NativeWindowHandle h_wnd)
390 : _type(h_wnd), WindowMemorySurface(_type::GetDeviceContextHandle())
391 {}
392 };
393
394
399 class YF_API WindowClass
400 {
401 private:
402 ::HINSTANCE h_instance;
403
404 public:
405 WindowClass(const wchar_t*, ::WNDPROC, ::UINT = 0,
406 ::HBRUSH = ::HBRUSH(COLOR_MENU + 1));
407 ~WindowClass();
408 };
409
410
412 yconstexpr wchar_t WindowClassName[]{L"YFramework Window"};
413
414
419 class YF_API HostWindow : private WindowReference, private YSLib::noncopyable
420 {
421 public:
426 std::atomic<bool> BoundsLimited{false};
427
432 std::map<::UINT, YSLib::GEvent<void(::WPARAM, ::LPARAM)>> MessageMap;
433
435 HostWindow(NativeWindowHandle);
436 DefDelMoveCtor(HostWindow)
437 virtual
438 ~HostWindow();
439
441
442 using WindowReference::GetClientBounds;
443 using WindowReference::GetClientLocation;
444 using WindowReference::GetClientSize;
446
448 using WindowReference::GetLocation;
449 using WindowReference::GetNativeHandle;
451 using WindowReference::GetOpacity;
452 using WindowReference::GetSize;
453
455 using WindowReference::SetClientBounds;
457 using WindowReference::SetOpacity;
459 using WindowReference::SetText;
460
461 using WindowReference::Close;
462
464 using WindowReference::Invalidate;
465
466 using WindowReference::Move;
468
470
471 using WindowReference::Resize;
472
473 using WindowReference::ResizeClient;
474
475 using WindowReference::Show;
477 };
478
479 } // namespace Windows;
480
481 } // namespace platform_ex;
482
483 #endif
484
platform_ex::Windows::WindowDeviceContextBase
Definition: include/YCLib/Win32GUI.h:324
platform_ex::Windows::WindowDeviceContextBase::hWindow
NativeWindowHandle hWindow
Definition: include/YCLib/Win32GUI.h:327
platform_ex::Windows::WindowClass
窗口类。
Definition: include/YCLib/Win32GUI.h:399
platform_ex::Windows::WindowClass::h_instance
::HINSTANCE h_instance
Definition: include/YCLib/Win32GUI.h:402
platform_ex::Windows::WindowClassName
yconstexpr wchar_t WindowClassName[]
Definition: include/YCLib/Win32GUI.h:412
DefDeDtor
#define DefDeDtor(_t)
定义默认析构函数。
Definition: YBaseMacro.h:146
platform_ex::Windows::WindowReference::WindowReference
WindowReference(NativeWindowHandle h={})
Definition: include/YCLib/Win32GUI.h:60
platform_ex::Windows::WindowMemorySurface::WindowMemorySurface
WindowMemorySurface(::HDC h_dc)
Definition: include/YCLib/Win32GUI.h:289
platform_ex::Windows::GSurface
显式区域表面：储存显式区域上的二维图形绘制状态。
Definition: include/YCLib/Win32GUI.h:385
platform_ex::Windows::WindowRegionDeviceContext::~WindowRegionDeviceContext
~WindowRegionDeviceContext()
Definition: include/YCLib/Win32GUI.h:371
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对于部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: ywidget.cpp:111
YModules.h
platform_ex::Windows::HostWindow::MessageMap
std::map<::UINT, YSLib::GEvent< void(::WPARAM,::LPARAM)> > MessageMap
窗口消息转发事件映射。
Definition: include/YCLib/Win32GUI.h:432
YF_API
#define YF_API
Definition: Platform.h:64
platform_ex::Windows::DefGetter
DefGetter(const ynothrow,::HKEY, Key, h_key)}
platform_ex::Windows::WindowDeviceContext
窗口设备上下文。
Definition: include/YCLib/Win32GUI.h:345
platform_ex::Windows::UpdateFrom
void UpdateFrom(YSLib::Drawing::BitmapPtr) ynothrow
platform_ex::Windows::ScreenBuffer::pBuffer
YSLib::Drawing::BitmapPtr pBuffer
Definition: include/YCLib/Win32GUI.h:176
platform_ex::Windows::WindowMemorySurface::h_owner_dc
::HDC h_owner_dc
Definition: include/YCLib/Win32GUI.h:286
platform_ex::Windows::WindowReference::DefDeCopyCtor
DefDeCopyCtor(WindowReference) WindowReference(WindowReference &&r) ynothrow
Definition: include/YCLib/Win32GUI.h:64
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: ywidget.cpp:206
platform_ex::Windows::WindowReference::hWindow
NativeWindowHandle hWindow
Definition: include/YCLib/Win32GUI.h:57
platform_ex::Windows::CreateNativeWindow
YF_API NativeWindowHandle CreateNativeWindow(const wchar_t *, const YSLib::Drawing::Size &, const wchar_t *=L"",::DWORD=WS_POPUP,::DWORD=WS_EX_LTRREADING)
按指定窗口类名、客户区大小、标题文本、样式和附加样式创建本机顶层窗口。
Definition: Win32GUI.cpp:222
platform_ex::Windows::WindowDeviceContext::~WindowDeviceContext
~WindowDeviceContext()
Definition: include/YCLib/Win32GUI.h:351
platform_ex::Windows::WindowMemorySurface::UpdatePremultiplied
void UpdatePremultiplied(ScreenRegionBuffer &rbuf, NativeWindowHandle h_wnd, YSLib::Drawing::AlphaType a=0xFF, const YSLib::Drawing::Point &pt={}) ynothrow
Definition: include/YCLib/Win32GUI.h:315
ystdex::swap
void swap(any &x, any &y)
交换对象。
Definition: any.h:729
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
platform_ex::Windows::GSurface::GSurface
GSurface(NativeWindowHandle h_wnd)
Definition: include/YCLib/Win32GUI.h:389
platform_ex::Windows::WindowReference
本机窗口引用。
Definition: include/YCLib/Win32GUI.h:54
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: ygdibase.h:235
platform_ex::Windows::WindowDeviceContextBase::WindowDeviceContextBase
WindowDeviceContextBase(NativeWindowHandle h_wnd,::HDC h_dc)
Definition: include/YCLib/Win32GUI.h:330
ImplExpr
#define ImplExpr(...)
Definition: YBaseMacro.h:93
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
platform_ex::Windows::UpdateTo
void UpdateTo(NativeWindowHandle, const YSLib::Drawing::Point &={}) ynothrow
platform_ex::Windows::HostWindow
宿主窗口。
Definition: include/YCLib/Win32GUI.h:419
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: ygdibase.h:416
platform_ex::Windows::ScreenRegionBuffer
ScreenRegionBuffer(const YSLib::Drawing::Size &s)
虚拟屏幕区域缓存。
Definition: E/include/YCLib/Win32GUI.h:235
YSLib::Drawing::GBinaryGroup
屏幕二元组。
Definition: ygdibase.h:54
platform_ex::Windows::ScreenBuffer::ScreenRegionBuffer
ScreenRegionBuffer(const YSLib::Drawing::Size &s)
虚拟屏幕区域缓存。
Definition: include/YCLib/Win32GUI.h:248
platform_ex::Windows::UpdatePremultipliedTo
void UpdatePremultipliedTo(NativeWindowHandle, YSLib::Drawing::AlphaType=0xFF, const YSLib::Drawing::Point &={}) ynothrow
Definition: Win32GUI.cpp:313
platform_ex::Windows::WindowRegionDeviceContext::ps
::PAINTSTRUCT ps
Definition: include/YCLib/Win32GUI.h:365
platform_ex::Windows::WindowMemorySurface::~WindowMemorySurface
~WindowMemorySurface()
Definition: include/YCLib/Win32GUI.h:292
platform_ex::Windows::WindowMemorySurface
窗口内存表面：储存窗口上的二维图形绘制状态。
Definition: include/YCLib/Win32GUI.h:283
platform_ex::NativeWindowHandle
::ANativeWindow * NativeWindowHandle
Definition: Android.h:50
platform_ex::Windows::ScreenBuffer
虚拟屏幕缓存。
Definition: include/YCLib/Win32GUI.h:169
platform_ex::Windows::s
return s
Definition: MinGW32.cpp:49
platform_ex::Windows::ScreenBuffer::hBitmap
::HBITMAP hBitmap
Definition: include/YCLib/Win32GUI.h:177
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
platform::BitmapPtr
PixelType * BitmapPtr
Definition: Video.h:295
YSLib::Drawing::r
bounds & r
Definition: ydraw.h:220
platform_ex::Windows::WindowRegionDeviceContext::WindowRegionDeviceContext
WindowRegionDeviceContext(NativeWindowHandle h_wnd)
Definition: include/YCLib/Win32GUI.h:368
platform_ex::Windows::WindowDeviceContext::WindowDeviceContext
WindowDeviceContext(NativeWindowHandle h_wnd)
Definition: include/YCLib/Win32GUI.h:348
platform_ex::Windows::WindowRegionDeviceContext
窗口区域设备上下文。
Definition: include/YCLib/Win32GUI.h:362
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
platform_ex::Windows::WindowDeviceContextBase::hDC
::HDC hDC
Definition: include/YCLib/Win32GUI.h:328
platform::AlphaType
ystdex::octet AlphaType
Definition: Video.h:186
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: ywidget.cpp:95
DefDelMoveCtor
#define DefDelMoveCtor(_t)
Definition: YBaseMacro.h:143
platform_ex::Windows::ScreenBuffer::size
YSLib::Drawing::Size size
Definition: include/YCLib/Win32GUI.h:173