]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
f38924e8 | 2 | // Name: src/gtk1/dcmemory.cpp |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
01111366 | 5 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 6 | // Licence: wxWindows licence |
c801d85f KB |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
14f355c2 VS |
9 | // For compilers that support precompilation, includes "wx.h". |
10 | #include "wx/wxprec.h" | |
11 | ||
10d30222 | 12 | #include "wx/gtk1/dcmemory.h" |
c801d85f | 13 | |
071a2d78 RR |
14 | #include <gdk/gdk.h> |
15 | #include <gtk/gtk.h> | |
83624f79 | 16 | |
c801d85f | 17 | //----------------------------------------------------------------------------- |
10d30222 | 18 | // wxMemoryDCImpl |
c801d85f KB |
19 | //----------------------------------------------------------------------------- |
20 | ||
10d30222 | 21 | IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl) |
c801d85f | 22 | |
10d30222 | 23 | void wxMemoryDCImpl::Init() |
c801d85f | 24 | { |
f38924e8 | 25 | m_ok = false; |
72cdf4c9 | 26 | |
4bc67cc5 | 27 | m_cmap = gtk_widget_get_default_colormap(); |
ff7b1510 | 28 | } |
c801d85f | 29 | |
10d30222 VZ |
30 | wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC *WXUNUSED(dc)) |
31 | : wxWindowDCImpl(owner) | |
c801d85f | 32 | { |
fea35690 | 33 | Init(); |
ff7b1510 | 34 | } |
c801d85f | 35 | |
10d30222 | 36 | wxMemoryDCImpl::~wxMemoryDCImpl() |
c801d85f | 37 | { |
ff7b1510 | 38 | } |
c801d85f | 39 | |
10d30222 | 40 | void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) |
c801d85f | 41 | { |
3d2d8da1 | 42 | Destroy(); |
fea35690 | 43 | |
4bc67cc5 | 44 | m_selected = bitmap; |
a1b806b9 | 45 | if (m_selected.IsOk()) |
6f65e337 | 46 | { |
4bc67cc5 RR |
47 | if (m_selected.GetPixmap()) |
48 | { | |
49 | m_window = m_selected.GetPixmap(); | |
50 | } | |
51 | else | |
52 | { | |
53 | m_window = m_selected.GetBitmap(); | |
54 | } | |
72cdf4c9 | 55 | |
f38924e8 | 56 | m_isMemDC = true; |
809934d2 RR |
57 | |
58 | SetUpDC(); | |
6f65e337 JS |
59 | } |
60 | else | |
72cdf4c9 | 61 | { |
f38924e8 | 62 | m_ok = false; |
d3b9f782 | 63 | m_window = NULL; |
6f65e337 | 64 | } |
ff7b1510 | 65 | } |
c801d85f | 66 | |
10d30222 | 67 | void wxMemoryDCImpl::SetPen( const wxPen& penOrig ) |
41fbc841 | 68 | { |
8ab40c52 | 69 | wxPen pen( penOrig ); |
a1b806b9 | 70 | if ( m_selected.IsOk() && |
8ab40c52 VZ |
71 | m_selected.GetBitmap() && |
72 | (pen != *wxTRANSPARENT_PEN) ) | |
41fbc841 | 73 | { |
8ab40c52 | 74 | pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 75 | } |
8ab40c52 | 76 | |
10d30222 | 77 | wxWindowDCImpl::SetPen( pen ); |
41fbc841 RR |
78 | } |
79 | ||
10d30222 | 80 | void wxMemoryDCImpl::SetBrush( const wxBrush& brushOrig ) |
41fbc841 | 81 | { |
8ab40c52 | 82 | wxBrush brush( brushOrig ); |
a1b806b9 | 83 | if ( m_selected.IsOk() && |
8ab40c52 VZ |
84 | m_selected.GetBitmap() && |
85 | (brush != *wxTRANSPARENT_BRUSH) ) | |
41fbc841 | 86 | { |
8ab40c52 | 87 | brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE); |
41fbc841 | 88 | } |
8ab40c52 | 89 | |
10d30222 | 90 | wxWindowDCImpl::SetBrush( brush ); |
8ab40c52 VZ |
91 | } |
92 | ||
10d30222 | 93 | void wxMemoryDCImpl::SetBackground( const wxBrush& brushOrig ) |
8ab40c52 VZ |
94 | { |
95 | wxBrush brush(brushOrig); | |
96 | ||
a1b806b9 | 97 | if ( m_selected.IsOk() && |
8ab40c52 VZ |
98 | m_selected.GetBitmap() && |
99 | (brush != *wxTRANSPARENT_BRUSH) ) | |
41fbc841 | 100 | { |
8ab40c52 | 101 | brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 102 | } |
8ab40c52 | 103 | |
10d30222 | 104 | wxWindowDCImpl::SetBackground( brush ); |
41fbc841 RR |
105 | } |
106 | ||
10d30222 | 107 | void wxMemoryDCImpl::SetTextForeground( const wxColour& col ) |
41fbc841 | 108 | { |
a1b806b9 | 109 | if ( m_selected.IsOk() && m_selected.GetBitmap() ) |
41fbc841 | 110 | { |
10d30222 | 111 | wxWindowDCImpl::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); |
41fbc841 RR |
112 | } |
113 | else | |
114 | { | |
10d30222 | 115 | wxWindowDCImpl::SetTextForeground( col ); |
41fbc841 RR |
116 | } |
117 | } | |
118 | ||
10d30222 | 119 | void wxMemoryDCImpl::SetTextBackground( const wxColour &col ) |
41fbc841 | 120 | { |
a1b806b9 | 121 | if (m_selected.IsOk() && m_selected.GetBitmap()) |
41fbc841 | 122 | { |
10d30222 | 123 | wxWindowDCImpl::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 RR |
124 | } |
125 | else | |
126 | { | |
10d30222 | 127 | wxWindowDCImpl::SetTextBackground( col ); |
41fbc841 RR |
128 | } |
129 | } | |
130 | ||
10d30222 | 131 | void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const |
c801d85f | 132 | { |
a1b806b9 | 133 | if (m_selected.IsOk()) |
4bc67cc5 RR |
134 | { |
135 | if (width) (*width) = m_selected.GetWidth(); | |
136 | if (height) (*height) = m_selected.GetHeight(); | |
137 | } | |
138 | else | |
139 | { | |
140 | if (width) (*width) = 0; | |
141 | if (height) (*height) = 0; | |
142 | } | |
ff7b1510 | 143 | } |