diff options
author | pspjuth <peter.spjuth@gmail.com> | 2001-08-21 20:21:36 (GMT) |
---|---|---|
committer | pspjuth <peter.spjuth@gmail.com> | 2001-08-21 20:21:36 (GMT) |
commit | 5de1e48a438ff12af2cdf2fa5542541d07be18b5 (patch) | |
tree | 8470e06c9c10c9cd3f5b83b65a958619ccc66d16 /generic/tkGrid.c | |
parent | c9fb1f587664806275461fcf4b872e8acdd913b9 (diff) | |
download | tk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.zip tk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.tar.gz tk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.tar.bz2 |
Objectified grid and pack commands.
Diffstat (limited to 'generic/tkGrid.c')
-rw-r--r-- | generic/tkGrid.c | 734 |
1 files changed, 378 insertions, 356 deletions
diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 6685f53..7fdfe19 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkGrid.c,v 1.12 2001/08/18 20:03:16 pspjuth Exp $ + * RCS: @(#) $Id: tkGrid.c,v 1.13 2001/08/21 20:21:36 pspjuth Exp $ */ #include "tkInt.h" @@ -236,25 +236,25 @@ static void ArrangeGrid _ANSI_ARGS_((ClientData clientData)); static int CheckSlotData _ANSI_ARGS_((Gridder *masterPtr, int slot, int slotType, int checkOnly)); static int ConfigureSlaves _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window tkwin, int argc, char *argv[])); + Tk_Window tkwin, int objc, Tcl_Obj *CONST objv[])); static void DestroyGrid _ANSI_ARGS_((char *memPtr)); static Gridder *GetGrid _ANSI_ARGS_((Tk_Window tkwin)); static int GridBboxCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridForgetRemoveCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridInfoCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridLocationCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridPropagateCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridRowColumnConfigureCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridSizeCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int GridSlavesCommand _ANSI_ARGS_((Tk_Window tkwin, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static void GridStructureProc _ANSI_ARGS_(( ClientData clientData, XEvent *eventPtr)); static void GridLostSlaveProc _ANSI_ARGS_((ClientData clientData, @@ -262,6 +262,8 @@ static void GridLostSlaveProc _ANSI_ARGS_((ClientData clientData, static void GridReqProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin)); static void InitMasterData _ANSI_ARGS_((Gridder *masterPtr)); +static Tcl_Obj *NewPairObj _ANSI_ARGS_((Tcl_Interp*, int, int)); +static Tcl_Obj *NewQuadObj _ANSI_ARGS_((Tcl_Interp*, int, int, int, int)); static int ResolveConstraints _ANSI_ARGS_((Gridder *gridPtr, int rowOrColumn, int maxOffset)); static void SetGridSize _ANSI_ARGS_((Gridder *gridPtr)); @@ -275,7 +277,7 @@ static void Unlink _ANSI_ARGS_((Gridder *gridPtr)); */ void TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp*, char*, int, int)); -int TkParsePadAmount _ANSI_ARGS_((Tcl_Interp*, Tk_Window, char*, int*, int*)); +int TkParsePadAmount _ANSI_ARGS_((Tcl_Interp*, Tk_Window, Tcl_Obj*, int*, int*)); static Tk_GeomMgr gridMgrType = { "grid", /* name */ @@ -301,61 +303,61 @@ static Tk_GeomMgr gridMgrType = { */ int -Tk_GridCmd(clientData, interp, argc, argv) +Tk_GridObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; - size_t length; /* streing length of argument */ - char c; /* 1st character of argument */ + static char *optionStrings[] = { + "bbox", "columnconfigure", "configure", "forget", + "info", "location", "propagate", "remove", + "rowconfigure", "size", "slaves", (char *) NULL }; + enum options { + GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE, GRID_FORGET, + GRID_INFO, GRID_LOCATION, GRID_PROPAGATE, GRID_REMOVE, + GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES }; + int index; + - if ((argc >= 2) && ((argv[1][0] == '.') || (argv[1][0] == REL_SKIP) || - (argv[1][0] == REL_VERT))) { - return ConfigureSlaves(interp, tkwin, argc-1, argv+1); + if (objc >= 2) { + char *argv1 = Tcl_GetString(objv[1]); + if ((argv1[0] == '.') || (argv1[0] == REL_SKIP) || + (argv1[0] == REL_VERT)) { + return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + } } - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option arg ?arg ...?\"", (char *) NULL); + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - - if ((c == 'b') && (strncmp(argv[1], "bbox", length) == 0)) { - return GridBboxCommand(tkwin, interp, argc, argv); - - } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { - if ((argv[2][0] != '.') && (argv[2][0] != REL_SKIP) && - (argv[2][0] != REL_VERT)) { - Tcl_AppendResult(interp, "bad argument \"", argv[2], - "\": must be name of window", (char *) NULL); - return TCL_ERROR; - } - return ConfigureSlaves(interp, tkwin, argc-2, argv+2); - - } else if (((c == 'f') && (strncmp(argv[1], "forget", length) == 0)) || - ((c == 'r') && (strncmp(argv[1], "remove", length) == 0))) { - return GridForgetRemoveCommand(tkwin, interp, argc, argv); - - } else if ((c == 'i') && (strncmp(argv[1], "info", length) == 0)) { - return GridInfoCommand(tkwin, interp, argc, argv); - } else if((c == 'l') && (strncmp(argv[1], "location", length) == 0)) { - return GridLocationCommand(tkwin, interp, argc, argv); + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } - } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) { - return GridPropagateCommand(tkwin, interp, argc, argv); + switch ((enum options) index) { + case GRID_BBOX: + return GridBboxCommand(tkwin, interp, objc, objv); + case GRID_CONFIGURE: + return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + case GRID_FORGET: + case GRID_REMOVE: + return GridForgetRemoveCommand(tkwin, interp, objc, objv); + case GRID_INFO: + return GridInfoCommand(tkwin, interp, objc, objv); + case GRID_LOCATION: + return GridLocationCommand(tkwin, interp, objc, objv); + case GRID_PROPAGATE: + return GridPropagateCommand(tkwin, interp, objc, objv); + case GRID_SIZE: + return GridSizeCommand(tkwin, interp, objc, objv); + case GRID_SLAVES: + return GridSlavesCommand(tkwin, interp, objc, objv); - } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0) - && (length > 1)) { - return GridSizeCommand(tkwin, interp, argc, argv); - - } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0) - && (length > 1)) { - return GridSlavesCommand(tkwin, interp, argc, argv); /* * Sample argument combinations: * grid columnconfigure <master> <index> -option @@ -364,21 +366,15 @@ Tk_GridCmd(clientData, interp, argc, argv) * grid rowconfigure <master> <index> -option * grid rowconfigure <master> <index> -option value -option value. */ - - } else if(((c == 'c') && (strncmp(argv[1], "columnconfigure", length) == 0) - && (length >= 3)) || - ((c == 'r') && (strncmp(argv[1], "rowconfigure", length) == 0) - && (length >=2))) { - return GridRowColumnConfigureCommand(tkwin, interp, argc, argv); - - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be bbox, columnconfigure, configure, forget, info, ", - "location, propagate, remove, rowconfigure, size, or slaves.", - (char *) NULL); - return TCL_ERROR; + + case GRID_COLUMNCONFIGURE: + case GRID_ROWCONFIGURE: + return GridRowColumnConfigureCommand(tkwin, interp, objc, objv); } - return TCL_OK; + + /* This should not happen */ + Tcl_SetResult(interp, "Internal error in grid.", TCL_STATIC); + return TCL_ERROR; } /* @@ -398,11 +394,11 @@ Tk_GridCmd(clientData, interp, argc, argv) */ static int -GridBboxCommand(tkwin, interp, argc, argv) +GridBboxCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; /* master grid record */ @@ -412,45 +408,40 @@ GridBboxCommand(tkwin, interp, argc, argv) int endX, endY; /* last column/row in the layout */ int x=0, y=0; /* starting pixels for this bounding box */ int width, height; /* size of the bounding box */ - char buf[TCL_INTEGER_SPACE * 4]; - if (argc!=3 && argc != 5 && argc != 7) { - Tcl_AppendResult(interp, "wrong number of arguments: ", - "must be \"",argv[0], - " bbox master ?column row ?column row??\"", - (char *) NULL); + if (objc!=3 && objc != 5 && objc != 7) { + Tcl_WrongNumArgs(interp, 2, objv, "master ?column row ?column row??"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); - if (argc >= 5) { - if (Tcl_GetInt(interp, argv[3], &column) != TCL_OK) { + if (objc >= 5) { + if (Tcl_GetIntFromObj(interp, objv[3], &column) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetInt(interp, argv[4], &row) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[4], &row) != TCL_OK) { return TCL_ERROR; } column2 = column; row2 = row; } - if (argc == 7) { - if (Tcl_GetInt(interp, argv[5], &column2) != TCL_OK) { + if (objc == 7) { + if (Tcl_GetIntFromObj(interp, objv[5], &column2) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetInt(interp, argv[6], &row2) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[6], &row2) != TCL_OK) { return TCL_ERROR; } } gridPtr = masterPtr->masterDataPtr; if (gridPtr == NULL) { - Tcl_SetResult(interp, "0 0 0 0", TCL_STATIC); + Tcl_SetObjResult(interp, NewQuadObj(interp, 0, 0, 0, 0)); return TCL_OK; } @@ -459,10 +450,10 @@ GridBboxCommand(tkwin, interp, argc, argv) endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); if ((endX == 0) || (endY == 0)) { - Tcl_SetResult(interp, "0 0 0 0", TCL_STATIC); + Tcl_SetObjResult(interp, NewQuadObj(interp, 0, 0, 0, 0)); return TCL_OK; } - if (argc == 3) { + if (objc == 3) { row = column = 0; row2 = endY; column2 = endX; @@ -505,9 +496,8 @@ GridBboxCommand(tkwin, interp, argc, argv) height = gridPtr->rowPtr[row2].offset - y; } - sprintf(buf, "%d %d %d %d", x + gridPtr->startX, y + gridPtr->startY, - width, height); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_SetObjResult(interp, NewQuadObj(interp, + x + gridPtr->startX, y + gridPtr->startY, width, height)); return TCL_OK; } @@ -529,22 +519,23 @@ GridBboxCommand(tkwin, interp, argc, argv) */ static int -GridForgetRemoveCommand(tkwin, interp, argc, argv) +GridForgetRemoveCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window slave; Gridder *slavePtr; int i; - char c = argv[1][0]; + char *string = Tcl_GetString(objv[1]); + char c = string[0]; - for (i = 2; i < argc; i++) { - slave = Tk_NameToWindow(interp, argv[i], tkwin); - if (slave == NULL) { + for (i = 2; i < objc; i++) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { return TCL_ERROR; } + slavePtr = GetGrid(slave); if (slavePtr->masterPtr != NULL) { @@ -597,23 +588,21 @@ GridForgetRemoveCommand(tkwin, interp, argc, argv) */ static int -GridInfoCommand(tkwin, interp, argc, argv) +GridInfoCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { register Gridder *slavePtr; Tk_Window slave; char buffer[64 + TCL_INTEGER_SPACE * 4]; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " info window\"", (char *) NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - slave = Tk_NameToWindow(interp, argv[2], tkwin); - if (slave == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { return TCL_ERROR; } slavePtr = GetGrid(slave); @@ -632,7 +621,7 @@ GridInfoCommand(tkwin, interp, argc, argv) TkPrintPadAmount(interp, "ipady", slavePtr->iPadY/2, slavePtr->iPadY); TkPrintPadAmount(interp, "padx", slavePtr->padLeft, slavePtr->padX); TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY); - StickyToString(slavePtr->sticky,buffer); + StickyToString(slavePtr->sticky, buffer); Tcl_AppendResult(interp, " -sticky ", buffer, (char *) NULL); return TCL_OK; } @@ -655,11 +644,11 @@ GridInfoCommand(tkwin, interp, argc, argv) */ static int -GridLocationCommand(tkwin, interp, argc, argv) +GridLocationCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; /* master grid record */ @@ -668,29 +657,26 @@ GridLocationCommand(tkwin, interp, argc, argv) int x, y; /* Offset in pixels, from edge of parent. */ int i, j; /* Corresponding column and row indeces. */ int endX, endY; /* end of grid */ - char buf[TCL_INTEGER_SPACE * 2]; - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " location master x y\"", (char *)NULL); + if (objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "master x y"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } - if (Tk_GetPixels(interp, master, argv[3], &x) != TCL_OK) { + if (Tk_GetPixelsFromObj(interp, master, objv[3], &x) != TCL_OK) { return TCL_ERROR; } - if (Tk_GetPixels(interp, master, argv[4], &y) != TCL_OK) { + if (Tk_GetPixelsFromObj(interp, master, objv[4], &y) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); if (masterPtr->masterDataPtr == NULL) { - Tcl_SetResult(interp, "-1 -1", TCL_STATIC); + Tcl_SetObjResult(interp, NewPairObj(interp, -1, -1)); return TCL_OK; } gridPtr = masterPtr->masterDataPtr; @@ -714,7 +700,7 @@ GridLocationCommand(tkwin, interp, argc, argv) i = -1; } else { x -= masterPtr->masterDataPtr->startX; - for (i=0;slotPtr[i].offset < x && i < endX; i++) { + for (i = 0; slotPtr[i].offset < x && i < endX; i++) { /* null body */ } } @@ -724,13 +710,12 @@ GridLocationCommand(tkwin, interp, argc, argv) j = -1; } else { y -= masterPtr->masterDataPtr->startY; - for (j=0;slotPtr[j].offset < y && j < endY; j++) { + for (j = 0; slotPtr[j].offset < y && j < endY; j++) { /* null body */ } } - sprintf(buf, "%d %d", i, j); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_SetObjResult(interp, NewPairObj(interp, i, j)); return TCL_OK; } @@ -752,34 +737,31 @@ GridLocationCommand(tkwin, interp, argc, argv) */ static int -GridPropagateCommand(tkwin, interp, argc, argv) +GridPropagateCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; int propagate; - if (argc > 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " propagate window ?boolean?\"", - (char *) NULL); + if (objc > 4) { + Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); - if (argc == 3) { - Tcl_SetResult(interp, - ((masterPtr->flags & DONT_PROPAGATE) ? "0" : "1"), - TCL_STATIC); + if (objc == 3) { + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); return TCL_OK; } - if (Tcl_GetBoolean(interp, argv[3], &propagate) != TCL_OK) { + if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { return TCL_ERROR; } @@ -827,69 +809,65 @@ GridPropagateCommand(tkwin, interp, argc, argv) */ static int -GridRowColumnConfigureCommand(tkwin, interp, argc, argv) +GridRowColumnConfigureCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; SlotInfo *slotPtr = NULL; - int slot; /* the column or row number */ - size_t length; /* the # of chars in the "-option" string */ + int slot; /* the column or row number */ int slotType; /* COLUMN or ROW */ - int size; /* the configuration value */ + int size; /* the configuration value */ int checkOnly; /* check the size only */ - int argcPtr; /* Number of items in index list */ - char **argvPtr; /* array of indeces */ - char **indexP; /* String value of current index list item. */ + int lObjc; /* Number of items in index list */ + Tcl_Obj **lObjv; /* array of indices */ int ok; /* temporary TCL result code */ - int i; - char c; + int i, j; + char *string; + static char *optionStrings[] = { + "-minsize", "-pad", "-weight", (char *) NULL }; + enum options { ROWCOL_MINSIZE, ROWCOL_PAD, ROWCOL_WEIGHT }; + int index; - if (((argc%2 != 0) && (argc>6)) || (argc < 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " master index ?-option value...?\"", - (char *)NULL); + if (((objc % 2 != 0) && (objc > 6)) || (objc < 4)) { + Tcl_WrongNumArgs(interp, 2, objv, "master index ?-option value...?"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } - if (Tcl_SplitList(interp, argv[3], &argcPtr, &argvPtr) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[3], &lObjc, &lObjv) != TCL_OK) { return TCL_ERROR; } - c = argv[1][0]; - checkOnly = ((argc == 4) || (argc == 5)); + string = Tcl_GetString(objv[1]); + checkOnly = ((objc == 4) || (objc == 5)); masterPtr = GetGrid(master); - slotType = (c == 'c') ? COLUMN : ROW; - if (checkOnly && argcPtr > 1) { - Tcl_AppendResult(interp, argv[3], + slotType = (*string == 'c') ? COLUMN : ROW; + if (checkOnly && lObjc > 1) { + Tcl_AppendResult(interp, Tcl_GetString(objv[3]), " must be a single element.", (char *) NULL); - Tcl_Free((char *)argvPtr); return TCL_ERROR; } - for (indexP=argvPtr; *indexP != NULL; indexP++) { - if (Tcl_GetInt(interp, *indexP, &slot) != TCL_OK) { - Tcl_Free((char *)argvPtr); + for (j = 0; j < lObjc; j++) { + if (Tcl_GetIntFromObj(interp, lObjv[j], &slot) != TCL_OK) { return TCL_ERROR; } ok = CheckSlotData(masterPtr, slot, slotType, checkOnly); - if ((ok!=TCL_OK) && ((argc<4) || (argc>5))) { - Tcl_AppendResult(interp, argv[0], - " ", argv[1], ": \"", *argvPtr,"\" is out of range", - (char *) NULL); - Tcl_Free((char *)argvPtr); + if ((ok != TCL_OK) && ((objc < 4) || (objc > 5))) { + Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " ", + Tcl_GetString(objv[1]), ": \"", Tcl_GetString(lObjv[j]), + "\" is out of range", (char *) NULL); return TCL_ERROR; } else if (ok == TCL_OK) { slotPtr = (slotType == COLUMN) ? - masterPtr->masterDataPtr->columnPtr : - masterPtr->masterDataPtr->rowPtr; + masterPtr->masterDataPtr->columnPtr : + masterPtr->masterDataPtr->rowPtr; } /* @@ -897,21 +875,27 @@ GridRowColumnConfigureCommand(tkwin, interp, argc, argv) * request is out of range, return all 0's. */ - if (argc == 4) { - Tcl_Free((char *)argvPtr); - } - if ((argc == 4) && (ok == TCL_OK)) { - char buf[64 + TCL_INTEGER_SPACE * 3]; + if (objc == 4) { + int minsize = 0, pad = 0, weight = 0; + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + + if (ok == TCL_OK) { + minsize = slotPtr[slot].minSize; + pad = slotPtr[slot].pad; + weight = slotPtr[slot].weight; + } - sprintf(buf, "-minsize %d -pad %d -weight %d", - slotPtr[slot].minSize,slotPtr[slot].pad, - slotPtr[slot].weight); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - return (TCL_OK); - } else if (argc == 4) { - Tcl_SetResult(interp, "-minsize 0 -pad 0 -weight 0", - TCL_STATIC); - return (TCL_OK); + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj("-minsize", -1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(minsize)); + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj("-pad", -1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(pad)); + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj("-weight", -1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(weight)); + Tcl_SetObjResult(interp, res); + return TCL_OK; } /* @@ -920,89 +904,64 @@ GridRowColumnConfigureCommand(tkwin, interp, argc, argv) * current value is returned. */ - for (i=4; i<argc; i+=2) { - length = strlen(argv[i]); - if ((*argv[i] != '-') || length < 2) { - Tcl_AppendResult(interp, "invalid arg \"", argv[i], - "\" :expecting -minsize, -pad, or -weight.", - (char *) NULL); - Tcl_Free((char *)argvPtr); + for (i = 4; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - if (strncmp(argv[i], "-minsize", length) == 0) { - if (argc == 5) { - char buf[TCL_INTEGER_SPACE]; - int value; - - value = (ok == TCL_OK) ? slotPtr[slot].minSize : 0; - sprintf(buf, "%d", value); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } else if (Tk_GetPixels(interp, master, argv[i+1], &size) + if (index == ROWCOL_MINSIZE) { + if (objc == 5) { + Tcl_SetObjResult(interp, Tcl_NewIntObj( + (ok == TCL_OK) ? slotPtr[slot].minSize : 0)); + } else if (Tk_GetPixelsFromObj(interp, master, objv[i+1], &size) != TCL_OK) { - Tcl_Free((char *)argvPtr); return TCL_ERROR; } else { slotPtr[slot].minSize = size; } } - else if (strncmp(argv[i], "-weight", length) == 0) { + else if (index == ROWCOL_WEIGHT) { int wt; - if (argc == 5) { - char buf[TCL_INTEGER_SPACE]; - int value; - - value = (ok == TCL_OK) ? slotPtr[slot].weight : 0; - sprintf(buf, "%d", value); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } else if (Tcl_GetInt(interp, argv[i+1], &wt) != TCL_OK) { - Tcl_Free((char *)argvPtr); + if (objc == 5) { + Tcl_SetObjResult(interp, Tcl_NewIntObj( + (ok == TCL_OK) ? slotPtr[slot].weight : 0)); + } else if (Tcl_GetIntFromObj(interp, objv[i+1], &wt) + != TCL_OK) { return TCL_ERROR; } else if (wt < 0) { - Tcl_AppendResult(interp, "invalid arg \"", argv[i], + Tcl_AppendResult(interp, "invalid arg \"", + Tcl_GetString(objv[i]), "\": should be non-negative", (char *) NULL); - Tcl_Free((char *)argvPtr); return TCL_ERROR; } else { slotPtr[slot].weight = wt; } } - else if (strncmp(argv[i], "-pad", length) == 0) { - if (argc == 5) { - char buf[TCL_INTEGER_SPACE]; - int value; - - value = (ok == TCL_OK) ? slotPtr[slot].pad : 0; - sprintf(buf, "%d", value); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } else if (Tk_GetPixels(interp, master, argv[i+1], &size) + else if (index == ROWCOL_PAD) { + if (objc == 5) { + Tcl_SetObjResult(interp, Tcl_NewIntObj( + (ok == TCL_OK) ? slotPtr[slot].pad : 0)); + } else if (Tk_GetPixelsFromObj(interp, master, objv[i+1], &size) != TCL_OK) { - Tcl_Free((char *)argvPtr); return TCL_ERROR; } else if (size < 0) { - Tcl_AppendResult(interp, "invalid arg \"", argv[i], + Tcl_AppendResult(interp, "invalid arg \"", + Tcl_GetString(objv[i]), "\": should be non-negative", (char *) NULL); - Tcl_Free((char *)argvPtr); return TCL_ERROR; } else { slotPtr[slot].pad = size; } - } else { - Tcl_AppendResult(interp, "invalid arg \"", - argv[i], "\": expecting -minsize, -pad, or -weight.", - (char *) NULL); - Tcl_Free((char *)argvPtr); - return TCL_ERROR; } } } - Tcl_Free((char *)argvPtr); /* * If we changed a property, re-arrange the table, * and check for constraint shrinkage. */ - if (argc != 5) { + if (objc != 5) { if (slotType == ROW) { int last = masterPtr->masterDataPtr->rowMax - 1; while ((last >= 0) && (slotPtr[last].weight == 0) @@ -1050,38 +1009,34 @@ GridRowColumnConfigureCommand(tkwin, interp, argc, argv) */ static int -GridSizeCommand(tkwin, interp, argc, argv) +GridSizeCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; GridMaster *gridPtr; /* pointer to grid data */ - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " size window\"", (char *) NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); if (masterPtr->masterDataPtr != NULL) { - char buf[TCL_INTEGER_SPACE * 2]; - SetGridSize(masterPtr); gridPtr = masterPtr->masterDataPtr; - sprintf(buf, "%d %d", + Tcl_SetObjResult(interp, NewPairObj(interp, MAX(gridPtr->columnEnd, gridPtr->columnMax), - MAX(gridPtr->rowEnd, gridPtr->rowMax)); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + MAX(gridPtr->rowEnd, gridPtr->rowMax))); } else { - Tcl_SetResult(interp, "0 0", TCL_STATIC); + Tcl_SetObjResult(interp, NewPairObj(interp, 0, 0)); } return TCL_OK; } @@ -1105,61 +1060,55 @@ GridSizeCommand(tkwin, interp, argc, argv) */ static int -GridSlavesCommand(tkwin, interp, argc, argv) +GridSlavesCommand(tkwin, interp, objc, objv) Tk_Window tkwin; /* Main window of the application. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window master; Gridder *masterPtr; /* master grid record */ Gridder *slavePtr; int i, value; - size_t length; int row = -1, column = -1; + static char *optionStrings[] = { + "-column", "-row", (char *) NULL }; + enum options { SLAVES_COLUMN, SLAVES_ROW }; + int index; + Tcl_Obj *res; - if ((argc < 3) || ((argc%2) == 0)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " slaves window ?-option value...?\"", - (char *) NULL); + if ((objc < 3) || ((objc % 2) == 0)) { + Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value...?"); return TCL_ERROR; } - for (i=3; i<argc; i+=2) { - length = strlen(argv[i]); - if ((*argv[i] != '-') || (length < 2)) { - Tcl_AppendResult(interp, "invalid args: should be \"", - argv[0], " slaves window ?-option value...?\"", - (char *) NULL); + for (i = 3; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetInt(interp, argv[i+1], &value) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &value) != TCL_OK) { return TCL_ERROR; } if (value < 0) { - Tcl_AppendResult(interp, argv[i], + Tcl_AppendResult(interp, Tcl_GetString(objv[i]), " is an invalid value: should NOT be < 0", (char *) NULL); return TCL_ERROR; } - if (strncmp(argv[i], "-column", length) == 0) { + if (index == SLAVES_COLUMN) { column = value; - } else if (strncmp(argv[i], "-row", length) == 0) { - row = value; } else { - Tcl_AppendResult(interp, argv[i], - " is an invalid option: should be \"", - "-row, -column\"", - (char *) NULL); - return TCL_ERROR; + row = value; } } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); - + + res = Tcl_NewListObj(0, NULL); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { if (column>=0 && (slavePtr->column > column @@ -1170,8 +1119,10 @@ GridSlavesCommand(tkwin, interp, argc, argv) slavePtr->row+slavePtr->numRows-1 < row)) { continue; } - Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin)); + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj(Tk_PathName(slavePtr->tkwin), -1)); } + Tcl_SetObjResult(interp, res); return TCL_OK; } @@ -2418,12 +2369,12 @@ GridStructureProc(clientData, eventPtr) */ static int -ConfigureSlaves(interp, tkwin, argc, argv) +ConfigureSlaves(interp, tkwin, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Window tkwin; /* Any window in application containing * slaves. Used to look up slave names. */ - int argc; /* Number of elements in argv. */ - char *argv[]; /* Argument strings: contains one or more + int objc; /* Number of elements in argv. */ + Tcl_Obj *CONST objv[]; /* Argument objects: contains one or more * window names followed by any number * of "option value" pairs. Caller must * make sure that there is at least one @@ -2432,7 +2383,7 @@ ConfigureSlaves(interp, tkwin, argc, argv) Gridder *masterPtr; Gridder *slavePtr; Tk_Window other, slave, parent, ancestor; - int i, j, c, tmp; + int i, j, tmp; size_t length; int numWindows; int width; @@ -2440,30 +2391,48 @@ ConfigureSlaves(interp, tkwin, argc, argv) int defaultColumnSpan = 1; /* default number of columns */ char *lastWindow; /* use this window to base current * Row/col on */ + static char *optionStrings[] = { + "-column", "-columnspan", "-in", "-ipadx", "-ipady", + "-padx", "-pady", "-row", "-rowspan", "-sticky", + (char *) NULL }; + enum options { + CONF_COLUMN, CONF_COLUMNSPAN, CONF_IN, CONF_IPADX, CONF_IPADY, + CONF_PADX, CONF_PADY, CONF_ROW, CONF_ROWSPAN, CONF_STICKY }; + int index; + char *string; + char firstChar, prevChar; /* * Count the number of windows, or window short-cuts. */ - for(numWindows=i=0;i<argc;i++) { - char firstChar = *argv[i]; + firstChar = 0; + for (numWindows = i = 0; i < objc; i++) { + prevChar = firstChar; + string = Tcl_GetStringFromObj(objv[i], &length); + firstChar = string[0]; + if (firstChar == '.') { numWindows++; continue; } - length = strlen(argv[i]); + if (length > 1 && i == 0) { + Tcl_AppendResult(interp, "bad argument \"", string, + "\": must be name of window", (char *) NULL); + return TCL_ERROR; + } if (length > 1 && firstChar == '-') { break; } if (length > 1) { Tcl_AppendResult(interp, "unexpected parameter, \"", - argv[i], "\", in configure list. ", + string, "\", in configure list. ", "Should be window name or option", (char *) NULL); return TCL_ERROR; } if ((firstChar == REL_HORIZ) && ((numWindows == 0) || - (*argv[i-1] == REL_SKIP) || (*argv[i-1] == REL_VERT))) { + (prevChar == REL_SKIP) || (prevChar == REL_VERT))) { Tcl_AppendResult(interp, "Must specify window before shortcut '-'.", (char *) NULL); @@ -2476,12 +2445,12 @@ ConfigureSlaves(interp, tkwin, argc, argv) } Tcl_AppendResult(interp, "invalid window shortcut, \"", - argv[i], "\" should be '-', 'x', or '^'", (char *) NULL); + string, "\" should be '-', 'x', or '^'", (char *) NULL); return TCL_ERROR; } numWindows = i; - if ((argc-numWindows)&1) { + if ((objc - numWindows) & 1) { Tcl_AppendResult(interp, "extra option or", " option with no value", (char *) NULL); return TCL_ERROR; @@ -2500,7 +2469,8 @@ ConfigureSlaves(interp, tkwin, argc, argv) masterPtr = NULL; for (j = 0; j < numWindows; j++) { - char firstChar = *argv[j]; + string = Tcl_GetString(objv[j]); + firstChar = string[0]; /* * '^' and 'x' cause us to skip a column. '-' is processed @@ -2515,19 +2485,20 @@ ConfigureSlaves(interp, tkwin, argc, argv) continue; } - for (defaultColumnSpan=1; - j + defaultColumnSpan < numWindows && - (*argv[j+defaultColumnSpan] == REL_HORIZ); + for (defaultColumnSpan = 1; j + defaultColumnSpan < numWindows; defaultColumnSpan++) { - /* null body */ + char *string = Tcl_GetString(objv[j + defaultColumnSpan]); + if (*string != REL_HORIZ) { + break; + } } - slave = Tk_NameToWindow(interp, argv[j], tkwin); - if (slave == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } + if (Tk_IsTopLevel(slave)) { - Tcl_AppendResult(interp, "can't manage \"", argv[j], + Tcl_AppendResult(interp, "can't manage \"", Tcl_GetString(objv[j]), "\": it's a top-level window", (char *) NULL); return TCL_ERROR; } @@ -2548,38 +2519,34 @@ ConfigureSlaves(interp, tkwin, argc, argv) * about keeping track of the old state. */ - for (i = numWindows; i < argc; i+=2) { - length = strlen(argv[i]); - c = argv[i][1]; - - if (length < 2) { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[i], "\": must be ", - "-column, -columnspan, -in, -ipadx, -ipady, ", - "-padx, -pady, -row, -rowspan, or -sticky", - (char *) NULL); + for (i = numWindows; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - if ((c == 'c') && (strncmp(argv[i], "-column", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp<0) { + if (index == CONF_COLUMN) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || + tmp < 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad column value \"", argv[i+1], + Tcl_AppendResult(interp, "bad column value \"", + Tcl_GetString(objv[i+1]), "\": must be a non-negative integer", (char *)NULL); return TCL_ERROR; } slavePtr->column = tmp; - } else if ((c == 'c') - && (strncmp(argv[i], "-columnspan", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp <= 0) { + } else if (index == CONF_COLUMNSPAN) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || + tmp <= 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad columnspan value \"", argv[i+1], + Tcl_AppendResult(interp, "bad columnspan value \"", + Tcl_GetString(objv[i+1]), "\": must be a positive integer", (char *)NULL); return TCL_ERROR; } slavePtr->numCols = tmp; - } else if ((c == 'i') && (strncmp(argv[i], "-in", length) == 0)) { - other = Tk_NameToWindow(interp, argv[i+1], tkwin); - if (other == NULL) { + } else if (index == CONF_IN) { + if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != + TCL_OK) { return TCL_ERROR; } if (other == slave) { @@ -2589,74 +2556,70 @@ ConfigureSlaves(interp, tkwin, argc, argv) } masterPtr = GetGrid(other); InitMasterData(masterPtr); - } else if ((c == 'i') - && (strncmp(argv[i], "-ipadx", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) + } else if (index == CONF_IPADX) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) || (tmp < 0)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad ipadx value \"", argv[i+1], + Tcl_AppendResult(interp, "bad ipadx value \"", + Tcl_GetString(objv[i+1]), "\": must be positive screen distance", (char *) NULL); return TCL_ERROR; } slavePtr->iPadX = tmp*2; - } else if ((c == 'i') - && (strncmp(argv[i], "-ipady", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { + } else if (index == CONF_IPADY) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) + || (tmp < 0)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad ipady value \"", argv[i+1], + Tcl_AppendResult(interp, "bad ipady value \"", + Tcl_GetString(objv[i+1]), "\": must be positive screen distance", (char *) NULL); return TCL_ERROR; } slavePtr->iPadY = tmp*2; - } else if ((c == 'p') - && (strncmp(argv[i], "-padx", length) == 0)) { - if (TkParsePadAmount(interp, tkwin, argv[i+1], + } else if (index == CONF_PADX) { + if (TkParsePadAmount(interp, tkwin, objv[i+1], &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { return TCL_ERROR; } - } else if ((c == 'p') - && (strncmp(argv[i], "-pady", length) == 0)) { - if (TkParsePadAmount(interp, tkwin, argv[i+1], + } else if (index == CONF_PADY) { + if (TkParsePadAmount(interp, tkwin, objv[i+1], &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { return TCL_ERROR; } - } else if ((c == 'r') && (strncmp(argv[i], "-row", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp<0) { + } else if (index == CONF_ROW) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK + || tmp < 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad grid value \"", argv[i+1], + Tcl_AppendResult(interp, "bad grid value \"", + Tcl_GetString(objv[i+1]), "\": must be a non-negative integer", (char *)NULL); return TCL_ERROR; } slavePtr->row = tmp; - } else if ((c == 'r') - && (strncmp(argv[i], "-rowspan", length) == 0)) { - if ((Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK) || tmp<=0) { + } else if (index == CONF_ROWSPAN) { + if ((Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) + || tmp <= 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad rowspan value \"", argv[i+1], + Tcl_AppendResult(interp, "bad rowspan value \"", + Tcl_GetString(objv[i+1]), "\": must be a positive integer", (char *)NULL); return TCL_ERROR; } slavePtr->numRows = tmp; - } else if ((c == 's') - && strncmp(argv[i], "-sticky", length) == 0) { - int sticky = StringToSticky(argv[i+1]); + } else if (index == CONF_STICKY) { + int sticky = StringToSticky(Tcl_GetString(objv[i+1])); if (sticky == -1) { - Tcl_AppendResult(interp, "bad stickyness value \"", argv[i+1], + Tcl_AppendResult(interp, "bad stickyness value \"", + Tcl_GetString(objv[i+1]), "\": must be a string containing n, e, s, and/or w", (char *)NULL); return TCL_ERROR; } slavePtr->sticky = sticky; - } else { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[i], "\": must be ", - "-column, -columnspan, -in, -ipadx, -ipady, ", - "-padx, -pady, -row, -rowspan, or -sticky", - (char *) NULL); - return TCL_ERROR; } } @@ -2699,7 +2662,7 @@ ConfigureSlaves(interp, tkwin, argc, argv) break; } if (Tk_IsTopLevel(ancestor)) { - Tcl_AppendResult(interp, "can't put ", argv[j], + Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); Unlink(slavePtr); @@ -2712,7 +2675,7 @@ ConfigureSlaves(interp, tkwin, argc, argv) */ if (masterPtr->masterPtr == slavePtr) { - Tcl_AppendResult(interp, "can't put ", argv[j], + Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), ", would cause management loop.", (char *) NULL); @@ -2762,10 +2725,13 @@ ConfigureSlaves(interp, tkwin, argc, argv) int match; /* found a match for the ^ */ int lastRow, lastColumn; /* implied end of table */ - if (*argv[j] == '.') { - lastWindow = argv[j]; + string = Tcl_GetString(objv[j]); + firstChar = string[0]; + + if (firstChar == '.') { + lastWindow = string; } - if (*argv[j] != REL_VERT) { + if (firstChar != REL_VERT) { continue; } @@ -2776,9 +2742,9 @@ ConfigureSlaves(interp, tkwin, argc, argv) } /* Count the number of consecutive ^'s starting from this position */ - for (width=1; width+j < numWindows && *argv[j+width] == REL_VERT; - width++) { - /* Null Body */ + for (width = 1; width + j < numWindows; width++) { + char *string = Tcl_GetString(objv[j+width]); + if (*string != REL_VERT) break; } /* @@ -2910,3 +2876,59 @@ StringToSticky(string) } return sticky; } + +/* + *---------------------------------------------------------------------- + * + * NewPairObj -- + * + * Creates a new list object and fills it with two integer objects. + * + * Results: + * The newly created list object is returned. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Tcl_Obj * +NewPairObj(interp, val1, val2) + Tcl_Interp *interp; /* Current interpreter. */ + int val1, val2; +{ + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val2)); + return res; +} + +/* + *---------------------------------------------------------------------- + * + * NewQuadObj -- + * + * Creates a new list object and fills it with four integer objects. + * + * Results: + * The newly created list object is returned. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Tcl_Obj * +NewQuadObj(interp, val1, val2, val3, val4) + Tcl_Interp *interp; /* Current interpreter. */ + int val1, val2, val3, val4; +{ + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val2)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val3)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val4)); + return res; +} |