X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf5752a4a050ded0fac576d3d76661e36320c6c6..8e5ec129614e2473fd240f2a6e94ee56e3a9039b:/src/gtk/dcclient.cpp diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 62e70ce5d6..06b60cd000 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,17 +15,20 @@ #endif #include "wx/dcclient.h" -#include "wx/dcmemory.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/dcmemory.h" + #include "wx/math.h" // for floating-point functions +#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 - #include #include #include @@ -172,7 +175,7 @@ static void wxCleanUpGCPool() for (int i = 0; i < wxGCPoolSize; i++) { if (wxGCPool[i].m_gc) - g_object_unref (G_OBJECT (wxGCPool[i].m_gc)); + g_object_unref (wxGCPool[i].m_gc); } free(wxGCPool); @@ -328,7 +331,7 @@ wxWindowDC::~wxWindowDC() Destroy(); if (m_layout) - g_object_unref( G_OBJECT( m_layout ) ); + g_object_unref (m_layout); if (m_fontdesc) pango_font_description_free( m_fontdesc ); } @@ -365,7 +368,11 @@ void wxWindowDC::SetUpDC() /* background colour */ m_backgroundBrush = *wxWHITE_BRUSH; m_backgroundBrush.GetColour().CalcPixel( m_cmap ); - GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor(); +#ifdef __WXGTK24__ + const GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor(); +#else + GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor(); +#endif /* m_textGC */ m_textForegroundColour.CalcPixel( m_cmap ); @@ -1062,7 +1069,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); - bool is_mono = (bitmap.GetBitmap() != NULL); + bool is_mono = bitmap.GetDepth() == 1; // scale/translate size and position int xx = XLOG2DEV(x); @@ -1126,7 +1133,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 ); - g_object_unref (G_OBJECT (gc)); + g_object_unref (gc); } if (is_mono) @@ -1155,12 +1162,12 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, GdkGC *gc = gdk_gc_new( bitmap2 ); gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); + gdk_wx_draw_bitmap( bitmap2, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 ); gdk_draw_drawable( m_window, m_textGC, bitmap2, 0, 0, xx, yy, -1, -1 ); - g_object_unref (G_OBJECT (bitmap2)); - g_object_unref (G_OBJECT (gc)); + g_object_unref (bitmap2); + g_object_unref (gc); } else { @@ -1201,7 +1208,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, } if (new_mask) - g_object_unref (G_OBJECT (new_mask)); + g_object_unref (new_mask); } bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, @@ -1369,7 +1376,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 ); - g_object_unref (G_OBJECT (gc)); + g_object_unref (gc); } if (is_mono) @@ -1409,12 +1416,12 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, GdkGC *gc = gdk_gc_new( bitmap ); gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); + gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetPixmap(), 0, 0, 0, 0, -1, -1 ); gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch ); - g_object_unref (G_OBJECT (bitmap)); - g_object_unref (G_OBJECT (gc)); + g_object_unref (bitmap); + g_object_unref (gc); } else { @@ -1442,7 +1449,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, } if (new_mask) - g_object_unref (G_OBJECT (new_mask)); + g_object_unref (new_mask); } else // use_bitmap_method { @@ -1582,16 +1589,17 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) { + if (!m_window || text.empty()) + return; + + wxCHECK_RET( Ok(), wxT("invalid window dc") ); + if ( wxIsNullDouble(angle) ) { DrawText(text, x, y); return; } - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (!m_window) return; - wxCoord w; wxCoord h; @@ -1822,7 +1830,7 @@ void wxWindowDC::SetFont( const wxFont &font ) if (oldContext != m_context) { if (m_layout) - g_object_unref( G_OBJECT( m_layout ) ); + g_object_unref (m_layout); m_layout = pango_layout_new( m_context ); } @@ -2001,7 +2009,7 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) { - if (m_brush.GetStipple()->GetPixmap()) + if (m_brush.GetStipple()->GetDepth() != 1) { gdk_gc_set_fill( m_brushGC, GDK_TILED ); gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() ); @@ -2009,7 +2017,7 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) else { gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() ); + gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetPixmap() ); } } @@ -2052,7 +2060,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok())) { - if (m_backgroundBrush.GetStipple()->GetPixmap()) + if (m_backgroundBrush.GetStipple()->GetDepth() != 1) { gdk_gc_set_fill( m_bgGC, GDK_TILED ); gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() ); @@ -2060,7 +2068,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) else { gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() ); + gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() ); } }