blob: 5e97b22296bc7adf3c8f6eb945a1e1f4b877da97 [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2003 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
19// -=- DeviceFrameBuffer.h
20//
21// The DeviceFrameBuffer class encapsulates the pixel data of a supplied
22// Device Context Handle (HDC)
23
24// *** THIS INTERFACE NEEDS TIDYING TO SEPARATE COORDINATE SYSTEMS BETTER ***
25
26#ifndef __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
27#define __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
28
29#define WIN32_LEAN_AND_MEAN
30#include <windows.h>
31
32#include <rfb_win32/DIBSectionBuffer.h>
33#include <rfb/Cursor.h>
34#include <rfb/Region.h>
35#include <rfb/Exception.h>
36
37namespace rfb {
38
39 class VNCServer;
40
41 namespace win32 {
42
43 // -=- DeviceFrameBuffer interface
44
45 // DeviceFrameBuffer is passed an HDC referring to a window or to
46 // the entire display. It may also be passed a rectangle specifying
47 // the Device-relative coordinates of the actual rectangle to treat
48 // as the desktop.
49
50 // Coordinate systems start getting really annoying here. There are
51 // three different "origins" to which coordinates might be relative:
52 //
53 // Desktop - VNC coordinates, top-left always (0,0)
54 // Device - DC coordinates. Top-left *usually (0,0) but could be other.
55 // Window - coordinates relative to the specified sub-rectangle within
56 // the supplied DC.
57 // Screen - Coordinates relative to the entire Windows virtual screen.
58 // The virtual screen includes all monitors that are part of
59 // the Windows desktop.
60
61 // The data member is made to point to an internal mirror of the
62 // current display data. Individual rectangles or regions of the
63 // buffer can be brought up to date by calling the grab functions.
64
65 class DeviceFrameBuffer : public DIBSectionBuffer {
66 public:
67 DeviceFrameBuffer(HDC deviceContext, const Rect& area_=Rect());
68 virtual ~DeviceFrameBuffer();
69
70 // - FrameBuffer overrides
71
72 virtual void grabRect(const Rect &rect);
73 virtual void grabRegion(const Region &region);
74
75 // - DIBSectionBuffer overrides
76
77 virtual void setPF(const PixelFormat& pf);
78 virtual void setSize(int w, int h);
79
80 // - DeviceFrameBuffer specific methods
81
82 void setCursor(HCURSOR c, VNCServer* server);
83 void updateColourMap();
84
85 // Set whether grabRect should ignore errors or throw exceptions
86 // Only set this if you are sure you'll capture the errors some other way!
87 void setIgnoreGrabErrors(bool ie) {ignoreGrabErrors=ie;}
88
89 protected:
90 // Translate supplied Desktop coordinates into Device-relative coordinates
91 // This translation may have been affected at start-time by the supplied sub-rect.
92 Point desktopToDevice(const Point p) const {return p.translate(deviceCoords.tl);}
93
94 HDC device;
95 DIBSectionBuffer cursorBm;
96 Cursor cursor;
97 Rect deviceCoords;
98 bool ignoreGrabErrors;
99 };
100
101 // -=- createDisplayDeviceFrameBuffer
102 // createDisplayDeviceFrameBuffer must be passed the name of a display device,
103 // and will return a new FrameBuffer object attached to that display
104 // device.
105 // If the device name is not specified then the default display is
106 // returned.
107
108 DeviceFrameBuffer *createDisplayDeviceFrameBuffer(const char *device=0);
109
110 // -=- createDisplayFrameBuffers
111 // Creates a set of framebuffers, one for each available display
112 // device.
113
114 typedef std::vector<DeviceFrameBuffer *> DeviceFrameBuffers;
115 void createDisplayDeviceFrameBuffers(DeviceFrameBuffers *fbs);
116
117 };
118
119};
120
121#endif // __RFB_WIN32_DEVICE_FRAME_BUFFER_H__