1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcscreen.cpp
3 // Purpose: wxScreenDCImpl 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"
17 #include "wx/window.h"
19 #include "wx/dcscreen.h"
23 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
31 #include "wx/motif/dcscreen.h"
33 IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl
, wxWindowDCImpl
)
35 WXWindow
wxScreenDCImpl::sm_overlayWindow
= 0;
36 int wxScreenDCImpl::sm_overlayWindowX
= 0;
37 int wxScreenDCImpl::sm_overlayWindowY
= 0;
39 // Create a DC representing the whole screen
40 wxScreenDCImpl::wxScreenDCImpl(wxScreenDC
*owner
)
41 : wxWindowDCImpl(owner
)
43 m_display
= wxGetDisplay();
44 Display
* display
= (Display
*) m_display
;
48 m_pixmap
= sm_overlayWindow
;
49 m_deviceOriginX
= - sm_overlayWindowX
;
50 m_deviceOriginY
= - sm_overlayWindowY
;
53 m_pixmap
= (WXPixmap
) RootWindow(display
, DefaultScreen(display
));
56 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
57 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
58 gcvalues
.graphics_exposures
= False
;
59 gcvalues
.subwindow_mode
= IncludeInferiors
;
60 gcvalues
.line_width
= 1;
61 m_gc
= XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
62 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
65 m_backgroundPixel
= gcvalues
.background
;
69 wxScreenDCImpl::~wxScreenDCImpl()
74 bool wxScreenDCImpl::StartDrawingOnTop(wxWindow
* window
)
77 int x
, y
, width
, height
;
78 window
->GetPosition(& x
, & y
);
79 if (window
->GetParent() && !window
->IsKindOf(CLASSINFO(wxFrame
)))
80 window
->GetParent()->ClientToScreen(& x
, & y
);
81 window
->GetSize(& width
, & height
);
82 rect
.x
= x
; rect
.y
= y
;
83 rect
.width
= width
; rect
.height
= height
;
85 return StartDrawingOnTop(& rect
);
88 bool wxScreenDCImpl::StartDrawingOnTop(wxRect
* rect
)
93 Display
*dpy
= (Display
*) wxGetDisplay();
94 Pixmap screenPixmap
= RootWindow(dpy
, DefaultScreen(dpy
));
99 wxDisplaySize(&width
, &height
);
103 x
= rect
->x
; y
= rect
->y
;
104 width
= rect
->width
; height
= rect
->height
;
106 sm_overlayWindowX
= x
;
107 sm_overlayWindowY
= y
;
109 XSetWindowAttributes attributes
;
110 attributes
.override_redirect
= True
;
111 unsigned long valueMask
= CWOverrideRedirect
;
113 sm_overlayWindow
= (WXWindow
) XCreateWindow(dpy
, screenPixmap
, x
, y
, width
, height
, 0,
114 wxDisplayDepth(), InputOutput
,
115 DefaultVisual(dpy
, 0), valueMask
,
118 if (sm_overlayWindow
)
120 XMapWindow(dpy
, (Window
) sm_overlayWindow
);
127 bool wxScreenDCImpl::EndDrawingOnTop()
129 if (sm_overlayWindow
)
131 XDestroyWindow((Display
*) wxGetDisplay(), (Window
) sm_overlayWindow
);
132 sm_overlayWindow
= 0;