]>
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 /////////////////////////////////////////////////////////////////////////////
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 SetBrush (* wxWHITE_BRUSH
);
59 SetPen (* wxBLACK_PEN
);
60 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
63 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
66 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
67 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
69 m_display
= wxGetDisplay();
71 Display
* display
= (Display
*) m_display
;
74 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
75 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
76 gcvalues
.graphics_exposures
= False
;
77 gcvalues
.subwindow_mode
= IncludeInferiors
;
78 gcvalues
.line_width
= 1;
79 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
80 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
83 m_backgroundPixel
= (int) gcvalues
.background
;
85 SetBrush (* wxWHITE_BRUSH
);
86 SetPen (* wxBLACK_PEN
);
89 wxMemoryDC::~wxMemoryDC(void)
93 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
98 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
101 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
103 m_pixmap
= m_bitmap
.GetDrawable();
104 Display
* display
= (Display
*) m_display
;
107 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
108 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
109 gcvalues
.graphics_exposures
= False
;
110 gcvalues
.subwindow_mode
= IncludeInferiors
;
111 gcvalues
.line_width
= 1;
112 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
113 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
116 m_backgroundPixel
= (int) gcvalues
.background
;
119 SetBrush (* wxWHITE_BRUSH
);
120 SetPen (* wxBLACK_PEN
);
125 m_pixmap
= (WXPixmap
) 0;
129 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
133 if (width
) (*width
) = m_bitmap
.GetWidth();
134 if (height
) (*height
) = m_bitmap
.GetHeight();
138 if (width
) (*width
) = 0;
139 if (height
) (*height
) = 0;