]>
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() : wxWindowDC()
28 m_cmap
= gtk_widget_get_default_colormap();
31 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
36 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
& penOrig
)
73 if ( m_selected
.Ok() &&
74 m_selected
.GetBitmap() &&
75 (pen
!= *wxTRANSPARENT_PEN
) )
77 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
80 wxWindowDC::SetPen( pen
);
83 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
85 wxBrush
brush( brushOrig
);
86 if ( m_selected
.Ok() &&
87 m_selected
.GetBitmap() &&
88 (brush
!= *wxTRANSPARENT_BRUSH
) )
90 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
93 wxWindowDC::SetBrush( brush
);
96 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
98 wxBrush
brush(brushOrig
);
100 if ( m_selected
.Ok() &&
101 m_selected
.GetBitmap() &&
102 (brush
!= *wxTRANSPARENT_BRUSH
) )
104 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
107 wxWindowDC::SetBackground( brush
);
110 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
112 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
114 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
118 wxWindowDC::SetTextForeground( col
);
122 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
124 if (m_selected
.Ok() && m_selected
.GetBitmap())
126 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
130 wxWindowDC::SetTextBackground( col
);
134 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
138 if (width
) (*width
) = m_selected
.GetWidth();
139 if (height
) (*height
) = m_selected
.GetHeight();
143 if (width
) (*width
) = 0;
144 if (height
) (*height
) = 0;