YSTest: ydevice.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
ydevice.h
浏览该文件的文档.
1 /*
2 © 2009-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
28 #ifndef YSL_INC_Core_YDevice_h_
29 #define YSL_INC_Core_YDevice_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YObject
33 #include YFM_YSLib_Core_YGDIBase
34
35 namespace YSLib
36 {
37
38 namespace Devices
39 {
40
45 class YF_API GraphicDevice : private noncopyable, protected Drawing::Graphics
46 {
47 public:
52 inline
53 GraphicDevice(SDst w, SDst h, Drawing::BitmapPtr p = {}) ynothrow
54 : Graphics(p, Drawing::Size(w, h))
55 {}
60 virtual DefDeDtor(GraphicDevice)
61
62
63
64 using Graphics::operator!;
65
66 using Graphics::operator bool;
68
73 virtual DefGetter(const, unique_ptr<Drawing::IImage>, BackBuffer,
74 unique_ptr<Drawing::IImage>())
76
77 using Graphics::GetBufferPtr;
78 using Graphics::GetHeight;
79 using Graphics::GetWidth;
80 using Graphics::GetSize;
81 using Graphics::GetSizeOfBuffer;
82 DefGetter(const ynothrow, const Graphics&, Context, *this)
84 };
85
86
91 class YF_API KeyInputDevice
92 {
93 public:
95 using Tester = std::function<bool(const KeyInput&, KeyIndex)>;
96
97 private:
99 KeyIndex width;
100
101 public:
102 explicit
103 KeyInputDevice(KeyIndex w = KeyBitsetWidth)
104 : width(w)
105 {
106 YAssert(w != 0, "Invalid key input device found.");
107 }
108 virtual DefDeDtor(KeyInputDevice)
109
110 DefGetter(const ynothrow, KeyIndex, Width, width)
111
113 virtual PDefH(KeyIndex, Map, KeyIndex code)
114 ImplRet(code < width ? code : 0)
115
117 static PDefH(bool, DefaultTest, const KeyInput& keys, KeyIndex code)
118 ImplRet(code < KeyBitsetWidth ? keys[code] : false)
119 };
120
121
126 class YF_API Screen : public GraphicDevice
127 {
128 public:
133 Screen(SDst w, SDst h, Drawing::BitmapPtr p = {}) ynothrow
134 : GraphicDevice(w, h, p)
135 {}
140 Screen(const Drawing::Size& s, Drawing::BitmapPtr p = {}) ynothrow
141 : Screen(s.Width, s.Height, p)
142 {}
143
148 virtual Drawing::BitmapPtr
149 GetCheckedBufferPtr() const ynothrow;
150
156 virtual void
157 Update(Drawing::BitmapPtr) ynothrow;
158 };
159
160 } // namespace Devices;
161
162 } // namespace YSLib;
163
164 #endif
165
YSLib::Devices::KeyInputDevice::width
KeyIndex width
宽度：设备支持的按键编码上界（不含）。
Definition: ydevice.h:99
YSLib::Devices::Screen
屏幕。
Definition: ydevice.h:126
DefDeDtor
#define DefDeDtor(_t)
定义默认析构函数。
Definition: YBaseMacro.h:146
ImplRet
#define ImplRet(...)
Definition: YBaseMacro.h:97
platform::KeyIndex
std::size_t KeyIndex
按键索引类型：标识特定的按键在按键集合中的位置。
Definition: Keys.h:42
YModules.h
YF_API
#define YF_API
Definition: Platform.h:64
YSLib::Drawing::Size::Height
SDst Height
宽和高。
Definition: ygdibase.h:258
YSLib::Devices::GraphicDevice::GraphicDevice
GraphicDevice(SDst w, SDst h, Drawing::BitmapPtr p={}) ynothrow
构造：指定宽度、高度和缓冲区指针。
Definition: ydevice.h:53
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::Devices::KeyInputDevice::KeyInputDevice
KeyInputDevice(KeyIndex w=KeyBitsetWidth)
Definition: ydevice.h:103
YSLib::Drawing::Graphics
二维图形接口上下文。
Definition: ygdibase.h:721
platform_ex::Windows::s
return s
Definition: MinGW32.cpp:49
YSLib::Devices::Screen::Screen
Screen(SDst w, SDst h, Drawing::BitmapPtr p={}) ynothrow
构造：指定宽度、高度和缓冲区指针。
Definition: ydevice.h:133
YSLib::Devices::Screen::Screen
Screen(const Drawing::Size &s, Drawing::BitmapPtr p={}) ynothrow
构造：指定大小和缓冲区指针。
Definition: ydevice.h:140
YSLib::Devices::KeyInputDevice
按键输入设备。
Definition: ydevice.h:91
platform::BitmapPtr
PixelType * BitmapPtr
Definition: Video.h:295
YSLib::Drawing::Width
if(YB_UNLIKELY(r >=sGraphics.Height)) throw std return pBuffer r *sGraphics Width
Definition: ygdibase.cpp:155
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
YSLib::Drawing::Size::Width
SDst Width
Definition: ygdibase.h:258
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:73
YSLib::Devices::KeyInputDevice::Tester
std::function< bool(const KeyInput &, KeyIndex)> Tester
输入测试器：判断是否在指定索引上激活输入状态。
Definition: ydevice.h:95
YSLib::Devices::GraphicDevice
图形设备。
Definition: ydevice.h:45