]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/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();
30 m_context
= gdk_pango_context_get();
31 // Note: The Sun customised version of Pango shipping with Solaris 10
32 // crashes if the language is left NULL (see bug 1374114)
33 pango_context_set_language( m_context
, gtk_get_default_language() );
34 m_layout
= pango_layout_new( m_context
);
35 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();
45 m_context
= gdk_pango_context_get();
46 pango_context_set_language( m_context
, gtk_get_default_language() );
47 m_layout
= pango_layout_new( m_context
);
48 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
51 wxMemoryDC::~wxMemoryDC()
53 g_object_unref(m_context
);
56 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
62 m_window
= m_selected
.GetPixmap();
64 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
73 m_window
= (GdkWindow
*) NULL
;
77 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
80 if ( m_selected
.Ok() &&
81 m_selected
.GetDepth() == 1 &&
82 (pen
!= *wxTRANSPARENT_PEN
) )
84 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
87 wxWindowDC::SetPen( pen
);
90 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
92 wxBrush
brush( brushOrig
);
93 if ( m_selected
.Ok() &&
94 m_selected
.GetDepth() == 1 &&
95 (brush
!= *wxTRANSPARENT_BRUSH
) )
97 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
100 wxWindowDC::SetBrush( brush
);
103 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
105 wxBrush
brush(brushOrig
);
107 if ( m_selected
.Ok() &&
108 m_selected
.GetDepth() == 1 &&
109 (brush
!= *wxTRANSPARENT_BRUSH
) )
111 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
114 wxWindowDC::SetBackground( brush
);
117 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
119 if ( m_selected
.Ok() && m_selected
.GetDepth() == 1 )
121 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
125 wxWindowDC::SetTextForeground( col
);
129 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
131 if (m_selected
.Ok() && m_selected
.GetDepth() == 1)
133 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
137 wxWindowDC::SetTextBackground( col
);
141 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
145 if (width
) (*width
) = m_selected
.GetWidth();
146 if (height
) (*height
) = m_selected
.GetHeight();
150 if (width
) (*width
) = 0;
151 if (height
) (*height
) = 0;