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