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