wxMotif compilation fixes after wxDC changes
[wxWidgets.git] / src / motif / dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcmemory.cpp
3 // Purpose: wxMemoryDCImpl 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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/utils.h"
17 #include "wx/settings.h"
18 #endif
19
20 #ifdef __VMS__
21 #pragma message disable nosimpint
22 #endif
23 #include <Xm/Xm.h>
24 #ifdef __VMS__
25 #pragma message enable nosimpint
26 #endif
27
28 #include "wx/motif/private.h"
29 #include "wx/motif/dcmemory.h"
30
31 //-----------------------------------------------------------------------------
32 // wxMemoryDCImpl
33 //-----------------------------------------------------------------------------
34
35 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl)
36
37 void wxMemoryDCImpl::Init()
38 {
39 m_ok = true;
40 m_display = wxGetDisplay();
41
42 Display* display = (Display*) m_display;
43
44 XGCValues gcvalues;
45 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
46 gcvalues.background = WhitePixel (display, DefaultScreen (display));
47 gcvalues.graphics_exposures = False;
48 gcvalues.subwindow_mode = IncludeInferiors;
49 gcvalues.line_width = 1;
50 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
51 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
52 &gcvalues);
53
54 m_backgroundPixel = gcvalues.background;
55
56 SetBrush (* wxWHITE_BRUSH);
57 SetPen (* wxBLACK_PEN);
58 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
59 }
60
61 wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc)
62 : wxWindowDCImpl(owner)
63 {
64 m_ok = true;
65 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
66 m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay();
67 else
68 m_display = wxGetDisplay();
69
70 Display* display = (Display*) m_display;
71
72 XGCValues gcvalues;
73 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
74 gcvalues.background = WhitePixel (display, DefaultScreen (display));
75 gcvalues.graphics_exposures = False;
76 gcvalues.subwindow_mode = IncludeInferiors;
77 gcvalues.line_width = 1;
78 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
79 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
80 &gcvalues);
81
82 m_backgroundPixel = gcvalues.background;
83
84 SetBrush (* wxWHITE_BRUSH);
85 SetPen (* wxBLACK_PEN);
86 }
87
88 wxMemoryDCImpl::~wxMemoryDCImpl(void)
89 {
90 }
91
92 void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
93 {
94 m_bitmap = bitmap;
95
96 if (m_gc)
97 XFreeGC((Display*) m_display, (GC) m_gc);
98 m_gc = (WXGC) NULL;
99
100 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
101 {
102 m_pixmap = m_bitmap.GetDrawable();
103 Display* display = (Display*) m_display;
104
105 XGCValues gcvalues;
106 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
107 gcvalues.background = WhitePixel (display, DefaultScreen (display));
108 gcvalues.graphics_exposures = False;
109 gcvalues.subwindow_mode = IncludeInferiors;
110 gcvalues.line_width = 1;
111 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
112 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
113 &gcvalues);
114
115 m_backgroundPixel = gcvalues.background;
116 m_ok = true;
117
118 SetBrush (* wxWHITE_BRUSH);
119 SetPen (* wxBLACK_PEN);
120 }
121 else
122 {
123 m_ok = false;
124 m_pixmap = (WXPixmap) 0;
125 };
126 }
127
128 void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
129 {
130 if (m_bitmap.Ok())
131 {
132 if (width) (*width) = m_bitmap.GetWidth();
133 if (height) (*height) = m_bitmap.GetHeight();
134 }
135 else
136 {
137 if (width) (*width) = 0;
138 if (height) (*height) = 0;
139 };
140 }