]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
d77d307dc5c3c76da744cbfb1ecd0bc61937dc94
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dcmemory.cpp
4 // Author: Robert Roebling
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/dcmemory.h"
14 #include "wx/gtk/dcmemory.h"
19 #if wxUSE_GRAPHICS_CONTEXT
20 #include "wx/graphics.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
)
29 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
)
30 : wxWindowDCImpl( owner
)
35 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxBitmap
& bitmap
)
36 : wxWindowDCImpl( owner
)
42 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC
*owner
, wxDC
*WXUNUSED(dc
) )
43 : wxWindowDCImpl( owner
)
48 wxMemoryDCImpl::~wxMemoryDCImpl()
50 g_object_unref(m_context
);
53 void wxMemoryDCImpl::Init()
57 m_cmap
= gtk_widget_get_default_colormap();
59 m_context
= gdk_pango_context_get();
60 // Note: The Sun customised version of Pango shipping with Solaris 10
61 // crashes if the language is left NULL (see bug 1374114)
62 pango_context_set_language( m_context
, gtk_get_default_language() );
63 m_layout
= pango_layout_new( m_context
);
64 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
67 #if wxUSE_GRAPHICS_CONTEXT
68 wxGraphicsContext
* wxMemoryDCImpl::CreateGraphicsContext()
70 wxMemoryDC
*memdc
= (wxMemoryDC
*) GetOwner();
71 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc
);
75 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap
)
82 m_gdkwindow
= m_selected
.GetPixmap();
84 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
91 m_gdkwindow
= (GdkWindow
*) NULL
;
95 void wxMemoryDCImpl::SetPen( const wxPen
& penOrig
)
98 if ( m_selected
.Ok() &&
99 m_selected
.GetDepth() == 1 &&
100 (pen
!= *wxTRANSPARENT_PEN
) )
102 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
105 wxWindowDCImpl::SetPen( pen
);
108 void wxMemoryDCImpl::SetBrush( const wxBrush
& brushOrig
)
110 wxBrush
brush( brushOrig
);
111 if ( m_selected
.Ok() &&
112 m_selected
.GetDepth() == 1 &&
113 (brush
!= *wxTRANSPARENT_BRUSH
) )
115 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
118 wxWindowDCImpl::SetBrush( brush
);
121 void wxMemoryDCImpl::SetBackground( const wxBrush
& brushOrig
)
123 wxBrush
brush(brushOrig
);
125 if ( m_selected
.Ok() &&
126 m_selected
.GetDepth() == 1 &&
127 (brush
!= *wxTRANSPARENT_BRUSH
) )
129 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
132 wxWindowDCImpl::SetBackground( brush
);
135 void wxMemoryDCImpl::SetTextForeground( const wxColour
& col
)
137 if ( m_selected
.Ok() && m_selected
.GetDepth() == 1 )
138 wxWindowDCImpl::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
140 wxWindowDCImpl::SetTextForeground( col
);
143 void wxMemoryDCImpl::SetTextBackground( const wxColour
&col
)
145 if (m_selected
.Ok() && m_selected
.GetDepth() == 1)
146 wxWindowDCImpl::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
148 wxWindowDCImpl::SetTextBackground( col
);
151 void wxMemoryDCImpl::DoGetSize( int *width
, int *height
) const
155 if (width
) (*width
) = m_selected
.GetWidth();
156 if (height
) (*height
) = m_selected
.GetHeight();
160 if (width
) (*width
) = 0;
161 if (height
) (*height
) = 0;
165 wxBitmap
wxMemoryDCImpl::DoGetAsBitmap(const wxRect
*subrect
) const
167 wxBitmap bmp
= GetSelectedBitmap();
168 return subrect
? bmp
.GetSubBitmap(*subrect
) : bmp
;
171 const wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap() const
176 wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap()