]>
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 // Note: The Sun customised version of Pango shipping with Solaris 10
33 // crashes if the language is left NULL (see bug 1374114)
34 pango_context_set_language( m_context
, gtk_get_default_language() );
35 m_layout
= pango_layout_new( m_context
);
36 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
40 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
45 m_cmap
= gtk_widget_get_default_colormap();
48 m_context
= gdk_pango_context_get();
49 pango_context_set_language( m_context
, gtk_get_default_language() );
50 m_layout
= pango_layout_new( m_context
);
51 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
55 wxMemoryDC::~wxMemoryDC()
58 g_object_unref(m_context
);
62 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
68 if (m_selected
.GetPixmap())
70 m_window
= m_selected
.GetPixmap();
74 m_window
= m_selected
.GetBitmap();
78 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
88 m_window
= (GdkWindow
*) NULL
;
92 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
95 if ( m_selected
.Ok() &&
96 m_selected
.GetBitmap() &&
97 (pen
!= *wxTRANSPARENT_PEN
) )
99 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
102 wxWindowDC::SetPen( pen
);
105 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
107 wxBrush
brush( brushOrig
);
108 if ( m_selected
.Ok() &&
109 m_selected
.GetBitmap() &&
110 (brush
!= *wxTRANSPARENT_BRUSH
) )
112 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
115 wxWindowDC::SetBrush( brush
);
118 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
120 wxBrush
brush(brushOrig
);
122 if ( m_selected
.Ok() &&
123 m_selected
.GetBitmap() &&
124 (brush
!= *wxTRANSPARENT_BRUSH
) )
126 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
129 wxWindowDC::SetBackground( brush
);
132 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
134 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
136 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
140 wxWindowDC::SetTextForeground( col
);
144 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
146 if (m_selected
.Ok() && m_selected
.GetBitmap())
148 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
152 wxWindowDC::SetTextBackground( col
);
156 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
160 if (width
) (*width
) = m_selected
.GetWidth();
161 if (height
) (*height
) = m_selected
.GetHeight();
165 if (width
) (*width
) = 0;
166 if (height
) (*height
) = 0;