+ int xx = XLOG2DEV (x);
+ int yy = YLOG2DEV (y);
+ int ww, hh;
+ wxDisplaySize (&ww, &hh);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, yy,
+ ww, yy);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xx, 0,
+ xx, hh);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ xx = XLOG2DEV_2 (x);
+ yy = YLOG2DEV_2 (y);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ 0, yy,
+ ww, yy);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xx, 0,
+ xx, hh);
+ }
+}
+
+void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ int xx1 = XLOG2DEV (x1);
+ int yy1 = YLOG2DEV (y1);
+ int xx2 = XLOG2DEV (x2);
+ int yy2 = YLOG2DEV (y2);
+ int xxc = XLOG2DEV (xc);
+ int yyc = YLOG2DEV (yc);
+ int xxc_2 = XLOG2DEV_2 (xc);
+ int yyc_2 = YLOG2DEV_2 (yc);
+
+ wxCoord dx = xx1 - xxc;
+ wxCoord dy = yy1 - yyc;
+ double radius = sqrt ((double)(dx * dx + dy * dy));
+ wxCoord r = (wxCoord) radius;
+
+ double radius1, radius2;
+
+ if (xx1 == xx2 && yy1 == yy2)
+ {
+ radius1 = 0.0;
+ radius2 = 360.0;
+ }
+ else if (radius == 0.0)
+ radius1 = radius2 = 0.0;
+ else
+ {
+ if (xx1 - xxc == 0)
+ if (yy1 - yyc < 0)
+ radius1 = 90.0;
+ else
+ radius1 = -90.0;
+ else
+ radius1 = -atan2 ((double) (yy1 - yyc), (double) (xx1 - xxc)) * 360.0 / (2 * M_PI);
+
+ if (xx2 - xxc == 0)
+ if (yy2 - yyc < 0)
+ radius2 = 90.0;
+ else
+ radius2 = -90.0;
+ else
+ radius2 = -atan2 ((double) (yy2 - yyc), (double) (xx2 - xxc)) * 360.0 / (2 * M_PI);
+ }
+ radius1 *= 64.0;
+ radius2 *= 64.0;
+ int alpha1 = (int) radius1;
+ int alpha2 = (int) (radius2 - radius1);
+ while (alpha2 <= 0)
+ alpha2 += 360 * 64;
+ while (alpha2 > 360 * 64)
+ alpha2 -= 360 * 64;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc,
+ xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
+
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
+ xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
+ }
+ CalcBoundingBox (x1, y1);
+ CalcBoundingBox (x2, y2);
+}
+
+void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ int xd, yd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wd = XLOG2DEVREL(width);
+ hd = YLOG2DEVREL(height);
+
+ if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
+ if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
+ int start = int(sa*64);
+ int end = int(ea*64);
+ if (start<0) start+=360*64;
+ if (end <0) end +=360*64;
+ if (end>start) end-=start;
+ else end+=360*64-start;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ m_autoSetting = true; // must be reset
+
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start, end);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
+ }
+
+ 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, start,end);
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+}
+
+void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
+
+ XDrawPoint ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y));
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawPoint ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y));
+
+ CalcBoundingBox (x, y);
+}
+
+void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+
+ XPoint *xpoints = new XPoint[n];
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ xpoints[i].x = (short)XLOG2DEV (points[i].x + xoffset);
+ xpoints[i].y = (short)YLOG2DEV (points[i].y + yoffset);
+ }
+ XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ for (i = 0; i < n; i++)
+ {
+ xpoints[i].x = (short)XLOG2DEV_2 (points[i].x + xoffset);
+ xpoints[i].y = (short)YLOG2DEV_2 (points[i].y + yoffset);
+ }
+ XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints, n, 0);
+ }
+ delete[]xpoints;
+ }
+}
+
+void wxWindowDC::DoDrawPolygon( int n, wxPoint points[],
+ wxCoord xoffset, wxCoord yoffset, int fillStyle )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ XPoint *xpoints1 = new XPoint[n + 1];
+ XPoint *xpoints2 = new XPoint[n + 1];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ xpoints1[i].x = (short)XLOG2DEV (points[i].x + xoffset);
+ xpoints1[i].y = (short)YLOG2DEV (points[i].y + yoffset);
+ xpoints2[i].x = (short)XLOG2DEV_2 (points[i].x + xoffset);
+ xpoints2[i].y = (short)YLOG2DEV_2 (points[i].y + yoffset);
+ CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
+ }
+
+ // Close figure for XDrawLines (not needed for XFillPolygon)
+ xpoints1[i].x = xpoints1[0].x;
+ xpoints1[i].y = xpoints1[0].y;
+ xpoints2[i].x = xpoints2[0].x;
+ xpoints2[i].y = xpoints2[0].y;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+ XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
+ XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n, Complex, 0);
+ XSetFillRule ((Display*) m_display, (GC) m_gc, EvenOddRule); // default mode
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XSetFillRule ((Display*) m_display,(GC) m_gcBacking,
+ fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
+ XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n, Complex, 0);
+ XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode
+ }
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0);
+ }
+
+ delete[]xpoints1;
+ delete[]xpoints2;
+}
+
+void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ int xd, yd, wfd, hfd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wfd = XLOG2DEVREL(width);
+ wd = wfd - WX_GC_CF;
+ hfd = YLOG2DEVREL(height);
+ hd = hfd - WX_GC_CF;
+
+ if (wfd == 0 || hfd == 0) return;
+ if (wd < 0) { wd = - wd; xd = xd - wd; }
+ if (hd < 0) { hd = - hd; yd = yd - hd; }
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ wfd, hfd);
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ wd, hd);
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+}
+
+void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
+{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ // If radius is negative, it's a proportion of the smaller dimension.
+
+ if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
+
+ int xd = XLOG2DEV (x);
+ int yd = YLOG2DEV (y);
+ int rd = XLOG2DEVREL ((long) radius);
+ int wd = XLOG2DEVREL (width) - WX_GC_CF;
+ int hd = YLOG2DEVREL (height) - WX_GC_CF;
+
+ int rw_d = rd * 2;
+ int rh_d = rw_d;
+
+ // If radius is zero use DrawRectangle() instead to avoid
+ // X drawing errors with small radii
+ if (rd == 0)
+ {
+ DrawRectangle( x, y, width, height );
+ return;
+ }
+
+ // Draw nothing if transformed w or h is 0
+ if (wd == 0 || hd == 0) return;
+
+ // CMB: adjust size if outline is drawn otherwise the result is
+ // 1 pixel too wide and high
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ {
+ wd--;
+ hd--;
+ }
+
+ // CMB: ensure dd is not larger than rectangle otherwise we
+ // get an hour glass shape
+ if (rw_d > wd) rw_d = wd;
+ if (rw_d > hd) rw_d = hd;
+ rd = rw_d / 2;
+
+ // For backing pixmap
+ int xd2 = XLOG2DEV_2 (x);
+ int yd2 = YLOG2DEV_2 (y);
+ int rd2 = XLOG2DEVREL ((long) radius);
+ int wd2 = XLOG2DEVREL (width) ;
+ int hd2 = YLOG2DEVREL (height) ;
+
+ int rw_d2 = rd2 * 2;
+ int rh_d2 = rw_d2;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
+ wd - rw_d, hd);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
+ wd, hd - rh_d);
+
+ // Arcs start from 3 o'clock, positive angles anticlockwise
+ // Top-left
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
+ rw_d, rh_d, 90 * 64, 90 * 64);
+ // Top-right
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
+ // rw_d, rh_d, 0, 90 * 64);
+ rw_d, rh_d, 0, 91 * 64);
+ // Bottom-right
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
+ yd + hd - rh_d,
+ // rw_d, rh_d, 270 * 64, 90 * 64);
+ rw_d, rh_d, 269 * 64, 92 * 64);
+ // Bottom-left
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
+ rw_d, rh_d, 180 * 64, 90 * 64);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2, wd2 - rw_d2, hd2);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + rd2, wd2, hd2 - rh_d2);
+
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2, rw_d2, rh_d2, 90 * 64, 90 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2, yd2,
+ // rw_d2, rh_d2, 0, 90 * 64);
+ rw_d2, rh_d2, 0, 91 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2,
+ yd2 + hd2 - rh_d2,
+ // rw_d2, rh_d2, 270 * 64, 90 * 64);
+ rw_d2, rh_d2, 269 * 64, 92 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 180 * 64, 90 * 64);
+ }
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ SetPen (m_pen);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
+ xd + wd - rd + 1, yd);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd + hd,
+ xd + wd - rd, yd + hd);
+
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
+ xd, yd + hd - rd);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd, yd + rd,
+ xd + wd, yd + hd - rd + 1);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
+ rw_d, rh_d, 90 * 64, 90 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
+ // rw_d, rh_d, 0, 90 * 64);
+ rw_d, rh_d, 0, 91 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
+ yd + hd - rh_d,
+ rw_d, rh_d, 269 * 64, 92 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
+ rw_d, rh_d, 180 * 64, 90 * 64);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2,
+ xd2 + wd2 - rd2 + 1, yd2);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2 + hd2,
+ xd2 + wd2 - rd2, yd2 + hd2);
+
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + rd2,
+ xd2, yd2 + hd2 - rd2);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2, yd2 + rd2,
+ xd2 + wd2, yd2 + hd2 - rd2 + 1);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2,
+ rw_d2, rh_d2, 90 * 64, 90 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2, yd2,
+ // rw_d2, rh_d2, 0, 90 * 64);
+ rw_d2, rh_d2, 0, 91 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2,
+ yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 269 * 64, 92 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 180 * 64, 90 * 64);
+ }
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+}
+
+void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
+{
+ 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)