]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcmemory.cpp
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"
19 #include "wx/settings.h"
23 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
38 wxMemoryDC::wxMemoryDC(void)
41 m_display
= wxGetDisplay();
43 Display
* display
= (Display
*) m_display
;
46 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
47 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
48 gcvalues
.graphics_exposures
= False
;
49 gcvalues
.subwindow_mode
= IncludeInferiors
;
50 gcvalues
.line_width
= 1;
51 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
52 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
55 m_backgroundPixel
= (int) gcvalues
.background
;
57 SetBrush (* wxWHITE_BRUSH
);
58 SetPen (* wxBLACK_PEN
);
59 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
62 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
65 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
66 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
68 m_display
= wxGetDisplay();
70 Display
* display
= (Display
*) m_display
;
73 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
74 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
75 gcvalues
.graphics_exposures
= False
;
76 gcvalues
.subwindow_mode
= IncludeInferiors
;
77 gcvalues
.line_width
= 1;
78 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
79 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
82 m_backgroundPixel
= (int) gcvalues
.background
;
84 SetBrush (* wxWHITE_BRUSH
);
85 SetPen (* wxBLACK_PEN
);
88 wxMemoryDC::~wxMemoryDC(void)
92 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
97 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
100 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
102 m_pixmap
= m_bitmap
.GetDrawable();
103 Display
* display
= (Display
*) m_display
;
106 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
107 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
108 gcvalues
.graphics_exposures
= False
;
109 gcvalues
.subwindow_mode
= IncludeInferiors
;
110 gcvalues
.line_width
= 1;
111 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
112 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
115 m_backgroundPixel
= (int) gcvalues
.background
;
118 SetBrush (* wxWHITE_BRUSH
);
119 SetPen (* wxBLACK_PEN
);
124 m_pixmap
= (WXPixmap
) 0;
128 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
132 if (width
) (*width
) = m_bitmap
.GetWidth();
133 if (height
) (*height
) = m_bitmap
.GetHeight();
137 if (width
) (*width
) = 0;
138 if (height
) (*height
) = 0;