X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e4da1035e402e722f799d3ed498dfa789b74f02f..920b9675d9e4ae7f721bd6eeb85c184a74434f7b:/src/gtk/dcclient.cpp diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index bd7308d271..43183328f9 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -3,7 +3,7 @@ // Purpose: // Author: Robert Roebling // RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling, Markus Holzem, Chris Breeze +// Copyright: (c) 1998 Robert Roebling, Chris Breeze // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -695,20 +695,28 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord if (m_pen.GetStyle() == wxTRANSPARENT) return; if (n <= 0) return; - CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset ); + GdkPoint *gpts = new GdkPoint[n]; + if (! gpts) + { + wxFAIL_MSG( wxT("Cannot allocate PolyLine") ); + return; + } - for (int i = 0; i < n-1; i++) + for (int i = 0; i < n; i++) { wxCoord x1 = XLOG2DEV(points[i].x + xoffset); - wxCoord x2 = XLOG2DEV(points[i+1].x + xoffset); - wxCoord y1 = YLOG2DEV(points[i].y + yoffset); // oh, what a waste - wxCoord y2 = YLOG2DEV(points[i+1].y + yoffset); + wxCoord y1 = YLOG2DEV(points[i].y + yoffset); - if (m_window) - gdk_draw_line( m_window, m_penGC, x1, y1, x2, y2 ); + CalcBoundingBox( x1 + xoffset, y1 + yoffset ); - CalcBoundingBox( points[i+1].x + xoffset, points[i+1].y + yoffset ); + gpts[i].x = x1; + gpts[i].y = y1; } + + if (m_window) + gdk_draw_lines( m_window, m_penGC, gpts, n); + + delete[] gpts; } void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle) ) @@ -1427,24 +1435,24 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCHECK_RET( font, wxT("invalid font") ); #endif - x = XLOG2DEV(x); y = YLOG2DEV(y); #ifdef __WXGTK20__ wxCHECK_RET( m_context, wxT("no Pango context") ); - wxCHECK_RET( m_layout, wxT("o Pango layout") ); + wxCHECK_RET( m_layout, wxT("no Pango layout") ); wxCHECK_RET( m_fontdesc, wxT("no Pango font description") ); #if wxUSE_UNICODE const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); - pango_layout_set_text( m_layout, (const char*) data, strlen( (const char*) data )); #else const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text( m_layout, (const char*) data, strlen( (const char*) data )); #endif + pango_layout_set_text( m_layout, (const char*) data, strlen( (const char*) data )); + int w,h; + if (m_scaleY != 1.0) { // If there is a user or actually any scale applied to @@ -1458,6 +1466,14 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // actually apply scaled font pango_layout_set_font_description( m_layout, m_fontdesc ); + + pango_layout_get_pixel_size( m_layout, &w, &h ); + if ( m_backgroundMode == wxSOLID ) + { + gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); + gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); + gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); + } // Draw layout. gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); @@ -1465,18 +1481,22 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // reset unscaled size pango_font_description_set_size( m_fontdesc, oldSize ); - // actually apply scaled font + // actually apply unscaled font pango_layout_set_font_description( m_layout, m_fontdesc ); } else { - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); + pango_layout_get_pixel_size( m_layout, &w, &h ); + if ( m_backgroundMode == wxSOLID ) + { + gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); + gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h); + gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); + } + // Draw layout. + gdk_draw_layout( m_window, m_textGC, x, y, m_layout ); } - // Measure layout. - int w,h; - pango_layout_get_pixel_size( m_layout, &w, &h ); wxCoord width = w; wxCoord height = h;