]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcscreen.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / motif / dcscreen.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/motif/dcscreen.cpp
fce127d7 3// Purpose: wxScreenDCImpl class
4bb6408c
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
4bb6408c 7// Copyright: (c) Julian Smart
de6185e2 8// Licence: wxWindows licence
4bb6408c
JS
9/////////////////////////////////////////////////////////////////////////////
10
1248b41f
MB
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
de6185e2
WS
14#ifndef WX_PRECOMP
15 #include "wx/utils.h"
cdccdfab 16 #include "wx/window.h"
76b49cf4 17 #include "wx/frame.h"
76c32e7b 18 #include "wx/dcscreen.h"
de6185e2
WS
19#endif
20
338dd992
JJ
21#ifdef __VMS__
22#pragma message disable nosimpint
23#endif
89c7e962 24#include <Xm/Xm.h>
338dd992
JJ
25#ifdef __VMS__
26#pragma message enable nosimpint
27#endif
89c7e962 28
3096bd2f 29#include "wx/motif/private.h"
fce127d7 30#include "wx/motif/dcscreen.h"
4bb6408c 31
fce127d7 32IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxWindowDCImpl)
4bb6408c 33
fce127d7
VZ
34WXWindow wxScreenDCImpl::sm_overlayWindow = 0;
35int wxScreenDCImpl::sm_overlayWindowX = 0;
36int wxScreenDCImpl::sm_overlayWindowY = 0;
89c7e962 37
4bb6408c 38// Create a DC representing the whole screen
fce127d7
VZ
39wxScreenDCImpl::wxScreenDCImpl(wxScreenDC *owner)
40 : wxWindowDCImpl(owner)
4bb6408c 41{
2d120f83
JS
42 m_display = wxGetDisplay();
43 Display* display = (Display*) m_display;
de6185e2 44
2d120f83
JS
45 if (sm_overlayWindow)
46 {
47 m_pixmap = sm_overlayWindow;
48 m_deviceOriginX = - sm_overlayWindowX;
49 m_deviceOriginY = - sm_overlayWindowY;
50 }
51 else
52 m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
de6185e2 53
2d120f83
JS
54 XGCValues gcvalues;
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,
62 &gcvalues);
de6185e2 63
3e0071d9 64 m_backgroundPixel = gcvalues.background;
96be256b 65 m_ok = true;
4bb6408c
JS
66}
67
fce127d7 68wxScreenDCImpl::~wxScreenDCImpl()
4bb6408c 69{
68be9f09 70 EndDrawingOnTop();
4bb6408c
JS
71}
72
fce127d7 73bool wxScreenDCImpl::StartDrawingOnTop(wxWindow* window)
dfc54541 74{
2d120f83
JS
75 wxRect rect;
76 int x, y, width, height;
77 window->GetPosition(& x, & y);
68be9f09 78 if (window->GetParent() && !window->IsKindOf(CLASSINFO(wxFrame)))
2d120f83
JS
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;
de6185e2 83
2d120f83 84 return StartDrawingOnTop(& rect);
dfc54541
JS
85}
86
fce127d7 87bool wxScreenDCImpl::StartDrawingOnTop(wxRect* rect)
dfc54541 88{
2d120f83 89 if (sm_overlayWindow)
96be256b 90 return false;
de6185e2 91
2d120f83
JS
92 Display *dpy = (Display*) wxGetDisplay();
93 Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
de6185e2 94
2d120f83
JS
95 int x = 0;
96 int y = 0;
97 int width, height;
98 wxDisplaySize(&width, &height);
de6185e2 99
2d120f83
JS
100 if (rect)
101 {
102 x = rect->x; y = rect->y;
103 width = rect->width; height = rect->height;
104 }
105 sm_overlayWindowX = x;
106 sm_overlayWindowY = y;
de6185e2 107
2d120f83
JS
108 XSetWindowAttributes attributes;
109 attributes.override_redirect = True;
110 unsigned long valueMask = CWOverrideRedirect;
de6185e2 111
2d120f83
JS
112 sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
113 wxDisplayDepth(), InputOutput,
114 DefaultVisual(dpy, 0), valueMask,
115 & attributes);
de6185e2 116
2d120f83
JS
117 if (sm_overlayWindow)
118 {
119 XMapWindow(dpy, (Window) sm_overlayWindow);
96be256b 120 return true;
2d120f83
JS
121 }
122 else
96be256b 123 return false;
dfc54541
JS
124}
125
fce127d7 126bool wxScreenDCImpl::EndDrawingOnTop()
dfc54541 127{
2d120f83
JS
128 if (sm_overlayWindow)
129 {
130 XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
131 sm_overlayWindow = 0;
96be256b 132 return true;
2d120f83
JS
133 }
134 else
96be256b 135 return false;
dfc54541 136}