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

Function Tk_ButtonCmd

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

Source from the content-addressed store, hash-verified

350 *--------------------------------------------------------------
351 */
352
353int
354Tk_ButtonCmd(clientData, interp, argc, argv)
355 ClientData clientData; /* Main window associated with
356 * interpreter. */
357 Tcl_Interp *interp; /* Current interpreter. */
358 int argc; /* Number of arguments. */
359 char **argv; /* Argument strings. */
360{
361 register Button *butPtr;
362 int type;
363 Tk_Window tkwin = (Tk_Window) clientData;
364 Tk_Window new;
365
366 if (argc < 2) {
367 Tcl_AppendResult(interp, "wrong # args: should be \"",
368 argv[0], " pathName ?options?\"", (char *) NULL);
369 return TCL_ERROR;
370 }
371
372 switch (argv[0][0]) {
373 case 'l':
374 type = TYPE_LABEL;
375 break;
376 case 'b':
377 type = TYPE_BUTTON;
378 break;
379 case 'c':
380 type = TYPE_CHECK_BUTTON;
381 break;
382 case 'r':
383 type = TYPE_RADIO_BUTTON;
384 break;
385 default:
386 sprintf(interp->result,
387 "unknown button-creation command \"%.50s\"");
388 return TCL_ERROR;
389 }
390
391 /*
392 * Create the new window.
393 */
394
395 new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
396 if (new == NULL) {
397 return TCL_ERROR;
398 }
399
400 /*
401 * Initialize the data structure for the button.
402 */
403
404 butPtr = (Button *) ckalloc(sizeof(Button));
405 butPtr->tkwin = new;
406 butPtr->interp = interp;
407 butPtr->type = type;
408 butPtr->text = NULL;
409 butPtr->textVarName = NULL;

Callers

nothing calls this directly

Calls 6

Tcl_AppendResultFunction · 0.85
Tk_CreateWindowFromPathFunction · 0.85
Tk_SetClassFunction · 0.85
ConfigureButtonFunction · 0.85
Tk_DestroyWindowFunction · 0.85
Tcl_CreateCommandFunction · 0.50

Tested by

no test coverage detected