summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjingham <jingham>1999-03-22 06:43:33 (GMT)
committerjingham <jingham>1999-03-22 06:43:33 (GMT)
commit8148ef3eca76d6d3e5f743388b5296d8213d3541 (patch)
tree1647c3d364865e716308423629674cc19d991619
parente147b28a4c6db21c7011dc9ca39178eb6de25ee0 (diff)
downloadtk-8148ef3eca76d6d3e5f743388b5296d8213d3541.zip
tk-8148ef3eca76d6d3e5f743388b5296d8213d3541.tar.gz
tk-8148ef3eca76d6d3e5f743388b5296d8213d3541.tar.bz2
Check the return of TkMacGetColor, and don't set the color if it comes back false.
-rw-r--r--mac/tkMacDraw.c230
1 files changed, 224 insertions, 6 deletions
diff --git a/mac/tkMacDraw.c b/mac/tkMacDraw.c
index df139f9..cee0eae 100644
--- a/mac/tkMacDraw.c
+++ b/mac/tkMacDraw.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacDraw.c,v 1.2 1998/09/14 18:23:35 stanton Exp $
+ * RCS: @(#) $Id: tkMacDraw.c,v 1.2.2.1 1999/03/22 06:43:33 jingham Exp $
*/
#include "tkInt.h"
@@ -220,7 +220,7 @@ XCopyPlane(
tmode = srcOr;
tmode = srcCopy + transparent;
- if (TkSetMacColor(gc->foreground, &macColor) == true) {
+ if (TkSetMacColor(gc->foreground, &macColor)) {
RGBForeColor(&macColor);
}
@@ -230,8 +230,9 @@ XCopyPlane(
* Case 1: opaque bitmaps.
*/
- TkSetMacColor(gc->background, &macColor);
+ if (TkSetMacColor(gc->background, &macColor)) {
RGBBackColor(&macColor);
+ }
tmode = srcCopy;
CopyBits(srcBit, destBit, &srcRect, &destRect, tmode, NULL);
} else if (clipPtr->type == TKP_CLIP_PIXMAP) {
@@ -671,6 +672,73 @@ XDrawRectangle(
/*
*----------------------------------------------------------------------
*
+ * XDrawRectangles --
+ *
+ * Draws the outlines of the specified rectangles as if a
+ * five-point PolyLine protocol request were specified for each
+ * rectangle:
+ *
+ * [x,y] [x+width,y] [x+width,y+height] [x,y+height]
+ * [x,y]
+ *
+ * For the specified rectangles, these functions do not draw a
+ * pixel more than once. XDrawRectangles draws the rectangles in
+ * the order listed in the array. If rectangles intersect, the
+ * intersecting pixels are drawn multiple times. Draws a
+ * rectangle.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws rectangles on the specified drawable.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+XDrawRectangles(display, d, gc, rectArr, numRects)
+ Display *display;
+ Drawable d;
+ GC gc;
+ XRectangle *rectArr;
+ int numRects;
+{
+ MacDrawable *macWin = (MacDrawable *) d;
+ Rect theRect;
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ GWorldPtr destPort;
+
+ register XRectangle *rectPtr;
+
+ destPort = TkMacGetDrawablePort(d);
+
+ display->request++;
+ GetGWorld(&saveWorld, &saveDevice);
+ SetGWorld(destPort, NULL);
+
+ TkMacSetUpClippingRgn(d);
+
+ TkMacSetUpGraphicsPort(gc);
+
+ ShowPen();
+ PenPixPat(gPenPat);
+
+ for (rectPtr = rectArr; numRects > 0; numRects--, rectPtr++) {
+ theRect.left = (short) (macWin->xOff + rectPtr->x);
+ theRect.top = (short) (macWin->yOff + rectPtr->y);
+ theRect.right = (short) (theRect.left + rectPtr->width);
+ theRect.bottom = (short) (theRect.top + rectPtr->height);
+
+ FrameRect(&theRect);
+ }
+
+ SetGWorld(saveWorld, saveDevice);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* XDrawArc --
*
* Draw an arc.
@@ -730,6 +798,65 @@ XDrawArc(
/*
*----------------------------------------------------------------------
*
+ * XDrawArcs --
+ *
+ * Draw an array of arcs.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws the arcs on the specified drawable.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+XDrawArcs(
+ Display* display, /* Display. */
+ Drawable d, /* Draw on this. */
+ GC gc, /* Use this GC. */
+ XArc *arcArr,
+ int numArcs)
+
+{
+ MacDrawable *macWin = (MacDrawable *) d;
+ Rect theRect;
+ short start, extent;
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ GWorldPtr destPort;
+ register XArc *arcPtr;
+
+ destPort = TkMacGetDrawablePort(d);
+
+ display->request++;
+ GetGWorld(&saveWorld, &saveDevice);
+ SetGWorld(destPort, NULL);
+
+ TkMacSetUpClippingRgn(d);
+
+ TkMacSetUpGraphicsPort(gc);
+
+ ShowPen();
+ PenPixPat(gPenPat);
+
+ for (arcPtr = arcArr; numArcs > 0; numArcs--, arcPtr++) {
+ theRect.left = (short) (macWin->xOff + arcPtr->x );
+ theRect.top = (short) (macWin->yOff + arcPtr->y);
+ theRect.right = (short) (theRect.left + arcPtr->width);
+ theRect.bottom = (short) (theRect.top + arcPtr->height);
+ start = (short) (90 - (arcPtr->angle1 / 64));
+ extent = (short) (-(arcPtr->angle2 / 64));
+
+ FrameArc(&theRect, start, extent);
+ }
+ SetGWorld(saveWorld, saveDevice);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* XFillArc --
*
* Draw a filled arc.
@@ -823,6 +950,97 @@ XFillArc(
/*
*----------------------------------------------------------------------
*
+ * XFillArc --
+ *
+ * Draw an array of filled arcs.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws the filled arcs on the specified drawable.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+XFillArcs(
+ Display* display, /* Display. */
+ Drawable d, /* Draw on this. */
+ GC gc, /* Use this GC. */
+ XArc *arcArr, /* Array of arcs */
+ int numArcs) /* number of arcs */
+{
+ MacDrawable *macWin = (MacDrawable *) d;
+ Rect theRect;
+ short start, extent;
+ PolyHandle polygon;
+ XArc *arcPtr;
+ double sin1, cos1, sin2, cos2, angle;
+ double boxWidth, boxHeight;
+ double vertex[2], center1[2], center2[2];
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ GWorldPtr destPort;
+
+ destPort = TkMacGetDrawablePort(d);
+
+ display->request++;
+ GetGWorld(&saveWorld, &saveDevice);
+ SetGWorld(destPort, NULL);
+
+ TkMacSetUpClippingRgn(d);
+
+ TkMacSetUpGraphicsPort(gc);
+
+ for (arcPtr = arcArr; numArcs > 0; numArcs--, arcPtr++) {
+ theRect.left = (short) (macWin->xOff + arcPtr->x);
+ theRect.top = (short) (macWin->yOff + arcPtr->y);
+ theRect.right = (short) (theRect.left + arcPtr->width);
+ theRect.bottom = (short) (theRect.top + arcPtr->height);
+ start = (short) (90 - (arcPtr->angle1 / 64));
+ extent = (short) (- (arcPtr->angle2 / 64));
+
+ if (gc->arc_mode == ArcChord) {
+ boxWidth = theRect.right - theRect.left;
+ boxHeight = theRect.bottom - theRect.top;
+ angle = -(arcPtr->angle1/64.0)*PI/180.0;
+ sin1 = sin(angle);
+ cos1 = cos(angle);
+ angle -= (arcPtr->angle2/64.0)*PI/180.0;
+ sin2 = sin(angle);
+ cos2 = cos(angle);
+ vertex[0] = (theRect.left + theRect.right)/2.0;
+ vertex[1] = (theRect.top + theRect.bottom)/2.0;
+ center1[0] = vertex[0] + cos1*boxWidth/2.0;
+ center1[1] = vertex[1] + sin1*boxHeight/2.0;
+ center2[0] = vertex[0] + cos2*boxWidth/2.0;
+ center2[1] = vertex[1] + sin2*boxHeight/2.0;
+
+ polygon = OpenPoly();
+ MoveTo((short) ((theRect.left + theRect.right)/2),
+ (short) ((theRect.top + theRect.bottom)/2));
+
+ LineTo((short) (center1[0] + 0.5), (short) (center1[1] + 0.5));
+ LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5));
+ ClosePoly();
+
+ ShowPen();
+ FillCArc(&theRect, start, extent, gPenPat);
+ FillCPoly(polygon, gPenPat);
+
+ KillPoly(polygon);
+ } else {
+ ShowPen();
+ FillCArc(&theRect, start, extent, gPenPat);
+ }
+ }
+ SetGWorld(saveWorld, saveDevice);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkScrollWindow --
*
* Scroll a rectangle of the specified window and accumulate
@@ -924,7 +1142,7 @@ TkScrollWindow(
SetGWorld(saveWorld, saveDevice);
/*
- * Fortunantly, the region returned by ScrollRect is symanticlly
+ * Fortunantly, the region returned by ScrollRect is symanticly
* the same as what we need to return in this function. If the
* region is empty we return zero to denote that no damage was
* created.
@@ -962,10 +1180,9 @@ TkMacSetUpGraphicsPort(
gPenPat = NewPixPat();
}
- if (TkSetMacColor(gc->foreground, &macColor) == true) {
+ if (TkSetMacColor(gc->foreground, &macColor)) {
/* TODO: cache RGBPats for preformace - measure gains... */
MakeRGBPat(gPenPat, &macColor);
- }
PenNormal();
if(gc->function == GXxor) {
@@ -975,6 +1192,7 @@ TkMacSetUpGraphicsPort(
PenSize(gc->line_width, gc->line_width);
}
}
+}
/*
*----------------------------------------------------------------------