]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dcmemory.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
6f65e337 | 5 | // RCS-ID: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
72cdf4c9 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "dcmemory.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/dcmemory.h" | |
15 | ||
071a2d78 RR |
16 | #include <gdk/gdk.h> |
17 | #include <gtk/gtk.h> | |
83624f79 | 18 | |
c801d85f KB |
19 | //----------------------------------------------------------------------------- |
20 | // wxMemoryDC | |
21 | //----------------------------------------------------------------------------- | |
22 | ||
ec758a20 | 23 | IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) |
c801d85f | 24 | |
4bc67cc5 | 25 | wxMemoryDC::wxMemoryDC() : wxWindowDC() |
c801d85f | 26 | { |
4bc67cc5 | 27 | m_ok = FALSE; |
72cdf4c9 | 28 | |
4bc67cc5 | 29 | m_cmap = gtk_widget_get_default_colormap(); |
cfcc3932 RR |
30 | |
31 | #ifdef __WXGTK20__ | |
32 | m_context = gdk_pango_context_get(); | |
33 | m_layout = pango_layout_new( m_context ); | |
34 | m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); | |
35 | #endif | |
ff7b1510 | 36 | } |
c801d85f | 37 | |
72cdf4c9 | 38 | wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) |
ec758a20 | 39 | : wxWindowDC() |
c801d85f | 40 | { |
4bc67cc5 | 41 | m_ok = FALSE; |
72cdf4c9 | 42 | |
4bc67cc5 | 43 | m_cmap = gtk_widget_get_default_colormap(); |
cfcc3932 RR |
44 | |
45 | #ifdef __WXGTK20__ | |
46 | m_context = gdk_pango_context_get(); | |
47 | m_layout = pango_layout_new( m_context ); | |
48 | m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); | |
49 | #endif | |
ff7b1510 | 50 | } |
c801d85f | 51 | |
4bc67cc5 | 52 | wxMemoryDC::~wxMemoryDC() |
c801d85f | 53 | { |
ff7b1510 | 54 | } |
c801d85f KB |
55 | |
56 | void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) | |
57 | { | |
3d2d8da1 | 58 | Destroy(); |
4bc67cc5 RR |
59 | m_selected = bitmap; |
60 | if (m_selected.Ok()) | |
6f65e337 | 61 | { |
4bc67cc5 RR |
62 | if (m_selected.GetPixmap()) |
63 | { | |
64 | m_window = m_selected.GetPixmap(); | |
65 | } | |
66 | else | |
67 | { | |
68 | m_window = m_selected.GetBitmap(); | |
69 | } | |
72cdf4c9 | 70 | |
4bc67cc5 | 71 | m_isMemDC = TRUE; |
809934d2 RR |
72 | |
73 | SetUpDC(); | |
6f65e337 JS |
74 | } |
75 | else | |
72cdf4c9 | 76 | { |
4bc67cc5 RR |
77 | m_ok = FALSE; |
78 | m_window = (GdkWindow *) NULL; | |
6f65e337 | 79 | } |
ff7b1510 | 80 | } |
c801d85f | 81 | |
8ab40c52 | 82 | void wxMemoryDC::SetPen( const wxPen& penOrig ) |
41fbc841 | 83 | { |
8ab40c52 VZ |
84 | wxPen pen( penOrig ); |
85 | if ( m_selected.Ok() && | |
86 | m_selected.GetBitmap() && | |
87 | (pen != *wxTRANSPARENT_PEN) ) | |
41fbc841 | 88 | { |
8ab40c52 | 89 | pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 90 | } |
8ab40c52 VZ |
91 | |
92 | wxWindowDC::SetPen( pen ); | |
41fbc841 RR |
93 | } |
94 | ||
8ab40c52 | 95 | void wxMemoryDC::SetBrush( const wxBrush& brushOrig ) |
41fbc841 | 96 | { |
8ab40c52 VZ |
97 | wxBrush brush( brushOrig ); |
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::SetBrush( brush ); | |
106 | } | |
107 | ||
108 | void wxMemoryDC::SetBackground( const wxBrush& brushOrig ) | |
109 | { | |
110 | wxBrush brush(brushOrig); | |
111 | ||
112 | if ( m_selected.Ok() && | |
113 | m_selected.GetBitmap() && | |
114 | (brush != *wxTRANSPARENT_BRUSH) ) | |
41fbc841 | 115 | { |
8ab40c52 | 116 | brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 | 117 | } |
8ab40c52 VZ |
118 | |
119 | wxWindowDC::SetBackground( brush ); | |
41fbc841 RR |
120 | } |
121 | ||
8ab40c52 | 122 | void wxMemoryDC::SetTextForeground( const wxColour& col ) |
41fbc841 | 123 | { |
8ab40c52 | 124 | if ( m_selected.Ok() && m_selected.GetBitmap() ) |
41fbc841 | 125 | { |
8ab40c52 | 126 | wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE); |
41fbc841 RR |
127 | } |
128 | else | |
129 | { | |
130 | wxWindowDC::SetTextForeground( col ); | |
131 | } | |
132 | } | |
133 | ||
134 | void wxMemoryDC::SetTextBackground( const wxColour &col ) | |
135 | { | |
136 | if (m_selected.Ok() && m_selected.GetBitmap()) | |
137 | { | |
8ab40c52 | 138 | wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE ); |
41fbc841 RR |
139 | } |
140 | else | |
141 | { | |
142 | wxWindowDC::SetTextBackground( col ); | |
143 | } | |
144 | } | |
145 | ||
4e4ea166 | 146 | void wxMemoryDC::DoGetSize( int *width, int *height ) const |
c801d85f | 147 | { |
4bc67cc5 RR |
148 | if (m_selected.Ok()) |
149 | { | |
150 | if (width) (*width) = m_selected.GetWidth(); | |
151 | if (height) (*height) = m_selected.GetHeight(); | |
152 | } | |
153 | else | |
154 | { | |
155 | if (width) (*width) = 0; | |
156 | if (height) (*height) = 0; | |
157 | } | |
ff7b1510 | 158 | } |
c801d85f KB |
159 | |
160 |