]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
98cd0efd3e5c15c20f3f29e991574ee3231ce105
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMemoryDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dcmemory.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #include "wx/dcmemory.h"
20 #include "wx/settings.h"
24 #pragma message disable nosimpint
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
39 wxMemoryDC::wxMemoryDC(void)
42 m_display
= wxGetDisplay();
44 Display
* display
= (Display
*) m_display
;
47 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
48 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
49 gcvalues
.graphics_exposures
= False
;
50 gcvalues
.subwindow_mode
= IncludeInferiors
;
51 gcvalues
.line_width
= 1;
52 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
53 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
56 m_backgroundPixel
= (int) gcvalues
.background
;
58 // Get the current Font so we can set it back later
60 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
61 m_oldFont
= (WXFont
) valReturn
.font
;
62 SetBrush (* wxWHITE_BRUSH
);
63 SetPen (* wxBLACK_PEN
);
64 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
67 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
70 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
71 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
73 m_display
= wxGetDisplay();
75 Display
* display
= (Display
*) m_display
;
78 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
79 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
80 gcvalues
.graphics_exposures
= False
;
81 gcvalues
.subwindow_mode
= IncludeInferiors
;
82 gcvalues
.line_width
= 1;
83 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
84 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
87 m_backgroundPixel
= (int) gcvalues
.background
;
89 // Get the current Font so we can set it back later
91 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
92 m_oldFont
= (WXFont
) valReturn
.font
;
93 SetBrush (* wxWHITE_BRUSH
);
94 SetPen (* wxBLACK_PEN
);
97 wxMemoryDC::~wxMemoryDC(void)
101 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
106 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
109 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
111 m_pixmap
= m_bitmap
.GetDrawable();
112 Display
* display
= (Display
*) m_display
;
115 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
116 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
117 gcvalues
.graphics_exposures
= False
;
118 gcvalues
.subwindow_mode
= IncludeInferiors
;
119 gcvalues
.line_width
= 1;
120 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
121 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
124 m_backgroundPixel
= (int) gcvalues
.background
;
127 // Get the current Font so we can set it back later
129 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
130 m_oldFont
= (WXFont
) valReturn
.font
;
132 SetBrush (* wxWHITE_BRUSH
);
133 SetPen (* wxBLACK_PEN
);
138 m_pixmap
= (WXPixmap
) 0;
142 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
146 if (width
) (*width
) = m_bitmap
.GetWidth();
147 if (height
) (*height
) = m_bitmap
.GetHeight();
151 if (width
) (*width
) = 0;
152 if (height
) (*height
) = 0;