]>
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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/dcmemory.h"
16 #include "wx/settings.h"
20 #pragma message disable nosimpint
24 #pragma message enable nosimpint
27 #include "wx/motif/private.h"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
35 wxMemoryDC::wxMemoryDC(void)
38 m_display
= wxGetDisplay();
40 Display
* display
= (Display
*) m_display
;
43 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
44 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
45 gcvalues
.graphics_exposures
= False
;
46 gcvalues
.subwindow_mode
= IncludeInferiors
;
47 gcvalues
.line_width
= 1;
48 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
49 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
52 m_backgroundPixel
= (int) gcvalues
.background
;
54 SetBrush (* wxWHITE_BRUSH
);
55 SetPen (* wxBLACK_PEN
);
56 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
59 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
62 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
63 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
65 m_display
= wxGetDisplay();
67 Display
* display
= (Display
*) m_display
;
70 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
71 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
72 gcvalues
.graphics_exposures
= False
;
73 gcvalues
.subwindow_mode
= IncludeInferiors
;
74 gcvalues
.line_width
= 1;
75 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
76 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
79 m_backgroundPixel
= (int) gcvalues
.background
;
81 SetBrush (* wxWHITE_BRUSH
);
82 SetPen (* wxBLACK_PEN
);
85 wxMemoryDC::~wxMemoryDC(void)
89 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
94 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
97 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
99 m_pixmap
= m_bitmap
.GetDrawable();
100 Display
* display
= (Display
*) m_display
;
103 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
104 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
105 gcvalues
.graphics_exposures
= False
;
106 gcvalues
.subwindow_mode
= IncludeInferiors
;
107 gcvalues
.line_width
= 1;
108 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
109 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
112 m_backgroundPixel
= (int) gcvalues
.background
;
115 SetBrush (* wxWHITE_BRUSH
);
116 SetPen (* wxBLACK_PEN
);
121 m_pixmap
= (WXPixmap
) 0;
125 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
129 if (width
) (*width
) = m_bitmap
.GetWidth();
130 if (height
) (*height
) = m_bitmap
.GetHeight();
134 if (width
) (*width
) = 0;
135 if (height
) (*height
) = 0;