/* * Radiobutton 'invoke' subcommand: * Sets the radiobutton -variable to the -value, evaluates the -command. */ static int RadiobuttonInvokeCommand( Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) { Radiobutton *radioPtr = recordPtr; WidgetCore *corePtr = &radioPtr->core; if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "invoke"); return TCL_ERROR; } if (corePtr->state & TTK_STATE_DISABLED) return TCL_OK; if (Tcl_ObjSetVar2(interp, radioPtr->radiobutton.variableObj, NULL, radioPtr->radiobutton.valueObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) return TCL_ERROR; if (WidgetDestroyed(corePtr)) return TCL_ERROR; return Tcl_EvalObjEx(interp, radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL); }
/* * Checkbutton 'invoke' subcommand: * Toggles the checkbutton state. */ static int CheckbuttonInvokeCommand( Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) { Checkbutton *checkPtr = recordPtr; WidgetCore *corePtr = &checkPtr->core; Tcl_Obj *newValue; if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "invoke"); return TCL_ERROR; } if (corePtr->state & TTK_STATE_DISABLED) return TCL_OK; /* * Toggle the selected state. */ if (corePtr->state & TTK_STATE_SELECTED) newValue = checkPtr->checkbutton.offValueObj; else newValue = checkPtr->checkbutton.onValueObj; if (Tcl_ObjSetVar2(interp, checkPtr->checkbutton.variableObj, NULL, newValue, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) return TCL_ERROR; if (WidgetDestroyed(corePtr)) return TCL_ERROR; return Tcl_EvalObjEx(interp, checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL); }
static int RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask) { Radiobutton *radioPtr = recordPtr; int status = TCL_OK; if (radioPtr->radiobutton.variableTrace) status = Ttk_FireTrace(radioPtr->radiobutton.variableTrace); if (status == TCL_OK && !WidgetDestroyed(&radioPtr->core)) status = BasePostConfigure(interp, recordPtr, mask); return status; }
/* * Variable trace procedure for -textvariable option: */ static void TextVariableChanged(void *clientData, const char *value) { Base *basePtr = clientData; Tcl_Obj *newText; if (WidgetDestroyed(&basePtr->core)) { return; } newText = value ? Tcl_NewStringObj(value, -1) : Tcl_NewStringObj("", 0); Tcl_IncrRefCount(newText); Tcl_DecrRefCount(basePtr->base.textObj); basePtr->base.textObj = newText; TtkResizeWidget(&basePtr->core); }
/* * Variable trace procedure for checkbutton -variable option */ static void CheckbuttonVariableChanged(void *clientData, const char *value) { Checkbutton *checkPtr = clientData; if (WidgetDestroyed(&checkPtr->core)) { return; } if (!value) { TtkWidgetChangeState(&checkPtr->core, TTK_STATE_ALTERNATE, 0); return; } /* else */ TtkWidgetChangeState(&checkPtr->core, 0, TTK_STATE_ALTERNATE); if (!strcmp(value, Tcl_GetString(checkPtr->checkbutton.onValueObj))) { TtkWidgetChangeState(&checkPtr->core, TTK_STATE_SELECTED, 0); } else { TtkWidgetChangeState(&checkPtr->core, 0, TTK_STATE_SELECTED); } }
/* UpdateScrollbar -- * Call the -scrollcommand callback to sync the scrollbar. * Returns: Whatever the -scrollcommand does. */ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h) { Scrollable *s = h->scrollPtr; WidgetCore *corePtr = h->corePtr; char arg1[TCL_DOUBLE_SPACE + 2]; char arg2[TCL_DOUBLE_SPACE + 2]; int code; h->flags &= ~SCROLL_UPDATE_REQUIRED; if (s->scrollCmd == NULL) { return TCL_OK; } arg1[0] = arg2[0] = ' '; Tcl_PrintDouble(interp, (double)s->first / s->total, arg1+1); Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1); Tcl_Preserve(corePtr); code = Tcl_VarEval(interp, s->scrollCmd, arg1, arg2, NULL); if (WidgetDestroyed(corePtr)) { Tcl_Release(corePtr); return TCL_ERROR; } Tcl_Release(corePtr); if (code != TCL_OK && !Tcl_InterpDeleted(interp)) { /* Disable the -scrollcommand, add to stack trace: */ ckfree(s->scrollCmd); s->scrollCmd = 0; Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */ "\n (scrolling command executed by "); Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin)); Tcl_AddErrorInfo(interp, ")"); } return code; }
/* ScalePostConfigure -- * Post-configuration hook. */ static int ScalePostConfigure( Tcl_Interp *interp, void *recordPtr, int mask) { Scale *scale = recordPtr; int status = TCL_OK; if (scale->scale.variableTrace) { status = Ttk_FireTrace(scale->scale.variableTrace); if (WidgetDestroyed(&scale->core)) { return TCL_ERROR; } if (status != TCL_OK) { /* Unset -variable: */ Ttk_UntraceVariable(scale->scale.variableTrace); Tcl_DecrRefCount(scale->scale.variableObj); scale->scale.variableTrace = 0; scale->scale.variableObj = NULL; status = TCL_ERROR; } } return status; }
/* $scale set $newValue */ static int ScaleSetCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scale *scalePtr = recordPtr; double from = 0.0, to = 1.0, value; int result = TCL_OK; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "set value"); return TCL_ERROR; } if (Tcl_GetDoubleFromObj(interp, objv[2], &value) != TCL_OK) { return TCL_ERROR; } if (scalePtr->core.state & TTK_STATE_DISABLED) { return TCL_OK; } /* ASSERT: fromObj and toObj are valid doubles. */ Tcl_GetDoubleFromObj(interp, scalePtr->scale.fromObj, &from); Tcl_GetDoubleFromObj(interp, scalePtr->scale.toObj, &to); /* Limit new value to between 'from' and 'to': */ if (from < to) { value = value < from ? from : value > to ? to : value; } else { value = value < to ? to : value > from ? from : value; } /* * Set value: */ Tcl_DecrRefCount(scalePtr->scale.valueObj); scalePtr->scale.valueObj = Tcl_NewDoubleObj(value); Tcl_IncrRefCount(scalePtr->scale.valueObj); TtkRedisplayWidget(&scalePtr->core); /* * Set attached variable, if any: */ if (scalePtr->scale.variableObj != NULL) { Tcl_ObjSetVar2(interp, scalePtr->scale.variableObj, NULL, scalePtr->scale.valueObj, TCL_GLOBAL_ONLY); } if (WidgetDestroyed(&scalePtr->core)) { return TCL_ERROR; } /* * Invoke -command, if any: */ if (scalePtr->scale.commandObj != NULL) { Tcl_Obj *cmdObj = Tcl_DuplicateObj(scalePtr->scale.commandObj); Tcl_IncrRefCount(cmdObj); Tcl_AppendToObj(cmdObj, " ", 1); Tcl_AppendObjToObj(cmdObj, scalePtr->scale.valueObj); result = Tcl_EvalObjEx(interp, cmdObj, TCL_EVAL_GLOBAL); Tcl_DecrRefCount(cmdObj); } return result; }
QtLayerWin32::~QtLayerWin32() { AppFinished(); WidgetDestroyed(); }
QtLayerMacOS::~QtLayerMacOS() { AppFinished(); WidgetDestroyed(); }