]>
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"
21 #include "wx/motif/private.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
29 wxMemoryDC::wxMemoryDC(void)
32 m_display
= wxGetDisplay();
34 Display
* display
= (Display
*) m_display
;
37 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
38 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
39 gcvalues
.graphics_exposures
= False
;
40 gcvalues
.line_width
= 1;
41 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
42 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
45 m_backgroundPixel
= (int) gcvalues
.background
;
47 // Get the current Font so we can set it back later
49 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
50 m_oldFont
= (WXFont
) valReturn
.font
;
51 SetBrush (wxWHITE_BRUSH
);
55 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
58 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
59 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
61 m_display
= wxGetDisplay();
63 Display
* display
= (Display
*) m_display
;
66 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
67 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
68 gcvalues
.graphics_exposures
= False
;
69 gcvalues
.line_width
= 1;
70 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
71 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
74 m_backgroundPixel
= (int) gcvalues
.background
;
76 // Get the current Font so we can set it back later
78 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
79 m_oldFont
= (WXFont
) valReturn
.font
;
80 SetBrush (wxWHITE_BRUSH
);
84 wxMemoryDC::~wxMemoryDC(void)
88 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
93 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
96 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
98 m_pixmap
= m_bitmap
.GetPixmap();
99 Display
* display
= (Display
*) m_display
;
102 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
103 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
104 gcvalues
.graphics_exposures
= False
;
105 gcvalues
.line_width
= 1;
106 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
107 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
110 m_backgroundPixel
= (int) gcvalues
.background
;
112 // Get the current Font so we can set it back later
114 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
115 m_oldFont
= (WXFont
) valReturn
.font
;
117 bool oldOpt
= GetOptimization();
118 SetOptimization(FALSE
);
120 SetBrush (wxWHITE_BRUSH
);
121 SetPen (wxBLACK_PEN
);
123 SetOptimization(oldOpt
);
130 m_pixmap
= (WXPixmap
) 0;
134 void wxMemoryDC::GetSize( int *width
, int *height
) const
138 if (width
) (*width
) = m_bitmap
.GetWidth();
139 if (height
) (*height
) = m_bitmap
.GetHeight();
143 if (width
) (*width
) = 0;
144 if (height
) (*height
) = 0;