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"
21 #pragma message disable nosimpint
25 #pragma message enable nosimpint
28 #include "wx/motif/private.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
32 WXWindow
wxScreenDC::sm_overlayWindow
= 0;
33 int wxScreenDC::sm_overlayWindowX
= 0;
34 int wxScreenDC::sm_overlayWindowY
= 0;
36 // Create a DC representing the whole screen
37 wxScreenDC::wxScreenDC()
39 m_display
= wxGetDisplay();
40 Display
* display
= (Display
*) m_display
;
44 m_pixmap
= sm_overlayWindow
;
45 m_deviceOriginX
= - sm_overlayWindowX
;
46 m_deviceOriginY
= - sm_overlayWindowY
;
49 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
52 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
53 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
54 gcvalues
.graphics_exposures
= False
;
55 gcvalues
.subwindow_mode
= IncludeInferiors
;
56 gcvalues
.line_width
= 1;
57 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
58 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
61 m_backgroundPixel
= (int) gcvalues
.background
;
65 wxScreenDC::~wxScreenDC()
69 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
72 int x
, y
, width
, height
;
73 window
->GetPosition(& x
, & y
);
74 if (window
->GetParent())
75 window
->GetParent()->ClientToScreen(& x
, & y
);
76 window
->GetSize(& width
, & height
);
77 rect
.x
= x
; rect
.y
= y
;
78 rect
.width
= width
; rect
.height
= height
;
80 return StartDrawingOnTop(& rect
);
83 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
)
88 Display
*dpy
= (Display
*) wxGetDisplay();
89 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
94 wxDisplaySize(&width
, &height
);
98 x
= rect
->x
; y
= rect
->y
;
99 width
= rect
->width
; height
= rect
->height
;
101 sm_overlayWindowX
= x
;
102 sm_overlayWindowY
= y
;
104 XSetWindowAttributes attributes
;
105 attributes
.override_redirect
= True
;
106 unsigned long valueMask
= CWOverrideRedirect
;
108 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
109 wxDisplayDepth(), InputOutput
,
110 DefaultVisual(dpy
, 0), valueMask
,
113 if (sm_overlayWindow
)
115 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
122 bool wxScreenDC::EndDrawingOnTop()
124 if (sm_overlayWindow
)
126 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
127 sm_overlayWindow
= 0;