]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/dcmemory.cpp
check default library directories in WX_PATH_FIND_LIBRARIES; do *not* add default...
[wxWidgets.git] / src / gtk / 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 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{
42c60e74
MR
57#ifdef __WXGTK20__
58 g_object_unref(m_context);
59#endif
ff7b1510 60}
c801d85f
KB
61
62void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
63{
3d2d8da1 64 Destroy();
4bc67cc5
RR
65 m_selected = bitmap;
66 if (m_selected.Ok())
6f65e337 67 {
4bc67cc5
RR
68 if (m_selected.GetPixmap())
69 {
70 m_window = m_selected.GetPixmap();
71 }
72 else
73 {
74 m_window = m_selected.GetBitmap();
75 }
72cdf4c9 76
7452aff5
VS
77#ifdef __WXGTK20__
78 m_selected.PurgeOtherRepresentations(wxBitmap::Pixmap);
79#endif
80
4bc67cc5 81 m_isMemDC = TRUE;
809934d2
RR
82
83 SetUpDC();
6f65e337
JS
84 }
85 else
72cdf4c9 86 {
4bc67cc5
RR
87 m_ok = FALSE;
88 m_window = (GdkWindow *) NULL;
6f65e337 89 }
ff7b1510 90}
c801d85f 91
8ab40c52 92void wxMemoryDC::SetPen( const wxPen& penOrig )
41fbc841 93{
8ab40c52
VZ
94 wxPen pen( penOrig );
95 if ( m_selected.Ok() &&
96 m_selected.GetBitmap() &&
97 (pen != *wxTRANSPARENT_PEN) )
41fbc841 98 {
8ab40c52 99 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 100 }
8ab40c52
VZ
101
102 wxWindowDC::SetPen( pen );
41fbc841
RR
103}
104
8ab40c52 105void wxMemoryDC::SetBrush( const wxBrush& brushOrig )
41fbc841 106{
8ab40c52
VZ
107 wxBrush brush( brushOrig );
108 if ( m_selected.Ok() &&
109 m_selected.GetBitmap() &&
110 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 111 {
8ab40c52 112 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 113 }
8ab40c52
VZ
114
115 wxWindowDC::SetBrush( brush );
116}
117
118void wxMemoryDC::SetBackground( const wxBrush& brushOrig )
119{
120 wxBrush brush(brushOrig);
121
122 if ( m_selected.Ok() &&
123 m_selected.GetBitmap() &&
124 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 125 {
8ab40c52 126 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 127 }
8ab40c52
VZ
128
129 wxWindowDC::SetBackground( brush );
41fbc841
RR
130}
131
8ab40c52 132void wxMemoryDC::SetTextForeground( const wxColour& col )
41fbc841 133{
8ab40c52 134 if ( m_selected.Ok() && m_selected.GetBitmap() )
41fbc841 135 {
8ab40c52 136 wxWindowDC::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841
RR
137 }
138 else
139 {
140 wxWindowDC::SetTextForeground( col );
141 }
142}
143
144void wxMemoryDC::SetTextBackground( const wxColour &col )
145{
146 if (m_selected.Ok() && m_selected.GetBitmap())
147 {
8ab40c52 148 wxWindowDC::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841
RR
149 }
150 else
151 {
152 wxWindowDC::SetTextBackground( col );
153 }
154}
155
4e4ea166 156void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 157{
4bc67cc5
RR
158 if (m_selected.Ok())
159 {
160 if (width) (*width) = m_selected.GetWidth();
161 if (height) (*height) = m_selected.GetHeight();
162 }
163 else
164 {
165 if (width) (*width) = 0;
166 if (height) (*height) = 0;
167 }
ff7b1510 168}
c801d85f
KB
169
170