1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxScreenDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcscreen.h"
16 #include "wx/dcscreen.h"
21 #include <wx/motif/private.h>
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
27 WXWindow
wxScreenDC::sm_overlayWindow
= 0;
28 int wxScreenDC::sm_overlayWindowX
= 0;
29 int wxScreenDC::sm_overlayWindowY
= 0;
31 // Create a DC representing the whole screen
32 wxScreenDC::wxScreenDC()
34 m_display
= wxGetDisplay();
35 Display
* display
= (Display
*) m_display
;
39 m_pixmap
= sm_overlayWindow
;
40 m_deviceOriginX
= - sm_overlayWindowX
;
41 m_deviceOriginY
= - sm_overlayWindowY
;
44 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
47 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
48 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
49 gcvalues
.graphics_exposures
= False
;
50 gcvalues
.line_width
= 1;
51 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
52 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
55 m_backgroundPixel
= (int) gcvalues
.background
;
59 wxScreenDC::~wxScreenDC()
63 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
66 int x
, y
, width
, height
;
67 window
->GetPosition(& x
, & y
);
68 window
->ClientToScreen(& x
, & y
);
69 window
->GetSize(& width
, & height
);
70 rect
.x
= x
; rect
.y
= y
;
71 rect
.width
= width
; rect
.height
= height
;
73 return StartDrawingOnTop(& rect
);
76 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
= NULL
)
81 Display
*dpy
= (Display
*) wxGetDisplay();
82 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
87 wxDisplaySize(&width
, &height
);
91 x
= rect
->x
; y
= rect
->y
;
92 width
= rect
->width
; height
= rect
->height
;
94 sm_overlayWindowX
= x
;
95 sm_overlayWindowY
= y
;
97 XSetWindowAttributes attributes
;
98 attributes
.override_redirect
= True
;
99 unsigned long valueMask
= CWOverrideRedirect
;
101 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
102 wxDisplayDepth(), InputOutput
,
103 DefaultVisual(dpy
, 0), valueMask
,
106 if (sm_overlayWindow
)
108 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
115 bool wxScreenDC::EndDrawingOnTop()
117 if (sm_overlayWindow
)
119 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
120 sm_overlayWindow
= 0;