summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvas.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2002-01-25 21:09:35 (GMT)
committerdgp <dgp@users.sourceforge.net>2002-01-25 21:09:35 (GMT)
commit6ed2bb40b9be7079b3eb3b9872657d06d568dc7f (patch)
tree2041d0c0de9f76a800e1af4c067e78376fbdd570 /generic/tkCanvas.c
parent7b64060dd94a995160cc8ccbd5bee7556fd996a9 (diff)
downloadtk-6ed2bb40b9be7079b3eb3b9872657d06d568dc7f.zip
tk-6ed2bb40b9be7079b3eb3b9872657d06d568dc7f.tar.gz
tk-6ed2bb40b9be7079b3eb3b9872657d06d568dc7f.tar.bz2
* Updated callers of Tcl_SplitList and Tcl_Merge.
* Updated callers of Tcl_GetStringResult. Rewrote PrintScrollFractions to ScrollFractions to stop scribbling directly on interp->result. * Updated callers of Tcl_GetVar, Tcl_GetVar2 * Updated callers of Tcl_SplitPath, Tcl_JoinPath, and Tcl_TranslateFileName.
Diffstat (limited to 'generic/tkCanvas.c')
-rw-r--r--generic/tkCanvas.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index e77c0f9..5b7d92c 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvas.c,v 1.17 2002/01/17 05:13:11 dgp Exp $
+ * RCS: @(#) $Id: tkCanvas.c,v 1.18 2002/01/25 21:09:36 dgp Exp $
*/
/* #define USE_OLD_TAG_SEARCH 1 */
@@ -299,9 +299,8 @@ static Tk_Item * NextItem _ANSI_ARGS_((TagSearch *searchPtr));
#endif /* USE_OLD_TAG_SEARCH */
static void PickCurrentItem _ANSI_ARGS_((TkCanvas *canvasPtr,
XEvent *eventPtr));
-static void PrintScrollFractions _ANSI_ARGS_((int screen1,
- int screen2, int object1, int object2,
- char *string));
+static Tcl_Obj * ScrollFractions _ANSI_ARGS_((int screen1,
+ int screen2, int object1, int object2));
#ifdef USE_OLD_TAG_SEARCH
static void RelinkItems _ANSI_ARGS_((TkCanvas *canvasPtr,
Tcl_Obj *tag, Tk_Item *prevPtr));
@@ -776,7 +775,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv)
command = Tk_GetBinding(interp, canvasPtr->bindingTable,
object, Tcl_GetStringFromObj(argv[3], NULL));
if (command == NULL) {
- char *string;
+ CONST char *string;
string = Tcl_GetStringResult(interp);
/*
@@ -1816,10 +1815,11 @@ CanvasWidgetCmd(clientData, interp, argc, argv)
double fraction;
if (argc == 2) {
- PrintScrollFractions(canvasPtr->xOrigin + canvasPtr->inset,
+ Tcl_SetObjResult(interp, ScrollFractions(
+ canvasPtr->xOrigin + canvasPtr->inset,
canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin)
- canvasPtr->inset, canvasPtr->scrollX1,
- canvasPtr->scrollX2, Tcl_GetStringResult(interp));
+ canvasPtr->scrollX2));
} else {
char **args = GetStringsFromObjs(argc, argv);
type = Tk_GetScrollInfo(interp, argc, args, &fraction, &count);
@@ -1859,10 +1859,11 @@ CanvasWidgetCmd(clientData, interp, argc, argv)
double fraction;
if (argc == 2) {
- PrintScrollFractions(canvasPtr->yOrigin + canvasPtr->inset,
+ Tcl_SetObjResult(interp,ScrollFractions(\
+ canvasPtr->yOrigin + canvasPtr->inset,
canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin)
- canvasPtr->inset, canvasPtr->scrollY1,
- canvasPtr->scrollY2, Tcl_GetStringResult(interp));
+ canvasPtr->scrollY2));
} else {
char **args = GetStringsFromObjs(argc, argv);
type = Tk_GetScrollInfo(interp, argc, args, &fraction, &count);
@@ -2062,7 +2063,7 @@ ConfigureCanvas(interp, canvasPtr, argc, argv, flags)
canvasPtr->scrollY2 = 0;
if (canvasPtr->regionString != NULL) {
int argc2;
- char **argv2;
+ CONST char **argv2;
if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString,
&argc2, &argv2) != TCL_OK) {
@@ -5205,12 +5206,12 @@ GridAlign(coord, spacing)
/*
*----------------------------------------------------------------------
*
- * PrintScrollFractions --
+ * ScrollFractions --
*
* Given the range that's visible in the window and the "100%
- * range" for what's in the canvas, print a string containing
- * the scroll fractions. This procedure is used for both x
- * and y scrolling.
+ * range" for what's in the canvas, return a list of two
+ * doubles representing the scroll fractions. This procedure
+ * is used for both x and y scrolling.
*
* Results:
* The memory pointed to by string is modified to hold
@@ -5223,17 +5224,15 @@ GridAlign(coord, spacing)
*----------------------------------------------------------------------
*/
-static void
-PrintScrollFractions(screen1, screen2, object1, object2, string)
+static Tcl_Obj *
+ScrollFractions(screen1, screen2, object1, object2)
int screen1; /* Lowest coordinate visible in the window. */
int screen2; /* Highest coordinate visible in the window. */
int object1; /* Lowest coordinate in the object. */
int object2; /* Highest coordinate in the object. */
- char *string; /* Two real numbers get printed here. Must
- * have enough storage for two %g
- * conversions. */
{
double range, f1, f2;
+ char buffer[2*TCL_DOUBLE_SPACE+2];
range = object2 - object1;
if (range <= 0) {
@@ -5252,7 +5251,8 @@ PrintScrollFractions(screen1, screen2, object1, object2, string)
f2 = f1;
}
}
- sprintf(string, "%g %g", f1, f2);
+ sprintf(buffer, "%g %g", f1, f2);
+ return Tcl_NewStringObj(buffer, -1);
}
/*
@@ -5281,7 +5281,6 @@ CanvasUpdateScrollbars(canvasPtr)
TkCanvas *canvasPtr; /* Information about canvas. */
{
int result;
- char buffer[200];
Tcl_Interp *interp;
int xOrigin, yOrigin, inset, width, height, scrollX1, scrollX2,
scrollY1, scrollY2;
@@ -5313,9 +5312,11 @@ CanvasUpdateScrollbars(canvasPtr)
scrollY2 = canvasPtr->scrollY2;
canvasPtr->flags &= ~UPDATE_SCROLLBARS;
if (canvasPtr->xScrollCmd != NULL) {
- PrintScrollFractions(xOrigin + inset, xOrigin + width - inset,
- scrollX1, scrollX2, buffer);
- result = Tcl_VarEval(interp, xScrollCmd, " ", buffer, (char *) NULL);
+ Tcl_Obj *fractions = ScrollFractions(xOrigin + inset,
+ xOrigin + width - inset, scrollX1, scrollX2);
+ result = Tcl_VarEval(interp, xScrollCmd, " ",
+ Tcl_GetString(fractions), (char *) NULL);
+ Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
Tcl_BackgroundError(interp);
}
@@ -5324,9 +5325,11 @@ CanvasUpdateScrollbars(canvasPtr)
}
if (yScrollCmd != NULL) {
- PrintScrollFractions(yOrigin + inset, yOrigin + height - inset,
- scrollY1, scrollY2, buffer);
- result = Tcl_VarEval(interp, yScrollCmd, " ", buffer, (char *) NULL);
+ Tcl_Obj *fractions = ScrollFractions(yOrigin + inset,
+ yOrigin + height - inset, scrollY1, scrollY2);
+ result = Tcl_VarEval(interp, yScrollCmd, " ",
+ Tcl_GetString(fractions), (char *) NULL);
+ Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
Tcl_BackgroundError(interp);
}