Import Tk 8.6.8
This commit is contained in:
184
win/tkWinDraw.c
184
win/tkWinDraw.c
@@ -486,7 +486,7 @@ XCopyPlane(
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TkPutImage --
|
||||
* TkPutImage, XPutImage --
|
||||
*
|
||||
* Copies a subimage from an in-memory image to a rectangle of of the
|
||||
* specified drawable.
|
||||
@@ -599,6 +599,21 @@ TkPutImage(
|
||||
TkWinReleaseDrawableDC(d, dc, &state);
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
XPutImage(
|
||||
Display *display,
|
||||
Drawable d, /* Destination drawable. */
|
||||
GC gc,
|
||||
XImage *image, /* Source image. */
|
||||
int src_x, int src_y, /* Offset of subimage. */
|
||||
int dest_x, int dest_y, /* Position of subimage origin in drawable. */
|
||||
unsigned int width, unsigned int height)
|
||||
/* Dimensions of subimage. */
|
||||
{
|
||||
return TkPutImage(NULL, 0, display, d, gc, image,
|
||||
src_x, src_y, dest_x, dest_y, width, height);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -625,7 +640,6 @@ XFillRectangles(
|
||||
int nrectangles)
|
||||
{
|
||||
HDC dc;
|
||||
int i;
|
||||
RECT rect;
|
||||
TkWinDCState state;
|
||||
HBRUSH brush, oldBrush;
|
||||
@@ -666,25 +680,26 @@ XFillRectangles(
|
||||
* result with the stipple pattern.
|
||||
*/
|
||||
|
||||
for (i = 0; i < nrectangles; i++) {
|
||||
bitmap = CreateCompatibleBitmap(dc, rectangles[i].width,
|
||||
rectangles[i].height);
|
||||
while (nrectangles-- > 0) {
|
||||
bitmap = CreateCompatibleBitmap(dc, rectangles[0].width,
|
||||
rectangles[0].height);
|
||||
oldBitmap = SelectObject(dcMem, bitmap);
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = rectangles[i].width;
|
||||
rect.bottom = rectangles[i].height;
|
||||
rect.right = rectangles[0].width;
|
||||
rect.bottom = rectangles[0].height;
|
||||
FillRect(dcMem, &rect, brush);
|
||||
BitBlt(dc, rectangles[i].x, rectangles[i].y, rectangles[i].width,
|
||||
rectangles[i].height, dcMem, 0, 0, COPYFG);
|
||||
BitBlt(dc, rectangles[0].x, rectangles[0].y, rectangles[0].width,
|
||||
rectangles[0].height, dcMem, 0, 0, COPYFG);
|
||||
if (gc->fill_style == FillOpaqueStippled) {
|
||||
FillRect(dcMem, &rect, bgBrush);
|
||||
BitBlt(dc, rectangles[i].x, rectangles[i].y,
|
||||
rectangles[i].width, rectangles[i].height, dcMem,
|
||||
BitBlt(dc, rectangles[0].x, rectangles[0].y,
|
||||
rectangles[0].width, rectangles[0].height, dcMem,
|
||||
0, 0, COPYBG);
|
||||
}
|
||||
SelectObject(dcMem, oldBitmap);
|
||||
DeleteObject(bitmap);
|
||||
++rectangles;
|
||||
}
|
||||
|
||||
DeleteDC(dcMem);
|
||||
@@ -693,22 +708,24 @@ XFillRectangles(
|
||||
DeleteObject(bgBrush);
|
||||
} else {
|
||||
if (gc->function == GXcopy) {
|
||||
for (i = 0; i < nrectangles; i++) {
|
||||
rect.left = rectangles[i].x;
|
||||
rect.right = rect.left + rectangles[i].width;
|
||||
rect.top = rectangles[i].y;
|
||||
rect.bottom = rect.top + rectangles[i].height;
|
||||
while (nrectangles-- > 0) {
|
||||
rect.left = rectangles[0].x;
|
||||
rect.right = rect.left + rectangles[0].width;
|
||||
rect.top = rectangles[0].y;
|
||||
rect.bottom = rect.top + rectangles[0].height;
|
||||
FillRect(dc, &rect, brush);
|
||||
++rectangles;
|
||||
}
|
||||
} else {
|
||||
HPEN newPen = CreatePen(PS_NULL, 0, gc->foreground);
|
||||
HPEN oldPen = SelectObject(dc, newPen);
|
||||
oldBrush = SelectObject(dc, brush);
|
||||
|
||||
for (i = 0; i < nrectangles; i++) {
|
||||
Rectangle(dc, rectangles[i].x, rectangles[i].y,
|
||||
rectangles[i].x + rectangles[i].width + 1,
|
||||
rectangles[i].y + rectangles[i].height + 1);
|
||||
while (nrectangles-- > 0) {
|
||||
Rectangle(dc, rectangles[0].x, rectangles[0].y,
|
||||
rectangles[0].x + rectangles[0].width + 1,
|
||||
rectangles[0].y + rectangles[0].height + 1);
|
||||
++rectangles;
|
||||
}
|
||||
|
||||
SelectObject(dc, oldBrush);
|
||||
@@ -721,6 +738,52 @@ XFillRectangles(
|
||||
return Success;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* MakeAndStrokePath --
|
||||
*
|
||||
* This function draws a shape using a list of points, a stipple pattern,
|
||||
* and the specified drawing function. It does it through creation of a
|
||||
* so-called 'path' (see GDI documentation on MSDN).
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
MakeAndStrokePath(
|
||||
HDC dc,
|
||||
POINT *winPoints,
|
||||
int npoints,
|
||||
WinDrawFunc func) /* Name of the Windows GDI drawing function:
|
||||
this is either Polyline or Polygon. */
|
||||
{
|
||||
BeginPath(dc);
|
||||
func(dc, winPoints, npoints);
|
||||
/*
|
||||
* In the case of closed polylines, the first and last points
|
||||
* are the same. We want miter or bevel join be rendered also
|
||||
* at this point, this needs telling the Windows GDI that the
|
||||
* path is closed.
|
||||
*/
|
||||
if (func == Polyline) {
|
||||
if ((winPoints[0].x == winPoints[npoints-1].x) &&
|
||||
(winPoints[0].y == winPoints[npoints-1].y)) {
|
||||
CloseFigure(dc);
|
||||
}
|
||||
EndPath(dc);
|
||||
StrokePath(dc);
|
||||
} else {
|
||||
EndPath(dc);
|
||||
StrokeAndFillPath(dc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -816,7 +879,7 @@ RenderObject(
|
||||
SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE
|
||||
: WINDING);
|
||||
oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground));
|
||||
func(dcMem, winPoints, npoints);
|
||||
MakeAndStrokePath(dcMem, winPoints, npoints, func);
|
||||
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG);
|
||||
|
||||
/*
|
||||
@@ -828,7 +891,7 @@ RenderObject(
|
||||
if (gc->fill_style == FillOpaqueStippled) {
|
||||
DeleteObject(SelectObject(dcMem,
|
||||
CreateSolidBrush(gc->background)));
|
||||
func(dcMem, winPoints, npoints);
|
||||
MakeAndStrokePath(dcMem, winPoints, npoints, func);
|
||||
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0,
|
||||
COPYBG);
|
||||
}
|
||||
@@ -844,7 +907,7 @@ RenderObject(
|
||||
|
||||
SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE
|
||||
: WINDING);
|
||||
func(dc, winPoints, npoints);
|
||||
MakeAndStrokePath(dc, winPoints, npoints, func);
|
||||
SelectObject(dc, oldPen);
|
||||
}
|
||||
DeleteObject(SelectObject(dc, oldBrush));
|
||||
@@ -940,7 +1003,7 @@ XFillPolygon(
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* XDrawRectangle --
|
||||
* XDrawRectangle, XDrawRectangles --
|
||||
*
|
||||
* Draws a rectangle.
|
||||
*
|
||||
@@ -985,11 +1048,32 @@ XDrawRectangle(
|
||||
TkWinReleaseDrawableDC(d, dc, &state);
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
XDrawRectangles(
|
||||
Display *display,
|
||||
Drawable d,
|
||||
GC gc,
|
||||
XRectangle rects[],
|
||||
int nrects)
|
||||
{
|
||||
int ret = Success;
|
||||
|
||||
while (nrects-- > 0) {
|
||||
ret = XDrawRectangle(display, d, gc, rects[0].x, rects[0].y,
|
||||
rects[0].width, rects[0].height);
|
||||
if (ret != Success) {
|
||||
break;
|
||||
}
|
||||
++rects;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* XDrawArc --
|
||||
* XDrawArc, XDrawArcs --
|
||||
*
|
||||
* Draw an arc.
|
||||
*
|
||||
@@ -1015,11 +1099,35 @@ XDrawArc(
|
||||
|
||||
return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0);
|
||||
}
|
||||
|
||||
int
|
||||
XDrawArcs(
|
||||
Display *display,
|
||||
Drawable d,
|
||||
GC gc,
|
||||
XArc *arcs,
|
||||
int narcs)
|
||||
{
|
||||
int ret = Success;
|
||||
|
||||
display->request++;
|
||||
|
||||
while (narcs-- > 0) {
|
||||
ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y,
|
||||
arcs[0].width, arcs[0].height,
|
||||
arcs[0].angle1, arcs[0].angle2, 0);
|
||||
if (ret != Success) {
|
||||
break;
|
||||
}
|
||||
++arcs;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* XFillArc --
|
||||
* XFillArc, XFillArcs --
|
||||
*
|
||||
* Draw a filled arc.
|
||||
*
|
||||
@@ -1045,6 +1153,30 @@ XFillArc(
|
||||
|
||||
return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1);
|
||||
}
|
||||
|
||||
int
|
||||
XFillArcs(
|
||||
Display *display,
|
||||
Drawable d,
|
||||
GC gc,
|
||||
XArc *arcs,
|
||||
int narcs)
|
||||
{
|
||||
int ret = Success;
|
||||
|
||||
display->request++;
|
||||
|
||||
while (narcs-- > 0) {
|
||||
ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y,
|
||||
arcs[0].width, arcs[0].height,
|
||||
arcs[0].angle1, arcs[0].angle2, 1);
|
||||
if (ret != Success) {
|
||||
break;
|
||||
}
|
||||
++arcs;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user