1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/dcmemory.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
12 #include "wx/gtk1/dcmemory.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
)
23 void wxMemoryDCImpl
::Init()
27 m_cmap
= gtk_widget_get_default_colormap();
30 wxMemoryDCImpl
::wxMemoryDCImpl(wxMemoryDC
*owner
, wxDC
*WXUNUSED(dc
))
31 : wxWindowDCImpl(owner
)
36 wxMemoryDCImpl
::~wxMemoryDCImpl()
40 void wxMemoryDCImpl
::DoSelect( const wxBitmap
& bitmap
)
45 if (m_selected
.IsOk())
47 if (m_selected
.GetPixmap())
49 m_window
= m_selected
.GetPixmap();
53 m_window
= m_selected
.GetBitmap();
67 void wxMemoryDCImpl
::SetPen( const wxPen
& penOrig
)
70 if ( m_selected
.IsOk() &&
71 m_selected
.GetBitmap() &&
72 (pen
!= *wxTRANSPARENT_PEN
) )
74 pen
.SetColour( pen
.GetColour() == *wxWHITE ?
*wxBLACK
: *wxWHITE
);
77 wxWindowDCImpl
::SetPen( pen
);
80 void wxMemoryDCImpl
::SetBrush( const wxBrush
& brushOrig
)
82 wxBrush
brush( brushOrig
);
83 if ( m_selected
.IsOk() &&
84 m_selected
.GetBitmap() &&
85 (brush
!= *wxTRANSPARENT_BRUSH
) )
87 brush
.SetColour( brush
.GetColour() == *wxWHITE ?
*wxBLACK
: *wxWHITE
);
90 wxWindowDCImpl
::SetBrush( brush
);
93 void wxMemoryDCImpl
::SetBackground( const wxBrush
& brushOrig
)
95 wxBrush
brush(brushOrig
);
97 if ( m_selected
.IsOk() &&
98 m_selected
.GetBitmap() &&
99 (brush
!= *wxTRANSPARENT_BRUSH
) )
101 brush
.SetColour( brush
.GetColour() == *wxWHITE ?
*wxBLACK
: *wxWHITE
);
104 wxWindowDCImpl
::SetBackground( brush
);
107 void wxMemoryDCImpl
::SetTextForeground( const wxColour
& col
)
109 if ( m_selected
.IsOk() && m_selected
.GetBitmap() )
111 wxWindowDCImpl
::SetTextForeground( col
== *wxWHITE ?
*wxBLACK
: *wxWHITE
);
115 wxWindowDCImpl
::SetTextForeground( col
);
119 void wxMemoryDCImpl
::SetTextBackground( const wxColour
&col
)
121 if (m_selected
.IsOk() && m_selected
.GetBitmap())
123 wxWindowDCImpl
::SetTextBackground( col
== *wxWHITE ?
*wxBLACK
: *wxWHITE
);
127 wxWindowDCImpl
::SetTextBackground( col
);
131 void wxMemoryDCImpl
::DoGetSize( int *width
, int *height
) const
133 if (m_selected
.IsOk())
135 if (width
) (*width
) = m_selected
.GetWidth();
136 if (height
) (*height
) = m_selected
.GetHeight();
140 if (width
) (*width
) = 0;
141 if (height
) (*height
) = 0;