]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcmemory.cpp
Printing update for Pango (GTK2 and X11-Unicode).
[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
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 23IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
c801d85f 24
4bc67cc5 25wxMemoryDC::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 38wxMemoryDC::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 52wxMemoryDC::~wxMemoryDC()
c801d85f 53{
ff7b1510 54}
c801d85f
KB
55
56void 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
41fbc841
RR
82void wxMemoryDC::SetPen( const wxPen &pen )
83{
84 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
85 {
86 if (*wxWHITE_PEN == pen)
87 wxWindowDC::SetPen( *wxBLACK_PEN );
88 else
89 wxWindowDC::SetPen( *wxWHITE_PEN );
90 }
91 else
92 {
93 wxWindowDC::SetPen( pen );
94 }
95}
96
97void wxMemoryDC::SetBrush( const wxBrush &brush )
98{
99 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
100 {
101 if (*wxWHITE_BRUSH == brush)
102 wxWindowDC::SetBrush( *wxBLACK_BRUSH );
103 else
104 wxWindowDC::SetBrush( *wxWHITE_BRUSH );
105 }
106 else
107 {
108 wxWindowDC::SetBrush( brush );
109 }
110}
111
112void wxMemoryDC::SetTextForeground( const wxColour &col )
113{
114 if (m_selected.Ok() && m_selected.GetBitmap())
115 {
116 if (col == *wxWHITE)
117 wxWindowDC::SetTextForeground( *wxBLACK );
118 else
119 wxWindowDC::SetTextForeground( *wxWHITE );
120 }
121 else
122 {
123 wxWindowDC::SetTextForeground( col );
124 }
125}
126
127void wxMemoryDC::SetTextBackground( const wxColour &col )
128{
129 if (m_selected.Ok() && m_selected.GetBitmap())
130 {
131 if (col == *wxWHITE)
132 wxWindowDC::SetTextBackground( *wxBLACK );
133 else
134 wxWindowDC::SetTextBackground( *wxWHITE );
135 }
136 else
137 {
138 wxWindowDC::SetTextBackground( col );
139 }
140}
141
4e4ea166 142void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 143{
4bc67cc5
RR
144 if (m_selected.Ok())
145 {
146 if (width) (*width) = m_selected.GetWidth();
147 if (height) (*height) = m_selected.GetHeight();
148 }
149 else
150 {
151 if (width) (*width) = 0;
152 if (height) (*height) = 0;
153 }
ff7b1510 154}
c801d85f
KB
155
156