]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
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 m_context
= gdk_pango_context_get();
32 m_layout
= pango_layout_new( m_context
);
33 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
37 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
42 m_cmap
= gtk_widget_get_default_colormap();
45 m_context
= gdk_pango_context_get();
46 m_layout
= pango_layout_new( m_context
);
47 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
51 wxMemoryDC::~wxMemoryDC()
54 g_object_unref(m_context
);
58 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
64 if (m_selected
.GetPixmap())
66 m_window
= m_selected
.GetPixmap();
70 m_window
= m_selected
.GetBitmap();
74 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
84 m_window
= (GdkWindow
*) NULL
;
88 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
91 if ( m_selected
.Ok() &&
92 m_selected
.GetBitmap() &&
93 (pen
!= *wxTRANSPARENT_PEN
) )
95 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
98 wxWindowDC::SetPen( pen
);
101 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
103 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::SetBrush( brush
);
114 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
116 wxBrush
brush(brushOrig
);
118 if ( m_selected
.Ok() &&
119 m_selected
.GetBitmap() &&
120 (brush
!= *wxTRANSPARENT_BRUSH
) )
122 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
125 wxWindowDC::SetBackground( brush
);
128 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
130 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
132 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
136 wxWindowDC::SetTextForeground( col
);
140 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
142 if (m_selected
.Ok() && m_selected
.GetBitmap())
144 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
148 wxWindowDC::SetTextBackground( col
);
152 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
156 if (width
) (*width
) = m_selected
.GetWidth();
157 if (height
) (*height
) = m_selected
.GetHeight();
161 if (width
) (*width
) = 0;
162 if (height
) (*height
) = 0;