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

Function ButtonWidgetCmd

micropolis-activity/src/tk/tkbutton.c:467–625  ·  view source on GitHub ↗
(clientData, interp, argc, argv)

Source from the content-addressed store, hash-verified

465 *
466 *--------------------------------------------------------------
467 */
468
469static int
470ButtonWidgetCmd(clientData, interp, argc, argv)
471 ClientData clientData; /* Information about button widget. */
472 Tcl_Interp *interp; /* Current interpreter. */
473 int argc; /* Number of arguments. */
474 char **argv; /* Argument strings. */
475{
476 register Button *butPtr = (Button *) clientData;
477 int result = TCL_OK;
478 int length;
479 char c;
480
481 if (argc < 2) {
482 sprintf(interp->result,
483 "wrong # args: should be \"%.50s option [arg arg ...]\"",
484 argv[0]);
485 return TCL_ERROR;
486 }
487 Tk_Preserve((ClientData) butPtr);
488 c = argv[1][0];
489 length = strlen(argv[1]);
490 if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)
491 && (butPtr->type != TYPE_LABEL)) {
492 if (argc > 2) {
493 sprintf(interp->result,
494 "wrong # args: should be \"%.50s activate\"",
495 argv[0]);
496 goto error;
497 }
498 if (butPtr->state != tkDisabledUid) {
499 butPtr->state = tkActiveUid;
500 Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->activeBorder);
501 goto redisplay;
502 }
503 } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) {
504 if (argc == 2) {
505 result = Tk_ConfigureInfo(interp, butPtr->tkwin, configSpecs,
506 (char *) butPtr, (char *) NULL, configFlags[butPtr->type]);
507 } else if (argc == 3) {
508 result = Tk_ConfigureInfo(interp, butPtr->tkwin, configSpecs,
509 (char *) butPtr, argv[2],
510 configFlags[butPtr->type]);
511 } else {
512 result = ConfigureButton(interp, butPtr, argc-2, argv+2,
513 configFlags[butPtr->type] | TK_CONFIG_ARGV_ONLY);
514 }
515 } else if ((c == 'd') && (strncmp(argv[1], "deactivate", length) == 0)
516 && (length > 2) && (butPtr->type != TYPE_LABEL)) {
517 if (argc > 2) {
518 sprintf(interp->result,
519 "wrong # args: should be \"%.50s deactivate\"",
520 argv[0]);
521 goto error;
522 }
523 if (butPtr->state != tkDisabledUid) {
524 butPtr->state = tkNormalUid;

Callers

nothing calls this directly

Calls 9

Tk_PreserveFunction · 0.85
Tk_ConfigureInfoFunction · 0.85
ConfigureButtonFunction · 0.85
DisplayButtonFunction · 0.85
InvokeButtonFunction · 0.85
Tk_ReleaseFunction · 0.85
Tk_SleepFunction · 0.70
Tk_CreateTimerHandlerFunction · 0.70

Tested by

no test coverage detected