]>
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 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "dcmemory.h"
14 #include "wx/dcmemory.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
,wxWindowDC
)
25 wxMemoryDC::wxMemoryDC() : wxWindowDC()
29 m_cmap
= gtk_widget_get_default_colormap();
32 m_context
= gdk_pango_context_get();
33 m_layout
= pango_layout_new( m_context
);
34 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();
46 m_context
= gdk_pango_context_get();
47 m_layout
= pango_layout_new( m_context
);
48 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
52 wxMemoryDC::~wxMemoryDC()
56 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
62 if (m_selected
.GetPixmap())
64 m_window
= m_selected
.GetPixmap();
68 m_window
= m_selected
.GetBitmap();
78 m_window
= (GdkWindow
*) NULL
;
82 void wxMemoryDC::SetPen( const wxPen
& penOrig
)
85 if ( m_selected
.Ok() &&
86 m_selected
.GetBitmap() &&
87 (pen
!= *wxTRANSPARENT_PEN
) )
89 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
92 wxWindowDC::SetPen( pen
);
95 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig
)
97 wxBrush
brush( brushOrig
);
98 if ( m_selected
.Ok() &&
99 m_selected
.GetBitmap() &&
100 (brush
!= *wxTRANSPARENT_BRUSH
) )
102 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
105 wxWindowDC::SetBrush( brush
);
108 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig
)
110 wxBrush
brush(brushOrig
);
112 if ( m_selected
.Ok() &&
113 m_selected
.GetBitmap() &&
114 (brush
!= *wxTRANSPARENT_BRUSH
) )
116 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
119 wxWindowDC::SetBackground( brush
);
122 void wxMemoryDC::SetTextForeground( const wxColour
& col
)
124 if ( m_selected
.Ok() && m_selected
.GetBitmap() )
126 wxWindowDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
130 wxWindowDC::SetTextForeground( col
);
134 void wxMemoryDC::SetTextBackground( const wxColour
&col
)
136 if (m_selected
.Ok() && m_selected
.GetBitmap())
138 wxWindowDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
142 wxWindowDC::SetTextBackground( col
);
146 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
150 if (width
) (*width
) = m_selected
.GetWidth();
151 if (height
) (*height
) = m_selected
.GetHeight();
155 if (width
) (*width
) = 0;
156 if (height
) (*height
) = 0;