]>
Commit | Line | Data |
---|---|---|
4bb6408c | 1 | ///////////////////////////////////////////////////////////////////////////// |
de6185e2 | 2 | // Name: src/motif/dcmemory.cpp |
4bb6408c JS |
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 | |
ea76a6a5 | 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 | ||
4bb6408c | 15 | #include "wx/dcmemory.h" |
de6185e2 WS |
16 | |
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/utils.h" | |
19 | #endif | |
20 | ||
0ba1a6f3 | 21 | #include "wx/settings.h" |
a4294b78 | 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 | 37 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC) |
4bb6408c JS |
38 | |
39 | wxMemoryDC::wxMemoryDC(void) | |
40 | { | |
ea76a6a5 | 41 | m_ok = true; |
a4294b78 | 42 | m_display = wxGetDisplay(); |
ea76a6a5 | 43 | |
a4294b78 | 44 | Display* display = (Display*) m_display; |
ea76a6a5 | 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 | 54 | &gcvalues); |
ea76a6a5 | 55 | |
a4294b78 | 56 | m_backgroundPixel = (int) gcvalues.background; |
ea76a6a5 | 57 | |
c0ed460c JS |
58 | SetBrush (* wxWHITE_BRUSH); |
59 | SetPen (* wxBLACK_PEN); | |
ea76a6a5 | 60 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); |
e933b5bc | 61 | } |
4bb6408c | 62 | |
a4294b78 | 63 | wxMemoryDC::wxMemoryDC( wxDC* dc ) |
4bb6408c | 64 | { |
ea76a6a5 | 65 | m_ok = true; |
a4294b78 JS |
66 | if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC))) |
67 | m_display = ((wxWindowDC*)dc)->GetDisplay(); | |
68 | else | |
69 | m_display = wxGetDisplay(); | |
ea76a6a5 | 70 | |
a4294b78 | 71 | Display* display = (Display*) m_display; |
ea76a6a5 | 72 | |
a4294b78 JS |
73 | XGCValues gcvalues; |
74 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
75 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
76 | gcvalues.graphics_exposures = False; | |
66eca538 | 77 | gcvalues.subwindow_mode = IncludeInferiors; |
a4294b78 JS |
78 | gcvalues.line_width = 1; |
79 | m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), | |
66eca538 | 80 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 81 | &gcvalues); |
ea76a6a5 | 82 | |
a4294b78 | 83 | m_backgroundPixel = (int) gcvalues.background; |
ea76a6a5 | 84 | |
c0ed460c JS |
85 | SetBrush (* wxWHITE_BRUSH); |
86 | SetPen (* wxBLACK_PEN); | |
e933b5bc | 87 | } |
4bb6408c JS |
88 | |
89 | wxMemoryDC::~wxMemoryDC(void) | |
90 | { | |
e933b5bc | 91 | } |
4bb6408c JS |
92 | |
93 | void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) | |
94 | { | |
2d120f83 | 95 | m_bitmap = bitmap; |
ea76a6a5 | 96 | |
2d120f83 JS |
97 | if (m_gc) |
98 | XFreeGC((Display*) m_display, (GC) m_gc); | |
99 | m_gc = (WXGC) NULL; | |
ea76a6a5 | 100 | |
2d120f83 JS |
101 | if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display)) |
102 | { | |
aae0472b | 103 | m_pixmap = m_bitmap.GetDrawable(); |
2d120f83 | 104 | Display* display = (Display*) m_display; |
ea76a6a5 | 105 | |
2d120f83 JS |
106 | XGCValues gcvalues; |
107 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
108 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
109 | gcvalues.graphics_exposures = False; | |
66eca538 | 110 | gcvalues.subwindow_mode = IncludeInferiors; |
2d120f83 | 111 | gcvalues.line_width = 1; |
21342bba | 112 | m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */, |
66eca538 | 113 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 114 | &gcvalues); |
ea76a6a5 | 115 | |
2d120f83 | 116 | m_backgroundPixel = (int) gcvalues.background; |
ea76a6a5 WS |
117 | m_ok = true; |
118 | ||
2d120f83 JS |
119 | SetBrush (* wxWHITE_BRUSH); |
120 | SetPen (* wxBLACK_PEN); | |
2d120f83 JS |
121 | } |
122 | else | |
123 | { | |
96be256b | 124 | m_ok = false; |
2d120f83 JS |
125 | m_pixmap = (WXPixmap) 0; |
126 | }; | |
e933b5bc | 127 | } |
4bb6408c | 128 | |
96f201da | 129 | void wxMemoryDC::DoGetSize( int *width, int *height ) const |
4bb6408c | 130 | { |
2d120f83 JS |
131 | if (m_bitmap.Ok()) |
132 | { | |
133 | if (width) (*width) = m_bitmap.GetWidth(); | |
134 | if (height) (*height) = m_bitmap.GetHeight(); | |
135 | } | |
136 | else | |
137 | { | |
138 | if (width) (*width) = 0; | |
139 | if (height) (*height) = 0; | |
140 | }; | |
e933b5bc | 141 | } |
4bb6408c JS |
142 | |
143 |