summaryrefslogtreecommitdiffstats
path: root/generic/tkListbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r--generic/tkListbox.c226
1 files changed, 107 insertions, 119 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index b795cc2..b035878 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -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: tkListbox.c,v 1.44.2.4 2010/01/29 12:41:11 nijtmans Exp $
+ * RCS: @(#) $Id: tkListbox.c,v 1.59 2010/04/23 08:32:56 nijtmans Exp $
*/
#include "default.h"
@@ -26,7 +26,7 @@ typedef struct {
/* Table defining configuration options
* available for the listbox. */
Tk_OptionTable itemAttrOptionTable;
- /* Table definining configuration options
+ /* Table defining configuration options
* available for listbox items. */
} ListboxOptionTables;
@@ -213,7 +213,7 @@ enum state {
STATE_DISABLED, STATE_NORMAL
};
-static char *stateStrings[] = {
+static const char *const stateStrings[] = {
"disabled", "normal", NULL
};
@@ -221,7 +221,7 @@ enum activeStyle {
ACTIVE_STYLE_DOTBOX, ACTIVE_STYLE_NONE, ACTIVE_STYLE_UNDERLINE
};
-static char *activeStyleStrings[] = {
+static const char *const activeStyleStrings[] = {
"dotbox", "none", "underline", NULL
};
@@ -340,7 +340,7 @@ static const Tk_OptionSpec itemAttrOptionSpecs[] = {
* dispatch the listbox widget command.
*/
-static const char *commandNames[] = {
+static const char *const commandNames[] = {
"activate", "bbox", "cget", "configure", "curselection", "delete", "get",
"index", "insert", "itemcget", "itemconfigure", "nearest", "scan",
"see", "selection", "size", "xview", "yview", NULL
@@ -353,21 +353,21 @@ enum command {
COMMAND_SIZE, COMMAND_XVIEW, COMMAND_YVIEW
};
-static const char *selCommandNames[] = {
+static const char *const selCommandNames[] = {
"anchor", "clear", "includes", "set", NULL
};
enum selcommand {
SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET
};
-static const char *scanCommandNames[] = {
+static const char *const scanCommandNames[] = {
"mark", "dragto", NULL
};
enum scancommand {
SCAN_MARK, SCAN_DRAGTO
};
-static const char *indexNames[] = {
+static const char *const indexNames[] = {
"active", "anchor", "end", NULL
};
enum indices {
@@ -436,7 +436,7 @@ static void MigrateHashEntries(Tcl_HashTable *table,
* that can be invoked from generic window code.
*/
-static Tk_ClassProcs listboxClass = {
+static const Tk_ClassProcs listboxClass = {
sizeof(Tk_ClassProcs), /* size */
ListboxWorldChanged, /* worldChangedProc */
NULL, /* createProc */
@@ -472,7 +472,7 @@ Tk_ListboxObjCmd(
ListboxOptionTables *optionTables;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?");
+ Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
return TCL_ERROR;
}
@@ -491,15 +491,14 @@ Tk_ListboxObjCmd(
* command, so future invocations will have access to it.
*/
- optionTables = (ListboxOptionTables *)
- ckalloc(sizeof(ListboxOptionTables));
+ optionTables = ckalloc(sizeof(ListboxOptionTables));
/*
* Set up an exit handler to free the optionTables struct.
*/
Tcl_SetAssocData(interp, "ListboxOptionTables",
- DestroyListboxOptionTables, (ClientData) optionTables);
+ DestroyListboxOptionTables, optionTables);
/*
* Create the listbox option table and the listbox item option table.
@@ -517,22 +516,20 @@ Tk_ListboxObjCmd(
* already (e.g. resource pointers).
*/
- listPtr = (Listbox *) ckalloc(sizeof(Listbox));
+ listPtr = ckalloc(sizeof(Listbox));
memset(listPtr, 0, (sizeof(Listbox)));
listPtr->tkwin = tkwin;
listPtr->display = Tk_Display(tkwin);
listPtr->interp = interp;
listPtr->widgetCmd = Tcl_CreateObjCommand(interp,
- Tk_PathName(listPtr->tkwin), ListboxWidgetObjCmd,
- (ClientData) listPtr, ListboxCmdDeletedProc);
+ Tk_PathName(listPtr->tkwin), ListboxWidgetObjCmd, listPtr,
+ ListboxCmdDeletedProc);
listPtr->optionTable = optionTables->listboxOptionTable;
listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable;
- listPtr->selection = (Tcl_HashTable *)
- ckalloc(sizeof(Tcl_HashTable));
+ listPtr->selection = ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS);
- listPtr->itemAttrTable = (Tcl_HashTable *)
- ckalloc(sizeof(Tcl_HashTable));
+ listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS);
listPtr->relief = TK_RELIEF_RAISED;
listPtr->textGC = None;
@@ -550,15 +547,15 @@ Tk_ListboxObjCmd(
* otherwise Tk might free it while we still need it.
*/
- Tcl_Preserve((ClientData) listPtr->tkwin);
+ Tcl_Preserve(listPtr->tkwin);
Tk_SetClass(listPtr->tkwin, "Listbox");
- Tk_SetClassProcs(listPtr->tkwin, &listboxClass, (ClientData) listPtr);
+ Tk_SetClassProcs(listPtr->tkwin, &listboxClass, listPtr);
Tk_CreateEventHandler(listPtr->tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
- ListboxEventProc, (ClientData) listPtr);
+ ListboxEventProc, listPtr);
Tk_CreateSelHandler(listPtr->tkwin, XA_PRIMARY, XA_STRING,
- ListboxFetchSelection, (ClientData) listPtr, XA_STRING);
+ ListboxFetchSelection, listPtr, XA_STRING);
if (Tk_InitOptions(interp, (char *)listPtr,
optionTables->listboxOptionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(listPtr->tkwin);
@@ -570,7 +567,7 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- Tcl_SetResult(interp, Tk_PathName(listPtr->tkwin), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin));
return TCL_OK;
}
@@ -599,12 +596,12 @@ ListboxWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */
{
- register Listbox *listPtr = (Listbox *) clientData;
+ register Listbox *listPtr = clientData;
int cmdIndex, index;
int result = TCL_OK;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
@@ -619,7 +616,7 @@ ListboxWidgetObjCmd(
return result;
}
- Tcl_Preserve((ClientData)listPtr);
+ Tcl_Preserve(listPtr);
/*
* The subcommand was valid, so continue processing.
@@ -696,10 +693,9 @@ ListboxWidgetObjCmd(
if (objPtr == NULL) {
result = TCL_ERROR;
break;
- } else {
- Tcl_SetObjResult(interp, objPtr);
- result = TCL_OK;
}
+ Tcl_SetObjResult(interp, objPtr);
+ result = TCL_OK;
} else {
result = ConfigureListbox(interp, listPtr, objc-2, objv+2, 0);
}
@@ -822,8 +818,8 @@ ListboxWidgetObjCmd(
Tcl_SetObjResult(interp, elemPtrs[first]);
} else {
- Tcl_SetListObj(Tcl_GetObjResult(interp), (last - first + 1),
- &(elemPtrs[first]));
+ Tcl_SetObjResult(interp,
+ Tcl_NewListObj(last-first+1, elemPtrs+first));
}
result = TCL_OK;
break;
@@ -845,7 +841,7 @@ ListboxWidgetObjCmd(
case COMMAND_INSERT:
if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "index ?element element ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "index ?element ...?");
result = TCL_ERROR;
break;
}
@@ -903,7 +899,7 @@ ListboxWidgetObjCmd(
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
- "index ?option? ?value? ?option value ...?");
+ "index ?-option? ?value? ?-option value ...?");
result = TCL_ERROR;
break;
}
@@ -1051,7 +1047,7 @@ ListboxWidgetObjCmd(
result = ListboxYviewSubCmd(interp, listPtr, objc, objv);
break;
}
- Tcl_Release((ClientData)listPtr);
+ Tcl_Release(listPtr);
return result;
}
@@ -1096,9 +1092,8 @@ ListboxBboxSubCmd(
*/
if ((listPtr->topIndex <= index) && (index < lastVisibleIndex)) {
- char buf[TCL_INTEGER_SPACE * 4];
Tcl_Obj *el;
- char *stringRep;
+ const char *stringRep;
int pixelWidth, stringLen, x, y, result;
Tk_FontMetrics fm;
@@ -1118,8 +1113,8 @@ ListboxBboxSubCmd(
x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
y = ((index - listPtr->topIndex)*listPtr->lineHeight)
+ listPtr->inset + listPtr->selBorderWidth;
- sprintf(buf, "%d %d %d %d", x, y, pixelWidth, fm.linespace);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d %d %d",
+ x, y, pixelWidth, fm.linespace));
}
return TCL_OK;
}
@@ -1242,7 +1237,7 @@ ListboxXviewSubCmd(
int index, count, type, windowWidth, windowUnits;
int offset = 0; /* Initialized to stop gcc warnings. */
- double fraction, fraction2;
+ double fraction;
windowWidth = Tk_Width(listPtr->tkwin)
- 2*(listPtr->inset + listPtr->selBorderWidth);
@@ -1250,7 +1245,7 @@ ListboxXviewSubCmd(
if (listPtr->maxWidth == 0) {
Tcl_SetResult(interp, "0.0 1.0", TCL_STATIC);
} else {
- char buf[TCL_DOUBLE_SPACE];
+ double fraction2;
fraction = listPtr->xOffset/((double) listPtr->maxWidth);
fraction2 = (listPtr->xOffset + windowWidth)
@@ -1258,10 +1253,8 @@ ListboxXviewSubCmd(
if (fraction2 > 1.0) {
fraction2 = 1.0;
}
- Tcl_PrintDouble(NULL, fraction, buf);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- Tcl_PrintDouble(NULL, fraction2, buf);
- Tcl_AppendResult(interp, " ", buf, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%g %g",
+ fraction, fraction2));
}
} else if (objc == 3) {
if (Tcl_GetIntFromObj(interp, objv[2], &index) != TCL_OK) {
@@ -1318,24 +1311,21 @@ ListboxYviewSubCmd(
Tcl_Obj *const objv[]) /* Array of arguments to the procedure */
{
int index, count, type;
- double fraction, fraction2;
+ double fraction;
if (objc == 2) {
if (listPtr->nElements == 0) {
Tcl_SetResult(interp, "0.0 1.0", TCL_STATIC);
} else {
- char buf[TCL_DOUBLE_SPACE];
+ double fraction2, numEls = (double) listPtr->nElements;
- fraction = listPtr->topIndex/((double) listPtr->nElements);
- fraction2 = (listPtr->topIndex+listPtr->fullLines)
- /((double) listPtr->nElements);
+ fraction = listPtr->topIndex / numEls;
+ fraction2 = (listPtr->topIndex+listPtr->fullLines) / numEls;
if (fraction2 > 1.0) {
fraction2 = 1.0;
}
- Tcl_PrintDouble(NULL, fraction, buf);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- Tcl_PrintDouble(NULL, fraction2, buf);
- Tcl_AppendResult(interp, " ", buf, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%g %g",
+ fraction, fraction2));
}
} else if (objc == 3) {
if (GetListboxIndex(interp, listPtr, objv[2], 0, &index) != TCL_OK) {
@@ -1398,16 +1388,17 @@ ListboxGetItemAttributes(
entry = Tcl_CreateHashEntry(listPtr->itemAttrTable,
(char *) INT2PTR(index), &isNew);
if (isNew) {
- attrs = (ItemAttr *) ckalloc(sizeof(ItemAttr));
+ attrs = ckalloc(sizeof(ItemAttr));
attrs->border = NULL;
attrs->selBorder = NULL;
attrs->fgColor = NULL;
attrs->selFgColor = NULL;
Tk_InitOptions(interp, (char *)attrs, listPtr->itemAttrOptionTable,
listPtr->tkwin);
- Tcl_SetHashValue(entry, (ClientData) attrs);
+ Tcl_SetHashValue(entry, attrs);
+ } else {
+ attrs = Tcl_GetHashValue(entry);
}
- attrs = (ItemAttr *)Tcl_GetHashValue(entry);
return attrs;
}
@@ -1449,7 +1440,7 @@ DestroyListbox(
if (listPtr->listVarName != NULL) {
Tcl_UntraceVar(listPtr->interp, listPtr->listVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ListboxListVarProc, (ClientData) listPtr);
+ ListboxListVarProc, listPtr);
}
/*
@@ -1457,7 +1448,7 @@ DestroyListbox(
*/
Tcl_DeleteHashTable(listPtr->selection);
- ckfree((char *)listPtr->selection);
+ ckfree(listPtr->selection);
/*
* Free the item attribute hash table.
@@ -1465,10 +1456,10 @@ DestroyListbox(
for (entry = Tcl_FirstHashEntry(listPtr->itemAttrTable, &search);
entry != NULL; entry = Tcl_NextHashEntry(&search)) {
- ckfree((char *)Tcl_GetHashValue(entry));
+ ckfree(Tcl_GetHashValue(entry));
}
Tcl_DeleteHashTable(listPtr->itemAttrTable);
- ckfree((char *)listPtr->itemAttrTable);
+ ckfree(listPtr->itemAttrTable);
/*
* Free up all the stuff that requires special handling, then let
@@ -1485,11 +1476,11 @@ DestroyListbox(
Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray);
}
- Tk_FreeConfigOptions((char *)listPtr, listPtr->optionTable,
+ Tk_FreeConfigOptions((char *) listPtr, listPtr->optionTable,
listPtr->tkwin);
- Tcl_Release((ClientData) listPtr->tkwin);
+ Tcl_Release(listPtr->tkwin);
listPtr->tkwin = NULL;
- ckfree((char *) listPtr);
+ ckfree(listPtr);
}
/*
@@ -1515,7 +1506,7 @@ DestroyListboxOptionTables(
ClientData clientData, /* Pointer to the OptionTables struct */
Tcl_Interp *interp) /* Pointer to the calling interp */
{
- ckfree((char *) clientData);
+ ckfree(clientData);
return;
}
@@ -1557,7 +1548,7 @@ ConfigureListbox(
if (listPtr->listVarName != NULL) {
Tcl_UntraceVar(interp, listPtr->listVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ListboxListVarProc, (ClientData) listPtr);
+ ListboxListVarProc, listPtr);
}
for (error = 0; error <= 1; error++) {
@@ -1600,8 +1591,8 @@ ConfigureListbox(
if (listPtr->exportSelection && !oldExport
&& (listPtr->numSelected != 0)) {
- Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection,
- (ClientData) listPtr);
+ Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY,
+ ListboxLostSelection, listPtr);
}
/*
@@ -1653,7 +1644,7 @@ ConfigureListbox(
listPtr->listObj = listVarObj;
Tcl_TraceVar(listPtr->interp, listPtr->listVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ListboxListVarProc, (ClientData) listPtr);
+ ListboxListVarProc, listPtr);
} else if (listPtr->listObj == NULL) {
listPtr->listObj = Tcl_NewObj();
}
@@ -1677,10 +1668,9 @@ ConfigureListbox(
Tcl_SetObjResult(interp, errorResult);
Tcl_DecrRefCount(errorResult);
return TCL_ERROR;
- } else {
- ListboxWorldChanged((ClientData) listPtr);
- return TCL_OK;
}
+ ListboxWorldChanged(listPtr);
+ return TCL_OK;
}
/*
@@ -1757,7 +1747,7 @@ ListboxWorldChanged(
XGCValues gcValues;
GC gc;
unsigned long mask;
- Listbox *listPtr = (Listbox *) instanceData;
+ Listbox *listPtr = instanceData;
if (listPtr->state & STATE_NORMAL) {
gcValues.foreground = listPtr->fgColorPtr->pixel;
@@ -1828,14 +1818,14 @@ static void
DisplayListbox(
ClientData clientData) /* Information about window. */
{
- register Listbox *listPtr = (Listbox *) clientData;
+ register Listbox *listPtr = clientData;
register Tk_Window tkwin = listPtr->tkwin;
GC gc;
int i, limit, x, y, prevSelected, freeGC, stringLen;
Tk_FontMetrics fm;
Tcl_Obj *curElement;
Tcl_HashEntry *entry;
- char *stringRep;
+ const char *stringRep;
ItemAttr *attrs;
Tk_3DBorder selectedBg;
XGCValues gcValues;
@@ -1856,23 +1846,23 @@ DisplayListbox(
listPtr->flags |= UPDATE_H_SCROLLBAR;
}
- Tcl_Preserve((ClientData) listPtr);
+ Tcl_Preserve(listPtr);
if (listPtr->flags & UPDATE_V_SCROLLBAR) {
ListboxUpdateVScrollbar(listPtr);
if ((listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(tkwin)) {
- Tcl_Release((ClientData) listPtr);
+ Tcl_Release(listPtr);
return;
}
}
if (listPtr->flags & UPDATE_H_SCROLLBAR) {
ListboxUpdateHScrollbar(listPtr);
if ((listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(tkwin)) {
- Tcl_Release((ClientData) listPtr);
+ Tcl_Release(listPtr);
return;
}
}
listPtr->flags &= ~(REDRAW_PENDING|UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR);
- Tcl_Release((ClientData) listPtr);
+ Tcl_Release(listPtr);
#ifndef TK_NO_DOUBLE_BUFFERING
/*
@@ -1946,7 +1936,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = (ItemAttr *)Tcl_GetHashValue(entry);
+ attrs = Tcl_GetHashValue(entry);
/*
* Default GC has the values from the widget at large.
@@ -2028,7 +2018,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = (ItemAttr *)Tcl_GetHashValue(entry);
+ attrs = Tcl_GetHashValue(entry);
gcValues.foreground = listPtr->fgColorPtr->pixel;
gcValues.font = Tk_FontId(listPtr->tkfont);
gcValues.graphics_exposures = False;
@@ -2218,7 +2208,7 @@ ListboxComputeGeometry(
int width, height, pixelWidth, pixelHeight, textLength, i, result;
Tk_FontMetrics fm;
Tcl_Obj *element;
- char *text;
+ const char *text;
if (fontChanged || maxIsStale) {
listPtr->xScrollUnit = Tk_TextWidth(listPtr->tkfont, "0", 1);
@@ -2304,7 +2294,7 @@ ListboxInsertSubCmd(
{
int i, oldMaxWidth, pixelWidth, result, length;
Tcl_Obj *newListObj;
- char *stringRep;
+ const char *stringRep;
oldMaxWidth = listPtr->maxWidth;
for (i = 0; i < objc; i++) {
@@ -2418,7 +2408,7 @@ ListboxDeleteSubCmd(
{
int count, i, widthChanged, length, result, pixelWidth;
Tcl_Obj *newListObj, *element;
- char *stringRep;
+ const char *stringRep;
Tcl_HashEntry *entry;
/*
@@ -2459,7 +2449,7 @@ ListboxDeleteSubCmd(
entry = Tcl_FindHashEntry(listPtr->itemAttrTable, (char *) INT2PTR(i));
if (entry != NULL) {
- ckfree((char *)Tcl_GetHashValue(entry));
+ ckfree(Tcl_GetHashValue(entry));
Tcl_DeleteHashEntry(entry);
}
@@ -2589,7 +2579,7 @@ ListboxEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Listbox *listPtr = (Listbox *) clientData;
+ Listbox *listPtr = clientData;
if (eventPtr->type == Expose) {
EventuallyRedrawRange(listPtr,
@@ -2664,7 +2654,7 @@ static void
ListboxCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Listbox *listPtr = (Listbox *) clientData;
+ Listbox *listPtr = clientData;
/*
* This procedure could be invoked either because the window was destroyed
@@ -2708,7 +2698,7 @@ GetListboxIndex(
int *indexPtr) /* Where to store converted index. */
{
int result, index;
- char *stringRep;
+ const char *stringRep;
/*
* First see if the index is one of the named indices.
@@ -2745,7 +2735,8 @@ GetListboxIndex(
if (stringRep[0] == '@') {
/* @x,y index */
int y;
- char *start, *end;
+ const char *start;
+ char *end;
start = stringRep + 1;
y = strtol(start, &end, 0);
@@ -3050,7 +3041,7 @@ ListboxSelect(
if (select) {
entry = Tcl_CreateHashEntry(listPtr->selection,
(char *) INT2PTR(i), &isNew);
- Tcl_SetHashValue(entry, (ClientData) NULL);
+ Tcl_SetHashValue(entry, NULL);
listPtr->numSelected++;
if (firstRedisplay < 0) {
firstRedisplay = i;
@@ -3064,8 +3055,8 @@ ListboxSelect(
}
if ((oldCount == 0) && (listPtr->numSelected > 0)
&& (listPtr->exportSelection)) {
- Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection,
- (ClientData) listPtr);
+ Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY,
+ ListboxLostSelection, listPtr);
}
return TCL_OK;
}
@@ -3102,11 +3093,11 @@ ListboxFetchSelection(
* not including terminating NULL
* character. */
{
- register Listbox *listPtr = (Listbox *) clientData;
+ register Listbox *listPtr = clientData;
Tcl_DString selection;
int length, count, needNewline, stringLen, i;
Tcl_Obj *curElement;
- char *stringRep;
+ const char *stringRep;
Tcl_HashEntry *entry;
if (!listPtr->exportSelection) {
@@ -3178,7 +3169,7 @@ static void
ListboxLostSelection(
ClientData clientData) /* Information about listbox widget. */
{
- register Listbox *listPtr = (Listbox *) clientData;
+ register Listbox *listPtr = clientData;
if ((listPtr->exportSelection) && (listPtr->nElements > 0)) {
ListboxSelect(listPtr, 0, listPtr->nElements-1, 0);
@@ -3222,7 +3213,7 @@ EventuallyRedrawRange(
return;
}
listPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayListbox, (ClientData) listPtr);
+ Tcl_DoWhenIdle(DisplayListbox, listPtr);
}
/*
@@ -3249,7 +3240,7 @@ static void
ListboxUpdateVScrollbar(
register Listbox *listPtr) /* Information about widget. */
{
- char firstStr[TCL_DOUBLE_SPACE+1], lastStr[TCL_DOUBLE_SPACE+1];
+ char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
double first, last;
int result;
Tcl_Interp *interp;
@@ -3261,16 +3252,15 @@ ListboxUpdateVScrollbar(
first = 0.0;
last = 1.0;
} else {
- first = listPtr->topIndex / (double) listPtr->nElements;
+ first = listPtr->topIndex / ((double) listPtr->nElements);
last = (listPtr->topIndex + listPtr->fullLines)
- / (double) listPtr->nElements;
+ / ((double) listPtr->nElements);
if (last > 1.0) {
last = 1.0;
}
}
- firstStr[0] = lastStr[0] = ' ';
- Tcl_PrintDouble(NULL, first, firstStr+1);
- Tcl_PrintDouble(NULL, last, lastStr+1);
+ Tcl_PrintDouble(NULL, first, firstStr);
+ Tcl_PrintDouble(NULL, last, lastStr);
/*
* We must hold onto the interpreter from the listPtr because the data at
@@ -3279,12 +3269,12 @@ ListboxUpdateVScrollbar(
interp = listPtr->interp;
Tcl_Preserve(interp);
- result = Tcl_VarEval(interp, listPtr->yScrollCmd, firstStr, lastStr,
- NULL);
+ result = Tcl_VarEval(interp, listPtr->yScrollCmd, " ", firstStr, " ",
+ lastStr, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (vertical scrolling command executed by listbox)");
- Tcl_BackgroundError(interp);
+ Tcl_BackgroundException(interp, result);
}
Tcl_Release(interp);
}
@@ -3313,7 +3303,7 @@ static void
ListboxUpdateHScrollbar(
register Listbox *listPtr) /* Information about widget. */
{
- char firstStr[TCL_DOUBLE_SPACE+1], lastStr[TCL_DOUBLE_SPACE+1];
+ char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
int result, windowWidth;
double first, last;
Tcl_Interp *interp;
@@ -3327,17 +3317,15 @@ ListboxUpdateHScrollbar(
first = 0;
last = 1.0;
} else {
- register double maxWide = (double) listPtr->maxWidth;
-
- first = listPtr->xOffset / maxWide;
- last = (listPtr->xOffset + windowWidth) / maxWide;
+ first = listPtr->xOffset/((double) listPtr->maxWidth);
+ last = (listPtr->xOffset + windowWidth)
+ /((double) listPtr->maxWidth);
if (last > 1.0) {
last = 1.0;
}
}
- firstStr[0] = lastStr[0] = ' ';
- Tcl_PrintDouble(NULL, first, firstStr+1);
- Tcl_PrintDouble(NULL, last, lastStr+1);
+ Tcl_PrintDouble(NULL, first, firstStr);
+ Tcl_PrintDouble(NULL, last, lastStr);
/*
* We must hold onto the interpreter because the data referred to at
@@ -3346,12 +3334,12 @@ ListboxUpdateHScrollbar(
interp = listPtr->interp;
Tcl_Preserve(interp);
- result = Tcl_VarEval(interp, listPtr->xScrollCmd, firstStr, lastStr,
- NULL);
+ result = Tcl_VarEval(interp, listPtr->xScrollCmd, " ", firstStr, " ",
+ lastStr, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (horizontal scrolling command executed by listbox)");
- Tcl_BackgroundError(interp);
+ Tcl_BackgroundException(interp, result);
}
Tcl_Release(interp);
}
@@ -3380,7 +3368,7 @@ ListboxListVarProc(
const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- Listbox *listPtr = (Listbox *)clientData;
+ Listbox *listPtr = clientData;
Tcl_Obj *oldListObj, *varListObj;
int oldLength, i;
Tcl_HashEntry *entry;
@@ -3456,7 +3444,7 @@ ListboxListVarProc(
entry = Tcl_FindHashEntry(listPtr->itemAttrTable,
(char *) INT2PTR(i));
if (entry != NULL) {
- ckfree((char *) Tcl_GetHashValue(entry));
+ ckfree(Tcl_GetHashValue(entry));
Tcl_DeleteHashEntry(entry);
}
}