]>
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( const wxBitmap
& bitmap
)
29 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
) );
42 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
47 m_cmap
= gtk_widget_get_default_colormap();
49 m_context
= gdk_pango_context_get();
50 pango_context_set_language( m_context
, gtk_get_default_language() );
51 m_layout
= pango_layout_new( m_context
);
52 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
55 wxMemoryDC::~wxMemoryDC()
57 g_object_unref(m_context
);
60 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
66 m_window
= m_selected
.GetPixmap();
68 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
77 m_window
= (GdkWindow
*) NULL
;
81 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
84 if ( m_selected
.Ok() &&
85 m_selected
.GetDepth() == 1 &&
86 (pen
!= *wxTRANSPARENT_PEN
) )
88 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
91 wxWindowDC::SetPen( pen
);
94 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
96 wxBrush
brush( brushOrig
);
97 if ( m_selected
.Ok() &&
98 m_selected
.GetDepth() == 1 &&
99 (brush
!= *wxTRANSPARENT_BRUSH
) )
101 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
104 wxWindowDC::SetBrush( brush
);
107 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
109 wxBrush
brush(brushOrig
);
111 if ( m_selected
.Ok() &&
112 m_selected
.GetDepth() == 1 &&
113 (brush
!= *wxTRANSPARENT_BRUSH
) )
115 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
118 wxWindowDC::SetBackground( brush
);
121 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
123 if ( m_selected
.Ok() && m_selected
.GetDepth() == 1 )
125 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
129 wxWindowDC::SetTextForeground( col
);
133 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
135 if (m_selected
.Ok() && m_selected
.GetDepth() == 1)
137 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
141 wxWindowDC::SetTextBackground( col
);
145 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
149 if (width
) (*width
) = m_selected
.GetWidth();
150 if (height
) (*height
) = m_selected
.GetHeight();
154 if (width
) (*width
) = 0;
155 if (height
) (*height
) = 0;