+ // FreeGetPixelCache();
+
+ // Be sure that foreground pixels (1) of
+ // the Icon will be painted with pen colour. [m_pen.SetColour()]
+ // Background pixels (0) will be painted with
+ // last selected background color. [::SetBackground]
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
+
+ int width, height;
+ Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
+ width = icon.GetWidth();
+ height = icon.GetHeight();
+ if (icon.GetDisplay() == m_display)
+ {
+ if (icon.GetDepth() <= 1)
+ {
+ XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y));
+ }
+
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ if (icon.GetDepth() <= 1)
+ {
+ XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ 0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ 0, 0, width, height,
+ (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y));
+ }
+ }
+ } else { /* Remote copy (different (Display*) m_displays) */
+ XImage *cache = NULL;
+ if (m_window && m_window->GetBackingPixmap())
+ XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),
+ (GC) m_gcBacking, 0, 0, width, height,
+ (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache);
+ XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
+ }
+ CalcBoundingBox (x, y);
+}
+#endif // 0
+
+// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
+bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
+ wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
+ wxCoord xsrcMask, wxCoord ysrcMask )
+{
+ wxCHECK_MSG( Ok(), FALSE, "invalid dc" );
+
+ wxWindowDC* sourceDC = wxDynamicCast(source, wxWindowDC);
+
+ wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." );
+
+ // FreeGetPixelCache();
+
+ // Be sure that foreground pixels (1) of the Icon will be painted with pen
+ // colour. [m_pen.SetColour()] Background pixels (0) will be painted with
+ // last selected background color. [::SetBackground]
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
+
+ // Do bitmap scaling if necessary
+
+ wxBitmap *scaledBitmap = (wxBitmap*) NULL;
+ Pixmap sourcePixmap = (Pixmap) NULL;
+ double scaleX, scaleY;
+ GetUserScale(& scaleX, & scaleY);
+
+ /* TODO: use the mask origin when drawing transparently */
+ if (xsrcMask == -1 && ysrcMask == -1)
+ {
+ xsrcMask = xsrc; ysrcMask = ysrc;
+ }
+
+ // Sorry, can't scale masks just yet
+ if (!useMask && (scaleX != 1.0 || scaleY != 1.0) && sourceDC->IsKindOf(CLASSINFO(wxMemoryDC)))
+ {
+ wxMemoryDC* memDC = (wxMemoryDC*) sourceDC;
+ wxBitmap& bitmap = memDC->GetBitmap();
+
+ wxASSERT_MSG( (bitmap.Ok()), "Bad source bitmap in wxWindowDC::Blit");
+
+ wxImage image(bitmap);
+ if (!image.Ok())
+ {
+ sourcePixmap = (Pixmap) bitmap.GetPixmap();
+ }
+ else
+ {
+ int scaledW = (int) (bitmap.GetWidth() * scaleX);
+ int scaledH = (int) (bitmap.GetHeight() * scaleY);
+
+ image = image.Scale(scaledW, scaledH);
+ scaledBitmap = new wxBitmap(image.ConvertToBitmap());
+ sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
+ }
+ }
+ else
+ sourcePixmap = (Pixmap) sourceDC->m_pixmap;
+
+ if (m_pixmap && sourcePixmap)
+ {
+ /* MATTHEW: [9] */
+ int orig = m_logicalFunction;
+
+ SetLogicalFunction (rop);
+
+ if (m_display != sourceDC->m_display)
+ {
+ XImage *cache = NULL;
+
+ if (m_window && m_window->GetBackingPixmap())
+ XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
+ (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),
+ (GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest),
+ TRUE, &cache);
+
+ if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
+ {
+ wxMemoryDC *memDC = (wxMemoryDC *)source;
+ wxBitmap& sel = memDC->GetBitmap();
+ if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
+ }
+ }
+
+ XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest),
+ FALSE, &cache);
+
+ if ( useMask )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
+ }
+
+ } else
+ {
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ // +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1
+ if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1)
+ {
+ XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest));
+ }
+ }
+ if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
+ {
+ wxMemoryDC *memDC = (wxMemoryDC *)source;
+ wxBitmap& sel = memDC->GetBitmap();
+ if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
+ }
+ }
+
+ // Check if we're copying from a mono bitmap
+ if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
+ ((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
+ {
+ XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest));
+
+ }
+ if ( useMask )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
+ }
+
+ } /* Remote/local (Display*) m_display */
+ CalcBoundingBox (xdest, ydest);
+ CalcBoundingBox (xdest + width, ydest + height);
+
+ SetLogicalFunction(orig);
+
+ if (scaledBitmap) delete scaledBitmap;
+
+ return TRUE;