1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcscreen.cpp
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/dcscreen.h"
19 #include "wx/window.h"
24 #pragma message disable nosimpint
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC
, wxWindowDC
)
35 WXWindow
wxScreenDC::sm_overlayWindow
= 0;
36 int wxScreenDC::sm_overlayWindowX
= 0;
37 int wxScreenDC::sm_overlayWindowY
= 0;
39 // Create a DC representing the whole screen
40 wxScreenDC::wxScreenDC()
42 m_display
= wxGetDisplay();
43 Display
* display
= (Display
*) m_display
;
47 m_pixmap
= sm_overlayWindow
;
48 m_deviceOriginX
= - sm_overlayWindowX
;
49 m_deviceOriginY
= - sm_overlayWindowY
;
52 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
55 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
56 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
57 gcvalues
.graphics_exposures
= False
;
58 gcvalues
.subwindow_mode
= IncludeInferiors
;
59 gcvalues
.line_width
= 1;
60 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
61 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
64 m_backgroundPixel
= (int) gcvalues
.background
;
68 wxScreenDC::~wxScreenDC()
73 bool wxScreenDC::StartDrawingOnTop(wxWindow
* window
)
76 int x
, y
, width
, height
;
77 window
->GetPosition(& x
, & y
);
78 if (window
->GetParent() && !window
->IsKindOf(CLASSINFO(wxFrame
)))
79 window
->GetParent()->ClientToScreen(& x
, & y
);
80 window
->GetSize(& width
, & height
);
81 rect
.x
= x
; rect
.y
= y
;
82 rect
.width
= width
; rect
.height
= height
;
84 return StartDrawingOnTop(& rect
);
87 bool wxScreenDC::StartDrawingOnTop(wxRect
* rect
)
92 Display
*dpy
= (Display
*) wxGetDisplay();
93 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
98 wxDisplaySize(&width
, &height
);
102 x
= rect
->x
; y
= rect
->y
;
103 width
= rect
->width
; height
= rect
->height
;
105 sm_overlayWindowX
= x
;
106 sm_overlayWindowY
= y
;
108 XSetWindowAttributes attributes
;
109 attributes
.override_redirect
= True
;
110 unsigned long valueMask
= CWOverrideRedirect
;
112 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
113 wxDisplayDepth(), InputOutput
,
114 DefaultVisual(dpy
, 0), valueMask
,
117 if (sm_overlayWindow
)
119 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
126 bool wxScreenDC::EndDrawingOnTop()
128 if (sm_overlayWindow
)
130 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
131 sm_overlayWindow
= 0;