]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcmemory.cpp
Applied patch [ 1435340 ] Add support of wxToggleButton to wxGenericValidator
[wxWidgets.git] / src / gtk1 / dcmemory.cpp
CommitLineData
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
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 22IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
c801d85f 23
4bc67cc5 24wxMemoryDC::wxMemoryDC() : wxWindowDC()
c801d85f 25{
4bc67cc5 26 m_ok = FALSE;
72cdf4c9 27
4bc67cc5 28 m_cmap = gtk_widget_get_default_colormap();
ff7b1510 29}
c801d85f 30
72cdf4c9 31wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
ec758a20 32 : wxWindowDC()
c801d85f 33{
4bc67cc5 34 m_ok = FALSE;
72cdf4c9 35
4bc67cc5 36 m_cmap = gtk_widget_get_default_colormap();
3d257b8d 37
ff7b1510 38}
c801d85f 39
4bc67cc5 40wxMemoryDC::~wxMemoryDC()
c801d85f 41{
ff7b1510 42}
c801d85f
KB
43
44void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
45{
3d2d8da1 46 Destroy();
4bc67cc5
RR
47 m_selected = bitmap;
48 if (m_selected.Ok())
6f65e337 49 {
4bc67cc5
RR
50 if (m_selected.GetPixmap())
51 {
52 m_window = m_selected.GetPixmap();
53 }
54 else
55 {
56 m_window = m_selected.GetBitmap();
57 }
72cdf4c9 58
4bc67cc5 59 m_isMemDC = TRUE;
809934d2
RR
60
61 SetUpDC();
6f65e337
JS
62 }
63 else
72cdf4c9 64 {
4bc67cc5
RR
65 m_ok = FALSE;
66 m_window = (GdkWindow *) NULL;
6f65e337 67 }
ff7b1510 68}
c801d85f 69
8ab40c52 70void wxMemoryDC::SetPen( const wxPen& penOrig )
41fbc841 71{
8ab40c52
VZ
72 wxPen pen( penOrig );
73 if ( m_selected.Ok() &&
74 m_selected.GetBitmap() &&
75 (pen != *wxTRANSPARENT_PEN) )
41fbc841 76 {
8ab40c52 77 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 78 }
8ab40c52
VZ
79
80 wxWindowDC::SetPen( pen );
41fbc841
RR
81}
82
8ab40c52 83void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
41fbc841 84{
8ab40c52
VZ
85 wxBrush brush( brushOrig );
86 if ( m_selected.Ok() &&
87 m_selected.GetBitmap() &&
88 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 89 {
8ab40c52 90 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 91 }
8ab40c52
VZ
92
93 wxWindowDC::SetBrush( brush );
94}
95
3d257b8d 96void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
8ab40c52
VZ
97{
98 wxBrush brush(brushOrig);
99
100 if ( m_selected.Ok() &&
101 m_selected.GetBitmap() &&
102 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 103 {
8ab40c52 104 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 105 }
8ab40c52
VZ
106
107 wxWindowDC::SetBackground( brush );
41fbc841
RR
108}
109
8ab40c52 110void wxMemoryDC::SetTextForeground( const wxColour& col )
41fbc841 111{
8ab40c52 112 if ( m_selected.Ok() && m_selected.GetBitmap() )
41fbc841 113 {
8ab40c52 114 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841
RR
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 {
8ab40c52 126 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841
RR
127 }
128 else
129 {
130 wxWindowDC::SetTextBackground( col );
131 }
132}
133
4e4ea166 134void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 135{
4bc67cc5
RR
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 }
ff7b1510 146}
c801d85f
KB
147
148