1
/////////////////////////////////////////////////////////////////////////////
2
// Name: src/gtk/dcmemory.cpp
4
// Author: Robert Roebling
5
// RCS-ID: $Id: dcmemory.cpp 70809 2012-03-04 23:50:35Z PC $
6
// Copyright: (c) 1998 Robert Roebling
7
// Licence: wxWindows licence
8
/////////////////////////////////////////////////////////////////////////////
10
// For compilers that support precompilation, includes "wx.h".
11
#include "wx/wxprec.h"
13
#include "wx/gtk/dcmemory.h"
17
//-----------------------------------------------------------------------------
19
//-----------------------------------------------------------------------------
21
IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl)
23
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner )
24
: wxWindowDCImpl( owner )
29
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap)
30
: wxWindowDCImpl( owner )
36
wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) )
37
: wxWindowDCImpl( owner )
42
wxMemoryDCImpl::~wxMemoryDCImpl()
44
g_object_unref(m_context);
47
void wxMemoryDCImpl::Init()
51
m_cmap = gtk_widget_get_default_colormap();
53
m_context = gdk_pango_context_get();
54
// Note: The Sun customised version of Pango shipping with Solaris 10
55
// crashes if the language is left NULL (see bug 1374114)
56
pango_context_set_language( m_context, gtk_get_default_language() );
57
m_layout = pango_layout_new( m_context );
58
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
61
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
66
if (m_selected.IsOk())
68
m_gdkwindow = m_selected.GetPixmap();
70
m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
81
void wxMemoryDCImpl::SetPen( const wxPen& penOrig )
84
if ( m_selected.IsOk() &&
85
m_selected.GetDepth() == 1 &&
86
(pen != *wxTRANSPARENT_PEN) )
88
pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
91
wxWindowDCImpl::SetPen( pen );
94
void wxMemoryDCImpl::SetBrush( const wxBrush& brushOrig )
96
wxBrush brush( brushOrig );
97
if ( m_selected.IsOk() &&
98
m_selected.GetDepth() == 1 &&
99
(brush != *wxTRANSPARENT_BRUSH) )
101
brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
104
wxWindowDCImpl::SetBrush( brush );
107
void wxMemoryDCImpl::SetBackground( const wxBrush& brushOrig )
109
wxBrush brush(brushOrig);
111
if ( m_selected.IsOk() &&
112
m_selected.GetDepth() == 1 &&
113
(brush != *wxTRANSPARENT_BRUSH) )
115
brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
118
wxWindowDCImpl::SetBackground( brush );
121
void wxMemoryDCImpl::SetTextForeground( const wxColour& col )
123
if ( m_selected.IsOk() && m_selected.GetDepth() == 1 )
124
wxWindowDCImpl::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
126
wxWindowDCImpl::SetTextForeground( col );
129
void wxMemoryDCImpl::SetTextBackground( const wxColour &col )
131
if (m_selected.IsOk() && m_selected.GetDepth() == 1)
132
wxWindowDCImpl::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
134
wxWindowDCImpl::SetTextBackground( col );
137
void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
139
if (m_selected.IsOk())
141
if (width) (*width) = m_selected.GetWidth();
142
if (height) (*height) = m_selected.GetHeight();
146
if (width) (*width) = 0;
147
if (height) (*height) = 0;
151
wxBitmap wxMemoryDCImpl::DoGetAsBitmap(const wxRect *subrect) const
153
wxBitmap bmp = GetSelectedBitmap();
154
return subrect ? bmp.GetSubBitmap(*subrect) : bmp;
157
const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
162
wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()