]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dcmemory.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
12 #include "wx/gtk/dcmemory.h"
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
)
22 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
)
23 : wxWindowDCImpl( owner
)
28 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxBitmap
& bitmap
)
29 : wxWindowDCImpl( owner
)
35 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxDC
*WXUNUSED(dc
) )
36 : wxWindowDCImpl( owner
)
41 wxMemoryDCImpl::~wxMemoryDCImpl()
43 g_object_unref(m_context
);
46 void wxMemoryDCImpl::Init()
50 m_cmap
= gtk_widget_get_default_colormap();
52 m_context
= gdk_pango_context_get();
53 // Note: The Sun customised version of Pango shipping with Solaris 10
54 // crashes if the language is left NULL (see bug 1374114)
55 pango_context_set_language( m_context
, gtk_get_default_language() );
56 m_layout
= pango_layout_new( m_context
);
57 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
60 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap
)
65 if (m_selected
.IsOk())
67 m_gdkwindow
= m_selected
.GetPixmap();
69 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
80 void wxMemoryDCImpl::SetPen( const wxPen
& penOrig
)
83 if ( m_selected
.IsOk() &&
84 m_selected
.GetDepth() == 1 &&
85 (pen
!= *wxTRANSPARENT_PEN
) )
87 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
90 wxWindowDCImpl::SetPen( pen
);
93 void wxMemoryDCImpl::SetBrush( const wxBrush
& brushOrig
)
95 wxBrush
brush( brushOrig
);
96 if ( m_selected
.IsOk() &&
97 m_selected
.GetDepth() == 1 &&
98 (brush
!= *wxTRANSPARENT_BRUSH
) )
100 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
103 wxWindowDCImpl::SetBrush( brush
);
106 void wxMemoryDCImpl::SetBackground( const wxBrush
& brushOrig
)
108 wxBrush
brush(brushOrig
);
110 if ( m_selected
.IsOk() &&
111 m_selected
.GetDepth() == 1 &&
112 (brush
!= *wxTRANSPARENT_BRUSH
) )
114 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
117 wxWindowDCImpl::SetBackground( brush
);
120 void wxMemoryDCImpl::SetTextForeground( const wxColour
& col
)
122 if ( m_selected
.IsOk() && m_selected
.GetDepth() == 1 )
123 wxWindowDCImpl::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
125 wxWindowDCImpl::SetTextForeground( col
);
128 void wxMemoryDCImpl::SetTextBackground( const wxColour
&col
)
130 if (m_selected
.IsOk() && m_selected
.GetDepth() == 1)
131 wxWindowDCImpl::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
133 wxWindowDCImpl::SetTextBackground( col
);
136 void wxMemoryDCImpl::DoGetSize( int *width
, int *height
) const
138 if (m_selected
.IsOk())
140 if (width
) (*width
) = m_selected
.GetWidth();
141 if (height
) (*height
) = m_selected
.GetHeight();
145 if (width
) (*width
) = 0;
146 if (height
) (*height
) = 0;
150 wxBitmap
wxMemoryDCImpl::DoGetAsBitmap(const wxRect
*subrect
) const
152 wxBitmap bmp
= GetSelectedBitmap();
153 return subrect
? bmp
.GetSubBitmap(*subrect
) : bmp
;
156 const wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap() const
161 wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap()
166 void* wxMemoryDCImpl::GetHandle() const
168 const wxBitmap
& bmp
= GetSelectedBitmap();
169 return bmp
.GetPixmap();