X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/15f0ad701496612df8c145e8e46d4b38515c0bbf..2240b1aa740739e35e646016511fc8a3302104a4:/src/gtk/dcclient.cpp diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 2ec99841b1..cfb49766cd 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: gtk/dcclient.cpp +// Name: src/gtk/dcclient.cpp // Purpose: // Author: Robert Roebling // RCS-ID: $Id$ @@ -15,13 +15,18 @@ #endif #include "wx/dcclient.h" -#include "wx/dcmemory.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/dcmemory.h" +#endif + #include "wx/image.h" #include "wx/module.h" -#include "wx/log.h" #include "wx/fontutil.h" #include "wx/gtk/win_gtk.h" +#include "wx/gtk/private.h" #include "wx/math.h" // for floating-point functions @@ -171,7 +176,7 @@ static void wxCleanUpGCPool() for (int i = 0; i < wxGCPoolSize; i++) { if (wxGCPool[i].m_gc) - gdk_gc_unref( wxGCPool[i].m_gc ); + g_object_unref (G_OBJECT (wxGCPool[i].m_gc)); } free(wxGCPool); @@ -1125,7 +1130,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED ); gdk_gc_set_stipple( gc, mask ); gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh ); - gdk_gc_unref( gc ); + g_object_unref (G_OBJECT (gc)); } if (is_mono) @@ -1158,8 +1163,8 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 ); - gdk_bitmap_unref( bitmap2 ); - gdk_gc_unref( gc ); + g_object_unref (G_OBJECT (bitmap2)); + g_object_unref (G_OBJECT (gc)); } else { @@ -1200,7 +1205,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, } if (new_mask) - gdk_bitmap_unref( new_mask ); + g_object_unref (G_OBJECT (new_mask)); } bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, @@ -1368,7 +1373,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED ); gdk_gc_set_stipple( gc, mask ); gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh ); - gdk_gc_unref( gc ); + g_object_unref (G_OBJECT (gc)); } if (is_mono) @@ -1412,8 +1417,8 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch ); - gdk_bitmap_unref( bitmap ); - gdk_gc_unref( gc ); + g_object_unref (G_OBJECT (bitmap)); + g_object_unref (G_OBJECT (gc)); } else { @@ -1441,7 +1446,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, } if (new_mask) - gdk_bitmap_unref( new_mask ); + g_object_unref (G_OBJECT (new_mask)); } else // use_bitmap_method { @@ -1496,16 +1501,11 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) bool underlined = m_font.Ok() && m_font.GetUnderlined(); -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - if ( !wdata ) + const wxCharBuffer data = wxGTK_CONV( text ); + if ( !data ) return; - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); -#endif - size_t datalen = strlen((const char*)data); - pango_layout_set_text( m_layout, (const char*) data, datalen); + const size_t datalen = strlen(data); + pango_layout_set_text( m_layout, data, datalen); if (underlined) { @@ -1700,27 +1700,24 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, *externalLeading = 0; if (string.empty()) - { return; - } - - // Set new font description - if (theFont) - pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description ); - // Set layout's text -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - const char *dataUTF8 = (const char *)data; -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - if ( !wdata ) - return; + // ensure that theFont is always non-NULL + if ( !theFont || !theFont->Ok() ) + theFont = wx_const_cast(wxFont *, &m_font); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - const char *dataUTF8 = (const char *)data; -#endif + // and use it if it's valid + if ( theFont->Ok() ) + { + pango_layout_set_font_description + ( + m_layout, + theFont->GetNativeFontInfo()->description + ); + } + // Set layout's text + const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, *theFont); if ( !dataUTF8 ) { // hardly ideal, but what else can we do if conversion failed?