You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeviceContext.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. // DeviceContext base class, wrapping Windows HDC, plus some
  19. // helper classes tailored to particular types of DC, such as
  20. // window and device DCs.
  21. #ifndef __RFB_WIN32_DEVICECONTEXT_H__
  22. #define __RFB_WIN32_DEVICECONTEXT_H__
  23. #include <windows.h>
  24. #include <rfb/PixelFormat.h>
  25. #include <rfb/Rect.h>
  26. #include <rfb_win32/TCharArray.h>
  27. namespace rfb {
  28. namespace win32 {
  29. // Base class, providing methods to get the bounding (clip) box,
  30. // and the pixel format, and access to the HDC itself.
  31. class DeviceContext {
  32. public:
  33. DeviceContext() : dc(0) {}
  34. virtual ~DeviceContext() {}
  35. operator HDC() const {return dc;}
  36. PixelFormat getPF() const;
  37. static PixelFormat getPF(HDC dc);
  38. Rect getClipBox() const;
  39. static Rect getClipBox(HDC dc);
  40. protected:
  41. HDC dc;
  42. };
  43. // -=- DeviceContext that opens a specific display device
  44. class DeviceDC : public DeviceContext {
  45. public:
  46. DeviceDC(const TCHAR* deviceName);
  47. ~DeviceDC();
  48. };
  49. // Get a DC for a particular window's client area.
  50. class WindowDC : public DeviceContext {
  51. public:
  52. WindowDC(HWND wnd);
  53. virtual ~WindowDC();
  54. protected:
  55. HWND hwnd;
  56. };
  57. // Create a new DC, compatible with an existing one.
  58. class CompatibleDC : public DeviceContext {
  59. public:
  60. CompatibleDC(HDC existing);
  61. virtual ~CompatibleDC();
  62. };
  63. // Create a new DC, compatible with an existing one, and
  64. // select the specified bitmap into it.
  65. class BitmapDC : public CompatibleDC {
  66. public:
  67. BitmapDC(HDC hdc, HBITMAP hbitmap);
  68. ~BitmapDC();
  69. protected:
  70. HBITMAP oldBitmap;
  71. };
  72. };
  73. };
  74. #endif