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