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