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