X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3cbab64109b007fa1d939fe588f5e79f9105b915..677dc0ed1a3ff68af15f6246d6d0708d5264b07a:/src/gtk1/dcclient.cpp diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 9e8c3de0e7..0c63a7d84c 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: gtk/dcclient.cpp +// Name: src/gtk1/dcclient.cpp // Purpose: // Author: Robert Roebling // RCS-ID: $Id$ @@ -15,16 +15,19 @@ #endif #include "wx/dcclient.h" -#include "wx/dcmemory.h" -#include "wx/image.h" -#include "wx/module.h" -#include "wx/log.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/dcmemory.h" + #include "wx/math.h" // for floating-point functions + #include "wx/image.h" + #include "wx/module.h" +#endif + #include "wx/fontutil.h" #include "wx/gtk1/win_gtk.h" -#include "wx/math.h" // for floating-point functions - #include #include #include @@ -653,20 +656,9 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord if (m_pen.GetStyle() == wxTRANSPARENT) return; if (n <= 0) return; - //Check, if scaling is necessary - bool doScale(true); - long val(10); - if (!xoffset) - if (!yoffset) - if (XLOG2DEV(val)==val) - if (YLOG2DEV(val)==val) - doScale = false; - GdkPoint *gpts = NULL; - - if (doScale){ - gpts = new GdkPoint[n]; - if (! gpts) + GdkPoint * const gpts = new GdkPoint[n]; + if ( !gpts ) { wxFAIL_MSG( wxT("Cannot allocate PolyLine") ); return; @@ -674,28 +666,17 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord for (int i = 0; i < n; i++) { - wxCoord x1 = XLOG2DEV(points[i].x + xoffset); - wxCoord y1 = YLOG2DEV(points[i].y + yoffset); - - CalcBoundingBox( x1 + xoffset, y1 + yoffset ); + wxCoord x = points[i].x + xoffset, + y = points[i].y + yoffset; - gpts[i].x = x1; - gpts[i].y = y1; - } - } - else { - for (int i = 0; i < n; i++) { - CalcBoundingBox( points[i].x, points[i].y ); - } + CalcBoundingBox(x + xoffset, y + yoffset); - //GdkPoint and wxPoint have the same memory allignment, so we can cast one into another - gpts = reinterpret_cast(points); + gpts[i].x = XLOG2DEV(x); + gpts[i].y = YLOG2DEV(y); } - if (m_window) - gdk_draw_lines( m_window, m_penGC, gpts, n); + gdk_draw_lines( m_window, m_penGC, gpts, n); - if (doScale) delete[] gpts; } @@ -705,102 +686,66 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor if (n <= 0) return; - //Check, if scaling is necessary - bool doScale(true); - long val(10); - if (!xoffset) - if (!yoffset) - if (XLOG2DEV(val)==val) - if (YLOG2DEV(val)==val){ - doScale = false; - } - - GdkPoint *gdkpoints = NULL; + GdkPoint * const gpts = new GdkPoint[n]; - if (doScale){ - gdkpoints = new GdkPoint[n+1]; //FIXME: Why the "+1" - - int i; - for (i = 0 ; i < n ; i++) + for (int i = 0 ; i < n ; i++) { - gdkpoints[i].x = XLOG2DEV(points[i].x + xoffset); - gdkpoints[i].y = YLOG2DEV(points[i].y + yoffset); + wxCoord x = points[i].x + xoffset, + y = points[i].y + yoffset; - CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset ); - } - } - else { - int i(0); - for (; i < n ; ++i) { - CalcBoundingBox( points[i].x, points[i].y ); - } - //GdkPoint and wxPoint have the same memory allignment, so we can cast one into another - gdkpoints = reinterpret_cast (points); + CalcBoundingBox(x + xoffset, y + yoffset); + + gpts[i].x = XLOG2DEV(x); + gpts[i].y = YLOG2DEV(y); } - if (m_window) + if (m_brush.GetStyle() == wxSOLID) + { + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + } + else if (m_brush.GetStyle() != wxTRANSPARENT) { - //I think wxSOLID is the most often used style (it is for me), - //so I put it in front of the if ... ifelse's - if (m_brush.GetStyle() == wxSOLID) + if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - }else - if (m_brush.GetStyle() != wxTRANSPARENT) + gdk_gc_set_ts_origin( m_textGC, + m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); + gdk_draw_polygon( m_window, m_textGC, TRUE, gpts, n ); + gdk_gc_set_ts_origin( m_textGC, 0, 0 ); + } else + if (IS_15_PIX_HATCH(m_brush.GetStyle())) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - } + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (IS_16_PIX_HATCH(m_brush.GetStyle())) + { + gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); + } else + if (m_brush.GetStyle() == wxSTIPPLE) + { + gdk_gc_set_ts_origin( m_brushGC, + m_deviceOriginX % m_brush.GetStipple()->GetWidth(), + m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } - - if (m_pen.GetStyle() != wxTRANSPARENT) + else { -/* - for (i = 0 ; i < n ; i++) - { - gdk_draw_line( m_window, m_penGC, - gdkpoints[i%n].x, - gdkpoints[i%n].y, - gdkpoints[(i+1)%n].x, - gdkpoints[(i+1)%n].y); - } -*/ - gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n ); - + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); } } - if (doScale) - delete[] gdkpoints; + if (m_pen.GetStyle() != wxTRANSPARENT) + { + gdk_draw_polygon( m_window, m_penGC, FALSE, gpts, n ); + + } + + delete[] gpts; } void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -1603,7 +1548,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, void wxWindowDC::DoGetTextExtent(const wxString &string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, - wxFont *theFont) const + const wxFont *theFont) const { if ( width ) *width = 0;