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 
46 {
47 public:
52  inline
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 
92 {
93 public:
95  using Tester = std::function<bool(const KeyInput&, KeyIndex)>;
96 
97 private:
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 
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 
KeyIndex width
宽度:设备支持的按键编码上界(不含)。
Definition: ydevice.h:99
#define DefDeDtor(_t)
定义默认析构函数。
Definition: YBaseMacro.h:146
#define ImplRet(...)
Definition: YBaseMacro.h:97
std::size_t KeyIndex
按键索引类型:标识特定的按键在按键集合中的位置。
Definition: Keys.h:42
#define YF_API
Definition: Platform.h:64
SDst Height
宽和高。
Definition: ygdibase.h:258
GraphicDevice(SDst w, SDst h, Drawing::BitmapPtr p={}) ynothrow
构造:指定宽度、高度和缓冲区指针。
Definition: ydevice.h:53
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
KeyInputDevice(KeyIndex w=KeyBitsetWidth)
Definition: ydevice.h:103
二维图形接口上下文。
Definition: ygdibase.h:721
Screen(SDst w, SDst h, Drawing::BitmapPtr p={}) ynothrow
构造:指定宽度、高度和缓冲区指针。
Definition: ydevice.h:133
Screen(const Drawing::Size &s, Drawing::BitmapPtr p={}) ynothrow
构造:指定大小和缓冲区指针。
Definition: ydevice.h:140
按键输入设备。
Definition: ydevice.h:91
PixelType * BitmapPtr
Definition: Video.h:295
if(YB_UNLIKELY(r >=sGraphics.Height)) throw std return pBuffer r *sGraphics Width
Definition: ygdibase.cpp:155
屏幕区域大小。
Definition: ygdibase.h:249
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
#define YAssert(_expr, _msg)
Definition: cassert.h:73
std::function< bool(const KeyInput &, KeyIndex)> Tester
输入测试器:判断是否在指定索引上激活输入状态。
Definition: ydevice.h:95
图形设备。
Definition: ydevice.h:45