]>
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();
81 m_window
= (GdkWindow
*) NULL
;
85 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
88 if ( m_selected
.Ok() &&
89 m_selected
.GetBitmap() &&
90 (pen
!= *wxTRANSPARENT_PEN
) )
92 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
95 wxWindowDC::SetPen( pen
);
98 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
100 wxBrush
brush( brushOrig
);
101 if ( m_selected
.Ok() &&
102 m_selected
.GetBitmap() &&
103 (brush
!= *wxTRANSPARENT_BRUSH
) )
105 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
108 wxWindowDC::SetBrush( brush
);
111 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
113 wxBrush
brush(brushOrig
);
115 if ( m_selected
.Ok() &&
116 m_selected
.GetBitmap() &&
117 (brush
!= *wxTRANSPARENT_BRUSH
) )
119 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
122 wxWindowDC::SetBackground( brush
);
125 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
127 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
129 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
133 wxWindowDC::SetTextForeground( col
);
137 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
139 if (m_selected
.Ok() && m_selected
.GetBitmap())
141 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
145 wxWindowDC::SetTextBackground( col
);
149 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
153 if (width
) (*width
) = m_selected
.GetWidth();
154 if (height
) (*height
) = m_selected
.GetHeight();
158 if (width
) (*width
) = 0;
159 if (height
) (*height
) = 0;