]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "dcmemory.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
17 #include "wx/dcmemory.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
,wxWindowDC
)
28 wxMemoryDC::wxMemoryDC() : wxWindowDC()
32 m_cmap
= gtk_widget_get_default_colormap();
35 m_context
= gdk_pango_context_get();
36 m_layout
= pango_layout_new( m_context
);
37 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
41 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
46 m_cmap
= gtk_widget_get_default_colormap();
49 m_context
= gdk_pango_context_get();
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;