summaryrefslogtreecommitdiffstats
path: root/tk8.6/generic/ttk
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-12-19 21:30:31 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-12-19 21:30:31 (GMT)
commit21ae37c5a9db158c6c4d54a0fa75b8e0b526ebed (patch)
tree312b750afe3bdbe92b5727e2e552da8ed1751b7f /tk8.6/generic/ttk
parent50f1824860159ebdb3896e14647a4562edf658d2 (diff)
parent0587fffc5409653d44546dbcebc7a497954cbb46 (diff)
downloadblt-21ae37c5a9db158c6c4d54a0fa75b8e0b526ebed.zip
blt-21ae37c5a9db158c6c4d54a0fa75b8e0b526ebed.tar.gz
blt-21ae37c5a9db158c6c4d54a0fa75b8e0b526ebed.tar.bz2
Merge branch 'devel'
Diffstat (limited to 'tk8.6/generic/ttk')
-rw-r--r--tk8.6/generic/ttk/ttkButton.c30
-rw-r--r--tk8.6/generic/ttk/ttkEntry.c22
-rw-r--r--tk8.6/generic/ttk/ttkLayout.c2
-rw-r--r--tk8.6/generic/ttk/ttkProgress.c12
-rw-r--r--tk8.6/generic/ttk/ttkScale.c17
-rw-r--r--tk8.6/generic/ttk/ttkState.c7
-rw-r--r--tk8.6/generic/ttk/ttkTrace.c15
-rw-r--r--tk8.6/generic/ttk/ttkTreeview.c2
8 files changed, 79 insertions, 28 deletions
diff --git a/tk8.6/generic/ttk/ttkButton.c b/tk8.6/generic/ttk/ttkButton.c
index c00754b..68a6293 100644
--- a/tk8.6/generic/ttk/ttkButton.c
+++ b/tk8.6/generic/ttk/ttkButton.c
@@ -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))
diff --git a/tk8.6/generic/ttk/ttkEntry.c b/tk8.6/generic/ttk/ttkEntry.c
index a25574a..f6a9c27 100644
--- a/tk8.6/generic/ttk/ttkEntry.c
+++ b/tk8.6/generic/ttk/ttkEntry.c
@@ -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);
}
diff --git a/tk8.6/generic/ttk/ttkLayout.c b/tk8.6/generic/ttk/ttkLayout.c
index ba24589..2fd90b6 100644
--- a/tk8.6/generic/ttk/ttkLayout.c
+++ b/tk8.6/generic/ttk/ttkLayout.c
@@ -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;
}
}
diff --git a/tk8.6/generic/ttk/ttkProgress.c b/tk8.6/generic/ttk/ttkProgress.c
index 4dc50a2..6c13992 100644
--- a/tk8.6/generic/ttk/ttkProgress.c
+++ b/tk8.6/generic/ttk/ttkProgress.c
@@ -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);
diff --git a/tk8.6/generic/ttk/ttkScale.c b/tk8.6/generic/ttk/ttkScale.c
index 69753d1..279fc7a 100644
--- a/tk8.6/generic/ttk/ttkScale.c
+++ b/tk8.6/generic/ttk/ttkScale.c
@@ -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;
}
diff --git a/tk8.6/generic/ttk/ttkState.c b/tk8.6/generic/ttk/ttkState.c
index c34b900..2941ca8 100644
--- a/tk8.6/generic/ttk/ttkState.c
+++ b/tk8.6/generic/ttk/ttkState.c
@@ -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 */
diff --git a/tk8.6/generic/ttk/ttkTrace.c b/tk8.6/generic/ttk/ttkTrace.c
index ba66db4..e6eead2 100644
--- a/tk8.6/generic/ttk/ttkTrace.c
+++ b/tk8.6/generic/ttk/ttkTrace.c
@@ -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);
/*
diff --git a/tk8.6/generic/ttk/ttkTreeview.c b/tk8.6/generic/ttk/ttkTreeview.c
index d957ad2..bef84f3 100644
--- a/tk8.6/generic/ttk/ttkTreeview.c
+++ b/tk8.6/generic/ttk/ttkTreeview.c
@@ -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;
}