]>
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 | |
4bb6408c | 7 | // Copyright: (c) Julian Smart |
ea76a6a5 | 8 | // Licence: wxWindows licence |
4bb6408c JS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
1248b41f MB |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
de6185e2 WS |
14 | #ifndef WX_PRECOMP |
15 | #include "wx/utils.h" | |
9eddec69 | 16 | #include "wx/settings.h" |
76c32e7b JJ |
17 | #include "wx/dcmemory.h" |
18 | #include "wx/dcclient.h" | |
de6185e2 WS |
19 | #endif |
20 | ||
338dd992 JJ |
21 | #ifdef __VMS__ |
22 | #pragma message disable nosimpint | |
23 | #endif | |
a4294b78 | 24 | #include <Xm/Xm.h> |
338dd992 JJ |
25 | #ifdef __VMS__ |
26 | #pragma message enable nosimpint | |
27 | #endif | |
a4294b78 JS |
28 | |
29 | #include "wx/motif/private.h" | |
fce127d7 | 30 | #include "wx/motif/dcmemory.h" |
4bb6408c JS |
31 | |
32 | //----------------------------------------------------------------------------- | |
fce127d7 | 33 | // wxMemoryDCImpl |
4bb6408c JS |
34 | //----------------------------------------------------------------------------- |
35 | ||
fce127d7 | 36 | IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl) |
4bb6408c | 37 | |
fce127d7 | 38 | void wxMemoryDCImpl::Init() |
4bb6408c | 39 | { |
ea76a6a5 | 40 | m_ok = true; |
a4294b78 | 41 | m_display = wxGetDisplay(); |
ea76a6a5 | 42 | |
a4294b78 | 43 | Display* display = (Display*) m_display; |
ea76a6a5 | 44 | |
a4294b78 JS |
45 | XGCValues gcvalues; |
46 | gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); | |
47 | gcvalues.background = WhitePixel (display, DefaultScreen (display)); | |
48 | gcvalues.graphics_exposures = False; | |
66eca538 | 49 | gcvalues.subwindow_mode = IncludeInferiors; |
a4294b78 JS |
50 | gcvalues.line_width = 1; |
51 | m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), | |
66eca538 | 52 | GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, |
2d120f83 | 53 | &gcvalues); |
ea76a6a5 | 54 | |
3e0071d9 | 55 | m_backgroundPixel = gcvalues.background; |
ea76a6a5 | 56 | |
c0ed460c JS |
57 | SetBrush (* wxWHITE_BRUSH); |
58 | SetPen (* wxBLACK_PEN); | |
ea76a6a5 | 59 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); |
e933b5bc | 60 | } |
4bb6408c | 61 | |
fce127d7 VZ |
62 | wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc) |
63 | : wxWindowDCImpl(owner) | |
4bb6408c | 64 | { |
ea76a6a5 | 65 | m_ok = true; |
a4294b78 | 66 | if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC))) |
fce127d7 | 67 | m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay(); |
a4294b78 JS |
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 | |
3e0071d9 | 83 | m_backgroundPixel = gcvalues.background; |
ea76a6a5 | 84 | |
c0ed460c JS |
85 | SetBrush (* wxWHITE_BRUSH); |
86 | SetPen (* wxBLACK_PEN); | |
e933b5bc | 87 | } |
4bb6408c | 88 | |
fce127d7 | 89 | wxMemoryDCImpl::~wxMemoryDCImpl(void) |
4bb6408c | 90 | { |
e933b5bc | 91 | } |
4bb6408c | 92 | |
fce127d7 | 93 | void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) |
4bb6408c | 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 | |
a1b806b9 | 101 | if (m_bitmap.IsOk() && (bitmap.GetDisplay() == m_display)) |
2d120f83 | 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 | |
3e0071d9 | 116 | m_backgroundPixel = 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 | |
fce127d7 | 129 | void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const |
4bb6408c | 130 | { |
a1b806b9 | 131 | if (m_bitmap.IsOk()) |
2d120f83 JS |
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 | } |