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

Function GraphViewCmd

micropolis-activity/src/sim/w_graph.c:353–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352
353int
354GraphViewCmd(CLIENT_ARGS)
355{
356 SimGraph *graph;
357 Tk_Window tkwin = (Tk_Window) clientData;
358
359 if (argc < 2) {
360 Tcl_AppendResult(interp, "wrong # args: should be \"",
361 argv[0], " pathName ?options?\"", (char *) NULL);
362 return TCL_ERROR;
363 }
364
365 tkwin = Tk_CreateWindowFromPath(interp, tkwin,
366 argv[1], (char *) NULL);
367 if (tkwin == NULL) {
368 return TCL_ERROR;
369 }
370
371 graph = (SimGraph *)ckalloc(sizeof (SimGraph));
372
373 graph->tkwin = tkwin;
374 graph->interp = interp;
375 graph->flags = 0;
376
377 Tk_SetClass(graph->tkwin, "GraphView");
378 Tk_CreateEventHandler(graph->tkwin,
379 VisibilityChangeMask |
380 ExposureMask |
381 StructureNotifyMask,
382 SimGraphEventProc, (ClientData) graph);
383 Tcl_CreateCommand(interp, Tk_PathName(graph->tkwin),
384 DoGraphCmd, (ClientData) graph, (void (*)()) NULL);
385
386/*
387 Tk_MakeWindowExist(graph->tkwin);
388*/
389
390 if (getenv("XSYNCHRONIZE") != NULL) {
391 XSynchronize(Tk_Display(tkwin), 1);
392 }
393
394 InitNewGraph(graph);
395 DoNewGraph(graph);
396
397 if (ConfigureSimGraph(interp, graph, argc-2, argv+2, 0) != TCL_OK) {
398 /* XXX: destroy graph */
399 Tk_DestroyWindow(graph->tkwin);
400 return TCL_ERROR;
401 }
402
403 interp->result = Tk_PathName(graph->tkwin);
404 return TCL_OK;
405}
406
407
408int

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected