MCPcopy Create free account
hub / github.com/SimHacker/micropolis / ScaleWidgetCmd

Function ScaleWidgetCmd

micropolis-activity/src/tk/tkscale.c:333–405  ·  view source on GitHub ↗
(clientData, interp, argc, argv)

Source from the content-addressed store, hash-verified

331 *
332 *--------------------------------------------------------------
333 */
334
335static int
336ScaleWidgetCmd(clientData, interp, argc, argv)
337 ClientData clientData; /* Information about scale
338 * widget. */
339 Tcl_Interp *interp; /* Current interpreter. */
340 int argc; /* Number of arguments. */
341 char **argv; /* Argument strings. */
342{
343 register Scale *scalePtr = (Scale *) clientData;
344 int result = TCL_OK;
345 int length;
346 char c;
347
348 if (argc < 2) {
349 Tcl_AppendResult(interp, "wrong # args: should be \"",
350 argv[0], " option ?arg arg ...?\"", (char *) NULL);
351 return TCL_ERROR;
352 }
353 Tk_Preserve((ClientData) scalePtr);
354 c = argv[1][0];
355 length = strlen(argv[1]);
356 if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) {
357 if (argc == 2) {
358 result = Tk_ConfigureInfo(interp, scalePtr->tkwin, configSpecs,
359 (char *) scalePtr, (char *) NULL, 0);
360 } else if (argc == 3) {
361 result = Tk_ConfigureInfo(interp, scalePtr->tkwin, configSpecs,
362 (char *) scalePtr, argv[2], 0);
363 } else {
364 result = ConfigureScale(interp, scalePtr, argc-2, argv+2,
365 TK_CONFIG_ARGV_ONLY);
366 }
367 } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
368 if (argc != 2) {
369 Tcl_AppendResult(interp, "wrong # args: should be \"",
370 argv[0], " get\"", (char *) NULL);
371 goto error;
372 }
373 sprintf(interp->result, "%d", scalePtr->value);
374 } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) {
375 int value;
376
377 if (argc != 3) {
378 Tcl_AppendResult(interp, "wrong # args: should be \"",
379 argv[0], " set value\"", (char *) NULL);
380 goto error;
381 }
382 if (Tcl_GetInt(interp, argv[2], &value) != TCL_OK) {
383 goto error;
384 }
385 if (scalePtr->state == tkNormalUid) {
386 if ((value < scalePtr->fromValue)
387 ^ (scalePtr->toValue < scalePtr->fromValue)) {
388 value = scalePtr->fromValue;
389 }
390 if ((value > scalePtr->toValue)

Callers

nothing calls this directly

Calls 7

Tcl_AppendResultFunction · 0.85
Tk_PreserveFunction · 0.85
Tk_ConfigureInfoFunction · 0.85
ConfigureScaleFunction · 0.85
Tcl_GetIntFunction · 0.85
SetScaleValueFunction · 0.85
Tk_ReleaseFunction · 0.85

Tested by

no test coverage detected