summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvArc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkCanvArc.c')
-rw-r--r--generic/tkCanvArc.c70
1 files changed, 23 insertions, 47 deletions
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index 37e117e..d658384 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvArc.c,v 1.1.4.3 1998/12/13 08:16:01 lfb Exp $
+ * RCS: @(#) $Id: tkCanvArc.c,v 1.1.4.4 1999/02/16 11:39:30 lfb Exp $
*/
#include <stdio.h>
@@ -168,17 +168,6 @@ Tk_ItemType tkArcType = {
# define PI 3.14159265358979323846
#endif
-/*
- * The uid's below comprise the legal values for the "-style"
- * option for arcs.
- */
-
-static Tk_Uid arcUid = NULL;
-static Tk_Uid chordUid = NULL;
-static Tk_Uid pieSliceUid = NULL;
-
-TCL_DECLARE_MUTEX(arcMutex) /* Used to guard access to Tk_Uids above.*/
-
/*
*--------------------------------------------------------------
@@ -221,20 +210,6 @@ CreateArc(interp, canvas, itemPtr, argc, argv)
}
/*
- * Carry out once-only initialization.
- */
-
- if (pieSliceUid == NULL) {
- Tcl_MutexLock(&arcMutex);
- if (pieSliceUid == NULL) {
- arcUid = Tk_GetUid("arc");
- chordUid = Tk_GetUid("chord");
- pieSliceUid = Tk_GetUid("pieslice");
- }
- Tcl_MutexUnlock(&arcMutex);
- }
-
- /*
* Carry out initialization that is needed in order to clean
* up after errors during the the remainder of this procedure.
*/
@@ -248,7 +223,7 @@ CreateArc(interp, canvas, itemPtr, argc, argv)
arcPtr->fillColor = NULL;
arcPtr->fillStipple = None;
arcPtr->outlineStipple = None;
- arcPtr->style = pieSliceUid;
+ arcPtr->style = Tk_GetUid("pieslice");
arcPtr->outlineGC = None;
arcPtr->fillGC = None;
@@ -389,12 +364,13 @@ ConfigureArc(interp, canvas, itemPtr, argc, argv, flags)
i = (int) (arcPtr->extent/360.0);
arcPtr->extent -= i*360.0;
- if ((arcPtr->style != arcUid) && (arcPtr->style != chordUid)
- && (arcPtr->style != pieSliceUid)) {
+ if ((arcPtr->style != Tk_GetUid("arc"))
+ && (arcPtr->style != Tk_GetUid("chord"))
+ && (arcPtr->style != Tk_GetUid("pieslice"))) {
Tcl_AppendResult(interp, "bad -style option \"",
arcPtr->style, "\": must be arc, chord, or pieslice",
(char *) NULL);
- arcPtr->style = pieSliceUid;
+ arcPtr->style = Tk_GetUid("pieslice");
return TCL_ERROR;
}
@@ -420,11 +396,11 @@ ConfigureArc(interp, canvas, itemPtr, argc, argv, flags)
}
arcPtr->outlineGC = newGC;
- if ((arcPtr->fillColor == NULL) || (arcPtr->style == arcUid)) {
+ if ((arcPtr->fillColor == NULL) || (arcPtr->style == Tk_GetUid("arc"))) {
newGC = None;
} else {
gcValues.foreground = arcPtr->fillColor->pixel;
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
gcValues.arc_mode = ArcChord;
} else {
gcValues.arc_mode = ArcPieSlice;
@@ -553,7 +529,7 @@ ComputeArcBbox(canvas, arcPtr)
TkIncludePoint((Tk_Item *) arcPtr, arcPtr->center2);
center[0] = (arcPtr->bbox[0] + arcPtr->bbox[2])/2;
center[1] = (arcPtr->bbox[1] + arcPtr->bbox[3])/2;
- if (arcPtr->style == pieSliceUid) {
+ if (arcPtr->style == Tk_GetUid("pieslice")) {
TkIncludePoint((Tk_Item *) arcPtr, center);
}
@@ -697,10 +673,10 @@ DisplayArc(canvas, itemPtr, display, drawable, x, y, width, height)
Tk_CanvasDrawableCoords(canvas, arcPtr->center2[0],
arcPtr->center2[1], &x2, &y2);
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
XDrawLine(display, drawable, arcPtr->outlineGC,
x1, y1, x2, y2);
- } else if (arcPtr->style == pieSliceUid) {
+ } else if (arcPtr->style == Tk_GetUid("pieslice")) {
short cx, cy;
Tk_CanvasDrawableCoords(canvas,
@@ -712,10 +688,10 @@ DisplayArc(canvas, itemPtr, display, drawable, x, y, width, height)
cx, cy, x2, y2);
}
} else {
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
display, drawable, arcPtr->outlineGC, None);
- } else if (arcPtr->style == pieSliceUid) {
+ } else if (arcPtr->style == Tk_GetUid("pieslice")) {
TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
display, drawable, arcPtr->outlineGC, None);
TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
@@ -793,7 +769,7 @@ ArcToPoint(canvas, itemPtr, pointPtr)
* we're dealing with.
*/
- if (arcPtr->style == arcUid) {
+ if (arcPtr->style == Tk_GetUid("arc")) {
if (angleInRange) {
return TkOvalToPoint(arcPtr->bbox, (double) arcPtr->width,
0, pointPtr);
@@ -819,7 +795,7 @@ ArcToPoint(canvas, itemPtr, pointPtr)
width = arcPtr->width;
}
- if (arcPtr->style == pieSliceUid) {
+ if (arcPtr->style == Tk_GetUid("pieslice")) {
if (width > 1.0) {
dist = TkPolygonToPoint(arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
pointPtr);
@@ -974,7 +950,7 @@ ArcToArea(canvas, itemPtr, rectPtr)
numPoints = 2;
pointPtr += 4;
- if ((arcPtr->style == pieSliceUid) && (arcPtr->extent < 180.0)) {
+ if ((arcPtr->style == Tk_GetUid("pieslice")) && (arcPtr->extent < 180.0)) {
pointPtr[0] = 0.0;
pointPtr[1] = 0.0;
numPoints++;
@@ -1048,7 +1024,7 @@ ArcToArea(canvas, itemPtr, rectPtr)
* polygon(s) forming the sides of a chord or pie-slice.
*/
- if (arcPtr->style == pieSliceUid) {
+ if (arcPtr->style == Tk_GetUid("pieslice")) {
if (width >= 1.0) {
if (TkPolygonToArea(arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
rectPtr) != -1) {
@@ -1064,7 +1040,7 @@ ArcToArea(canvas, itemPtr, rectPtr)
return 0;
}
}
- } else if (arcPtr->style == chordUid) {
+ } else if (arcPtr->style == Tk_GetUid("chord")) {
if (width >= 1.0) {
if (TkPolygonToArea(arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
rectPtr) != -1) {
@@ -1315,7 +1291,7 @@ ComputeArcOutline(arcPtr)
* center point. The second point is the corner point.
*/
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
outlinePtr[0] = outlinePtr[12] = corner1[0];
outlinePtr[1] = outlinePtr[13] = corner1[1];
TkGetButtPoints(arcPtr->center2, arcPtr->center1,
@@ -1330,7 +1306,7 @@ ComputeArcOutline(arcPtr)
- arcPtr->center1[0];
outlinePtr[9] = arcPtr->center2[1] + outlinePtr[11]
- arcPtr->center1[1];
- } else if (arcPtr->style == pieSliceUid) {
+ } else if (arcPtr->style == Tk_GetUid("pieslice")) {
/*
* For pie slices, generate two polygons, one for each side
* of the pie slice. The first arm has a shape like this,
@@ -1626,7 +1602,7 @@ ArcToPostscript(interp, canvas, itemPtr, prepass)
(arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2,
(arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2);
Tcl_AppendResult(interp, buffer, (char *) NULL);
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
sprintf(buffer, "0 0 1 %.15g %.15g arc closepath\nsetmatrix\n",
ang1, ang2);
} else {
@@ -1678,9 +1654,9 @@ ArcToPostscript(interp, canvas, itemPtr, prepass)
} else {
Tcl_AppendResult(interp, "stroke\n", (char *) NULL);
}
- if (arcPtr->style != arcUid) {
+ if (arcPtr->style != Tk_GetUid("arc")) {
Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- if (arcPtr->style == chordUid) {
+ if (arcPtr->style == Tk_GetUid("chord")) {
Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
CHORD_OUTLINE_PTS);
} else {