]>
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( const wxBitmap
& bitmap
)
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
= gcvalues
.background
;
57 SetBrush (* wxWHITE_BRUSH
);
58 SetPen (* wxBLACK_PEN
);
59 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
65 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
68 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
69 m_display
= ((wxWindowDC
*)dc
)->GetDisplay();
71 m_display
= wxGetDisplay();
73 Display
* display
= (Display
*) m_display
;
76 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
77 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
78 gcvalues
.graphics_exposures
= False
;
79 gcvalues
.subwindow_mode
= IncludeInferiors
;
80 gcvalues
.line_width
= 1;
81 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
82 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
85 m_backgroundPixel
= gcvalues
.background
;
87 SetBrush (* wxWHITE_BRUSH
);
88 SetPen (* wxBLACK_PEN
);
91 wxMemoryDC::~wxMemoryDC(void)
95 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
100 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
103 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
105 m_pixmap
= m_bitmap
.GetDrawable();
106 Display
* display
= (Display
*) m_display
;
109 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
110 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
111 gcvalues
.graphics_exposures
= False
;
112 gcvalues
.subwindow_mode
= IncludeInferiors
;
113 gcvalues
.line_width
= 1;
114 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
115 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
118 m_backgroundPixel
= gcvalues
.background
;
121 SetBrush (* wxWHITE_BRUSH
);
122 SetPen (* wxBLACK_PEN
);
127 m_pixmap
= (WXPixmap
) 0;
131 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
135 if (width
) (*width
) = m_bitmap
.GetWidth();
136 if (height
) (*height
) = m_bitmap
.GetHeight();
140 if (width
) (*width
) = 0;
141 if (height
) (*height
) = 0;