]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/dcmemory.cpp
d502b5bd48d9ce06fee27693e0e67b10c944373d
   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" 
  14 #include "wx/gtk/dcmemory.h" 
  19 //----------------------------------------------------------------------------- 
  21 //----------------------------------------------------------------------------- 
  23 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
) 
  25 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC 
*owner 
) 
  26   : wxWindowDCImpl( owner 
) 
  31 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC 
*owner
, wxBitmap
& bitmap
) 
  32   : wxWindowDCImpl( owner 
) 
  38 wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC 
*owner
, wxDC 
*WXUNUSED(dc
) ) 
  39   : wxWindowDCImpl( owner 
) 
  44 wxMemoryDCImpl::~wxMemoryDCImpl() 
  46     g_object_unref(m_context
); 
  49 void wxMemoryDCImpl::Init() 
  53     m_cmap 
= gtk_widget_get_default_colormap(); 
  55     m_context 
= gdk_pango_context_get(); 
  56     // Note: The Sun customised version of Pango shipping with Solaris 10 
  57     // crashes if the language is left NULL (see bug 1374114) 
  58     pango_context_set_language( m_context
, gtk_get_default_language() ); 
  59     m_layout 
= pango_layout_new( m_context 
); 
  60     m_fontdesc 
= pango_font_description_copy( pango_context_get_font_description( m_context 
) ); 
  63 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap 
) 
  68     if (m_selected
.IsOk()) 
  70         m_gdkwindow 
= m_selected
.GetPixmap(); 
  72         m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
); 
  83 void wxMemoryDCImpl::SetPen( const wxPen
& penOrig 
) 
  86     if ( m_selected
.IsOk() && 
  87             m_selected
.GetDepth() == 1 && 
  88                 (pen 
!= *wxTRANSPARENT_PEN
) ) 
  90         pen
.SetColour( pen
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
  93     wxWindowDCImpl::SetPen( pen 
); 
  96 void wxMemoryDCImpl::SetBrush( const wxBrush
& brushOrig 
) 
  98     wxBrush 
brush( brushOrig 
); 
  99     if ( m_selected
.IsOk() && 
 100             m_selected
.GetDepth() == 1 && 
 101                 (brush 
!= *wxTRANSPARENT_BRUSH
) ) 
 103         brush
.SetColour( brush
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE
); 
 106     wxWindowDCImpl::SetBrush( brush 
); 
 109 void wxMemoryDCImpl::SetBackground( const wxBrush
& brushOrig 
) 
 111     wxBrush 
brush(brushOrig
); 
 113     if ( m_selected
.IsOk() && 
 114             m_selected
.GetDepth() == 1 && 
 115                 (brush 
!= *wxTRANSPARENT_BRUSH
) ) 
 117         brush
.SetColour( brush
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
 120     wxWindowDCImpl::SetBackground( brush 
); 
 123 void wxMemoryDCImpl::SetTextForeground( const wxColour
& col 
) 
 125     if ( m_selected
.IsOk() && m_selected
.GetDepth() == 1 ) 
 126         wxWindowDCImpl::SetTextForeground( col 
== *wxWHITE 
? *wxBLACK 
: *wxWHITE
); 
 128         wxWindowDCImpl::SetTextForeground( col 
); 
 131 void wxMemoryDCImpl::SetTextBackground( const wxColour 
&col 
) 
 133     if (m_selected
.IsOk() && m_selected
.GetDepth() == 1) 
 134         wxWindowDCImpl::SetTextBackground( col 
== *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
 136         wxWindowDCImpl::SetTextBackground( col 
); 
 139 void wxMemoryDCImpl::DoGetSize( int *width
, int *height 
) const 
 141     if (m_selected
.IsOk()) 
 143         if (width
) (*width
) = m_selected
.GetWidth(); 
 144         if (height
) (*height
) = m_selected
.GetHeight(); 
 148         if (width
) (*width
) = 0; 
 149         if (height
) (*height
) = 0; 
 153 wxBitmap 
wxMemoryDCImpl::DoGetAsBitmap(const wxRect 
*subrect
) const 
 155     wxBitmap bmp 
= GetSelectedBitmap(); 
 156     return subrect 
? bmp
.GetSubBitmap(*subrect
) : bmp
; 
 159 const wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap() const 
 164 wxBitmap
& wxMemoryDCImpl::GetSelectedBitmap()