- wxRegion tmp( xx,yy,ww,hh );
- tmp.Intersect( m_currentClippingRegion );
- if (tmp.IsEmpty())
- return TRUE;
- }
-
- int old_logical_func = m_logicalFunction;
- SetLogicalFunction( logical_func );
-
- if (use_bitmap_method)
- {
- // scale/translate bitmap size
- wxCoord bm_width = memDC->m_selected.GetWidth();
- wxCoord bm_height = memDC->m_selected.GetHeight();
-
- // Get clip coords for the bitmap. If we don't
- // use wxBitmap::Rescale(), which can clip the
- // bitmap, these are the same as the original
- // coordinates
- wxCoord cx = xx;
- wxCoord cy = yy;
- wxCoord cw = ww;
- wxCoord ch = hh;
-
- // interpret userscale of src too
- double xsc,ysc;
- memDC->GetUserScale(&xsc,&ysc);
- bm_width = (int) (bm_width / xsc);
- bm_height = (int) (bm_height / ysc);
-
- wxCoord bm_ww = XLOG2DEVREL( bm_width );
- wxCoord bm_hh = YLOG2DEVREL( bm_height );
-
- // Scale bitmap if required
- wxBitmap use_bitmap;
- if ((memDC->m_selected.GetWidth()!= bm_ww) || ( memDC->m_selected.GetHeight()!= bm_hh))
- {
- // This indicates that the blitting code below will get
- // a clipped bitmap and therefore needs to move the origin
- // accordingly
- wxRegion tmp( xx,yy,ww,hh );
- tmp.Intersect( m_currentClippingRegion );
- tmp.GetBox(cx,cy,cw,ch);
-
- // Scale and clipped bitmap
- use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh);
- }
- else
- {
- // Don't scale bitmap
- use_bitmap = memDC->m_selected;
- }
-
- // apply mask if any
- GdkBitmap *mask = (GdkBitmap *) NULL;
- if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
-
- GdkBitmap *new_mask = (GdkBitmap*) NULL;
-
- if (useMask && mask)
- {
- if (!m_currentClippingRegion.IsNull())
- {
- GdkColor col;
- new_mask = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, 1 );
- GdkGC *gc = gdk_gc_new( new_mask );
- col.pixel = 0;
- gdk_gc_set_foreground( gc, &col );
- gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh );
- col.pixel = 0;
- gdk_gc_set_background( gc, &col );
- col.pixel = 1;
- gdk_gc_set_foreground( gc, &col );
- gdk_gc_set_clip_region( gc, m_currentClippingRegion.GetRegion() );
- // was: gdk_gc_set_clip_origin( gc, -xx, -yy );
- gdk_gc_set_clip_origin( gc, -cx, -cy );
- 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 );
- gdk_gc_unref( gc );
- }
-
- if (is_mono)
- {
- if (new_mask)
- gdk_gc_set_clip_mask( m_textGC, new_mask );
- else
- gdk_gc_set_clip_mask( m_textGC, mask );
- // was: gdk_gc_set_clip_origin( m_textGC, xx, yy );
- gdk_gc_set_clip_origin( m_textGC, cx, cy );
- }
- else
- {
- if (new_mask)
- gdk_gc_set_clip_mask( m_penGC, new_mask );
- else
- gdk_gc_set_clip_mask( m_penGC, mask );
- // was: gdk_gc_set_clip_origin( m_penGC, xx, yy );
- gdk_gc_set_clip_origin( m_penGC, cx, cy );
- }
- }
-
- // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
- // drawing a mono-bitmap (XBitmap) we use the current text GC
-
- if (is_mono)
- {
-#ifdef __WXGTK20__
- GdkPixmap *bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, -1 );
- 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_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
-
- gdk_bitmap_unref( bitmap );
- gdk_gc_unref( gc );
-#else
- // was: gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
- gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, cx, cy, cw, ch );
-#endif
- }
- else
- {
- // was: gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
- gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch );
- }
-
- // remove mask again if any
- if (useMask && mask)
- {
- if (is_mono)
- {
- gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
- gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsNull())
- gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
- }
- else
- {
- gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
- gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsNull())
- gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
- }
- }
-
- if (new_mask)
- gdk_bitmap_unref( new_mask );
- }
- else // use_bitmap_method
- {
- if ((width != ww) || (height != hh))
- {
- // get clip coords
- wxRegion tmp( xx,yy,ww,hh );
- tmp.Intersect( m_currentClippingRegion );
- wxCoord cx,cy,cw,ch;
- tmp.GetBox(cx,cy,cw,ch);
-
- // rescale bitmap
- wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
-
- // draw scaled bitmap
- // was: gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
- gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 );
- }
- else
- {
- // No scaling and not a memory dc with a mask either
-
- // copy including child window contents
- gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
- gdk_window_copy_area( m_window, m_penGC, xx, yy,
- srcDC->GetWindow(),
- xsrc, ysrc, width, height );
- gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
- }