]> git.saurik.com Git - wxWidgets.git/blob - src/motif/dcscreen.cpp
made unzip.c accept / and \ in filenames as equal
[wxWidgets.git] / src / motif / dcscreen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcscreen.cpp
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "dcscreen.h"
14 #endif
15
16 #include "wx/window.h"
17 #include "wx/dcscreen.h"
18 #include "wx/utils.h"
19
20 #ifdef __VMS__
21 #pragma message disable nosimpint
22 #endif
23 #include <Xm/Xm.h>
24 #ifdef __VMS__
25 #pragma message enable nosimpint
26 #endif
27
28 #include "wx/motif/private.h"
29
30 IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
31
32 WXWindow wxScreenDC::sm_overlayWindow = 0;
33 int wxScreenDC::sm_overlayWindowX = 0;
34 int wxScreenDC::sm_overlayWindowY = 0;
35
36 // Create a DC representing the whole screen
37 wxScreenDC::wxScreenDC()
38 {
39 m_display = wxGetDisplay();
40 Display* display = (Display*) m_display;
41
42 if (sm_overlayWindow)
43 {
44 m_pixmap = sm_overlayWindow;
45 m_deviceOriginX = - sm_overlayWindowX;
46 m_deviceOriginY = - sm_overlayWindowY;
47 }
48 else
49 m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
50
51 XGCValues gcvalues;
52 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
53 gcvalues.background = WhitePixel (display, DefaultScreen (display));
54 gcvalues.graphics_exposures = False;
55 gcvalues.subwindow_mode = IncludeInferiors;
56 gcvalues.line_width = 1;
57 m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
58 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
59 &gcvalues);
60
61 m_backgroundPixel = (int) gcvalues.background;
62 m_ok = TRUE;
63 }
64
65 wxScreenDC::~wxScreenDC()
66 {
67 }
68
69 bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
70 {
71 wxRect rect;
72 int x, y, width, height;
73 window->GetPosition(& x, & y);
74 if (window->GetParent())
75 window->GetParent()->ClientToScreen(& x, & y);
76 window->GetSize(& width, & height);
77 rect.x = x; rect.y = y;
78 rect.width = width; rect.height = height;
79
80 return StartDrawingOnTop(& rect);
81 }
82
83 bool wxScreenDC::StartDrawingOnTop(wxRect* rect)
84 {
85 if (sm_overlayWindow)
86 return FALSE;
87
88 Display *dpy = (Display*) wxGetDisplay();
89 Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
90
91 int x = 0;
92 int y = 0;
93 int width, height;
94 wxDisplaySize(&width, &height);
95
96 if (rect)
97 {
98 x = rect->x; y = rect->y;
99 width = rect->width; height = rect->height;
100 }
101 sm_overlayWindowX = x;
102 sm_overlayWindowY = y;
103
104 XSetWindowAttributes attributes;
105 attributes.override_redirect = True;
106 unsigned long valueMask = CWOverrideRedirect;
107
108 sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
109 wxDisplayDepth(), InputOutput,
110 DefaultVisual(dpy, 0), valueMask,
111 & attributes);
112
113 if (sm_overlayWindow)
114 {
115 XMapWindow(dpy, (Window) sm_overlayWindow);
116 return TRUE;
117 }
118 else
119 return FALSE;
120 }
121
122 bool wxScreenDC::EndDrawingOnTop()
123 {
124 if (sm_overlayWindow)
125 {
126 XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
127 sm_overlayWindow = 0;
128 return TRUE;
129 }
130 else
131 return FALSE;
132 }