summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-27 10:47:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-27 10:47:08 (GMT)
commit9d65143eb6ec4d77828501177d7275b0c84b5958 (patch)
tree8a454ebe32c3664e20032d0599e2b21db90158c8
parent1a3e22f450317f68c5428a283836403d7548373a (diff)
downloadtk-9d65143eb6ec4d77828501177d7275b0c84b5958.zip
tk-9d65143eb6ec4d77828501177d7275b0c84b5958.tar.gz
tk-9d65143eb6ec4d77828501177d7275b0c84b5958.tar.bz2
A few more tweaks, using size_t in Tcl 9 builds.
-rw-r--r--generic/tkText.c7
-rw-r--r--generic/ttk/ttkEntry.c22
-rw-r--r--generic/ttk/ttkNotebook.c48
3 files changed, 38 insertions, 39 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 0c4d74c..2f5991b 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -3425,7 +3425,8 @@ TextFetchSelection(
{
TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
- int count, chunkSize, offsetInSeg;
+ int count, chunkSize;
+ TkSizeT offsetInSeg;
TkTextSearch search;
TkTextSegment *segPtr;
@@ -3484,12 +3485,10 @@ TextFetchSelection(
*/
while (1) {
- TkSizeT offsetInSeg1;
if (maxBytes == 0) {
goto fetchDone;
}
- segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg1);
- offsetInSeg = offsetInSeg1;
+ segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg);
chunkSize = segPtr->size - offsetInSeg;
if (chunkSize > (int)maxBytes) {
chunkSize = (int)maxBytes;
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index aedc384..e07617c 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1756,7 +1756,7 @@ typedef struct {
Tcl_Obj *postCommandObj;
Tcl_Obj *valuesObj;
Tcl_Obj *heightObj;
- int currentIndex;
+ TkSizeT currentIndex;
} ComboboxPart;
typedef struct {
@@ -1786,7 +1786,7 @@ ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
Combobox *cb = (Combobox *)recordPtr;
- cb->combobox.currentIndex = -1;
+ cb->combobox.currentIndex = TCL_INDEX_NONE;
TtkTrackElementState(&cb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1818,35 +1818,35 @@ static int ComboboxCurrentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Combobox *cbPtr = (Combobox *)recordPtr;
- int currentIndex = cbPtr->combobox.currentIndex;
+ TkSizeT currentIndex = cbPtr->combobox.currentIndex;
const char *currentValue = cbPtr->entry.string;
int nValues;
Tcl_Obj **values;
- Tcl_ListObjGetElements(interp,cbPtr->combobox.valuesObj,&nValues,&values);
+ Tcl_ListObjGetElements(interp, cbPtr->combobox.valuesObj, &nValues, &values);
if (objc == 2) {
/* Check if currentIndex still valid:
*/
- if ( currentIndex < 0
- || currentIndex >= nValues
+ if ( currentIndex == TCL_INDEX_NONE
+ || currentIndex >= (TkSizeT)nValues
|| strcmp(currentValue,Tcl_GetString(values[currentIndex]))
)
{
/* Not valid. Check current value against each element in -values:
*/
- for (currentIndex = 0; currentIndex < nValues; ++currentIndex) {
+ for (currentIndex = 0; currentIndex < (TkSizeT)nValues; ++currentIndex) {
if (!strcmp(currentValue,Tcl_GetString(values[currentIndex]))) {
break;
}
}
- if (currentIndex >= nValues) {
+ if (currentIndex >= (TkSizeT)nValues) {
/* Not found */
- currentIndex = -1;
+ currentIndex = TCL_INDEX_NONE;
}
}
cbPtr->combobox.currentIndex = currentIndex;
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(currentIndex));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)currentIndex));
return TCL_OK;
} else if (objc == 3) {
TkSizeT idx;
@@ -1858,7 +1858,7 @@ static int ComboboxCurrentCommand(
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
return TCL_ERROR;
}
- currentIndex = (int)idx;
+ currentIndex = idx;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Incorrect index %s", Tcl_GetString(objv[2])));
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index c17f255..7ad46a4 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -94,8 +94,8 @@ typedef struct
Ttk_Manager *mgr; /* Geometry manager */
Tk_OptionTable tabOptionTable; /* Tab options */
Tk_OptionTable paneOptionTable; /* Tab+pane options */
- int currentIndex; /* index of currently selected tab */
- int activeIndex; /* index of currently active tab */
+ TkSizeT currentIndex; /* index of currently selected tab */
+ TkSizeT activeIndex; /* index of currently active tab */
Ttk_Layout tabLayout; /* Sublayout for tabs */
Ttk_Box clientArea; /* Where to pack slave widgets */
@@ -272,7 +272,7 @@ static TkSizeT IdentifyTab(Notebook *nb, int x, int y)
* ActivateTab --
* Set the active tab index, redisplay if necessary.
*/
-static void ActivateTab(Notebook *nb, int index)
+static void ActivateTab(Notebook *nb, TkSizeT index)
{
if (index != nb->notebook.activeIndex) {
nb->notebook.activeIndex = index;
@@ -293,13 +293,13 @@ static Ttk_State TabState(Notebook *nb, TkSizeT index)
Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
TkSizeT i = 0;
- if ((int)index == nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
state |= TTK_STATE_SELECTED;
} else {
state &= ~TTK_STATE_FOCUS;
}
- if ((int)index == nb->notebook.activeIndex) {
+ if (index == nb->notebook.activeIndex) {
state |= TTK_STATE_ACTIVE;
}
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
@@ -589,8 +589,8 @@ static void NotebookPlaceSlave(Notebook *nb, TkSizeT slaveIndex)
static void NotebookPlaceSlaves(void *recordPtr)
{
Notebook *nb = (Notebook *)recordPtr;
- int currentIndex = nb->notebook.currentIndex;
- if (currentIndex >= 0) {
+ TkSizeT currentIndex = nb->notebook.currentIndex;
+ if (currentIndex != TCL_INDEX_NONE) {
NotebookDoLayout(nb);
NotebookPlaceSlave(nb, currentIndex);
}
@@ -700,11 +700,11 @@ static void TabRemoved(void *managerData, TkSizeT index)
Notebook *nb = (Notebook *)managerData;
Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
- if ((int)index == nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
}
- if ((int)index < nb->notebook.currentIndex) {
+ if (index + 1 < nb->notebook.currentIndex + 1) {
--nb->notebook.currentIndex;
}
@@ -728,7 +728,7 @@ static int TabRequest(void *managerData, TkSizeT index, int width, int height)
*/
static int AddTab(
Tcl_Interp *interp, Notebook *nb,
- int destIndex, Tk_Window slaveWindow,
+ TkSizeT destIndex, Tk_Window slaveWindow,
int objc, Tcl_Obj *const objv[])
{
Tab *tab;
@@ -759,9 +759,9 @@ static int AddTab(
/* Adjust indices and/or autoselect first tab:
*/
- if (nb->notebook.currentIndex < 0) {
+ if (nb->notebook.currentIndex == TCL_INDEX_NONE) {
SelectTab(nb, destIndex);
- } else if (nb->notebook.currentIndex >= destIndex) {
+ } else if (nb->notebook.currentIndex + 1 >= destIndex + 1) {
++nb->notebook.currentIndex;
}
@@ -940,7 +940,7 @@ static int NotebookInsertCommand(
{
Notebook *nb = (Notebook *)recordPtr;
TkSizeT current = nb->notebook.currentIndex;
- TkSizeT nSlaves1 = Ttk_NumberSlaves(nb->notebook.mgr);
+ TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
TkSizeT srcIndex, destIndex;
if (objc < 4) {
@@ -985,14 +985,14 @@ static int NotebookInsertCommand(
return TCL_ERROR;
}
- if (destIndex + 1 >= nSlaves1 + 1) {
- destIndex = nSlaves1 - 1;
+ if (destIndex + 1 >= nSlaves + 1) {
+ destIndex = nSlaves - 1;
}
Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex);
/* Adjust internal indexes:
*/
- nb->notebook.activeIndex = -1;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
if (current == srcIndex) {
nb->notebook.currentIndex = destIndex;
} else if (destIndex + 1 <= current + 1 && current + 1 < srcIndex + 1) {
@@ -1051,7 +1051,7 @@ static int NotebookHideCommand(
tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
tab->state = TAB_STATE_HIDDEN;
- if (index == (TkSizeT)nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
}
@@ -1151,7 +1151,7 @@ static int NotebookSelectCommand(
Notebook *nb = (Notebook *)recordPtr;
if (objc == 2) {
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
Tk_Window pane = Ttk_SlaveWindow(
nb->notebook.mgr, nb->notebook.currentIndex);
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1));
@@ -1233,7 +1233,7 @@ static int NotebookTabCommand(
/* If the current tab has become disabled or hidden,
* select the next nondisabled, unhidden one:
*/
- if (index == (TkSizeT)nb->notebook.currentIndex && tab->state != TAB_STATE_NORMAL) {
+ if (index == nb->notebook.currentIndex && tab->state != TAB_STATE_NORMAL) {
SelectNearestTab(nb);
}
@@ -1273,8 +1273,8 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
nb->notebook.tabOptionTable = Tk_CreateOptionTable(interp,TabOptionSpecs);
nb->notebook.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs);
- nb->notebook.currentIndex = -1;
- nb->notebook.activeIndex = -1;
+ nb->notebook.currentIndex = TCL_INDEX_NONE;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
nb->notebook.tabLayout = 0;
nb->notebook.clientArea = Ttk_MakeBox(0,0,1,1);
@@ -1359,8 +1359,8 @@ static void DisplayTab(Notebook *nb, int index, Drawable d)
static void NotebookDisplay(void *clientData, Drawable d)
{
Notebook *nb = (Notebook *)clientData;
- int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
- int index;
+ TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
+ TkSizeT index;
/* Draw notebook background (base layout):
*/
@@ -1374,7 +1374,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
DisplayTab(nb, index, d);
}
}
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
DisplayTab(nb, nb->notebook.currentIndex, d);
}
}