]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcmemory.cpp
Fixed GetIcon to keep up with return type change on all other platforms.
[wxWidgets.git] / src / gtk1 / dcmemory.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.cpp
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
c801d85f
KB
13#include "wx/dcmemory.h"
14
071a2d78
RR
15#include <gdk/gdk.h>
16#include <gtk/gtk.h>
83624f79 17
c801d85f
KB
18//-----------------------------------------------------------------------------
19// wxMemoryDC
20//-----------------------------------------------------------------------------
21
ec758a20 22IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
c801d85f 23
4bc67cc5 24wxMemoryDC::wxMemoryDC() : wxWindowDC()
c801d85f 25{
4bc67cc5 26 m_ok = FALSE;
72cdf4c9 27
4bc67cc5 28 m_cmap = gtk_widget_get_default_colormap();
cfcc3932
RR
29
30#ifdef __WXGTK20__
31 m_context = gdk_pango_context_get();
32 m_layout = pango_layout_new( m_context );
33 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
34#endif
ff7b1510 35}
c801d85f 36
72cdf4c9 37wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
ec758a20 38 : wxWindowDC()
c801d85f 39{
4bc67cc5 40 m_ok = FALSE;
72cdf4c9 41
4bc67cc5 42 m_cmap = gtk_widget_get_default_colormap();
cfcc3932
RR
43
44#ifdef __WXGTK20__
45 m_context = gdk_pango_context_get();
46 m_layout = pango_layout_new( m_context );
47 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
48#endif
ff7b1510 49}
c801d85f 50
4bc67cc5 51wxMemoryDC::~wxMemoryDC()
c801d85f 52{
42c60e74
MR
53#ifdef __WXGTK20__
54 g_object_unref(m_context);
55#endif
ff7b1510 56}
c801d85f
KB
57
58void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
59{
3d2d8da1 60 Destroy();
4bc67cc5
RR
61 m_selected = bitmap;
62 if (m_selected.Ok())
6f65e337 63 {
4bc67cc5
RR
64 if (m_selected.GetPixmap())
65 {
66 m_window = m_selected.GetPixmap();
67 }
68 else
69 {
70 m_window = m_selected.GetBitmap();
71 }
72cdf4c9 72
7452aff5
VS
73#ifdef __WXGTK20__
74 m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
75#endif
76
4bc67cc5 77 m_isMemDC = TRUE;
809934d2
RR
78
79 SetUpDC();
6f65e337
JS
80 }
81 else
72cdf4c9 82 {
4bc67cc5
RR
83 m_ok = FALSE;
84 m_window = (GdkWindow *) NULL;
6f65e337 85 }
ff7b1510 86}
c801d85f 87
8ab40c52 88void wxMemoryDC::SetPen( const wxPen& penOrig )
41fbc841 89{
8ab40c52
VZ
90 wxPen pen( penOrig );
91 if ( m_selected.Ok() &&
92 m_selected.GetBitmap() &&
93 (pen != *wxTRANSPARENT_PEN) )
41fbc841 94 {
8ab40c52 95 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 96 }
8ab40c52
VZ
97
98 wxWindowDC::SetPen( pen );
41fbc841
RR
99}
100
8ab40c52 101void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
41fbc841 102{
8ab40c52
VZ
103 wxBrush brush( brushOrig );
104 if ( m_selected.Ok() &&
105 m_selected.GetBitmap() &&
106 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 107 {
8ab40c52 108 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 109 }
8ab40c52
VZ
110
111 wxWindowDC::SetBrush( brush );
112}
113
114void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
115{
116 wxBrush brush(brushOrig);
117
118 if ( m_selected.Ok() &&
119 m_selected.GetBitmap() &&
120 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 121 {
8ab40c52 122 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 123 }
8ab40c52
VZ
124
125 wxWindowDC::SetBackground( brush );
41fbc841
RR
126}
127
8ab40c52 128void wxMemoryDC::SetTextForeground( const wxColour& col )
41fbc841 129{
8ab40c52 130 if ( m_selected.Ok() && m_selected.GetBitmap() )
41fbc841 131 {
8ab40c52 132 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841
RR
133 }
134 else
135 {
136 wxWindowDC::SetTextForeground( col );
137 }
138}
139
140void wxMemoryDC::SetTextBackground( const wxColour &col )
141{
142 if (m_selected.Ok() && m_selected.GetBitmap())
143 {
8ab40c52 144 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841
RR
145 }
146 else
147 {
148 wxWindowDC::SetTextBackground( col );
149 }
150}
151
4e4ea166 152void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 153{
4bc67cc5
RR
154 if (m_selected.Ok())
155 {
156 if (width) (*width) = m_selected.GetWidth();
157 if (height) (*height) = m_selected.GetHeight();
158 }
159 else
160 {
161 if (width) (*width) = 0;
162 if (height) (*height) = 0;
163 }
ff7b1510 164}
c801d85f
KB
165
166