]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/dcmemory.cpp
Added empty wxDataViewCtrl header and control name string.
[wxWidgets.git] / src / gtk / 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();
e90d93d1
MW
32 // Note: The Sun customised version of Pango shipping with Solaris 10
33 // crashes if the language is left NULL (see bug 1374114)
203b65dd 34 pango_context_set_language( m_context, gtk_get_default_language() );
cfcc3932
RR
35 m_layout = pango_layout_new( m_context );
36 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
37#endif
ff7b1510 38}
c801d85f 39
72cdf4c9 40wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
ec758a20 41 : wxWindowDC()
c801d85f 42{
4bc67cc5 43 m_ok = FALSE;
72cdf4c9 44
4bc67cc5 45 m_cmap = gtk_widget_get_default_colormap();
cfcc3932
RR
46
47#ifdef __WXGTK20__
48 m_context = gdk_pango_context_get();
203b65dd 49 pango_context_set_language( m_context, gtk_get_default_language() );
cfcc3932
RR
50 m_layout = pango_layout_new( m_context );
51 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
52#endif
ff7b1510 53}
c801d85f 54
4bc67cc5 55wxMemoryDC::~wxMemoryDC()
c801d85f 56{
42c60e74
MR
57#ifdef __WXGTK20__
58 g_object_unref(m_context);
59#endif
ff7b1510 60}
c801d85f
KB
61
62void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
63{
3d2d8da1 64 Destroy();
4bc67cc5
RR
65 m_selected = bitmap;
66 if (m_selected.Ok())
6f65e337 67 {
4bc67cc5
RR
68 if (m_selected.GetPixmap())
69 {
70 m_window = m_selected.GetPixmap();
71 }
72 else
73 {
74 m_window = m_selected.GetBitmap();
75 }
72cdf4c9 76
7452aff5
VS
77#ifdef __WXGTK20__
78 m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
79#endif
80
4bc67cc5 81 m_isMemDC = TRUE;
809934d2
RR
82
83 SetUpDC();
6f65e337
JS
84 }
85 else
72cdf4c9 86 {
4bc67cc5
RR
87 m_ok = FALSE;
88 m_window = (GdkWindow *) NULL;
6f65e337 89 }
ff7b1510 90}
c801d85f 91
8ab40c52 92void wxMemoryDC::SetPen( const wxPen& penOrig )
41fbc841 93{
8ab40c52
VZ
94 wxPen pen( penOrig );
95 if ( m_selected.Ok() &&
96 m_selected.GetBitmap() &&
97 (pen != *wxTRANSPARENT_PEN) )
41fbc841 98 {
8ab40c52 99 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 100 }
8ab40c52
VZ
101
102 wxWindowDC::SetPen( pen );
41fbc841
RR
103}
104
8ab40c52 105void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
41fbc841 106{
8ab40c52
VZ
107 wxBrush brush( brushOrig );
108 if ( m_selected.Ok() &&
109 m_selected.GetBitmap() &&
110 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 111 {
8ab40c52 112 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 113 }
8ab40c52
VZ
114
115 wxWindowDC::SetBrush( brush );
116}
117
118void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
119{
120 wxBrush brush(brushOrig);
121
122 if ( m_selected.Ok() &&
123 m_selected.GetBitmap() &&
124 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 125 {
8ab40c52 126 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 127 }
8ab40c52
VZ
128
129 wxWindowDC::SetBackground( brush );
41fbc841
RR
130}
131
8ab40c52 132void wxMemoryDC::SetTextForeground( const wxColour& col )
41fbc841 133{
8ab40c52 134 if ( m_selected.Ok() && m_selected.GetBitmap() )
41fbc841 135 {
8ab40c52 136 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841
RR
137 }
138 else
139 {
140 wxWindowDC::SetTextForeground( col );
141 }
142}
143
144void wxMemoryDC::SetTextBackground( const wxColour &col )
145{
146 if (m_selected.Ok() && m_selected.GetBitmap())
147 {
8ab40c52 148 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841
RR
149 }
150 else
151 {
152 wxWindowDC::SetTextBackground( col );
153 }
154}
155
4e4ea166 156void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 157{
4bc67cc5
RR
158 if (m_selected.Ok())
159 {
160 if (width) (*width) = m_selected.GetWidth();
161 if (height) (*height) = m_selected.GetHeight();
162 }
163 else
164 {
165 if (width) (*width) = 0;
166 if (height) (*height) = 0;
167 }
ff7b1510 168}
c801d85f
KB
169
170