]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMemoryDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcmemory.h"
16 #include "wx/dcmemory.h"
17 #include "wx/settings.h"
22 #include "wx/motif/private.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
30 wxMemoryDC::wxMemoryDC(void)
33 m_display
= wxGetDisplay();
35 Display
* display
= (Display
*) m_display
;
38 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
39 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
40 gcvalues
.graphics_exposures
= False
;
41 gcvalues
.line_width
= 1;
42 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
43 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
46 m_backgroundPixel
= (int) gcvalues
.background
;
48 // Get the current Font so we can set it back later
50 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
51 m_oldFont
= (WXFont
) valReturn
.font
;
52 SetBrush (* wxWHITE_BRUSH
);
53 SetPen (* wxBLACK_PEN
);
54 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
57 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
60 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
61 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
63 m_display
= wxGetDisplay();
65 Display
* display
= (Display
*) m_display
;
68 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
69 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
70 gcvalues
.graphics_exposures
= False
;
71 gcvalues
.line_width
= 1;
72 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
73 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
76 m_backgroundPixel
= (int) gcvalues
.background
;
78 // Get the current Font so we can set it back later
80 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
81 m_oldFont
= (WXFont
) valReturn
.font
;
82 SetBrush (* wxWHITE_BRUSH
);
83 SetPen (* wxBLACK_PEN
);
86 wxMemoryDC::~wxMemoryDC(void)
90 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
95 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
98 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
100 m_pixmap
= m_bitmap
.GetPixmap();
101 Display
* display
= (Display
*) m_display
;
104 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
105 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
106 gcvalues
.graphics_exposures
= False
;
107 gcvalues
.line_width
= 1;
108 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
109 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
112 m_backgroundPixel
= (int) gcvalues
.background
;
114 // Get the current Font so we can set it back later
116 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
117 m_oldFont
= (WXFont
) valReturn
.font
;
119 bool oldOpt
= GetOptimization();
120 SetOptimization(FALSE
);
122 SetBrush (* wxWHITE_BRUSH
);
123 SetPen (* wxBLACK_PEN
);
125 SetOptimization(oldOpt
);
132 m_pixmap
= (WXPixmap
) 0;
136 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
140 if (width
) (*width
) = m_bitmap
.GetWidth();
141 if (height
) (*height
) = m_bitmap
.GetHeight();
145 if (width
) (*width
) = 0;
146 if (height
) (*height
) = 0;