1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "dcmemory.h"
14 #include "wx/dcmemory.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
,wxWindowDC
)
25 wxMemoryDC
::wxMemoryDC() : wxWindowDC()
29 m_cmap
= gtk_widget_get_default_colormap();
32 wxMemoryDC
::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
37 m_cmap
= gtk_widget_get_default_colormap();
40 wxMemoryDC
::~wxMemoryDC()
44 void wxMemoryDC
::SelectObject( const wxBitmap
& bitmap
)
49 if (m_selected
.GetPixmap())
51 m_window
= m_selected
.GetPixmap();
55 m_window
= m_selected
.GetBitmap();
65 m_window
= (GdkWindow
*) NULL
;
69 void wxMemoryDC
::SetPen( const wxPen
&pen
)
71 if (m_selected
.Ok() && m_selected
.GetBitmap() && (*wxTRANSPARENT_PEN
!= pen
))
73 if (*wxWHITE_PEN
== pen
)
74 wxWindowDC
::SetPen( *wxBLACK_PEN
);
76 wxWindowDC
::SetPen( *wxWHITE_PEN
);
80 wxWindowDC
::SetPen( pen
);
84 void wxMemoryDC
::SetBrush( const wxBrush
&brush
)
86 if (m_selected
.Ok() && m_selected
.GetBitmap() && (*wxTRANSPARENT_BRUSH
!= brush
))
88 if (*wxWHITE_BRUSH
== brush
)
89 wxWindowDC
::SetBrush( *wxBLACK_BRUSH
);
91 wxWindowDC
::SetBrush( *wxWHITE_BRUSH
);
95 wxWindowDC
::SetBrush( brush
);
99 void wxMemoryDC
::SetTextForeground( const wxColour
&col
)
101 if (m_selected
.Ok() && m_selected
.GetBitmap())
104 wxWindowDC
::SetTextForeground( *wxBLACK
);
106 wxWindowDC
::SetTextForeground( *wxWHITE
);
110 wxWindowDC
::SetTextForeground( col
);
114 void wxMemoryDC
::SetTextBackground( const wxColour
&col
)
116 if (m_selected
.Ok() && m_selected
.GetBitmap())
119 wxWindowDC
::SetTextBackground( *wxBLACK
);
121 wxWindowDC
::SetTextBackground( *wxWHITE
);
125 wxWindowDC
::SetTextBackground( col
);
129 void wxMemoryDC
::DoGetSize( int *width
, int *height
) const
133 if (width
) (*width
) = m_selected
.GetWidth();
134 if (height
) (*height
) = m_selected
.GetHeight();
138 if (width
) (*width
) = 0;
139 if (height
) (*height
) = 0;