X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/903f689bf7c3c379cba45881373aa9bdd15d6e70..520e470fdd0daef09c77938db642e4583933c90d:/src/gtk/dcclient.cpp diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index e75db15ce0..84d0cebf07 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -28,7 +28,7 @@ #define num_hatches 6 static GdkPixmap *hatches[num_hatches]; -static GdkPixmap **hatch_bitmap = NULL; +static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL; //----------------------------------------------------------------------------- // constants @@ -87,20 +87,20 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC,wxDC) wxPaintDC::wxPaintDC(void) { - m_penGC = NULL; - m_brushGC = NULL; - m_textGC = NULL; - m_bgGC = NULL; - m_cmap = NULL; + m_penGC = (GdkGC *) NULL; + m_brushGC = (GdkGC *) NULL; + m_textGC = (GdkGC *) NULL; + m_bgGC = (GdkGC *) NULL; + m_cmap = (GdkColormap *) NULL; } wxPaintDC::wxPaintDC( wxWindow *window ) { - m_penGC = NULL; - m_brushGC = NULL; - m_textGC = NULL; - m_bgGC = NULL; - m_cmap = NULL; + m_penGC = (GdkGC *) NULL; + m_brushGC = (GdkGC *) NULL; + m_textGC = (GdkGC *) NULL; + m_bgGC = (GdkGC *) NULL; + m_cmap = (GdkColormap *) NULL; if (!window) return; GtkWidget *widget = window->m_wxwindow; @@ -115,11 +115,6 @@ wxPaintDC::wxPaintDC( wxWindow *window ) m_isDrawable = TRUE; SetUpDC(); - - long x = 0; - long y = 0; - window->GetDrawingOffset( &x, &y ); - SetInternalDeviceOrigin( -x, -y ); } wxPaintDC::~wxPaintDC(void) @@ -129,10 +124,12 @@ wxPaintDC::~wxPaintDC(void) void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col), int WXUNUSED(style) ) { + wxFAIL_MSG( "wxPaintDC::FloodFill not implemented" ); } bool wxPaintDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const { + wxFAIL_MSG( "wxPaintDC::GetPixel not implemented" ); return FALSE; } @@ -140,6 +137,10 @@ void wxPaintDC::DrawLine( long x1, long y1, long x2, long y2 ) { if (!Ok()) return; + // FIXME: is this right? Causes a segfault on my system and doesn't + // seem right: wxPaintDC does not inherit from wxMemoryDC + // if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (m_pen.GetStyle() != wxTRANSPARENT) { gdk_draw_line( m_window, m_penGC, @@ -151,6 +152,10 @@ void wxPaintDC::CrossHair( long x, long y ) { if (!Ok()) return; + // FIXME: is this right? Causes a segfault on my system and doesn't + // seem right: wxPaintDC does not inherit from wxMemoryDC + // if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (m_pen.GetStyle() != wxTRANSPARENT) { int w = 0; @@ -169,6 +174,8 @@ void wxPaintDC::DrawArc( long x1, long y1, long x2, long y2, double xc, double y { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + long xx1 = XLOG2DEV(x1); long yy1 = YLOG2DEV(y1); long xx2 = XLOG2DEV(x2); @@ -217,6 +224,8 @@ void wxPaintDC::DrawEllipticArc( long x, long y, long width, long height, double { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + long xx = XLOG2DEV(x); long yy = YLOG2DEV(y); long ww = m_signX * XLOG2DEVREL(width); @@ -239,6 +248,8 @@ void wxPaintDC::DrawPoint( long x, long y ) { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (m_pen.GetStyle() != wxTRANSPARENT) gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); } @@ -247,6 +258,8 @@ void wxPaintDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset ) { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (m_pen.GetStyle() == wxTRANSPARENT) return; for (int i = 0; i < n-1; i++) @@ -263,6 +276,8 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset ) { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (m_pen.GetStyle() == wxTRANSPARENT) return; wxNode *node = points->First(); @@ -279,10 +294,12 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset ) } } -void wxPaintDC::DrawPolygon( int n, wxPoint points[], - long xoffset, long yoffset, int WXUNUSED(fillStyle) ) - { - if (!Ok()) return; +void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle) ) +{ + if (!Ok()) return; + + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (!n) return; // Nothing to draw GdkPoint *gdkpoints = new GdkPoint[n+1]; int i; @@ -304,12 +321,13 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[], delete[] gdkpoints; } -void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, - long yoffset, int WXUNUSED(fillStyle)) - { +void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUNUSED(fillStyle)) +{ + if (!Ok()) return; + + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + int n = lines->Number(); - - if (!Ok()) return; GdkPoint *gdkpoints = new GdkPoint[n]; wxNode *node = lines->First(); int cnt=0; @@ -341,6 +359,8 @@ void wxPaintDC::DrawRectangle( long x, long y, long width, long height ) { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + long xx = XLOG2DEV(x); long yy = YLOG2DEV(y); long ww = m_signX * XLOG2DEVREL(width); @@ -364,6 +384,8 @@ void wxPaintDC::DrawRoundedRectangle( long x, long y, long width, long height, d { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + if (radius < 0.0) radius = - radius * ((width < height) ? width : height); long xx = XLOG2DEV(x); @@ -429,6 +451,8 @@ void wxPaintDC::DrawEllipse( long x, long y, long width, long height ) { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + long xx = XLOG2DEV(x); long yy = YLOG2DEV(y); long ww = m_signX * XLOG2DEVREL(width); @@ -456,10 +480,12 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) if (!icon.Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + int xx = XLOG2DEV(x); int yy = YLOG2DEV(y); - GdkBitmap *mask = NULL; + GdkBitmap *mask = (GdkBitmap *) NULL; if (icon.GetMask()) mask = icon.GetMask()->GetBitmap(); if (useMask && mask) @@ -473,7 +499,7 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) if (useMask && mask) { - gdk_gc_set_clip_mask( m_penGC, NULL ); + gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_origin( m_penGC, 0, 0 ); } } @@ -483,21 +509,22 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height, { if (!Ok()) return FALSE; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + // CMB 20/5/98: add blitting of bitmaps if (source->IsKindOf(CLASSINFO(wxMemoryDC))) { wxMemoryDC* srcDC = (wxMemoryDC*)source; - GdkBitmap* bmap = srcDC->m_selected.GetBitmap(); + GdkBitmap* bmap = srcDC->m_selected.GetBitmap(); if (bmap) { - gdk_draw_bitmap ( - m_window, - m_textGC, - bmap, - source->DeviceToLogicalX(xsrc), source->DeviceToLogicalY(ysrc), - XLOG2DEV(xdest), YLOG2DEV(ydest), - source->DeviceToLogicalXRel(width), source->DeviceToLogicalYRel(height) - ); + gdk_draw_bitmap( m_window, m_textGC, bmap, + source->DeviceToLogicalX(xsrc), + source->DeviceToLogicalY(ysrc), + XLOG2DEV(xdest), + YLOG2DEV(ydest), + source->DeviceToLogicalXRel(width), + source->DeviceToLogicalYRel(height) ); return TRUE; } } @@ -524,6 +551,8 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us { if (!Ok()) return; + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + GdkFont *font = m_font.GetInternalFont( m_scaleY ); x = XLOG2DEV(x); @@ -552,22 +581,25 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us } } - - bool wxPaintDC::CanGetTextExtent(void) const { return TRUE; } void wxPaintDC::GetTextExtent( const wxString &string, long *width, long *height, - long *WXUNUSED(descent), long *WXUNUSED(externalLeading), - wxFont *WXUNUSED(theFont), bool WXUNUSED(use16) ) + long *descent, long *externalLeading, + wxFont *theFont, bool WXUNUSED(use16) ) { if (!Ok()) return; - GdkFont *font = m_font.GetInternalFont( m_scaleY ); + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; + + GdkFont *font = fontToUse.GetInternalFont( m_scaleY ); if (width) (*width) = long(gdk_string_width( font, string ) / m_scaleX); if (height) (*height) = long((font->ascent + font->descent) / m_scaleY); + if (descent) (*descent) = long(font->descent / m_scaleY); + if (externalLeading) (*externalLeading) = 0; // ?? } long wxPaintDC::GetCharWidth(void) @@ -575,7 +607,7 @@ long wxPaintDC::GetCharWidth(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return gdk_string_width( font, "H" ); + return long(gdk_string_width( font, "H" ) / m_scaleX); } long wxPaintDC::GetCharHeight(void) @@ -583,14 +615,14 @@ long wxPaintDC::GetCharHeight(void) if (!Ok()) return 0; GdkFont *font = m_font.GetInternalFont( m_scaleY ); - return font->ascent + font->descent; + return long((font->ascent + font->descent) / m_scaleY); } void wxPaintDC::Clear(void) { if (!Ok()) return; -// DestroyClippingRegion(); + if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); if (m_isDrawable) { @@ -823,10 +855,10 @@ void wxPaintDC::DestroyClippingRegion(void) { wxDC::DestroyClippingRegion(); - gdk_gc_set_clip_rectangle( m_penGC, NULL ); - gdk_gc_set_clip_rectangle( m_brushGC, NULL ); - gdk_gc_set_clip_rectangle( m_textGC, NULL ); - gdk_gc_set_clip_rectangle( m_bgGC, NULL ); + gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL ); + gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL ); + gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL ); + gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL ); } void wxPaintDC::SetUpDC(void) @@ -852,12 +884,12 @@ void wxPaintDC::SetUpDC(void) if (!hatch_bitmap) { hatch_bitmap = hatches; - hatch_bitmap[0] = gdk_bitmap_create_from_data( NULL, bdiag_bits, bdiag_width, bdiag_height ); - hatch_bitmap[1] = gdk_bitmap_create_from_data( NULL, cdiag_bits, cdiag_width, cdiag_height ); - hatch_bitmap[2] = gdk_bitmap_create_from_data( NULL, fdiag_bits, fdiag_width, fdiag_height ); - hatch_bitmap[3] = gdk_bitmap_create_from_data( NULL, cross_bits, cross_width, cross_height ); - hatch_bitmap[4] = gdk_bitmap_create_from_data( NULL, horiz_bits, horiz_width, horiz_height ); - hatch_bitmap[5] = gdk_bitmap_create_from_data( NULL, verti_bits, verti_width, verti_height ); + hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height ); + hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height ); + hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height ); + hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height ); + hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height ); + hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height ); } } @@ -981,7 +1013,7 @@ static void wx_spline_draw_point_array(wxDC *dc) } } -void wxPaintDC::DrawOpenSpline( wxList *points ) +void wxPaintDC::DrawSpline( wxList *points ) { wxPoint *p; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;