]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dcmemory.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #include "wx/dcmemory.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
23 IMPLEMENT_ABSTRACT_CLASS(wxGTKMemoryImplDC
, wxGTKWindowImplDC
)
25 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDC
,wxWindowDC
)
29 wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC
*owner
)
30 : wxGTKWindowImplDC( owner
)
35 wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC
*owner
, wxBitmap
& bitmap
)
36 : wxGTKWindowImplDC( owner
)
39 owner
->SelectObject(bitmap
);
42 wxGTKMemoryImplDC::wxGTKMemoryImplDC( wxMemoryDC
*owner
, wxDC
*WXUNUSED(dc
) )
43 : wxGTKWindowImplDC( owner
)
48 wxMemoryDC::wxMemoryDC()
53 wxMemoryDC::wxMemoryDC(wxBitmap
& bitmap
)
59 wxMemoryDC::wxMemoryDC( wxDC
*WXUNUSED(dc
) )
66 wxGTKMemoryImplDC::~wxGTKMemoryImplDC()
68 g_object_unref(m_context
);
71 void wxGTKMemoryImplDC::Init()
75 m_cmap
= gtk_widget_get_default_colormap();
77 m_context
= gdk_pango_context_get();
78 // Note: The Sun customised version of Pango shipping with Solaris 10
79 // crashes if the language is left NULL (see bug 1374114)
80 pango_context_set_language( m_context
, gtk_get_default_language() );
81 m_layout
= pango_layout_new( m_context
);
82 m_fontdesc
= pango_font_description_copy( pango_context_get_font_description( m_context
) );
85 void wxGTKMemoryImplDC::DoSelect( const wxBitmap
& bitmap
)
92 m_window
= m_selected
.GetPixmap();
94 m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
);
101 m_window
= (GdkWindow
*) NULL
;
105 void wxGTKMemoryImplDC::SetPen( const wxPen
& penOrig
)
107 wxPen
pen( penOrig
);
108 if ( m_selected
.Ok() &&
109 m_selected
.GetDepth() == 1 &&
110 (pen
!= *wxTRANSPARENT_PEN
) )
112 pen
.SetColour( pen
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
115 wxGTKWindowImplDC::SetPen( pen
);
118 void wxGTKMemoryImplDC::SetBrush( const wxBrush
& brushOrig
)
120 wxBrush
brush( brushOrig
);
121 if ( m_selected
.Ok() &&
122 m_selected
.GetDepth() == 1 &&
123 (brush
!= *wxTRANSPARENT_BRUSH
) )
125 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
128 wxGTKWindowImplDC::SetBrush( brush
);
131 void wxGTKMemoryImplDC::SetBackground( const wxBrush
& brushOrig
)
133 wxBrush
brush(brushOrig
);
135 if ( m_selected
.Ok() &&
136 m_selected
.GetDepth() == 1 &&
137 (brush
!= *wxTRANSPARENT_BRUSH
) )
139 brush
.SetColour( brush
.GetColour() == *wxWHITE
? *wxBLACK
: *wxWHITE
);
142 wxGTKWindowImplDC::SetBackground( brush
);
145 void wxGTKMemoryImplDC::SetTextForeground( const wxColour
& col
)
147 if ( m_selected
.Ok() && m_selected
.GetDepth() == 1 )
149 wxGTKWindowImplDC::SetTextForeground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
153 wxGTKWindowImplDC::SetTextForeground( col
);
157 void wxGTKMemoryImplDC::SetTextBackground( const wxColour
&col
)
159 if (m_selected
.Ok() && m_selected
.GetDepth() == 1)
161 wxGTKWindowImplDC::SetTextBackground( col
== *wxWHITE
? *wxBLACK
: *wxWHITE
);
165 wxGTKWindowImplDC::SetTextBackground( col
);
169 void wxGTKMemoryImplDC::DoGetSize( int *width
, int *height
) const
173 if (width
) (*width
) = m_selected
.GetWidth();
174 if (height
) (*height
) = m_selected
.GetHeight();
178 if (width
) (*width
) = 0;
179 if (height
) (*height
) = 0;
183 wxBitmap
wxGTKMemoryImplDC::DoGetAsBitmap(const wxRect
*subrect
) const
185 wxBitmap bmp
= GetSelectedBitmap();
186 return subrect
? bmp
.GetSubBitmap(*subrect
) : bmp
;
189 const wxBitmap
& wxGTKMemoryImplDC::GetSelectedBitmap() const
194 wxBitmap
& wxGTKMemoryImplDC::GetSelectedBitmap()