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
)
50 if (m_selected
.GetPixmap())
52 m_window
= m_selected
.GetPixmap();
56 m_window
= m_selected
.GetBitmap();
66 m_window
= (GdkWindow
*) NULL
;
70 void wxMemoryDC
::SetPen( const wxPen
&pen
)
72 if (m_selected
.Ok() && m_selected
.GetBitmap() && (*wxTRANSPARENT_PEN
!= pen
))
74 if (*wxWHITE_PEN
== pen
)
75 wxWindowDC
::SetPen( *wxBLACK_PEN
);
77 wxWindowDC
::SetPen( *wxWHITE_PEN
);
81 wxWindowDC
::SetPen( pen
);
85 void wxMemoryDC
::SetBrush( const wxBrush
&brush
)
87 if (m_selected
.Ok() && m_selected
.GetBitmap() && (*wxTRANSPARENT_BRUSH
!= brush
))
89 if (*wxWHITE_BRUSH
== brush
)
90 wxWindowDC
::SetBrush( *wxBLACK_BRUSH
);
92 wxWindowDC
::SetBrush( *wxWHITE_BRUSH
);
96 wxWindowDC
::SetBrush( brush
);
100 void wxMemoryDC
::SetTextForeground( const wxColour
&col
)
102 if (m_selected
.Ok() && m_selected
.GetBitmap())
105 wxWindowDC
::SetTextForeground( *wxBLACK
);
107 wxWindowDC
::SetTextForeground( *wxWHITE
);
111 wxWindowDC
::SetTextForeground( col
);
115 void wxMemoryDC
::SetTextBackground( const wxColour
&col
)
117 if (m_selected
.Ok() && m_selected
.GetBitmap())
120 wxWindowDC
::SetTextBackground( *wxBLACK
);
122 wxWindowDC
::SetTextBackground( *wxWHITE
);
126 wxWindowDC
::SetTextBackground( col
);
130 void wxMemoryDC
::DoGetSize( int *width
, int *height
) const
134 if (width
) (*width
) = m_selected
.GetWidth();
135 if (height
) (*height
) = m_selected
.GetHeight();
139 if (width
) (*width
) = 0;
140 if (height
) (*height
) = 0;