]> git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
fixed minor combobox bug: GetValue() reported wrong value when caleld from TEXT_UPDAT...
[wxWidgets.git] / src / motif / dcmemory.cpp
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"
17 #include "wx/settings.h"
18 #include "wx/utils.h"
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
30 //-----------------------------------------------------------------------------
31 // wxMemoryDC
32 //-----------------------------------------------------------------------------
33
34 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
35
36 wxMemoryDC::wxMemoryDC(void)
37 {
38 m_ok = TRUE;
39 m_display = wxGetDisplay();
40
41 Display* display = (Display*) m_display;
42
43 XGCValues gcvalues;
44 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
45 gcvalues.background = WhitePixel (display, DefaultScreen (display));
46 gcvalues.graphics_exposures = False;
47 gcvalues.subwindow_mode = IncludeInferiors;
48 gcvalues.line_width = 1;
49 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
50 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
51 &gcvalues);
52
53 m_backgroundPixel = (int) gcvalues.background;
54
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;
59 SetBrush (* wxWHITE_BRUSH);
60 SetPen (* wxBLACK_PEN);
61 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
62 };
63
64 wxMemoryDC::wxMemoryDC( wxDC* dc )
65 {
66 m_ok = TRUE;
67 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
68 m_display = ((wxWindowDC*)dc)->GetDisplay();
69 else
70 m_display = wxGetDisplay();
71
72 Display* display = (Display*) m_display;
73
74 XGCValues gcvalues;
75 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
76 gcvalues.background = WhitePixel (display, DefaultScreen (display));
77 gcvalues.graphics_exposures = False;
78 gcvalues.subwindow_mode = IncludeInferiors;
79 gcvalues.line_width = 1;
80 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
81 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
82 &gcvalues);
83
84 m_backgroundPixel = (int) gcvalues.background;
85
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;
90 SetBrush (* wxWHITE_BRUSH);
91 SetPen (* wxBLACK_PEN);
92 };
93
94 wxMemoryDC::~wxMemoryDC(void)
95 {
96 };
97
98 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
99 {
100 m_bitmap = bitmap;
101
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;
115 gcvalues.subwindow_mode = IncludeInferiors;
116 gcvalues.line_width = 1;
117 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
118 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
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 };
143 };
144
145 void wxMemoryDC::DoGetSize( int *width, int *height ) const
146 {
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 };
157 };
158
159