]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
fixed BC compilation bug (line 145)
[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
32 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
33 : wxWindowDC()
34 {
35 m_ok = FALSE;
36
37 m_cmap = gtk_widget_get_default_colormap();
38 }
39
40 wxMemoryDC::~wxMemoryDC()
41 {
42 }
43
44 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
45 {
46 m_selected = bitmap;
47 if (m_selected.Ok())
48 {
49 if (m_selected.GetPixmap())
50 {
51 m_window = m_selected.GetPixmap();
52 }
53 else
54 {
55 m_window = m_selected.GetBitmap();
56 }
57
58 SetUpDC();
59
60 m_isMemDC = TRUE;
61 }
62 else
63 {
64 m_ok = FALSE;
65 m_window = (GdkWindow *) NULL;
66 }
67 }
68
69 void wxMemoryDC::SetPen( const wxPen &pen )
70 {
71 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
72 {
73 if (*wxWHITE_PEN == pen)
74 wxWindowDC::SetPen( *wxBLACK_PEN );
75 else
76 wxWindowDC::SetPen( *wxWHITE_PEN );
77 }
78 else
79 {
80 wxWindowDC::SetPen( pen );
81 }
82 }
83
84 void wxMemoryDC::SetBrush( const wxBrush &brush )
85 {
86 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
87 {
88 if (*wxWHITE_BRUSH == brush)
89 wxWindowDC::SetBrush( *wxBLACK_BRUSH );
90 else
91 wxWindowDC::SetBrush( *wxWHITE_BRUSH );
92 }
93 else
94 {
95 wxWindowDC::SetBrush( brush );
96 }
97 }
98
99 void wxMemoryDC::SetTextForeground( const wxColour &col )
100 {
101 if (m_selected.Ok() && m_selected.GetBitmap())
102 {
103 if (col == *wxWHITE)
104 wxWindowDC::SetTextForeground( *wxBLACK );
105 else
106 wxWindowDC::SetTextForeground( *wxWHITE );
107 }
108 else
109 {
110 wxWindowDC::SetTextForeground( col );
111 }
112 }
113
114 void wxMemoryDC::SetTextBackground( const wxColour &col )
115 {
116 if (m_selected.Ok() && m_selected.GetBitmap())
117 {
118 if (col == *wxWHITE)
119 wxWindowDC::SetTextBackground( *wxBLACK );
120 else
121 wxWindowDC::SetTextBackground( *wxWHITE );
122 }
123 else
124 {
125 wxWindowDC::SetTextBackground( col );
126 }
127 }
128
129 void wxMemoryDC::DoGetSize( int *width, int *height ) const
130 {
131 if (m_selected.Ok())
132 {
133 if (width) (*width) = m_selected.GetWidth();
134 if (height) (*height) = m_selected.GetHeight();
135 }
136 else
137 {
138 if (width) (*width) = 0;
139 if (height) (*height) = 0;
140 }
141 }
142
143