YSTest: Win32GUI.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
E/include/YCLib/Win32GUI.h
浏览该文件的文档.
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
29 #ifndef YCL_MinGW32_INC_Win32GUI_h_
30 #define YCL_MinGW32_INC_Win32GUI_h_ 1
31
32 #include "MinGW32.h"
33 #include <YSLib/Core/ygdibase.h>
34 #include <mutex> // for std::mutex;
35 #include <atomic>
36
37 namespace platform_ex
38 {
39
41 using NativeWindowHandle = ::HWND;
42
43 inline namespace Windows
44 {
45
52 class YF_API WindowReference
53 {
54 protected:
55 NativeWindowHandle hWindow;
56
57 public:
58 WindowReference(NativeWindowHandle h = {})
59 : hWindow(h)
60 {}
61 DefDeMoveCtor(WindowReference)
62
63
64
65 YSLib::Drawing::Rect
66 GetClientBounds() const;
67 YSLib::Drawing::Point
68 GetClientLocation() const;
69 YSLib::Drawing::Size
70 GetClientSize() const;
72 YSLib::Drawing::Point
73 GetLocation() const;
74 DefGetter(const ynothrow, NativeWindowHandle, NativeHandle, hWindow)
81 YSLib::Drawing::AlphaType
82 GetOpacity() const;
83 YSLib::Drawing::Size
84 GetSize() const;
85
87 void
88 SetClientBounds(const YSLib::Drawing::Rect&);
94 void
95 SetOpacity(YSLib::Drawing::AlphaType);
100 void
101 SetText(const wchar_t*);
102
104 void
105 Close();
106
111 void
112 Invalidate();
113
118 void
119 Move(const YSLib::Drawing::Point&);
120
125 void
126 Resize(const YSLib::Drawing::Size&);
127
132 void
133 ResizeClient(const YSLib::Drawing::Size&);
134
139 bool
140 Show() ynothrow;
141 };
142
143
148 YF_API NativeWindowHandle
149 CreateNativeWindow(const wchar_t*, const YSLib::Drawing::Size&,
150 const wchar_t* = L"", ::DWORD = WS_POPUP, ::DWORD = WS_EX_LTRREADING);
151
152
154
155
160 class YF_API ScreenBuffer
161 {
162 private:
164 YSLib::Drawing::Size size;
165
166 protected:
167 YSLib::Drawing::BitmapPtr pBuffer;
168 ::HBITMAP hBitmap;
169
170 public:
171 ScreenBuffer(const YSLib::Drawing::Size&);
173 ScreenBuffer(ScreenBuffer&&) ynothrow;
174 ~ScreenBuffer();
175
177 ScreenBuffer&
178 operator=(ScreenBuffer&&);
179
181
182 DefGetter(const ynothrow, YSLib::Drawing::BitmapPtr, BufferPtr, pBuffer)
183 DefGetter(const ynothrow, ::HBITMAP, NativeHandle, hBitmap)
184 DefGetter(const ynothrow, const YSLib::Drawing::Size&, Size, size)
185
192 void
193 Premultiply(YSLib::Drawing::BitmapPtr) ynothrow;
194
200 void
201 Resize(const YSLib::Drawing::Size&);
202
208 void
209 UpdateFrom(YSLib::Drawing::BitmapPtr) ynothrow;
211
212 /*
213 \brief 交换。
214 \since build 430
215 */
216 void
217 swap(ScreenBuffer&) ynothrow;
218 };
219
221 inline DefSwap(ynothrow, ScreenBuffer)
222
223
229 class YF_API ScreenRegionBuffer : private ScreenBuffer
230 {
231 private:
232 std::mutex mtx;
233
234 public:
235 ScreenRegionBuffer(const YSLib::Drawing::Size& s)
236 : ScreenBuffer(s), mtx()
237 {}
238
239 using ScreenBuffer::GetBufferPtr;
240 using ScreenBuffer::GetNativeHandle;
241 using ScreenBuffer::GetSize;
242 DefGetter(ynothrow, ScreenBuffer&, ScreenBufferRef, *this)
243
244
245 using ScreenBuffer::Premultiply;
247 using ScreenBuffer::Resize;
248
249 void
250 UpdateFrom(YSLib::Drawing::BitmapPtr) ynothrow;
251
253 void
254 UpdatePremultipliedTo(NativeWindowHandle, YSLib::Drawing::AlphaType = 0xFF,
255 const YSLib::Drawing::Point& = {}) ynothrow;
256
257 void
258 UpdateTo(NativeWindowHandle, const YSLib::Drawing::Point& = {}) ynothrow;
259 };
261
262
264
265
269 class YF_API WindowMemorySurface
270 {
271 private:
272 ::HDC h_owner_dc, h_mem_dc;
273
274 public:
275 WindowMemorySurface(::HDC h_dc)
276 : h_owner_dc(h_dc), h_mem_dc(::CreateCompatibleDC(h_dc))
277 {}
278 ~WindowMemorySurface()
279 {
280 ::DeleteDC(h_mem_dc);
281 }
282
283 DefGetter(const ynothrow, ::HDC, OwnerHandle, h_owner_dc)
284 DefGetter(const ynothrow, ::HDC, NativeHandle, h_mem_dc)
285
287 void
288 Update(ScreenBuffer&, const YSLib::Drawing::Point& = {}) ynothrow;
290 void
291 Update(ScreenRegionBuffer& rbuf, const YSLib::Drawing::Point& pt = {})
292 ynothrow
293 {
294 Update(rbuf.GetScreenBufferRef(), pt);
295 }
296
298 void
299 UpdatePremultiplied(ScreenBuffer&, NativeWindowHandle,
300 YSLib::Drawing::AlphaType = 0xFF, const YSLib::Drawing::Point& = {})
301 ynothrow;
303 void
304 UpdatePremultiplied(ScreenRegionBuffer& rbuf, NativeWindowHandle h_wnd,
305 YSLib::Drawing::AlphaType a = 0xFF,
306 const YSLib::Drawing::Point& pt = {}) ynothrow
307 {
308 UpdatePremultiplied(rbuf.GetScreenBufferRef(), h_wnd, a, pt);
309 }
310 };
311
312
313 class YF_API WindowDeviceContextBase
314 {
315 protected:
316 NativeWindowHandle hWindow;
317 ::HDC hDC;
318
319 WindowDeviceContextBase(NativeWindowHandle h_wnd, ::HDC h_dc)
320 : hWindow(h_wnd), hDC(h_dc)
321 {}
322 DefDeDtor(WindowDeviceContextBase)
323
324 public:
325 DefGetter(const ynothrow, ::HDC, DeviceContextHandle, hDC)
326 DefGetter(const ynothrow, NativeWindowHandle, WindowHandle, hWindow)
327 };
328
329
334 class YF_API WindowDeviceContext : public WindowDeviceContextBase
335 {
336 protected:
337 WindowDeviceContext(NativeWindowHandle h_wnd)
338 : WindowDeviceContextBase(h_wnd, ::GetDC(h_wnd))
339 {}
340 ~WindowDeviceContext()
341 {
342 ::ReleaseDC(hWindow, hDC);
343 }
344 };
345
346
351 class YF_API WindowRegionDeviceContext : public WindowDeviceContextBase
352 {
353 private:
354 ::PAINTSTRUCT ps;
355
356 protected:
357 WindowRegionDeviceContext(NativeWindowHandle h_wnd)
358 : WindowDeviceContextBase(h_wnd, ::BeginPaint(h_wnd, &ps))
359 {}
360 ~WindowRegionDeviceContext()
361 {
362 ::EndPaint(hWindow, &ps);
363 }
364 };
366
367
373 template<typename _type = WindowDeviceContext>
374 class GSurface : public _type, public WindowMemorySurface
375 {
376 public:
378 GSurface(NativeWindowHandle h_wnd)
379 : _type(h_wnd), WindowMemorySurface(_type::GetDeviceContextHandle())
380 {}
381 };
382
383
388 class YF_API WindowClass
389 {
390 private:
391 ::HINSTANCE h_instance;
392
393 public:
394 WindowClass(const wchar_t*, ::WNDPROC, ::UINT = 0,
395 ::HBRUSH = ::HBRUSH(COLOR_MENU + 1));
396 ~WindowClass();
397 };
398
399
401 yconstexpr wchar_t WindowClassName[]{L"YFramework Window"};
402
403
408 class YF_API HostWindow : private WindowReference, private YSLib::noncopyable
409 {
410 public:
416 std::atomic<bool> BoundsLimited{false};
417
419 HostWindow(NativeWindowHandle);
420 DefDelMoveCtor(HostWindow)
421 virtual
422 ~HostWindow();
423
425
426 using WindowReference::GetClientBounds;
427 using WindowReference::GetClientLocation;
428 using WindowReference::GetClientSize;
430
432 using WindowReference::GetLocation;
433 using WindowReference::GetNativeHandle;
435 using WindowReference::GetOpacity;
436 using WindowReference::GetSize;
437
439 using WindowReference::SetClientBounds;
441 using WindowReference::SetOpacity;
443 using WindowReference::SetText;
444
445 using WindowReference::Close;
446
448 using WindowReference::Invalidate;
449
450 using WindowReference::Move;
452
453 virtual void
454 OnDestroy();
455
456 virtual void
457 OnLostFocus();
458
459 virtual void
460 OnPaint();
461
463
464 using WindowReference::Resize;
465
466 using WindowReference::ResizeClient;
467
468 using WindowReference::Show;
470 };
471
472 } // namespace Windows;
473
474 } // namespace platform_ex;
475
476 #endif
477
platform_ex::Windows::WindowDeviceContextBase
Definition: include/YCLib/Win32GUI.h:324
MinGW32.h
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: E/include/YCLib/Win32GUI.h:58
platform_ex::Windows::WindowMemorySurface::WindowMemorySurface
WindowMemorySurface(::HDC h_dc)
Definition: E/include/YCLib/Win32GUI.h:275
platform_ex::Windows::WindowRegionDeviceContext::~WindowRegionDeviceContext
~WindowRegionDeviceContext()
Definition: E/include/YCLib/Win32GUI.h:360
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对于部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: ywidget.cpp:111
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
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: ywidget.cpp:206
platform_ex::Windows::hBitmap
hBitmap(sbuf.hBitmap)
Definition: Win32GUI.cpp:248
platform_ex::Windows::WindowMemorySurface::Update
void Update(ScreenRegionBuffer &rbuf, const YSLib::Drawing::Point &pt={}) ynothrow
Definition: E/include/YCLib/Win32GUI.h:291
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: E/include/YCLib/Win32GUI.h:340
platform_ex::Windows::WindowMemorySurface::UpdatePremultiplied
void UpdatePremultiplied(ScreenRegionBuffer &rbuf, NativeWindowHandle h_wnd, YSLib::Drawing::AlphaType a=0xFF, const YSLib::Drawing::Point &pt={}) ynothrow
Definition: E/include/YCLib/Win32GUI.h:304
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: E/include/YCLib/Win32GUI.h:378
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: ygdibase.h:235
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:141
platform_ex::Windows::WindowDeviceContextBase::WindowDeviceContextBase
WindowDeviceContextBase(NativeWindowHandle h_wnd,::HDC h_dc)
Definition: E/include/YCLib/Win32GUI.h:319
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::ScreenRegionBuffer
ScreenRegionBuffer(const YSLib::Drawing::Size &s)
虚拟屏幕区域缓存。
Definition: E/include/YCLib/Win32GUI.h:235
YSLib::Drawing::GBinaryGroup< SPos >
platform_ex::Windows::UpdatePremultipliedTo
void UpdatePremultipliedTo(NativeWindowHandle, YSLib::Drawing::AlphaType=0xFF, const YSLib::Drawing::Point &={}) ynothrow
Definition: Win32GUI.cpp:313
platform_ex::Windows::WindowMemorySurface::~WindowMemorySurface
~WindowMemorySurface()
Definition: E/include/YCLib/Win32GUI.h:278
platform_ex::Windows::WindowMemorySurface
窗口内存表面：储存窗口上的二维图形绘制状态。
Definition: include/YCLib/Win32GUI.h:283
platform_ex::NativeWindowHandle
::ANativeWindow * NativeWindowHandle
Definition: Android.h:50
platform_ex::Windows::s
return s
Definition: MinGW32.cpp:49
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
platform::BitmapPtr
PixelType * BitmapPtr
Definition: Video.h:295
platform_ex::Windows::WindowRegionDeviceContext::WindowRegionDeviceContext
WindowRegionDeviceContext(NativeWindowHandle h_wnd)
Definition: E/include/YCLib/Win32GUI.h:357
platform_ex::Windows::WindowDeviceContext::WindowDeviceContext
WindowDeviceContext(NativeWindowHandle h_wnd)
Definition: E/include/YCLib/Win32GUI.h:337
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
ygdibase.h
平台无关的基础图形学对象。
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