]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/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 pango_context_set_language( m_context
, gtk_get_default_language() );
33 m_layout
= pango_layout_new( m_context
);
34 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
38 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
43 m_cmap
= gtk_widget_get_default_colormap();
46 m_context
= gdk_pango_context_get();
47 pango_context_set_language( m_context
, gtk_get_default_language() );
48 m_layout
= pango_layout_new( m_context
);
49 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
53 wxMemoryDC::~wxMemoryDC()
56 g_object_unref(m_context
);
60 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
66 if (m_selected
.GetPixmap())
68 m_window
= m_selected
.GetPixmap();
72 m_window
= m_selected
.GetBitmap();
76 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
86 m_window
= (GdkWindow
*) NULL
;
90 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
93 if ( m_selected
.Ok() &&
94 m_selected
.GetBitmap() &&
95 (pen
!= *wxTRANSPARENT_PEN
) )
97 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
100 wxWindowDC::SetPen( pen
);
103 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
105 wxBrush
brush( brushOrig
);
106 if ( m_selected
.Ok() &&
107 m_selected
.GetBitmap() &&
108 (brush
!= *wxTRANSPARENT_BRUSH
) )
110 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
113 wxWindowDC::SetBrush( brush
);
116 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
118 wxBrush
brush(brushOrig
);
120 if ( m_selected
.Ok() &&
121 m_selected
.GetBitmap() &&
122 (brush
!= *wxTRANSPARENT_BRUSH
) )
124 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
127 wxWindowDC::SetBackground( brush
);
130 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
132 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
134 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
138 wxWindowDC::SetTextForeground( col
);
142 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
144 if (m_selected
.Ok() && m_selected
.GetBitmap())
146 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
150 wxWindowDC::SetTextBackground( col
);
154 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
158 if (width
) (*width
) = m_selected
.GetWidth();
159 if (height
) (*height
) = m_selected
.GetHeight();
163 if (width
) (*width
) = 0;
164 if (height
) (*height
) = 0;