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