]>
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()
59 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
65 if (m_selected
.GetPixmap())
67 m_window
= m_selected
.GetPixmap();
71 m_window
= m_selected
.GetBitmap();
75 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
85 m_window
= (GdkWindow
*) NULL
;
89 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
92 if ( m_selected
.Ok() &&
93 m_selected
.GetBitmap() &&
94 (pen
!= *wxTRANSPARENT_PEN
) )
96 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
99 wxWindowDC::SetPen( pen
);
102 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
104 wxBrush
brush( brushOrig
);
105 if ( m_selected
.Ok() &&
106 m_selected
.GetBitmap() &&
107 (brush
!= *wxTRANSPARENT_BRUSH
) )
109 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
112 wxWindowDC::SetBrush( brush
);
115 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
117 wxBrush
brush(brushOrig
);
119 if ( m_selected
.Ok() &&
120 m_selected
.GetBitmap() &&
121 (brush
!= *wxTRANSPARENT_BRUSH
) )
123 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
126 wxWindowDC::SetBackground( brush
);
129 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
131 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
133 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
137 wxWindowDC::SetTextForeground( col
);
141 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
143 if (m_selected
.Ok() && m_selected
.GetBitmap())
145 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
149 wxWindowDC::SetTextBackground( col
);
153 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
157 if (width
) (*width
) = m_selected
.GetWidth();
158 if (height
) (*height
) = m_selected
.GetHeight();
162 if (width
) (*width
) = 0;
163 if (height
) (*height
) = 0;