Imported Tk 8.6.9

This commit is contained in:
Steve Dower
2018-12-11 10:05:28 -08:00
parent 753ac6b037
commit 5ba5cbc9af
184 changed files with 6223 additions and 1994 deletions

View File

@@ -489,12 +489,15 @@ static int
CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
Checkbutton *checkPtr = recordPtr;
Ttk_TraceHandle *vt = Ttk_TraceVariable(
interp, checkPtr->checkbutton.variableObj,
CheckbuttonVariableChanged, checkPtr);
if (!vt) {
return TCL_ERROR;
Tcl_Obj *varName = checkPtr->checkbutton.variableObj;
Ttk_TraceHandle *vt = NULL;
if (varName != NULL && *Tcl_GetString(varName) != '\0') {
vt = Ttk_TraceVariable(interp, varName,
CheckbuttonVariableChanged, checkPtr);
if (!vt) {
return TCL_ERROR;
}
}
if (BaseConfigure(interp, recordPtr, mask) != TCL_OK){
@@ -502,7 +505,9 @@ CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TCL_ERROR;
}
Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
if (checkPtr->checkbutton.variableTrace) {
Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
}
checkPtr->checkbutton.variableTrace = vt;
return TCL_OK;
@@ -548,10 +553,13 @@ CheckbuttonInvokeCommand(
else
newValue = checkPtr->checkbutton.onValueObj;
if (Tcl_ObjSetVar2(interp,
checkPtr->checkbutton.variableObj, NULL, newValue,
TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
== NULL)
if (checkPtr->checkbutton.variableObj == NULL ||
*Tcl_GetString(checkPtr->checkbutton.variableObj) == '\0')
CheckbuttonVariableChanged(checkPtr, Tcl_GetString(newValue));
else if (Tcl_ObjSetVar2(interp,
checkPtr->checkbutton.variableObj, NULL, newValue,
TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
== NULL)
return TCL_ERROR;
if (WidgetDestroyed(corePtr))

View File

@@ -337,7 +337,8 @@ EntryFetchSelection(
const char *string;
const char *selStart, *selEnd;
if (entryPtr->entry.selectFirst < 0 || !entryPtr->entry.exportSelection) {
if (entryPtr->entry.selectFirst < 0 || (!entryPtr->entry.exportSelection)
|| Tcl_IsSafe(entryPtr->core.interp)) {
return -1;
}
string = entryPtr->entry.displayString;
@@ -372,11 +373,12 @@ static void EntryLostSelection(ClientData clientData)
/* EntryOwnSelection --
* Assert ownership of the PRIMARY selection,
* if -exportselection set and selection is present.
* if -exportselection set and selection is present and interp is unsafe.
*/
static void EntryOwnSelection(Entry *entryPtr)
{
if (entryPtr->entry.exportSelection
&& (!Tcl_IsSafe(entryPtr->core.interp))
&& !(entryPtr->core.flags & GOT_SELECTION)) {
Tk_OwnSelection(entryPtr->core.tkwin, XA_PRIMARY, EntryLostSelection,
(ClientData) entryPtr);
@@ -999,7 +1001,8 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* Claim the selection, in case we've suddenly started exporting it.
*/
if (entryPtr->entry.exportSelection && entryPtr->entry.selectFirst != -1) {
if (entryPtr->entry.exportSelection && (entryPtr->entry.selectFirst != -1)
&& (!Tcl_IsSafe(entryPtr->core.interp))) {
EntryOwnSelection(entryPtr);
}
@@ -1241,6 +1244,7 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Draw cursor:
*/
if (showCursor) {
Ttk_Box field = Ttk_ClientRegion(entryPtr->core.layout, "field");
int cursorX = EntryCharPosition(entryPtr, entryPtr->entry.insertPos),
cursorY = entryPtr->entry.layoutY,
cursorHeight = entryPtr->entry.layoutHeight,
@@ -1254,10 +1258,16 @@ static void EntryDisplay(void *clientData, Drawable d)
/* @@@ should: maybe: SetCaretPos even when blinked off */
Tk_SetCaretPos(tkwin, cursorX, cursorY, cursorHeight);
gc = EntryGetGC(entryPtr, es.insertColorObj, clipRegion);
cursorX -= cursorWidth/2;
if (cursorX < field.x) {
cursorX = field.x;
} else if (cursorX + cursorWidth > field.x + field.width) {
cursorX = field.x + field.width - cursorWidth;
}
gc = EntryGetGC(entryPtr, es.insertColorObj, None);
XFillRectangle(Tk_Display(tkwin), d, gc,
cursorX-cursorWidth/2, cursorY, cursorWidth, cursorHeight);
XSetClipMask(Tk_Display(tkwin), gc, None);
cursorX, cursorY, cursorWidth, cursorHeight);
Tk_FreeGC(Tk_Display(tkwin), gc);
}

View File

@@ -702,6 +702,8 @@ Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *interp, Tcl_Obj *objPtr)
if (childSpec) {
tail->child = Ttk_ParseLayoutTemplate(interp, childSpec);
if (!tail->child) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("Invalid -children value"));
Tcl_SetErrorCode(interp, "TTK", "VALUE", "CHILDREN", NULL);
goto error;
}
}

View File

@@ -421,21 +421,23 @@ static int ProgressbarStepCommand(
}
newValueObj = Tcl_NewDoubleObj(value);
Tcl_IncrRefCount(newValueObj);
TtkRedisplayWidget(&pb->core);
/* Update value by setting the linked -variable, if there is one:
*/
if (pb->progress.variableTrace) {
return Tcl_ObjSetVar2(
interp, pb->progress.variableObj, 0, newValueObj,
TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)
? TCL_OK : TCL_ERROR;
int result = Tcl_ObjSetVar2(
interp, pb->progress.variableObj, 0, newValueObj,
TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)
? TCL_OK : TCL_ERROR;
Tcl_DecrRefCount(newValueObj);
return result;
}
/* Otherwise, change the -value directly:
*/
Tcl_IncrRefCount(newValueObj);
Tcl_DecrRefCount(pb->progress.valueObj);
pb->progress.valueObj = newValueObj;
CheckAnimation(pb);

View File

@@ -15,6 +15,10 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/* Bit fields for OptionSpec mask field:
*/
#define STATE_CHANGED (0x100) /* -state option changed */
/*
* Scale widget record
*/
@@ -35,6 +39,11 @@ typedef struct
/* internal state */
Ttk_TraceHandle *variableTrace;
/*
* Compatibility/legacy options:
*/
Tcl_Obj *stateObj;
} ScalePart;
typedef struct
@@ -66,6 +75,10 @@ static Tk_OptionSpec ScaleOptionSpecs[] =
DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-state", "state", "State",
"normal", Tk_Offset(Scale,scale.stateObj), -1,
0,0,STATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
@@ -139,6 +152,10 @@ static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
}
scale->scale.variableTrace = vt;
if (mask & STATE_CHANGED) {
TtkCheckStateOption(&scale->core, scale->scale.stateObj);
}
return TCL_OK;
}

View File

@@ -130,7 +130,8 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
unsigned int offbits = objPtr->internalRep.longValue & 0x0000FFFF;
unsigned int mask = onbits | offbits;
Tcl_DString result;
int i, len;
int i;
size_t len;
Tcl_DStringInit(&result);
@@ -146,9 +147,9 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
len = Tcl_DStringLength(&result);
if (len) {
/* 'len' includes extra trailing ' ' */
objPtr->bytes = Tcl_Alloc((unsigned)len);
objPtr->bytes = Tcl_Alloc(len);
objPtr->length = len-1;
strncpy(objPtr->bytes, Tcl_DStringValue(&result), (size_t)len-1);
strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1);
objPtr->bytes[len-1] = '\0';
} else {
/* empty string */

View File

@@ -26,8 +26,8 @@ static char *
VarTraceProc(
ClientData clientData, /* Widget record pointer */
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *name1, /* (unused) */
const char *name2, /* (unused) */
const char *name1, /* Name of variable. */
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
Ttk_TraceHandle *tracePtr = clientData;
@@ -38,6 +38,17 @@ VarTraceProc(
return NULL;
}
/*
* See ticket [5d991b82].
*/
if (tracePtr->varnameObj == NULL) {
Tcl_UntraceVar2(interp, name1, name2,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
VarTraceProc, clientData);
return NULL;
}
name = Tcl_GetString(tracePtr->varnameObj);
/*

View File

@@ -1825,7 +1825,7 @@ static int DrawSubtree(
static int DrawForest(
Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
{
while (item && row <= tv->tree.yscroll.last) {
while (item && row < tv->tree.yscroll.last) {
row = DrawSubtree(tv, item, d, depth, row);
item = item->next;
}