Import Tk 8.6.10
This commit is contained in:
@@ -8,11 +8,7 @@
|
||||
* Copyright (c) 2004 Joe English
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <tkInt.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "tkInt.h"
|
||||
#include "ttkTheme.h"
|
||||
#include "ttkWidget.h"
|
||||
|
||||
@@ -333,7 +329,7 @@ EntryFetchSelection(
|
||||
ClientData clientData, int offset, char *buffer, int maxBytes)
|
||||
{
|
||||
Entry *entryPtr = (Entry *) clientData;
|
||||
size_t byteCount;
|
||||
int byteCount;
|
||||
const char *string;
|
||||
const char *selStart, *selEnd;
|
||||
|
||||
@@ -347,7 +343,7 @@ EntryFetchSelection(
|
||||
selEnd = Tcl_UtfAtIndex(selStart,
|
||||
entryPtr->entry.selectLast - entryPtr->entry.selectFirst);
|
||||
byteCount = selEnd - selStart - offset;
|
||||
if (byteCount > (size_t)maxBytes) {
|
||||
if (byteCount > maxBytes) {
|
||||
/* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */
|
||||
byteCount = maxBytes;
|
||||
}
|
||||
@@ -979,7 +975,7 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
|
||||
Ttk_TraceHandle *vt = 0;
|
||||
|
||||
if (mask & TEXTVAR_CHANGED) {
|
||||
if (textVarName && *Tcl_GetString(textVarName)) {
|
||||
if (textVarName && *Tcl_GetString(textVarName) != '\0') {
|
||||
vt = Ttk_TraceVariable(interp,
|
||||
textVarName,EntryTextVariableTrace,entryPtr);
|
||||
if (!vt) return TCL_ERROR;
|
||||
@@ -1155,7 +1151,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
|
||||
mask |= GCForeground;
|
||||
}
|
||||
gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
|
||||
if (clip != None) {
|
||||
if (clip != NULL) {
|
||||
TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip);
|
||||
}
|
||||
return gc;
|
||||
@@ -1265,7 +1261,7 @@ static void EntryDisplay(void *clientData, Drawable d)
|
||||
cursorX = field.x + field.width - cursorWidth;
|
||||
}
|
||||
|
||||
gc = EntryGetGC(entryPtr, es.insertColorObj, None);
|
||||
gc = EntryGetGC(entryPtr, es.insertColorObj, NULL);
|
||||
XFillRectangle(Tk_Display(tkwin), d, gc,
|
||||
cursorX, cursorY, cursorWidth, cursorHeight);
|
||||
Tk_FreeGC(Tk_Display(tkwin), gc);
|
||||
@@ -1297,7 +1293,7 @@ static void EntryDisplay(void *clientData, Drawable d)
|
||||
* it from the Xft guts (if they're being used).
|
||||
*/
|
||||
#ifdef HAVE_XFT
|
||||
TkUnixSetXftClipRegion(None);
|
||||
TkUnixSetXftClipRegion(NULL);
|
||||
#endif
|
||||
TkDestroyRegion(clipRegion);
|
||||
}
|
||||
@@ -1366,6 +1362,7 @@ EntryIndex(
|
||||
*indexPtr = Tk_PointToChar(entryPtr->entry.textLayout,
|
||||
x - entryPtr->entry.layoutX, 0);
|
||||
|
||||
TtkUpdateScrollInfo(entryPtr->entry.xscrollHandle);
|
||||
if (*indexPtr < entryPtr->entry.xscroll.first) {
|
||||
*indexPtr = entryPtr->entry.xscroll.first;
|
||||
}
|
||||
@@ -1660,7 +1657,7 @@ static int EntryXViewCommand(
|
||||
if (EntryIndex(interp, entryPtr, objv[2], &newFirst) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
TtkScrollTo(entryPtr->entry.xscrollHandle, newFirst);
|
||||
TtkScrollTo(entryPtr->entry.xscrollHandle, newFirst, 1);
|
||||
return TCL_OK;
|
||||
}
|
||||
return TtkScrollviewCommand(interp, objc, objv, entryPtr->entry.xscrollHandle);
|
||||
@@ -1703,6 +1700,16 @@ static WidgetSpec EntryWidgetSpec = {
|
||||
EntryDisplay /* displayProc */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* Named indices for the combobox "current" command
|
||||
*/
|
||||
static const char *const comboboxCurrentIndexNames[] = {
|
||||
"end", NULL
|
||||
};
|
||||
enum comboboxCurrentIndices {
|
||||
INDEX_END
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* +++ Combobox widget record.
|
||||
*/
|
||||
@@ -1804,15 +1811,42 @@ static int ComboboxCurrentCommand(
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex));
|
||||
return TCL_OK;
|
||||
} else if (objc == 3) {
|
||||
if (Tcl_GetIntFromObj(interp, objv[2], ¤tIndex) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (currentIndex < 0 || currentIndex >= nValues) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"Index %s out of range", Tcl_GetString(objv[2])));
|
||||
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
int result, index;
|
||||
|
||||
result = Tcl_GetIndexFromObj(NULL, objv[2], comboboxCurrentIndexNames,
|
||||
"", 0, &index);
|
||||
if (result == TCL_OK) {
|
||||
|
||||
/*
|
||||
* The index is one of the named indices.
|
||||
*/
|
||||
|
||||
switch (index) {
|
||||
case INDEX_END:
|
||||
/* "end" index */
|
||||
currentIndex = nValues - 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* The index should be just an integer.
|
||||
*/
|
||||
|
||||
if (Tcl_GetIntFromObj(NULL, objv[2], ¤tIndex) != TCL_OK) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"Incorrect index %s", Tcl_GetString(objv[2])));
|
||||
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (currentIndex < 0 || currentIndex >= nValues) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
|
||||
"Index %s out of range", Tcl_GetString(objv[2])));
|
||||
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
cbPtr->combobox.currentIndex = currentIndex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user