+ 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 )
+ {
+ 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 )
+ {
+ 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;
+}
+
+void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ // Since X draws from the baseline of the text, must add the text height
+ int cx = 0;
+ int cy = 0;
+ int ascent = 0;
+ int slen;
+
+ // Set FillStyle, otherwise X will use current stipple!
+ XGCValues gcV, gcBackingV;
+
+ XGetGCValues ((Display*) m_display, (GC)m_gc, GCFillStyle, &gcV);
+ XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid);
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XGetGCValues ((Display*) m_display, (GC)m_gcBacking, GCFillStyle,
+ &gcBackingV );
+ XSetFillStyle ((Display*) m_display, (GC) m_gcBacking, FillSolid);
+ }
+
+ slen = strlen(text);
+
+ if (m_font.Ok())
+ {
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
+ int direction, descent;
+ XCharStruct overall_return;
+#if 0
+ if (use16)
+ (void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction,
+ &ascent, &descent, &overall_return);
+ else
+#endif // 0
+ (void)XTextExtents((XFontStruct*) pFontStruct,
+ wxConstCast(text.c_str(), char),
+ slen, &direction,
+ &ascent, &descent, &overall_return);
+
+ cx = overall_return.width;
+ cy = ascent + descent;
+ }
+
+ // First draw a rectangle representing the text background, if a text
+ // background is specified
+ if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT))
+ {
+ wxColour oldPenColour = m_currentColour;
+ m_currentColour = m_textBackgroundColour;
+ bool sameColour = (oldPenColour.Ok () && m_textBackgroundColour.Ok () &&
+ (oldPenColour.Red () == m_textBackgroundColour.Red ()) &&
+ (oldPenColour.Blue () == m_textBackgroundColour.Blue ()) &&
+ (oldPenColour.Green () == m_textBackgroundColour.Green ()));
+
+ // This separation of the big && test required for gcc2.7/HP UX 9.02
+ // or pixel value can be corrupted!
+ sameColour = (sameColour &&
+ (oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel()));
+
+ if (!sameColour || !GetOptimization())
+ {
+ int pixel = m_textBackgroundColour.AllocColour(m_display);
+ m_currentColour = m_textBackgroundColour;
+
+ // Set the GC to the required colour
+ if (pixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
+ }
+ else
+ m_textBackgroundColour = oldPenColour ;
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy);
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y), cx, cy);
+ }
+
+ // Now set the text foreground and draw the text
+ if (m_textForegroundColour.Ok ())
+ {
+ wxColour oldPenColour = m_currentColour;
+ m_currentColour = m_textForegroundColour;
+ bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () &&
+ (oldPenColour.Red () == m_currentColour.Red ()) &&
+ (oldPenColour.Blue () == m_currentColour.Blue ()) &&
+ (oldPenColour.Green () == m_currentColour.Green ()) &&
+ (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
+
+ if (!sameColour || !GetOptimization())
+ {
+ int pixel = CalculatePixel(m_textForegroundColour,
+ m_currentColour, FALSE);
+
+ // Set the GC to the required colour
+ if (pixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
+ }
+ else
+ m_textForegroundColour = oldPenColour;
+ }
+
+ // We need to add the ascent, not the whole height, since X draws at the
+ // point above the descender.
+#if 0