1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxScreenDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dcscreen.h"
16 #include "wx/window.h"
18 #include "wx/dcscreen.h"
22 #pragma message disable nosimpint
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
33 WXWindow
wxScreenDC::sm_overlayWindow
= 0;
34 int wxScreenDC::sm_overlayWindowX
= 0;
35 int wxScreenDC::sm_overlayWindowY
= 0;
37 // Create a DC representing the whole screen
38 wxScreenDC::wxScreenDC()
40 m_display
= wxGetDisplay();
41 Display
* display
= (Display
*) m_display
;
45 m_pixmap
= sm_overlayWindow
;
46 m_deviceOriginX
= - sm_overlayWindowX
;
47 m_deviceOriginY
= - sm_overlayWindowY
;
50 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
53 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
54 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
55 gcvalues
.graphics_exposures
= False
;
56 gcvalues
.subwindow_mode
= IncludeInferiors
;
57 gcvalues
.line_width
= 1;
58 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
59 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
62 m_backgroundPixel
= (int) gcvalues
.background
;
66 wxScreenDC::~wxScreenDC()
71 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
74 int x
, y
, width
, height
;
75 window
->GetPosition(& x
, & y
);
76 if (window
->GetParent() && !window
->IsKindOf(CLASSINFO(wxFrame
)))
77 window
->GetParent()->ClientToScreen(& x
, & y
);
78 window
->GetSize(& width
, & height
);
79 rect
.x
= x
; rect
.y
= y
;
80 rect
.width
= width
; rect
.height
= height
;
82 return StartDrawingOnTop(& rect
);
85 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
)
90 Display
*dpy
= (Display
*) wxGetDisplay();
91 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
96 wxDisplaySize(&width
, &height
);
100 x
= rect
->x
; y
= rect
->y
;
101 width
= rect
->width
; height
= rect
->height
;
103 sm_overlayWindowX
= x
;
104 sm_overlayWindowY
= y
;
106 XSetWindowAttributes attributes
;
107 attributes
.override_redirect
= True
;
108 unsigned long valueMask
= CWOverrideRedirect
;
110 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
111 wxDisplayDepth(), InputOutput
,
112 DefaultVisual(dpy
, 0), valueMask
,
115 if (sm_overlayWindow
)
117 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
124 bool wxScreenDC::EndDrawingOnTop()
126 if (sm_overlayWindow
)
128 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
129 sm_overlayWindow
= 0;