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