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/window.h"
17 #include "wx/dcscreen.h"
22 #include <wx/motif/private.h>
24 #if !USE_SHARED_LIBRARY
25 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
28 WXWindow
wxScreenDC::sm_overlayWindow
= 0;
29 int wxScreenDC::sm_overlayWindowX
= 0;
30 int wxScreenDC::sm_overlayWindowY
= 0;
32 // Create a DC representing the whole screen
33 wxScreenDC::wxScreenDC()
35 m_display
= wxGetDisplay();
36 Display
* display
= (Display
*) m_display
;
40 m_pixmap
= sm_overlayWindow
;
41 m_deviceOriginX
= - sm_overlayWindowX
;
42 m_deviceOriginY
= - sm_overlayWindowY
;
45 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
48 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
49 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
50 gcvalues
.graphics_exposures
= False
;
51 gcvalues
.subwindow_mode
= IncludeInferiors
;
52 gcvalues
.line_width
= 1;
53 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
54 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
57 m_backgroundPixel
= (int) gcvalues
.background
;
61 wxScreenDC::~wxScreenDC()
65 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
68 int x
, y
, width
, height
;
69 window
->GetPosition(& x
, & y
);
70 if (window
->GetParent())
71 window
->GetParent()->ClientToScreen(& x
, & y
);
72 window
->GetSize(& width
, & height
);
73 rect
.x
= x
; rect
.y
= y
;
74 rect
.width
= width
; rect
.height
= height
;
76 return StartDrawingOnTop(& rect
);
79 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
)
84 Display
*dpy
= (Display
*) wxGetDisplay();
85 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
90 wxDisplaySize(&width
, &height
);
94 x
= rect
->x
; y
= rect
->y
;
95 width
= rect
->width
; height
= rect
->height
;
97 sm_overlayWindowX
= x
;
98 sm_overlayWindowY
= y
;
100 XSetWindowAttributes attributes
;
101 attributes
.override_redirect
= True
;
102 unsigned long valueMask
= CWOverrideRedirect
;
104 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
105 wxDisplayDepth(), InputOutput
,
106 DefaultVisual(dpy
, 0), valueMask
,
109 if (sm_overlayWindow
)
111 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
118 bool wxScreenDC::EndDrawingOnTop()
120 if (sm_overlayWindow
)
122 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
123 sm_overlayWindow
= 0;