]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcscreen.cpp
added wxUSE_IMAGE; added write-only wxXPMHandler
[wxWidgets.git] / src / motif / dcscreen.cpp
CommitLineData
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"
68be9f09 17#include "wx/frame.h"
4bb6408c 18#include "wx/dcscreen.h"
89c7e962
JS
19#include "wx/utils.h"
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"
4bb6408c 30
dfc54541 31IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
4bb6408c 32
89c7e962
JS
33WXWindow wxScreenDC::sm_overlayWindow = 0;
34int wxScreenDC::sm_overlayWindowX = 0;
35int wxScreenDC::sm_overlayWindowY = 0;
36
4bb6408c
JS
37// Create a DC representing the whole screen
38wxScreenDC::wxScreenDC()
39{
2d120f83
JS
40 m_display = wxGetDisplay();
41 Display* display = (Display*) m_display;
42
43 if (sm_overlayWindow)
44 {
45 m_pixmap = sm_overlayWindow;
46 m_deviceOriginX = - sm_overlayWindowX;
47 m_deviceOriginY = - sm_overlayWindowY;
48 }
49 else
50 m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
51
52 XGCValues gcvalues;
53 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
54 gcvalues.background = WhitePixel (display, DefaultScreen (display));
55 gcvalues.graphics_exposures = False;
56 gcvalues.subwindow_mode = IncludeInferiors;
57 gcvalues.line_width = 1;
58 m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
59 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
60 &gcvalues);
61
62 m_backgroundPixel = (int) gcvalues.background;
63 m_ok = TRUE;
4bb6408c
JS
64}
65
66wxScreenDC::~wxScreenDC()
67{
68be9f09 68 EndDrawingOnTop();
4bb6408c
JS
69}
70
dfc54541
JS
71bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
72{
2d120f83
JS
73 wxRect rect;
74 int x, y, width, height;
75 window->GetPosition(& x, & y);
68be9f09 76 if (window->GetParent() && !window->IsKindOf(CLASSINFO(wxFrame)))
2d120f83
JS
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 85bool 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
124bool 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}