]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/dcmemory.cpp
no changes but more comments in DoSetClientSize() (explains the change of rev 1.624...
[wxWidgets.git] / src / gtk1 / dcmemory.cpp
... / ...
CommitLineData
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// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#include "wx/dcmemory.h"
14
15#include <gdk/gdk.h>
16#include <gtk/gtk.h>
17
18//-----------------------------------------------------------------------------
19// wxMemoryDC
20//-----------------------------------------------------------------------------
21
22IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
23
24wxMemoryDC::wxMemoryDC() : wxWindowDC()
25{
26 m_ok = FALSE;
27
28 m_cmap = gtk_widget_get_default_colormap();
29}
30
31wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
32 : wxWindowDC()
33{
34 m_ok = FALSE;
35
36 m_cmap = gtk_widget_get_default_colormap();
37
38}
39
40wxMemoryDC::~wxMemoryDC()
41{
42}
43
44void 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
70void wxMemoryDC::SetPen( const wxPen& penOrig )
71{
72 wxPen pen( penOrig );
73 if ( m_selected.Ok() &&
74 m_selected.GetBitmap() &&
75 (pen != *wxTRANSPARENT_PEN) )
76 {
77 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
78 }
79
80 wxWindowDC::SetPen( pen );
81}
82
83void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
84{
85 wxBrush brush( brushOrig );
86 if ( m_selected.Ok() &&
87 m_selected.GetBitmap() &&
88 (brush != *wxTRANSPARENT_BRUSH) )
89 {
90 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
91 }
92
93 wxWindowDC::SetBrush( brush );
94}
95
96void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
97{
98 wxBrush brush(brushOrig);
99
100 if ( m_selected.Ok() &&
101 m_selected.GetBitmap() &&
102 (brush != *wxTRANSPARENT_BRUSH) )
103 {
104 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
105 }
106
107 wxWindowDC::SetBackground( brush );
108}
109
110void wxMemoryDC::SetTextForeground( const wxColour& col )
111{
112 if ( m_selected.Ok() && m_selected.GetBitmap() )
113 {
114 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
115 }
116 else
117 {
118 wxWindowDC::SetTextForeground( col );
119 }
120}
121
122void wxMemoryDC::SetTextBackground( const wxColour &col )
123{
124 if (m_selected.Ok() && m_selected.GetBitmap())
125 {
126 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
127 }
128 else
129 {
130 wxWindowDC::SetTextBackground( col );
131 }
132}
133
134void wxMemoryDC::DoGetSize( int *width, int *height ) const
135{
136 if (m_selected.Ok())
137 {
138 if (width) (*width) = m_selected.GetWidth();
139 if (height) (*height) = m_selected.GetHeight();
140 }
141 else
142 {
143 if (width) (*width) = 0;
144 if (height) (*height) = 0;
145 }
146}
147
148