]>
Commit | Line | Data |
---|---|---|
4bb6408c | 1 | ///////////////////////////////////////////////////////////////////////////// |
de6185e2 | 2 | // Name: src/motif/dcmemory.cpp |
fce127d7 | 3 | // Purpose: wxMemoryDCImpl class |
4bb6408c JS |
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 | ||
de6185e2 WS |
15 | #ifndef WX_PRECOMP |
16 | #include "wx/utils.h" | |
9eddec69 | 17 | #include "wx/settings.h" |
de6185e2 WS |
18 | #endif |
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" | |
fce127d7 | 29 | #include "wx/motif/dcmemory.h" |
4bb6408c JS |
30 | |
31 | //----------------------------------------------------------------------------- | |
fce127d7 | 32 | // wxMemoryDCImpl |
4bb6408c JS |
33 | //----------------------------------------------------------------------------- |
34 | ||
fce127d7 | 35 | IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl) |
4bb6408c | 36 | |
fce127d7 | 37 | void wxMemoryDCImpl::Init() |
4bb6408c | 38 | { |
ea76a6a5 | 39 | m_ok = true; |
a4294b78 | 40 | m_display = wxGetDisplay(); |
ea76a6a5 | 41 | |
a4294b78 | 42 | Display* display = (Display*) m_display; |
ea76a6a5 | 43 | |
a4294b78 JS |
44 | XGCValues gcvalues; |
45 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
46 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
47 | gcvalues.graphics_exposures = False; | |
66eca538 | 48 | gcvalues.subwindow_mode = IncludeInferiors; |
a4294b78 JS |
49 | gcvalues.line_width = 1; |
50 | m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), | |
66eca538 | 51 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 52 | &gcvalues); |
ea76a6a5 | 53 | |
3e0071d9 | 54 | m_backgroundPixel = gcvalues.background; |
ea76a6a5 | 55 | |
c0ed460c JS |
56 | SetBrush (* wxWHITE_BRUSH); |
57 | SetPen (* wxBLACK_PEN); | |
ea76a6a5 | 58 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); |
e933b5bc | 59 | } |
4bb6408c | 60 | |
fce127d7 VZ |
61 | wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc) |
62 | : wxWindowDCImpl(owner) | |
4bb6408c | 63 | { |
ea76a6a5 | 64 | m_ok = true; |
a4294b78 | 65 | if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC))) |
fce127d7 | 66 | m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay(); |
a4294b78 JS |
67 | else |
68 | m_display = wxGetDisplay(); | |
ea76a6a5 | 69 | |
a4294b78 | 70 | Display* display = (Display*) m_display; |
ea76a6a5 | 71 | |
a4294b78 JS |
72 | XGCValues gcvalues; |
73 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
74 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
75 | gcvalues.graphics_exposures = False; | |
66eca538 | 76 | gcvalues.subwindow_mode = IncludeInferiors; |
a4294b78 JS |
77 | gcvalues.line_width = 1; |
78 | m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), | |
66eca538 | 79 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 80 | &gcvalues); |
ea76a6a5 | 81 | |
3e0071d9 | 82 | m_backgroundPixel = gcvalues.background; |
ea76a6a5 | 83 | |
c0ed460c JS |
84 | SetBrush (* wxWHITE_BRUSH); |
85 | SetPen (* wxBLACK_PEN); | |
e933b5bc | 86 | } |
4bb6408c | 87 | |
fce127d7 | 88 | wxMemoryDCImpl::~wxMemoryDCImpl(void) |
4bb6408c | 89 | { |
e933b5bc | 90 | } |
4bb6408c | 91 | |
fce127d7 | 92 | void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) |
4bb6408c | 93 | { |
2d120f83 | 94 | m_bitmap = bitmap; |
ea76a6a5 | 95 | |
2d120f83 JS |
96 | if (m_gc) |
97 | XFreeGC((Display*) m_display, (GC) m_gc); | |
98 | m_gc = (WXGC) NULL; | |
ea76a6a5 | 99 | |
2d120f83 JS |
100 | if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display)) |
101 | { | |
aae0472b | 102 | m_pixmap = m_bitmap.GetDrawable(); |
2d120f83 | 103 | Display* display = (Display*) m_display; |
ea76a6a5 | 104 | |
2d120f83 JS |
105 | XGCValues gcvalues; |
106 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
107 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
108 | gcvalues.graphics_exposures = False; | |
66eca538 | 109 | gcvalues.subwindow_mode = IncludeInferiors; |
2d120f83 | 110 | gcvalues.line_width = 1; |
21342bba | 111 | m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */, |
66eca538 | 112 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 113 | &gcvalues); |
ea76a6a5 | 114 | |
3e0071d9 | 115 | m_backgroundPixel = gcvalues.background; |
ea76a6a5 WS |
116 | m_ok = true; |
117 | ||
2d120f83 JS |
118 | SetBrush (* wxWHITE_BRUSH); |
119 | SetPen (* wxBLACK_PEN); | |
2d120f83 JS |
120 | } |
121 | else | |
122 | { | |
96be256b | 123 | m_ok = false; |
2d120f83 JS |
124 | m_pixmap = (WXPixmap) 0; |
125 | }; | |
e933b5bc | 126 | } |
4bb6408c | 127 | |
fce127d7 | 128 | void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const |
4bb6408c | 129 | { |
2d120f83 JS |
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 | }; | |
e933b5bc | 140 | } |