1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxScreenDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #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()
70 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
73 int x
, y
, width
, height
;
74 window
->GetPosition(& x
, & y
);
75 if (window
->GetParent() && !window
->IsKindOf(CLASSINFO(wxFrame
)))
76 window
->GetParent()->ClientToScreen(& x
, & y
);
77 window
->GetSize(& width
, & height
);
78 rect
.x
= x
; rect
.y
= y
;
79 rect
.width
= width
; rect
.height
= height
;
81 return StartDrawingOnTop(& rect
);
84 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
)
89 Display
*dpy
= (Display
*) wxGetDisplay();
90 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
95 wxDisplaySize(&width
, &height
);
99 x
= rect
->x
; y
= rect
->y
;
100 width
= rect
->width
; height
= rect
->height
;
102 sm_overlayWindowX
= x
;
103 sm_overlayWindowY
= y
;
105 XSetWindowAttributes attributes
;
106 attributes
.override_redirect
= True
;
107 unsigned long valueMask
= CWOverrideRedirect
;
109 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
110 wxDisplayDepth(), InputOutput
,
111 DefaultVisual(dpy
, 0), valueMask
,
114 if (sm_overlayWindow
)
116 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
123 bool wxScreenDC::EndDrawingOnTop()
125 if (sm_overlayWindow
)
127 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
128 sm_overlayWindow
= 0;