]>
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 //----------------------------------------------------------------------------- 
  22 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
,wxWindowDC
) 
  24 wxMemoryDC::wxMemoryDC() : wxWindowDC() 
  28     m_cmap 
= gtk_widget_get_default_colormap(); 
  30     m_context 
= gdk_pango_context_get(); 
  31     // Note: The Sun customised version of Pango shipping with Solaris 10 
  32     // crashes if the language is left NULL (see bug 1374114) 
  33     pango_context_set_language( m_context
, gtk_get_default_language() ); 
  34     m_layout 
= pango_layout_new( m_context 
); 
  35     m_fontdesc 
= pango_font_description_copy( pango_context_get_font_description( m_context 
) ); 
  38 wxMemoryDC::wxMemoryDC( wxDC 
*WXUNUSED(dc
) ) 
  43     m_cmap 
= gtk_widget_get_default_colormap(); 
  45     m_context 
= gdk_pango_context_get(); 
  46     pango_context_set_language( m_context
, gtk_get_default_language() ); 
  47     m_layout 
= pango_layout_new( m_context 
); 
  48     m_fontdesc 
= pango_font_description_copy( pango_context_get_font_description( m_context 
) ); 
  51 wxMemoryDC::~wxMemoryDC() 
  53     g_object_unref(m_context
); 
  56 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap 
) 
  62         if (m_selected
.GetPixmap()) 
  64             m_window 
= m_selected
.GetPixmap(); 
  68             m_window 
= m_selected
.GetBitmap(); 
  71         m_selected
.PurgeOtherRepresentations(wxBitmap::Pixmap
); 
  80         m_window 
= (GdkWindow 
*) NULL
; 
  84 void wxMemoryDC::SetPen( const wxPen
& penOrig 
) 
  87     if ( m_selected
.Ok() && 
  88             m_selected
.GetBitmap() && 
  89                 (pen 
!= *wxTRANSPARENT_PEN
) ) 
  91         pen
.SetColour( pen
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
  94     wxWindowDC::SetPen( pen 
); 
  97 void wxMemoryDC::SetBrush( const wxBrush
& brushOrig 
) 
  99     wxBrush 
brush( brushOrig 
); 
 100     if ( m_selected
.Ok() && 
 101             m_selected
.GetBitmap() && 
 102                 (brush 
!= *wxTRANSPARENT_BRUSH
) ) 
 104         brush
.SetColour( brush
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE
); 
 107     wxWindowDC::SetBrush( brush 
); 
 110 void wxMemoryDC::SetBackground( const wxBrush
& brushOrig 
) 
 112     wxBrush 
brush(brushOrig
); 
 114     if ( m_selected
.Ok() && 
 115             m_selected
.GetBitmap() && 
 116                 (brush 
!= *wxTRANSPARENT_BRUSH
) ) 
 118         brush
.SetColour( brush
.GetColour() == *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
 121     wxWindowDC::SetBackground( brush 
); 
 124 void wxMemoryDC::SetTextForeground( const wxColour
& col 
) 
 126     if ( m_selected
.Ok() && m_selected
.GetBitmap() ) 
 128         wxWindowDC::SetTextForeground( col 
== *wxWHITE 
? *wxBLACK 
: *wxWHITE
); 
 132         wxWindowDC::SetTextForeground( col 
); 
 136 void wxMemoryDC::SetTextBackground( const wxColour 
&col 
) 
 138     if (m_selected
.Ok() && m_selected
.GetBitmap()) 
 140         wxWindowDC::SetTextBackground( col 
== *wxWHITE 
? *wxBLACK 
: *wxWHITE 
); 
 144         wxWindowDC::SetTextBackground( col 
); 
 148 void wxMemoryDC::DoGetSize( int *width
, int *height 
) const 
 152         if (width
) (*width
) = m_selected
.GetWidth(); 
 153         if (height
) (*height
) = m_selected
.GetHeight(); 
 157         if (width
) (*width
) = 0; 
 158         if (height
) (*height
) = 0;