summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpspjuth <peter.spjuth@gmail.com>2001-08-21 20:21:36 (GMT)
committerpspjuth <peter.spjuth@gmail.com>2001-08-21 20:21:36 (GMT)
commit5de1e48a438ff12af2cdf2fa5542541d07be18b5 (patch)
tree8470e06c9c10c9cd3f5b83b65a958619ccc66d16
parentc9fb1f587664806275461fcf4b872e8acdd913b9 (diff)
downloadtk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.zip
tk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.tar.gz
tk-5de1e48a438ff12af2cdf2fa5542541d07be18b5.tar.bz2
Objectified grid and pack commands.
-rw-r--r--ChangeLog11
-rw-r--r--generic/tkGrid.c734
-rw-r--r--generic/tkInt.h12
-rw-r--r--generic/tkPack.c344
-rw-r--r--generic/tkWindow.c6
-rw-r--r--tests/grid.test64
-rw-r--r--tests/oldpack.test4
-rw-r--r--tests/pack.test8
8 files changed, 613 insertions, 570 deletions
diff --git a/ChangeLog b/ChangeLog
index 084442d..bc2a91e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-08-20 Peter Spjuth <peter.spjuth@space.se>
+
+ * generic/tkInt.h:
+ * generic/tkWindow.c:
+ * generic/tkGrid.c:
+ * generic/tkPack.c:
+ * tests/grid.test:
+ * tests/oldpack.test:
+ * tests/pack.test: Objectified grid and pack commands.
+
2001-08-20 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* generic/tkObj.c (TkGetWindowFromObj): Rewrote window code to
@@ -15,6 +25,7 @@
is incremented every time a window is deleted.
2001-08-18 Peter Spjuth <peter.spjuth@space.se>
+
* doc/grid.n:
* tests/grid.test:
* generic/tkGrid.c: Grid configure rejected initial "x" and "^"
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;
+}
diff --git a/generic/tkInt.h b/generic/tkInt.h
index e94f0c6..0142200 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: $Id: tkInt.h,v 1.37 2001/08/21 14:43:08 dkf Exp $
+ * RCS: $Id: tkInt.h,v 1.38 2001/08/21 20:21:36 pspjuth Exp $
*/
#ifndef _TKINT
@@ -942,8 +942,9 @@ EXTERN int Tk_GetSaveFileObjCmd _ANSI_ARGS_((
EXTERN int Tk_GrabObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
-EXTERN int Tk_GridCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+EXTERN int Tk_GridObjCmd _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]));
EXTERN int Tk_ImageObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
@@ -968,8 +969,9 @@ EXTERN int Tk_MessageObjCmd _ANSI_ARGS_((ClientData clientData,
EXTERN int Tk_OptionObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
-EXTERN int Tk_PackCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+EXTERN int Tk_PackObjCmd _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]));
EXTERN int Tk_PlaceObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
diff --git a/generic/tkPack.c b/generic/tkPack.c
index a6df7a9..6d52789 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -10,13 +10,14 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkPack.c,v 1.7 2001/02/12 18:06:47 drh Exp $
+ * RCS: @(#) $Id: tkPack.c,v 1.8 2001/08/21 20:21:36 pspjuth Exp $
*/
#include "tkPort.h"
#include "tkInt.h"
typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side;
+static char *sideNames[] = {"top", "bottom", "left", "right", (char *) NULL };
/* For each window that the packer cares about (either because
* the window is managed by the packer or because the window
@@ -120,12 +121,12 @@ static Tk_GeomMgr packerType = {
static void ArrangePacking _ANSI_ARGS_((ClientData clientData));
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 DestroyPacker _ANSI_ARGS_((char *memPtr));
static Packer * GetPacker _ANSI_ARGS_((Tk_Window tkwin));
static int PackAfter _ANSI_ARGS_((Tcl_Interp *interp,
- Packer *prevPtr, Packer *masterPtr, int argc,
- char **argv));
+ Packer *prevPtr, Packer *masterPtr, int objc,
+ Tcl_Obj *CONST objv[]));
static void PackReqProc _ANSI_ARGS_((ClientData clientData,
Tk_Window tkwin));
static void PackStructureProc _ANSI_ARGS_((ClientData clientData,
@@ -191,51 +192,71 @@ TkPrintPadAmount(interp, switchName, halfSpace, allSpace)
*/
int
-Tk_PackCmd(clientData, interp, argc, argv)
+Tk_PackObjCmd(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;
- int c;
-
- if ((argc >= 2) && (argv[1][0] == '.')) {
- return ConfigureSlaves(interp, tkwin, argc-1, argv+1);
+ char *argv2;
+ static char *optionStrings[] = {
+ /* after, append, before and unpack are deprecated */
+ "after", "append", "before", "unpack",
+ "configure", "forget", "info", "propagate", "slaves", (char *) NULL };
+ enum options {
+ PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK,
+ PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES };
+ int index;
+
+ if (objc >= 2) {
+ char *string = Tcl_GetString(objv[1]);
+ if (string[0] == '.') {
+ return ConfigureSlaves(interp, tkwin, objc-1, objv+1);
+ }
+ }
+ if (objc < 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
+ return TCL_ERROR;
}
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option arg ?arg ...?\"", (char *) NULL);
+
+ if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
+ &index) != TCL_OK) {
+ /*
+ * Call it again without the deprecated ones to get a proper
+ * error message.
+ * This works well since there can't be any ambiguity between
+ * deprecated and new options.
+ */
+
+ Tcl_ResetResult(interp);
+ Tcl_GetIndexFromObj(interp, objv[1], &optionStrings[4], "option", 0,
+ &index);
return TCL_ERROR;
}
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (length >= 2)
- && (strncmp(argv[1], "after", length) == 0)) {
+
+ argv2 = Tcl_GetString(objv[2]);
+ if (index == PACK_AFTER) {
Packer *prevPtr;
Tk_Window tkwin2;
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
prevPtr = GetPacker(tkwin2);
if (prevPtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
+ Tcl_AppendResult(interp, "window \"", argv2,
"\" isn't packed", (char *) NULL);
return TCL_ERROR;
}
- return PackAfter(interp, prevPtr, prevPtr->masterPtr, argc-3, argv+3);
- } else if ((c == 'a') && (length >= 2)
- && (strncmp(argv[1], "append", length) == 0)) {
+ return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3);
+ } else if (index == PACK_APPEND) {
Packer *masterPtr;
register Packer *prevPtr;
Tk_Window tkwin2;
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
masterPtr = GetPacker(tkwin2);
@@ -245,19 +266,18 @@ Tk_PackCmd(clientData, interp, argc, argv)
prevPtr = prevPtr->nextPtr;
}
}
- return PackAfter(interp, prevPtr, masterPtr, argc-3, argv+3);
- } else if ((c == 'b') && (strncmp(argv[1], "before", length) == 0)) {
+ return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3);
+ } else if (index == PACK_BEFORE) {
Packer *packPtr, *masterPtr;
register Packer *prevPtr;
Tk_Window tkwin2;
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
packPtr = GetPacker(tkwin2);
if (packPtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
+ Tcl_AppendResult(interp, "window \"", argv2,
"\" isn't packed", (char *) NULL);
return TCL_ERROR;
}
@@ -275,22 +295,21 @@ Tk_PackCmd(clientData, interp, argc, argv)
}
}
}
- return PackAfter(interp, prevPtr, masterPtr, argc-3, argv+3);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) {
- if (argv[2][0] != '.') {
- Tcl_AppendResult(interp, "bad argument \"", argv[2],
+ return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3);
+ } else if (index == PACK_CONFIGURE) {
+ if (argv2[0] != '.') {
+ Tcl_AppendResult(interp, "bad argument \"", argv2,
"\": 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)) {
+ return ConfigureSlaves(interp, tkwin, objc-2, objv+2);
+ } else if (index == PACK_FORGET) {
Tk_Window slave;
Packer *slavePtr;
int i;
- 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) {
continue;
}
slavePtr = GetPacker(slave);
@@ -305,23 +324,20 @@ Tk_PackCmd(clientData, interp, argc, argv)
Tk_UnmapWindow(slavePtr->tkwin);
}
}
- } else if ((c == 'i') && (strncmp(argv[1], "info", length) == 0)) {
+ } else if (index == PACK_INFO) {
register Packer *slavePtr;
Tk_Window slave;
- static char *sideNames[] = {"top", "bottom", "left", "right"};
- 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 = GetPacker(slave);
if (slavePtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
+ Tcl_AppendResult(interp, "window \"", argv2,
"\" isn't packed", (char *) NULL);
return TCL_ERROR;
}
@@ -352,30 +368,25 @@ Tk_PackCmd(clientData, interp, argc, argv)
TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY);
Tcl_AppendResult(interp, " -side ", sideNames[slavePtr->side],
(char *) NULL);
- } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) {
+ } else if (index == PACK_PROPAGATE) {
Tk_Window master;
Packer *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 = GetPacker(master);
- if (argc == 3) {
- if (masterPtr->flags & DONT_PROPAGATE) {
- Tcl_SetResult(interp, "0", TCL_STATIC);
- } else {
- Tcl_SetResult(interp, "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;
}
if (propagate) {
@@ -396,17 +407,15 @@ Tk_PackCmd(clientData, interp, argc, argv)
} else {
masterPtr->flags |= DONT_PROPAGATE;
}
- } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0)) {
+ } else if (index == PACK_SLAVES) {
Tk_Window master;
Packer *masterPtr, *slavePtr;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " slaves 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 = GetPacker(master);
@@ -414,17 +423,15 @@ Tk_PackCmd(clientData, interp, argc, argv)
slavePtr = slavePtr->nextPtr) {
Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin));
}
- } else if ((c == 'u') && (strncmp(argv[1], "unpack", length) == 0)) {
+ } else if (index == PACK_UNPACK) {
Tk_Window tkwin2;
Packer *packPtr;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " unpack window\"", (char *) NULL);
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
packPtr = GetPacker(tkwin2);
@@ -438,12 +445,8 @@ Tk_PackCmd(clientData, interp, argc, argv)
Unlink(packPtr);
Tk_UnmapWindow(packPtr->tkwin);
}
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be configure, forget, info, ",
- "propagate, or slaves", (char *) NULL);
- return TCL_ERROR;
}
+
return TCL_OK;
}
@@ -1049,10 +1052,10 @@ GetPacker(tkwin)
*/
int
-TkParsePadAmount(interp, tkwin, padSpec, halfPtr, allPtr)
+TkParsePadAmount(interp, tkwin, specObj, halfPtr, allPtr)
Tcl_Interp *interp; /* Interpreter for error reporting. */
Tk_Window tkwin; /* A window. Needed by Tk_GetPixels() */
- char *padSpec; /* The argument to "-padx", "-pady", "-ipadx",
+ Tcl_Obj *specObj; /* The argument to "-padx", "-pady", "-ipadx",
* or "-ipady". The thing to be parsed. */
int *halfPtr; /* Write the left/top part of padding here */
int *allPtr; /* Write the total padding here */
@@ -1061,6 +1064,7 @@ TkParsePadAmount(interp, tkwin, padSpec, halfPtr, allPtr)
char *separator = 0; /* Separator between 1st and 2nd pixel widths */
int sepChar; /* Character used as the separator */
int firstInt, secondInt; /* The two components of the padding */
+ char *padSpec = Tcl_GetString(specObj);
for (secondPart=padSpec;
(*secondPart != '\0') && !isspace(UCHAR(*secondPart));
@@ -1124,21 +1128,21 @@ TkParsePadAmount(interp, tkwin, padSpec, halfPtr, allPtr)
*/
static int
-PackAfter(interp, prevPtr, masterPtr, argc, argv)
+PackAfter(interp, prevPtr, masterPtr, objc, objv)
Tcl_Interp *interp; /* Interpreter for error reporting. */
Packer *prevPtr; /* Pack windows in argv just after this
* window; NULL means pack as first
* child of masterPtr. */
Packer *masterPtr; /* Master in which to pack windows. */
- int argc; /* Number of elements in argv. */
- char **argv; /* Array of lists, each containing 2
+ int objc; /* Number of elements in objv. */
+ Tcl_Obj *CONST objv[]; /* Array of lists, each containing 2
* elements: window name and side
* against which to pack. */
{
register Packer *packPtr;
Tk_Window tkwin, ancestor, parent;
size_t length;
- char **options;
+ Tcl_Obj **options;
int index, optionCount, c;
/*
@@ -1148,10 +1152,10 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
* "padx 20".
*/
- for ( ; argc > 0; argc -= 2, argv += 2, prevPtr = packPtr) {
- if (argc < 2) {
+ for ( ; objc > 0; objc -= 2, objv += 2, prevPtr = packPtr) {
+ if (objc < 2) {
Tcl_AppendResult(interp, "wrong # args: window \"",
- argv[0], "\" should be followed by options",
+ Tcl_GetString(objv[0]), "\" should be followed by options",
(char *) NULL);
return TCL_ERROR;
}
@@ -1162,8 +1166,8 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
* or a descendant of its parent.
*/
- tkwin = Tk_NameToWindow(interp, argv[0], masterPtr->tkwin);
- if (tkwin == NULL) {
+ if (TkGetWindowFromObj(interp, masterPtr->tkwin, objv[0], &tkwin)
+ != TCL_OK) {
return TCL_ERROR;
}
@@ -1174,7 +1178,7 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
}
if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) {
badWindow:
- Tcl_AppendResult(interp, "can't pack ", argv[0],
+ Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[0]),
" inside ", Tk_PathName(masterPtr->tkwin),
(char *) NULL);
return TCL_ERROR;
@@ -1192,7 +1196,8 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
* Process options for this window.
*/
- if (Tcl_SplitList(interp, argv[1], &optionCount, &options) != TCL_OK) {
+ if (Tcl_ListObjGetElements(interp, objv[1], &optionCount, &options)
+ != TCL_OK) {
return TCL_ERROR;
}
packPtr->side = TOP;
@@ -1203,10 +1208,10 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
packPtr->flags &= ~(FILLX|FILLY|EXPAND);
packPtr->flags |= OLD_STYLE;
for (index = 0 ; index < optionCount; index++) {
- char *curOpt = options[index];
+ Tcl_Obj *curOptPtr = options[index];
+ char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length);
c = curOpt[0];
- length = strlen(curOpt);
if ((c == 't')
&& (strncmp(curOpt, "top", length)) == 0) {
@@ -1236,11 +1241,11 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
Tcl_AppendResult(interp, "wrong # args: \"", curOpt,
"\" option must be followed by screen distance",
(char *) NULL);
- goto error;
+ return TCL_ERROR;
}
if (TkParsePadAmount(interp, tkwin, options[index+1],
&packPtr->padLeft, &packPtr->padX) != TCL_OK) {
- goto error;
+ return TCL_ERROR;
}
packPtr->padX /= 2;
packPtr->padLeft /= 2;
@@ -1252,7 +1257,7 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
}
if (TkParsePadAmount(interp, tkwin, options[index+1],
&packPtr->padTop, &packPtr->padY) != TCL_OK) {
- goto error;
+ return TCL_ERROR;
}
packPtr->padY /= 2;
packPtr->padTop /= 2;
@@ -1264,11 +1269,11 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
Tcl_AppendResult(interp, "wrong # args: \"frame\" ",
"option must be followed by anchor point",
(char *) NULL);
- goto error;
+ return TCL_ERROR;
}
- if (Tk_GetAnchor(interp, options[index+1],
+ if (Tk_GetAnchorFromObj(interp, options[index+1],
&packPtr->anchor) != TCL_OK) {
- goto error;
+ return TCL_ERROR;
}
index++;
} else {
@@ -1276,7 +1281,7 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
"\": should be top, bottom, left, right, ",
"expand, fill, fillx, filly, padx, pady, or frame",
(char *) NULL);
- goto error;
+ return TCL_ERROR;
}
}
@@ -1312,7 +1317,6 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
}
Tk_ManageGeometry(tkwin, &packerType, (ClientData) packPtr);
}
- ckfree((char *) options);
}
/*
@@ -1328,10 +1332,6 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv)
Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
}
return TCL_OK;
-
- error:
- ckfree((char *) options);
- return TCL_ERROR;
}
/*
@@ -1523,12 +1523,12 @@ PackStructureProc(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
@@ -1536,15 +1536,23 @@ ConfigureSlaves(interp, tkwin, argc, argv)
{
Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr;
Tk_Window other, slave, parent, ancestor;
- int i, j, numWindows, c, tmp, positionGiven;
- size_t length;
+ int i, j, numWindows, tmp, positionGiven;
+ char *string;
+ static char *optionStrings[] = {
+ "-after", "-anchor", "-before", "-expand", "-fill",
+ "-in", "-ipadx", "-ipady", "-padx", "-pady", "-side", (char *) NULL };
+ enum options {
+ CONF_AFTER, CONF_ANCHOR, CONF_BEFORE, CONF_EXPAND, CONF_FILL,
+ CONF_IN, CONF_IPADX, CONF_IPADY, CONF_PADX, CONF_PADY, CONF_SIDE };
+ int index, side;
/*
* Find out how many windows are specified.
*/
- for (numWindows = 0; numWindows < argc; numWindows++) {
- if (argv[numWindows][0] != '.') {
+ for (numWindows = 0; numWindows < objc; numWindows++) {
+ string = Tcl_GetString(objv[numWindows]);
+ if (string[0] != '.') {
break;
}
}
@@ -1564,12 +1572,11 @@ ConfigureSlaves(interp, tkwin, argc, argv)
prevPtr = NULL;
positionGiven = 0;
for (j = 0; j < numWindows; j++) {
- 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 pack \"", argv[j],
+ Tcl_AppendResult(interp, "can't pack \"", Tcl_GetString(objv[j]),
"\": it's a top-level window", (char *) NULL);
return TCL_ERROR;
}
@@ -1591,45 +1598,43 @@ ConfigureSlaves(interp, tkwin, argc, argv)
slavePtr->flags &= ~(FILLX|FILLY|EXPAND);
}
- for (i = numWindows; i < argc; i+=2) {
- if ((i+2) > argc) {
- Tcl_AppendResult(interp, "extra option \"", argv[i],
+ for (i = numWindows; i < objc; i+=2) {
+ if ((i+2) > objc) {
+ Tcl_AppendResult(interp, "extra option \"",
+ Tcl_GetString(objv[i]),
"\" (option with no value?)", (char *) NULL);
return TCL_ERROR;
}
- length = strlen(argv[i]);
- if (length < 2) {
- goto badOption;
+ if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option",
+ 0, &index) != TCL_OK) {
+ return TCL_ERROR;
}
- c = argv[i][1];
- if ((c == 'a') && (strncmp(argv[i], "-after", length) == 0)
- && (length >= 2)) {
+ if (index == CONF_AFTER) {
if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other)
+ != TCL_OK) {
return TCL_ERROR;
}
prevPtr = GetPacker(other);
if (prevPtr->masterPtr == NULL) {
notPacked:
- Tcl_AppendResult(interp, "window \"", argv[i+1],
+ Tcl_AppendResult(interp, "window \"",
+ Tcl_GetString(objv[i+1]),
"\" isn't packed", (char *) NULL);
return TCL_ERROR;
}
masterPtr = prevPtr->masterPtr;
positionGiven = 1;
}
- } else if ((c == 'a') && (strncmp(argv[i], "-anchor", length) == 0)
- && (length >= 2)) {
- if (Tk_GetAnchor(interp, argv[i+1], &slavePtr->anchor)
+ } else if (index == CONF_ANCHOR) {
+ if (Tk_GetAnchorFromObj(interp, objv[i+1], &slavePtr->anchor)
!= TCL_OK) {
return TCL_ERROR;
}
- } else if ((c == 'b')
- && (strncmp(argv[i], "-before", length) == 0)) {
+ } else if (index == CONF_BEFORE) {
if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other)
+ != TCL_OK) {
return TCL_ERROR;
}
otherPtr = GetPacker(other);
@@ -1647,33 +1652,33 @@ ConfigureSlaves(interp, tkwin, argc, argv)
}
positionGiven = 1;
}
- } else if ((c == 'e')
- && (strncmp(argv[i], "-expand", length) == 0)) {
- if (Tcl_GetBoolean(interp, argv[i+1], &tmp) != TCL_OK) {
+ } else if (index == CONF_EXPAND) {
+ if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
return TCL_ERROR;
}
slavePtr->flags &= ~EXPAND;
if (tmp) {
slavePtr->flags |= EXPAND;
}
- } else if ((c == 'f') && (strncmp(argv[i], "-fill", length) == 0)) {
- if (strcmp(argv[i+1], "none") == 0) {
+ } else if (index == CONF_FILL) {
+ string = Tcl_GetString(objv[i+1]);
+ if (strcmp(string, "none") == 0) {
slavePtr->flags &= ~(FILLX|FILLY);
- } else if (strcmp(argv[i+1], "x") == 0) {
+ } else if (strcmp(string, "x") == 0) {
slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX;
- } else if (strcmp(argv[i+1], "y") == 0) {
+ } else if (strcmp(string, "y") == 0) {
slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY;
- } else if (strcmp(argv[i+1], "both") == 0) {
+ } else if (strcmp(string, "both") == 0) {
slavePtr->flags |= FILLX|FILLY;
} else {
- Tcl_AppendResult(interp, "bad fill style \"", argv[i+1],
+ Tcl_AppendResult(interp, "bad fill style \"", string,
"\": must be none, x, y, or both", (char *) NULL);
return TCL_ERROR;
}
- } else if ((c == 'i') && (strcmp(argv[i], "-in") == 0)) {
+ } else if (index == CONF_IN) {
if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
+ if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other)
+ != TCL_OK) {
return TCL_ERROR;
}
masterPtr = GetPacker(other);
@@ -1685,49 +1690,32 @@ ConfigureSlaves(interp, tkwin, argc, argv)
}
positionGiven = 1;
}
- } else if ((c == 'i') && (strcmp(argv[i], "-ipadx") == 0)) {
- if (TkParsePadAmount(interp, slave, argv[i+1],
+ } else if (index == CONF_IPADX) {
+ if (TkParsePadAmount(interp, slave, objv[i+1],
0, &slavePtr->iPadX) != TCL_OK) {
return TCL_ERROR;
}
- } else if ((c == 'i') && (strcmp(argv[i], "-ipady") == 0)) {
- if (TkParsePadAmount(interp, slave, argv[i+1],
+ } else if (index == CONF_IPADY) {
+ if (TkParsePadAmount(interp, slave, objv[i+1],
0, &slavePtr->iPadY) != TCL_OK) {
return TCL_ERROR;
}
- } else if ((c == 'p') && (strcmp(argv[i], "-padx") == 0)) {
- if (TkParsePadAmount(interp, slave, argv[i+1],
+ } else if (index == CONF_PADX) {
+ if (TkParsePadAmount(interp, slave, objv[i+1],
&slavePtr->padLeft, &slavePtr->padX) != TCL_OK) {
return TCL_ERROR;
}
- } else if ((c == 'p') && (strcmp(argv[i], "-pady") == 0)) {
- if (TkParsePadAmount(interp, slave, argv[i+1],
+ } else if (index == CONF_PADY) {
+ if (TkParsePadAmount(interp, slave, objv[i+1],
&slavePtr->padTop, &slavePtr->padY) != TCL_OK) {
return TCL_ERROR;
}
- } else if ((c == 's') && (strncmp(argv[i], "-side", length) == 0)) {
- c = argv[i+1][0];
- if ((c == 't') && (strcmp(argv[i+1], "top") == 0)) {
- slavePtr->side = TOP;
- } else if ((c == 'b') && (strcmp(argv[i+1], "bottom") == 0)) {
- slavePtr->side = BOTTOM;
- } else if ((c == 'l') && (strcmp(argv[i+1], "left") == 0)) {
- slavePtr->side = LEFT;
- } else if ((c == 'r') && (strcmp(argv[i+1], "right") == 0)) {
- slavePtr->side = RIGHT;
- } else {
- Tcl_AppendResult(interp, "bad side \"", argv[i+1],
- "\": must be top, bottom, left, or right",
- (char *) NULL);
+ } else if (index == CONF_SIDE) {
+ if (Tcl_GetIndexFromObj(interp, objv[i+1], sideNames, "side",
+ TCL_EXACT, &side) != TCL_OK) {
return TCL_ERROR;
}
- } else {
- badOption:
- Tcl_AppendResult(interp, "unknown or ambiguous option \"",
- argv[i], "\": must be -after, -anchor, -before, ",
- "-expand, -fill, -in, -ipadx, -ipady, -padx, ",
- "-pady, or -side", (char *) NULL);
- return TCL_ERROR;
+ slavePtr->side = side;
}
}
@@ -1780,14 +1768,14 @@ ConfigureSlaves(interp, tkwin, argc, argv)
break;
}
if (Tk_IsTopLevel(ancestor)) {
- Tcl_AppendResult(interp, "can't pack ", argv[j],
+ Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[j]),
" inside ", Tk_PathName(masterPtr->tkwin),
(char *) NULL);
return TCL_ERROR;
}
}
if (slave == masterPtr->tkwin) {
- Tcl_AppendResult(interp, "can't pack ", argv[j],
+ Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[j]),
" inside itself", (char *) NULL);
return TCL_ERROR;
}
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 1102fab..6869980 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.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: tkWindow.c,v 1.34 2001/08/21 14:43:08 dkf Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.35 2001/08/21 20:21:36 pspjuth Exp $
*/
#include "tkPort.h"
@@ -106,11 +106,11 @@ static TkCmd commands[] = {
{"focus", NULL, Tk_FocusObjCmd, 1, 1},
{"font", NULL, Tk_FontObjCmd, 1, 1},
{"grab", NULL, Tk_GrabObjCmd, 0, 1},
- {"grid", Tk_GridCmd, NULL, 1, 1},
+ {"grid", NULL, Tk_GridObjCmd, 1, 1},
{"image", NULL, Tk_ImageObjCmd, 1, 1},
{"lower", NULL, Tk_LowerObjCmd, 1, 1},
{"option", NULL, Tk_OptionObjCmd, 1, 1},
- {"pack", Tk_PackCmd, NULL, 1, 1},
+ {"pack", NULL, Tk_PackObjCmd, 1, 1},
{"place", NULL, Tk_PlaceObjCmd, 1, 0},
{"raise", NULL, Tk_RaiseObjCmd, 1, 1},
{"selection", NULL, Tk_SelectionObjCmd, 0, 1},
diff --git a/tests/grid.test b/tests/grid.test
index 7384748..9e351a8 100644
--- a/tests/grid.test
+++ b/tests/grid.test
@@ -5,7 +5,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: grid.test,v 1.10 2001/08/18 20:03:17 pspjuth Exp $
+# RCS: @(#) $Id: grid.test,v 1.11 2001/08/21 20:21:36 pspjuth Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -46,7 +46,7 @@ test grid-1.1 {basic argument checking} {
test grid-1.2 {basic argument checking} {
list [catch {grid foo bar} msg] $msg
-} {1 {bad option "foo": must be bbox, columnconfigure, configure, forget, info, location, propagate, remove, rowconfigure, size, or slaves.}}
+} {1 {bad option "foo": must be bbox, columnconfigure, configure, forget, info, location, propagate, remove, rowconfigure, size, or slaves}}
test grid-1.3 {basic argument checking} {
button .b
@@ -98,7 +98,7 @@ test grid-2.2 {bbox} {
test grid-2.3 {bbox: argument checking} {
list [catch {grid bbox . 0 0 5} msg] $msg
-} {1 {wrong number of arguments: must be "grid bbox master ?column row ?column row??"}}
+} {1 {wrong # args: should be "grid bbox master ?column row ?column row??"}}
test grid-2.4 {bbox} {
list [catch {grid bbox .bad 0 0} msg] $msg
@@ -191,6 +191,19 @@ test grid-3.7 {configure: basic argument checking} {
} {1 {can't put .f.b inside .}}
grid_reset 3.7
+test grid-3.8 {configure: basic argument checking} {
+ button .b
+ grid configure x .b
+ grid slaves .
+} {.b}
+grid_reset 3.8
+
+test grid-3.9 {configure: basic argument checking} {
+ button .b
+ list [catch {grid configure y .b} msg] $msg
+} {1 {invalid window shortcut, "y" should be '-', 'x', or '^'}}
+grid_reset 3.9
+
test grid-4.1 {forget: basic argument checking} {
list [catch {grid forget foo} msg] $msg
} {1 {bad window path name "foo"}}
@@ -501,19 +514,19 @@ test grid-9.3 {slaves} {
test grid-9.4 {slaves} {
list [catch {grid slaves . a b} msg] $msg
-} {1 {invalid args: should be "grid slaves window ?-option value...?"}}
+} {1 {bad option "a": must be -column or -row}}
test grid-9.5 {slaves} {
- list [catch {grid slaves . -foo x} msg] $msg
+ list [catch {grid slaves . -column x} msg] $msg
} {1 {expected integer but got "x"}}
test grid-9.6 {slaves} {
- list [catch {grid slaves . -foo -3} msg] $msg
-} {1 {-foo is an invalid value: should NOT be < 0}}
+ list [catch {grid slaves . -row -3} msg] $msg
+} {1 {-row is an invalid value: should NOT be < 0}}
test grid-9.7 {slaves} {
list [catch {grid slaves . -foo 3} msg] $msg
-} {1 {-foo is an invalid option: should be "-row, -column"}}
+} {1 {bad option "-foo": must be -column or -row}}
test grid-9.8 {slaves} {
list [catch {grid slaves .x -row 3} msg] $msg
@@ -584,7 +597,7 @@ grid_reset 10.6
test grid-10.7 {column/row configure} {
list [catch {grid columnconfigure . 0 -foo} msg] $msg
-} {1 {invalid arg "-foo": expecting -minsize, -pad, or -weight.}}
+} {1 {bad option "-foo": must be -minsize, -pad, or -weight}}
grid_reset 10.7
test grid-10.8 {column/row configure} {
@@ -606,34 +619,34 @@ grid_reset 10.10
test grid-10.11 {column/row configure} {
list [catch {grid columnconfigure . 0 -weight bad} msg] $msg
} {1 {expected integer but got "bad"}}
-grid_reset 10.10a
+grid_reset 10.11
test grid-10.12 {column/row configure} {
list [catch {grid columnconfigure . 0 -weight -3} msg] $msg
} {1 {invalid arg "-weight": should be non-negative}}
-grid_reset 10.11
+grid_reset 10.12
test grid-10.13 {column/row configure} {
grid columnconfigure . 0 -weight 3
grid columnconfigure . 0 -weight
} {3}
-grid_reset 10.12
+grid_reset 10.13
test grid-10.14 {column/row configure} {
list [catch {grid columnconfigure . 0 -pad foo} msg] $msg
} {1 {bad screen distance "foo"}}
-grid_reset 10.13
+grid_reset 10.14
test grid-10.15 {column/row configure} {
list [catch {grid columnconfigure . 0 -pad -3} msg] $msg
} {1 {invalid arg "-pad": should be non-negative}}
-grid_reset 10.14
+grid_reset 10.15
test grid-10.16 {column/row configure} {
grid columnconfigure . 0 -pad 3
grid columnconfigure . 0 -pad
} {3}
-grid_reset 10.15
+grid_reset 10.16
test grid-10.17 {column/row configure} {
frame .f
@@ -649,17 +662,24 @@ test grid-10.17 {column/row configure} {
grid columnconfigure .f 0 -weight 0
set a
} {0 1 0 1}
-grid_reset 10.16
+grid_reset 10.17
test grid-10.18 {column/row configure} {
frame .f
- grid columnconfigure .f 0 -minsize 10 -weight 1
+ grid columnconfigure .f {0 2} -minsize 10 -weight 1
list [grid columnconfigure .f 0 -minsize] \
[grid columnconfigure .f 1 -minsize] \
+ [grid columnconfigure .f 2 -minsize] \
[grid columnconfigure .f 0 -weight] \
- [grid columnconfigure .f 1 -weight]
-} {10 0 1 0}
-grid_reset 10.17
+ [grid columnconfigure .f 1 -weight] \
+ [grid columnconfigure .f 2 -weight]
+} {10 0 10 1 0 1}
+grid_reset 10.18
+
+test grid-10.19 {column/row configure} {
+ list [catch {grid columnconfigure . {0 -1 2} -weight 1} msg] $msg
+} {1 {grid columnconfigure: "-1" is out of range}}
+grid_reset 10.19
# auto-placement tests
@@ -804,7 +824,7 @@ grid_reset 11.13
test grid-11.14 {default widget placement} {
foreach i {1 2 3} {
- frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red
+ frame .f$i -width 60 -height 60 -highlightthickness 0 -bg red
}
grid .f1 .f2
grid ^ .f3
@@ -815,7 +835,7 @@ test grid-11.14 {default widget placement} {
[winfo width .f$i],[winfo height .f$i]"
}
set a
-} {{0,25 50,50} {50,0 50,50} {50,50 50,50}}
+} {{0,30 60,60} {60,0 60,60} {60,60 60,60}}
grid_reset 11.14
test grid-11.15 {^ ^ test with multiple windows} {
diff --git a/tests/oldpack.test b/tests/oldpack.test
index a793304..e809da5 100644
--- a/tests/oldpack.test
+++ b/tests/oldpack.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: oldpack.test,v 1.3 1999/04/16 01:51:40 stanton Exp $
+# RCS: @(#) $Id: oldpack.test,v 1.4 2001/08/21 20:21:36 pspjuth Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -449,7 +449,7 @@ test pack-8.16 {syntax errors} {
set msg ""
set result [catch {pack append .pack .pack.blue {frame south}} msg]
concat $result $msg
-} {1 bad anchor position "south": must be n, ne, e, se, s, sw, w, nw, or center}
+} {1 bad anchor "south": must be n, ne, e, se, s, sw, w, nw, or center}
test pack-8.17 {syntax errors} {
set msg ""
set result [catch {pack append .pack .pack.blue {padx -2}} msg]
diff --git a/tests/pack.test b/tests/pack.test
index a36cb58..1603762 100644
--- a/tests/pack.test
+++ b/tests/pack.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: pack.test,v 1.6 2001/02/12 18:06:48 drh Exp $
+# RCS: @(#) $Id: pack.test,v 1.7 2001/08/21 20:21:36 pspjuth Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -704,7 +704,7 @@ test pack-12.8 {command options and errors} {
test pack-12.9 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a -anchor gorp} msg] $msg
-} {1 {bad anchor position "gorp": must be n, ne, e, se, s, sw, w, nw, or center}}
+} {1 {bad anchor "gorp": must be n, ne, e, se, s, sw, w, nw, or center}}
test pack-12.10 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a -before gorp} msg] $msg
@@ -781,7 +781,7 @@ test pack-12.23 {command options and errors} {
test pack-12.24 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a -lousy bac} msg] $msg
-} {1 {unknown or ambiguous option "-lousy": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side}}
+} {1 {bad option "-lousy": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side}}
test pack-12.25 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a -padx} msg] $msg
@@ -789,7 +789,7 @@ test pack-12.25 {command options and errors} {
test pack-12.26 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a {} 22} msg] $msg
-} {1 {unknown or ambiguous option "": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side}}
+} {1 {bad option "": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side}}
test pack-12.27 {command options and errors} {
pack forget .pack.a .pack.b .pack.c .pack.d
list [catch {pack .pack.a -in .} msg] $msg