]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/dcmemory.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #include "wx/dcmemory.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
,wxWindowDC
)
24 wxMemoryDC::wxMemoryDC( const wxBitmap
& bitmap
)
29 m_cmap
= gtk_widget_get_default_colormap();
35 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
40 m_cmap
= gtk_widget_get_default_colormap();
44 wxMemoryDC::~wxMemoryDC()
48 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
54 if (m_selected
.GetPixmap())
56 m_window
= m_selected
.GetPixmap();
60 m_window
= m_selected
.GetBitmap();
70 m_window
= (GdkWindow
*) NULL
;
74 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
77 if ( m_selected
.Ok() &&
78 m_selected
.GetBitmap() &&
79 (pen
!= *wxTRANSPARENT_PEN
) )
81 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
84 wxWindowDC::SetPen( pen
);
87 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
89 wxBrush
brush( brushOrig
);
90 if ( m_selected
.Ok() &&
91 m_selected
.GetBitmap() &&
92 (brush
!= *wxTRANSPARENT_BRUSH
) )
94 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
97 wxWindowDC::SetBrush( brush
);
100 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
102 wxBrush
brush(brushOrig
);
104 if ( m_selected
.Ok() &&
105 m_selected
.GetBitmap() &&
106 (brush
!= *wxTRANSPARENT_BRUSH
) )
108 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
111 wxWindowDC::SetBackground( brush
);
114 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
116 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
118 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
122 wxWindowDC::SetTextForeground( col
);
126 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
128 if (m_selected
.Ok() && m_selected
.GetBitmap())
130 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
134 wxWindowDC::SetTextBackground( col
);
138 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
142 if (width
) (*width
) = m_selected
.GetWidth();
143 if (height
) (*height
) = m_selected
.GetHeight();
147 if (width
) (*width
) = 0;
148 if (height
) (*height
) = 0;