]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/dcmemory.cpp
Remove obsolete header used only with CodeWarrior MetroWerks compiler.
[wxWidgets.git] / src / gtk / dcmemory.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
f38924e8 2// Name: src/gtk/dcmemory.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
6f65e337 5// RCS-ID: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
888dde65 13#include "wx/gtk/dcmemory.h"
c801d85f 14
071a2d78 15#include <gtk/gtk.h>
83624f79 16
c801d85f 17//-----------------------------------------------------------------------------
888dde65 18// wxMemoryDCImpl
c801d85f
KB
19//-----------------------------------------------------------------------------
20
888dde65 21IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl)
ab171e95 22
03647350 23wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner )
888dde65 24 : wxWindowDCImpl( owner )
03647350
VZ
25{
26 Init();
ab171e95 27}
c801d85f 28
03647350 29wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap)
888dde65 30 : wxWindowDCImpl( owner )
03647350
VZ
31{
32 Init();
33 DoSelect(bitmap);
ab171e95 34}
72cdf4c9 35
888dde65
RR
36wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) )
37 : wxWindowDCImpl( owner )
ab171e95
RR
38{
39 Init();
40}
c801d85f 41
888dde65 42wxMemoryDCImpl::~wxMemoryDCImpl()
c801d85f 43{
42c60e74 44 g_object_unref(m_context);
ff7b1510 45}
c801d85f 46
888dde65 47void wxMemoryDCImpl::Init()
ab171e95
RR
48{
49 m_ok = false;
50
51 m_cmap = gtk_widget_get_default_colormap();
52
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 ) );
59}
60
888dde65 61void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
c801d85f 62{
3d2d8da1 63 Destroy();
fea35690 64
4bc67cc5 65 m_selected = bitmap;
a1b806b9 66 if (m_selected.IsOk())
6f65e337 67 {
888dde65 68 m_gdkwindow = m_selected.GetPixmap();
72cdf4c9 69
7452aff5 70 m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
7452aff5 71
ab171e95 72 SetUpDC( true );
6f65e337
JS
73 }
74 else
72cdf4c9 75 {
f38924e8 76 m_ok = false;
d3b9f782 77 m_gdkwindow = NULL;
6f65e337 78 }
ff7b1510 79}
c801d85f 80
888dde65 81void wxMemoryDCImpl::SetPen( const wxPen& penOrig )
41fbc841 82{
8ab40c52 83 wxPen pen( penOrig );
a1b806b9 84 if ( m_selected.IsOk() &&
b85229d1 85 m_selected.GetDepth() == 1 &&
8ab40c52 86 (pen != *wxTRANSPARENT_PEN) )
41fbc841 87 {
8ab40c52 88 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 89 }
8ab40c52 90
888dde65 91 wxWindowDCImpl::SetPen( pen );
41fbc841
RR
92}
93
888dde65 94void wxMemoryDCImpl::SetBrush( const wxBrush& brushOrig )
41fbc841 95{
8ab40c52 96 wxBrush brush( brushOrig );
a1b806b9 97 if ( m_selected.IsOk() &&
b85229d1 98 m_selected.GetDepth() == 1 &&
8ab40c52 99 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 100 {
8ab40c52 101 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 102 }
8ab40c52 103
888dde65 104 wxWindowDCImpl::SetBrush( brush );
8ab40c52
VZ
105}
106
888dde65 107void wxMemoryDCImpl::SetBackground( const wxBrush& brushOrig )
8ab40c52
VZ
108{
109 wxBrush brush(brushOrig);
110
a1b806b9 111 if ( m_selected.IsOk() &&
b85229d1 112 m_selected.GetDepth() == 1 &&
8ab40c52 113 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 114 {
8ab40c52 115 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 116 }
8ab40c52 117
888dde65 118 wxWindowDCImpl::SetBackground( brush );
41fbc841
RR
119}
120
888dde65 121void wxMemoryDCImpl::SetTextForeground( const wxColour& col )
41fbc841 122{
a1b806b9 123 if ( m_selected.IsOk() && m_selected.GetDepth() == 1 )
888dde65 124 wxWindowDCImpl::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 125 else
888dde65 126 wxWindowDCImpl::SetTextForeground( col );
41fbc841
RR
127}
128
888dde65 129void wxMemoryDCImpl::SetTextBackground( const wxColour &col )
41fbc841 130{
a1b806b9 131 if (m_selected.IsOk() && m_selected.GetDepth() == 1)
888dde65 132 wxWindowDCImpl::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 133 else
888dde65 134 wxWindowDCImpl::SetTextBackground( col );
41fbc841
RR
135}
136
888dde65 137void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
c801d85f 138{
a1b806b9 139 if (m_selected.IsOk())
4bc67cc5
RR
140 {
141 if (width) (*width) = m_selected.GetWidth();
142 if (height) (*height) = m_selected.GetHeight();
143 }
144 else
145 {
146 if (width) (*width) = 0;
147 if (height) (*height) = 0;
148 }
ff7b1510 149}
ab171e95 150
888dde65 151wxBitmap wxMemoryDCImpl::DoGetAsBitmap(const wxRect *subrect) const
ab171e95
RR
152{
153 wxBitmap bmp = GetSelectedBitmap();
154 return subrect ? bmp.GetSubBitmap(*subrect) : bmp;
155}
156
888dde65 157const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
ab171e95
RR
158{
159 return m_selected;
160}
161
888dde65 162wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
ab171e95
RR
163{
164 return m_selected;
165}
166