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