]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
f38924e8 | 2 | // Name: src/gtk1/dcmemory.cpp |
c801d85f KB |
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 | 22 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) |
c801d85f | 23 | |
fea35690 | 24 | void wxMemoryDC::Init() |
c801d85f | 25 | { |
f38924e8 | 26 | m_ok = false; |
72cdf4c9 | 27 | |
4bc67cc5 | 28 | m_cmap = gtk_widget_get_default_colormap(); |
ff7b1510 | 29 | } |
c801d85f | 30 | |
72cdf4c9 | 31 | wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) |
f38924e8 | 32 | : wxWindowDC() |
c801d85f | 33 | { |
fea35690 | 34 | Init(); |
ff7b1510 | 35 | } |
c801d85f | 36 | |
4bc67cc5 | 37 | wxMemoryDC::~wxMemoryDC() |
c801d85f | 38 | { |
ff7b1510 | 39 | } |
c801d85f | 40 | |
fea35690 | 41 | void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) |
c801d85f | 42 | { |
3d2d8da1 | 43 | Destroy(); |
fea35690 | 44 | |
4bc67cc5 RR |
45 | m_selected = bitmap; |
46 | if (m_selected.Ok()) | |
6f65e337 | 47 | { |
4bc67cc5 RR |
48 | if (m_selected.GetPixmap()) |
49 | { | |
50 | m_window = m_selected.GetPixmap(); | |
51 | } | |
52 | else | |
53 | { | |
54 | m_window = m_selected.GetBitmap(); | |
55 | } | |
72cdf4c9 | 56 | |
f38924e8 | 57 | m_isMemDC = true; |
809934d2 RR |
58 | |
59 | SetUpDC(); | |
6f65e337 JS |
60 | } |
61 | else | |
72cdf4c9 | 62 | { |
f38924e8 | 63 | m_ok = false; |
4bc67cc5 | 64 | m_window = (GdkWindow *) NULL; |
6f65e337 | 65 | } |
ff7b1510 | 66 | } |
c801d85f | 67 | |
8ab40c52 | 68 | void wxMemoryDC::SetPen( const wxPen& penOrig ) |
41fbc841 | 69 | { |
8ab40c52 VZ |
70 | wxPen pen( penOrig ); |
71 | if ( m_selected.Ok() && | |
72 | m_selected.GetBitmap() && | |
73 | (pen != *wxTRANSPARENT_PEN) ) | |
41fbc841 | 74 | { |
8ab40c52 | 75 | pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 76 | } |
8ab40c52 VZ |
77 | |
78 | wxWindowDC::SetPen( pen ); | |
41fbc841 RR |
79 | } |
80 | ||
8ab40c52 | 81 | void wxMemoryDC::SetBrush( const wxBrush& brushOrig ) |
41fbc841 | 82 | { |
8ab40c52 VZ |
83 | wxBrush brush( brushOrig ); |
84 | if ( m_selected.Ok() && | |
85 | m_selected.GetBitmap() && | |
86 | (brush != *wxTRANSPARENT_BRUSH) ) | |
41fbc841 | 87 | { |
8ab40c52 | 88 | brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); |
41fbc841 | 89 | } |
8ab40c52 VZ |
90 | |
91 | wxWindowDC::SetBrush( brush ); | |
92 | } | |
93 | ||
3d257b8d | 94 | void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) |
8ab40c52 VZ |
95 | { |
96 | wxBrush brush(brushOrig); | |
97 | ||
98 | if ( m_selected.Ok() && | |
99 | m_selected.GetBitmap() && | |
100 | (brush != *wxTRANSPARENT_BRUSH) ) | |
41fbc841 | 101 | { |
8ab40c52 | 102 | brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 103 | } |
8ab40c52 VZ |
104 | |
105 | wxWindowDC::SetBackground( brush ); | |
41fbc841 RR |
106 | } |
107 | ||
8ab40c52 | 108 | void wxMemoryDC::SetTextForeground( const wxColour& col ) |
41fbc841 | 109 | { |
8ab40c52 | 110 | if ( m_selected.Ok() && m_selected.GetBitmap() ) |
41fbc841 | 111 | { |
8ab40c52 | 112 | wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); |
41fbc841 RR |
113 | } |
114 | else | |
115 | { | |
116 | wxWindowDC::SetTextForeground( col ); | |
117 | } | |
118 | } | |
119 | ||
120 | void wxMemoryDC::SetTextBackground( const wxColour &col ) | |
121 | { | |
122 | if (m_selected.Ok() && m_selected.GetBitmap()) | |
123 | { | |
8ab40c52 | 124 | wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 RR |
125 | } |
126 | else | |
127 | { | |
128 | wxWindowDC::SetTextBackground( col ); | |
129 | } | |
130 | } | |
131 | ||
4e4ea166 | 132 | void wxMemoryDC::DoGetSize( int *width, int *height ) const |
c801d85f | 133 | { |
4bc67cc5 RR |
134 | if (m_selected.Ok()) |
135 | { | |
136 | if (width) (*width) = m_selected.GetWidth(); | |
137 | if (height) (*height) = m_selected.GetHeight(); | |
138 | } | |
139 | else | |
140 | { | |
141 | if (width) (*width) = 0; | |
142 | if (height) (*height) = 0; | |
143 | } | |
ff7b1510 | 144 | } |