X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dfad0599246651d4994e348d868a3e65613c7379..a5e13868ca700aa39bae26b8fb13c640f466d9f0:/src/gtk1/dcclient.cpp?ds=sidebyside diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 84d0cebf07..3e8025961b 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -2,9 +2,8 @@ // Name: dcclient.cpp // Purpose: // Author: Robert Roebling -// Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Copyright: (c) 1998 Robert Roebling, Markus Holzem, Chris Breeze // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -92,6 +91,7 @@ wxPaintDC::wxPaintDC(void) m_textGC = (GdkGC *) NULL; m_bgGC = (GdkGC *) NULL; m_cmap = (GdkColormap *) NULL; + m_isMemDC = FALSE; } wxPaintDC::wxPaintDC( wxWindow *window ) @@ -112,13 +112,14 @@ wxPaintDC::wxPaintDC( wxWindow *window ) else m_cmap = gtk_widget_get_colormap( window->m_widget ); - m_isDrawable = TRUE; + m_isMemDC = FALSE; SetUpDC(); } wxPaintDC::~wxPaintDC(void) { + Destroy(); } void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1), @@ -137,10 +138,6 @@ 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, @@ -152,10 +149,6 @@ 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; @@ -174,8 +167,6 @@ 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); @@ -224,8 +215,6 @@ 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); @@ -248,8 +237,6 @@ 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) ); } @@ -258,8 +245,6 @@ 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++) @@ -276,8 +261,6 @@ 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(); @@ -298,8 +281,6 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset { 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; @@ -325,8 +306,6 @@ void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUN { if (!Ok()) return; - if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); - int n = lines->Number(); GdkPoint *gdkpoints = new GdkPoint[n]; wxNode *node = lines->First(); @@ -359,8 +338,6 @@ 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); @@ -384,8 +361,6 @@ 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); @@ -451,8 +426,6 @@ 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); @@ -480,8 +453,6 @@ 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); @@ -509,10 +480,9 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height, { if (!Ok()) return FALSE; - if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); + wxClientDC *csrc = (wxClientDC*)source; - // CMB 20/5/98: add blitting of bitmaps - if (source->IsKindOf(CLASSINFO(wxMemoryDC))) + if (csrc->m_isMemDC) { wxMemoryDC* srcDC = (wxMemoryDC*)source; GdkBitmap* bmap = srcDC->m_selected.GetBitmap(); @@ -529,7 +499,6 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height, } } - wxClientDC *csrc = (wxClientDC*)source; gdk_window_copy_area ( m_window, m_penGC, XLOG2DEV(xdest), YLOG2DEV(ydest), csrc->GetWindow(), @@ -551,8 +520,6 @@ 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); @@ -622,9 +589,7 @@ void wxPaintDC::Clear(void) { if (!Ok()) return; - if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage(); - - if (m_isDrawable) + if (!m_isMemDC) { gdk_window_clear( m_window ); } @@ -863,15 +828,12 @@ void wxPaintDC::DestroyClippingRegion(void) void wxPaintDC::SetUpDC(void) { + Destroy(); m_ok = TRUE; m_logicalFunction = wxCOPY; - if (m_penGC) gdk_gc_unref( m_penGC ); m_penGC = gdk_gc_new( m_window ); - if (m_brushGC) gdk_gc_unref( m_brushGC ); m_brushGC = gdk_gc_new( m_window ); - if (m_textGC) gdk_gc_unref( m_textGC ); m_textGC = gdk_gc_new( m_window ); - if (m_bgGC) gdk_gc_unref( m_bgGC ); m_bgGC = gdk_gc_new( m_window ); SetTextForeground( m_textForegroundColour ); SetTextBackground( m_textBackgroundColour ); @@ -893,6 +855,18 @@ void wxPaintDC::SetUpDC(void) } } +void wxPaintDC::Destroy(void) +{ + if (m_penGC) gdk_gc_unref( m_penGC ); + m_penGC = (GdkGC*) NULL; + if (m_brushGC) gdk_gc_unref( m_brushGC ); + m_brushGC = (GdkGC*) NULL; + if (m_textGC) gdk_gc_unref( m_textGC ); + m_textGC = (GdkGC*) NULL; + if (m_bgGC) gdk_gc_unref( m_bgGC ); + m_bgGC = (GdkGC*) NULL; +} + GdkWindow *wxPaintDC::GetWindow(void) { return m_window;