windows.dc.h.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <chapter xml:id="windows.dc.h">
  2. <title><tt>__vic/windows/dc.h</tt></title>
  3. <p>C++ wrappers for Win32 GDI device context (DC).</p>
  4. <chapter xml:id="windows--DC">
  5. <title><tt>windows::DC</tt></title>
  6. <code-block lang="C++"><![CDATA[
  7. class windows::DC
  8. {
  9. public:
  10. DC() = default;
  11. explicit DC(HDC hdc);
  12. static DC CreateCompatible(HDC hdc);
  13. bool ReleaseNT(HWND hwnd) noexcept;
  14. void Release(HWND hwnd);
  15. bool DeleteNT() noexcept;
  16. void Delete();
  17. int GetHorzRes() const;
  18. int GetVertRes() const;
  19. HWND GetWindow() const;
  20. HGDIOBJ GetCurrentObject(UINT uObjType) const;
  21. HBRUSH GetCurrentBrush() const;
  22. HPEN GetCurrentPen() const;
  23. HFONT GetCurrentFont() const;
  24. HBITMAP GetCurrentBitmap() const;
  25. void Select(HGDIOBJ hObj); // not a region object
  26. void Select(HRGN hReg);
  27. COLORREF SetPixel(int x, int y, COLORREF c);
  28. bool MoveTo(int x, int y, POINT *p = 0);
  29. bool LineTo(int x, int y);
  30. bool PolyBezier(const POINT *lppt, DWORD cPoints);
  31. bool FillRect(const RECT &rect, HBRUSH hbr);
  32. bool BlitTo(HDC dcDest, int x, int y,
  33. int w, int h, DWORD dwRop = SRCCOPY) const;
  34. bool BlitTo(HDC dcDest, const RECT &r, DWORD dwRop = SRCCOPY) const;
  35. void ClearHandle();
  36. HDC Handle() const;
  37. void Handle(HDC hdc);
  38. operator HDC() const;
  39. };
  40. ]]></code-block>
  41. <p>General purpose <tt>HDC</tt> wrapper. Use <xref to="windows--ClientDC"/>
  42. instead of <tt>::ReleaseDC()</tt>. Use <xref to="windows--PaintDC"/> instead of
  43. <tt>::BeginPaint()</tt>/<tt>::EndPaint()</tt>.</p>
  44. <note>For the most functions returning <tt>false</tt> on error no any addition
  45. information can be obtained using <tt>::GetLastError()</tt>.</note>
  46. <section><title>Class members</title>
  47. <synopsis>
  48. <prototype>DC() = default</prototype>
  49. <p>Creates an uninitialized value.</p>
  50. </synopsis>
  51. <synopsis>
  52. <prototype>explicit DC(HDC hdc)</prototype>
  53. <postcondition><tt>Handle() == hdc</tt></postcondition>
  54. </synopsis>
  55. <synopsis>
  56. <prototype>static DC CreateCompatible(HDC hdc)</prototype>
  57. <p>Calls <tt>::CreateCompatibleDC()</tt>.</p>
  58. </synopsis>
  59. <synopsis>
  60. <prototype>bool ReleaseNT(HWND hwnd) noexcept</prototype>
  61. <p>Calls <tt>::ReleaseDC()</tt> and returns <tt>false</tt> on error.</p>
  62. </synopsis>
  63. <synopsis>
  64. <prototype>void Release(HWND hwnd)</prototype>
  65. <p>Calls <tt>::ReleaseDC()</tt> and throws on error.</p>
  66. </synopsis>
  67. <synopsis>
  68. <prototype>bool DeleteNT() noexcept</prototype>
  69. <p>Calls <tt>::DeleteDC()</tt> and returns <tt>false</tt> on error.</p>
  70. </synopsis>
  71. <synopsis>
  72. <prototype>void Delete()</prototype>
  73. <p>Calls <tt>::DeleteDC()</tt> and throws on error.</p>
  74. </synopsis>
  75. <synopsis>
  76. <prototype>int GetHorzRes() const</prototype>
  77. <p>Returns a horizontal resolution of the DC.</p>
  78. </synopsis>
  79. <synopsis>
  80. <prototype>int GetVertRes() const</prototype>
  81. <p>Returns a vertical resolution of the DC.</p>
  82. </synopsis>
  83. <synopsis>
  84. <prototype>HWND GetWindow() const</prototype>
  85. <p>Calls <tt>::WindowFromDC()</tt> and returns its result.</p>
  86. </synopsis>
  87. <synopsis>
  88. <prototype>HGDIOBJ GetCurrentObject(UINT uObjType) const</prototype>
  89. <p>Calls <tt>::GetCurrentObject()</tt> with the specified <tt>uObjType</tt>
  90. and returns its result.</p>
  91. </synopsis>
  92. <synopsis>
  93. <prototype>HBRUSH GetCurrentBrush() const</prototype>
  94. <prototype>HPEN GetCurrentPen() const</prototype>
  95. <prototype>HFONT GetCurrentFont() const</prototype>
  96. <prototype>HBITMAP GetCurrentBitmap() const</prototype>
  97. <p>Calls <tt>::GetCurrentObject()</tt> for the corresponding object type
  98. and returns its result.</p>
  99. </synopsis>
  100. <synopsis>
  101. <prototype>void Select(HGDIOBJ hObj)</prototype>
  102. <p>Calls <tt>::SelectObject()</tt> for object that is not a region and
  103. throws on error.</p>
  104. </synopsis>
  105. <synopsis>
  106. <prototype>void Select(HRGN hReg)</prototype>
  107. <p>Calls <tt>::SelectObject()</tt> for region object and throws on error.</p>
  108. </synopsis>
  109. <synopsis>
  110. <prototype>COLORREF SetPixel(int x, int y, COLORREF c)</prototype>
  111. <p>Calls <tt>::SetPixel()</tt> and returns its result.</p>
  112. </synopsis>
  113. <synopsis>
  114. <prototype>bool MoveTo(int x, int y, POINT *p = 0)</prototype>
  115. <p>Calls <tt>::MoveToEx()</tt> and returns <tt>false</tt> on error.</p>
  116. </synopsis>
  117. <synopsis>
  118. <prototype>bool LineTo(int x, int y)</prototype>
  119. <p>Calls <tt>::LineTo()</tt> and returns <tt>false</tt> on error.</p>
  120. </synopsis>
  121. <synopsis>
  122. <prototype>bool PolyBezier(const POINT *lppt, DWORD cPoints)</prototype>
  123. <p>Calls <tt>::PolyBezier()</tt> and returns <tt>false</tt> on error.</p>
  124. </synopsis>
  125. <synopsis>
  126. <prototype>bool FillRect(const RECT &amp;rect, HBRUSH hbr)</prototype>
  127. <p>Calls <tt>::PolyBezier()</tt> and returns <tt>false</tt> on error.</p>
  128. </synopsis>
  129. <synopsis>
  130. <prototype>bool BlitTo(HDC dcDest, int x, int y, int w, int h, DWORD dwRop = SRCCOPY) const</prototype>
  131. <prototype>bool BlitTo(HDC dcDest, const RECT &amp;r, DWORD dwRop = SRCCOPY) const</prototype>
  132. <p>Calls <tt>::BitBlt()</tt> and returns <tt>false</tt> on error.</p>
  133. <note><tt>::GetLastError()</tt> can be used to get extended error information.</note>
  134. </synopsis>
  135. <synopsis>
  136. <prototype>void ClearHandle()</prototype>
  137. <postcondition><tt>!Handle()</tt></postcondition>
  138. </synopsis>
  139. <synopsis>
  140. <prototype>HDC Handle() const</prototype>
  141. <prototype>operator HDC() const</prototype>
  142. <p>Returns the wrapped HDC value.</p>
  143. </synopsis>
  144. <synopsis>
  145. <prototype>void Handle(HDC hdc)</prototype>
  146. <postcondition><tt>Handle() == hdc</tt></postcondition>
  147. </synopsis>
  148. </section>
  149. </chapter>
  150. <chapter xml:id="windows--ClientDC">
  151. <title><tt>windows::ClientDC</tt></title>
  152. <code-block lang="C++">
  153. class windows::ClientDC : public windows::DC, private non_copyable
  154. {
  155. public:
  156. explicit ClientDC(HWND hwnd);
  157. ClientDC(HDC hdc, HWND hwnd);
  158. ~ClientDC();
  159. };
  160. </code-block>
  161. <p>RAII-wrapper. Calls <tt>::ReleaseDC()</tt> in destructor.</p>
  162. <section><title>Class members</title>
  163. <synopsis>
  164. <prototype>explicit ClientDC(HWND hwnd)</prototype>
  165. <p>Calls <tt>::GetDC(hwnd)</tt>. Throws on error.</p>
  166. </synopsis>
  167. <synopsis>
  168. <prototype>ClientDC(HDC hdc, HWND hwnd)</prototype>
  169. <p>Adopts <tt>hdc</tt> for the subsequent release in the destructor.</p>
  170. <precondition><tt>hdc</tt> is a valid handler returned by
  171. <tt>::GetDC(hwnd)</tt> call.</precondition>
  172. <postcondition><tt>Handle() == hdc</tt></postcondition>
  173. </synopsis>
  174. <synopsis>
  175. <prototype>~ClientDC()</prototype>
  176. <p>Calls <tt>::ReleaseDC()</tt>.</p>
  177. </synopsis>
  178. </section>
  179. </chapter>
  180. <chapter xml:id="windows--PaintDC">
  181. <title><tt>windows::PaintDC</tt></title>
  182. <code-block lang="C++">
  183. class windows::PaintDC :
  184. public windows::DC, public PAINTSTRUCT, private non_copyable
  185. {
  186. public:
  187. explicit PaintDC(HWND hwnd);
  188. ~PaintDC();
  189. };
  190. </code-block>
  191. <p>Wrapper for <tt>PAINTSTRUCT</tt> and
  192. <tt>::BeginPaint()</tt>/<tt>::EndPaint()</tt> calls.</p>
  193. <section><title>Class members</title>
  194. <synopsis>
  195. <prototype>explicit PaintDC(HWND hwnd)</prototype>
  196. <p>Calls <tt>::BeginPaint(hwnd, this)</tt>. Throws on error.</p>
  197. </synopsis>
  198. <synopsis>
  199. <prototype>~PaintDC()</prototype>
  200. <p>Calls <tt>::EndPaint()</tt>.</p>
  201. </synopsis>
  202. </section>
  203. </chapter>
  204. </chapter>