+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ // Check for negative width and height
+ if (height < 0)
+ {
+ y = y + height;
+ height = - height ;
+ }
+
+ if (width < 0)
+ {
+ x = x + width;
+ width = - width ;
+ }
+
+ static const int angle = 23040;
+
+ int xd, yd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wd = XLOG2DEVREL(width) ;
+ hd = YLOG2DEVREL(height) ;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ XLOG2DEVREL (width) - WX_GC_CF,
+ YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ XLOG2DEVREL (width) - WX_GC_CF,
+ YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+
+}
+
+bool wxWindowDC::CanDrawBitmap() const
+{
+ wxCHECK_MSG( Ok(), false, "invalid dc" );
+
+ return true;
+}
+
+// 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." );
+
+ // Be sure that foreground pixels (1) of the Icon will be painted with
+ // foreground colour. [m_textForegroundColour] Background pixels (0)
+ // will be painted with backgound colour (m_textBackgroundColour)
+ // Using ::SetPen is horribly slow, so avoid doing it
+ int oldBackgroundPixel = -1;
+ int oldForegroundPixel = -1;
+
+ if (m_textBackgroundColour.Ok())
+ {
+ oldBackgroundPixel = m_backgroundPixel;
+ int pixel = m_textBackgroundColour.AllocColour(m_display);
+
+ XSetBackground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetBackground ((Display*) m_display,(GC) m_gcBacking,
+ pixel);
+ }
+ if (m_textForegroundColour.Ok())
+ {
+ oldForegroundPixel = m_currentColour.GetPixel();
+
+ if( m_textForegroundColour.GetPixel() <= -1 )
+ CalculatePixel( m_textForegroundColour,
+ m_textForegroundColour, true);
+
+ int pixel = m_textForegroundColour.GetPixel();
+ if (pixel > -1)
+ SetForegroundPixelWithLogicalFunction(pixel);
+ }
+
+ // Do bitmap scaling if necessary
+
+ wxBitmap *scaledBitmap = (wxBitmap*) NULL;
+ Pixmap sourcePixmap = (Pixmap) NULL;
+ double scaleX, scaleY;
+ GetUserScale(& scaleX, & scaleY);
+ bool retVal = false;
+
+ /* 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.ConvertToImage();
+ if (!image.Ok())
+ {
+ sourcePixmap = (Pixmap) bitmap.GetDrawable();
+ }
+ else
+ {
+ int scaledW = (int) (bitmap.GetWidth() * scaleX);
+ int scaledH = (int) (bitmap.GetHeight() * scaleY);
+
+ image = image.Scale(scaledW, scaledH);
+ scaledBitmap = new wxBitmap(image);
+ sourcePixmap = (Pixmap) scaledBitmap->GetDrawable();
+ }
+ }
+ 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()->GetBitmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
+ 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 )
+ {
+ if ( m_clipRegion )
+ XSetRegion ((Display*) m_display, (GC) m_gc,
+ (Region) m_clipRegion);
+ else
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
+ }
+
+ } else
+ { //XGCValues values;
+ //XGetGCValues((Display*)m_display, (GC)m_gc, GCForeground, &values);
+
+ 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()->GetBitmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
+ 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 )
+ {
+ if ( m_clipRegion )
+ XSetRegion ((Display*) m_display, (GC) m_gc,
+ (Region) m_clipRegion);
+ else
+ 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);
+
+ retVal = true;
+ }
+ if (scaledBitmap) delete scaledBitmap;
+
+ if (oldBackgroundPixel > -1)
+ {
+ XSetBackground ((Display*) m_display, (GC) m_gc, oldBackgroundPixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetBackground ((Display*) m_display,(GC) m_gcBacking,
+ oldBackgroundPixel);
+ }
+ if (oldForegroundPixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, oldForegroundPixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking,
+ oldForegroundPixel);
+ }
+
+ return retVal;
+}