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