]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
fix for opening files with VC++ 8 (closes bug 994337)
[wxWidgets.git] / src / motif / dcmemory.cpp
CommitLineData
4bb6408c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.cpp
3// Purpose: wxMemoryDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
4bb6408c
JS
13#pragma implementation "dcmemory.h"
14#endif
15
1248b41f
MB
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
4bb6408c 19#include "wx/dcmemory.h"
0ba1a6f3 20#include "wx/settings.h"
a4294b78
JS
21#include "wx/utils.h"
22
338dd992
JJ
23#ifdef __VMS__
24#pragma message disable nosimpint
25#endif
a4294b78 26#include <Xm/Xm.h>
338dd992
JJ
27#ifdef __VMS__
28#pragma message enable nosimpint
29#endif
a4294b78
JS
30
31#include "wx/motif/private.h"
4bb6408c
JS
32
33//-----------------------------------------------------------------------------
34// wxMemoryDC
35//-----------------------------------------------------------------------------
36
16c1f7f3 37IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
4bb6408c
JS
38
39wxMemoryDC::wxMemoryDC(void)
40{
a4294b78
JS
41 m_ok = TRUE;
42 m_display = wxGetDisplay();
2d120f83 43
a4294b78 44 Display* display = (Display*) m_display;
2d120f83 45
a4294b78
JS
46 XGCValues gcvalues;
47 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
48 gcvalues.background = WhitePixel (display, DefaultScreen (display));
49 gcvalues.graphics_exposures = False;
66eca538 50 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
51 gcvalues.line_width = 1;
52 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 53 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83
JS
54 &gcvalues);
55
a4294b78 56 m_backgroundPixel = (int) gcvalues.background;
2d120f83 57
a4294b78
JS
58 // Get the current Font so we can set it back later
59 XGCValues valReturn;
60 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
61 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
62 SetBrush (* wxWHITE_BRUSH);
63 SetPen (* wxBLACK_PEN);
a756f210 64 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
4bb6408c
JS
65};
66
a4294b78 67wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 68{
a4294b78
JS
69 m_ok = TRUE;
70 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
71 m_display = ((wxWindowDC*)dc)->GetDisplay();
72 else
73 m_display = wxGetDisplay();
2d120f83 74
a4294b78 75 Display* display = (Display*) m_display;
2d120f83 76
a4294b78
JS
77 XGCValues gcvalues;
78 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
79 gcvalues.background = WhitePixel (display, DefaultScreen (display));
80 gcvalues.graphics_exposures = False;
66eca538 81 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
82 gcvalues.line_width = 1;
83 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 84 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83
JS
85 &gcvalues);
86
a4294b78 87 m_backgroundPixel = (int) gcvalues.background;
2d120f83 88
a4294b78
JS
89 // Get the current Font so we can set it back later
90 XGCValues valReturn;
91 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
92 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
93 SetBrush (* wxWHITE_BRUSH);
94 SetPen (* wxBLACK_PEN);
4bb6408c
JS
95};
96
97wxMemoryDC::~wxMemoryDC(void)
98{
99};
100
101void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
102{
2d120f83 103 m_bitmap = bitmap;
a4294b78 104
2d120f83
JS
105 if (m_gc)
106 XFreeGC((Display*) m_display, (GC) m_gc);
107 m_gc = (WXGC) NULL;
108
109 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
110 {
aae0472b 111 m_pixmap = m_bitmap.GetDrawable();
2d120f83
JS
112 Display* display = (Display*) m_display;
113
114 XGCValues gcvalues;
115 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
116 gcvalues.background = WhitePixel (display, DefaultScreen (display));
117 gcvalues.graphics_exposures = False;
66eca538 118 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 119 gcvalues.line_width = 1;
21342bba 120 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 121 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83
JS
122 &gcvalues);
123
124 m_backgroundPixel = (int) gcvalues.background;
4cae9a20 125 m_ok = TRUE;
2d120f83
JS
126
127 // Get the current Font so we can set it back later
128 XGCValues valReturn;
129 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
130 m_oldFont = (WXFont) valReturn.font;
131
132 bool oldOpt = GetOptimization();
133 SetOptimization(FALSE);
134
135 SetBrush (* wxWHITE_BRUSH);
136 SetPen (* wxBLACK_PEN);
137
138 SetOptimization(oldOpt);
139
2d120f83
JS
140 }
141 else
142 {
143 m_ok = FALSE;
144 m_pixmap = (WXPixmap) 0;
145 };
4bb6408c
JS
146};
147
96f201da 148void wxMemoryDC::DoGetSize( int *width, int *height ) const
4bb6408c 149{
2d120f83
JS
150 if (m_bitmap.Ok())
151 {
152 if (width) (*width) = m_bitmap.GetWidth();
153 if (height) (*height) = m_bitmap.GetHeight();
154 }
155 else
156 {
157 if (width) (*width) = 0;
158 if (height) (*height) = 0;
159 };
4bb6408c
JS
160};
161
162