]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
According to Stefan Neis this file isn't used by anything other than
[wxWidgets.git] / src / gtk / dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcmemory.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "dcmemory.h"
12 #endif
13
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
16
17 #include "wx/dcmemory.h"
18
19 #include <gdk/gdk.h>
20 #include <gtk/gtk.h>
21
22 //-----------------------------------------------------------------------------
23 // wxMemoryDC
24 //-----------------------------------------------------------------------------
25
26 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
27
28 wxMemoryDC::wxMemoryDC() : wxWindowDC()
29 {
30 m_ok = FALSE;
31
32 m_cmap = gtk_widget_get_default_colormap();
33
34 #ifdef __WXGTK20__
35 m_context = gdk_pango_context_get();
36 m_layout = pango_layout_new( m_context );
37 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
38 #endif
39 }
40
41 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
42 : wxWindowDC()
43 {
44 m_ok = FALSE;
45
46 m_cmap = gtk_widget_get_default_colormap();
47
48 #ifdef __WXGTK20__
49 m_context = gdk_pango_context_get();
50 m_layout = pango_layout_new( m_context );
51 m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
52 #endif
53 }
54
55 wxMemoryDC::~wxMemoryDC()
56 {
57 }
58
59 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
60 {
61 Destroy();
62 m_selected = bitmap;
63 if (m_selected.Ok())
64 {
65 if (m_selected.GetPixmap())
66 {
67 m_window = m_selected.GetPixmap();
68 }
69 else
70 {
71 m_window = m_selected.GetBitmap();
72 }
73
74 m_isMemDC = TRUE;
75
76 SetUpDC();
77 }
78 else
79 {
80 m_ok = FALSE;
81 m_window = (GdkWindow *) NULL;
82 }
83 }
84
85 void wxMemoryDC::SetPen( const wxPen& penOrig )
86 {
87 wxPen pen( penOrig );
88 if ( m_selected.Ok() &&
89 m_selected.GetBitmap() &&
90 (pen != *wxTRANSPARENT_PEN) )
91 {
92 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
93 }
94
95 wxWindowDC::SetPen( pen );
96 }
97
98 void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
99 {
100 wxBrush brush( brushOrig );
101 if ( m_selected.Ok() &&
102 m_selected.GetBitmap() &&
103 (brush != *wxTRANSPARENT_BRUSH) )
104 {
105 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
106 }
107
108 wxWindowDC::SetBrush( brush );
109 }
110
111 void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
112 {
113 wxBrush brush(brushOrig);
114
115 if ( m_selected.Ok() &&
116 m_selected.GetBitmap() &&
117 (brush != *wxTRANSPARENT_BRUSH) )
118 {
119 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
120 }
121
122 wxWindowDC::SetBackground( brush );
123 }
124
125 void wxMemoryDC::SetTextForeground( const wxColour& col )
126 {
127 if ( m_selected.Ok() && m_selected.GetBitmap() )
128 {
129 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
130 }
131 else
132 {
133 wxWindowDC::SetTextForeground( col );
134 }
135 }
136
137 void wxMemoryDC::SetTextBackground( const wxColour &col )
138 {
139 if (m_selected.Ok() && m_selected.GetBitmap())
140 {
141 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
142 }
143 else
144 {
145 wxWindowDC::SetTextBackground( col );
146 }
147 }
148
149 void wxMemoryDC::DoGetSize( int *width, int *height ) const
150 {
151 if (m_selected.Ok())
152 {
153 if (width) (*width) = m_selected.GetWidth();
154 if (height) (*height) = m_selected.GetHeight();
155 }
156 else
157 {
158 if (width) (*width) = 0;
159 if (height) (*height) = 0;
160 }
161 }
162
163