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