int GraphCmdconfigure(GRAPH_ARGS) { int result = TCL_OK; if (argc == 2) { result = Tk_ConfigureInfo(interp, graph->tkwin, GraphConfigSpecs, (char *) graph, (char *) NULL, 0); } else if (argc == 3) { result = Tk_ConfigureInfo(interp, graph->tkwin, GraphConfigSpecs, (char *) graph, argv[2], 0); } else { result = ConfigureSimGraph(interp, graph, argc-2, argv+2, TK_CONFIG_ARGV_ONLY); } return TCL_OK; }
static int ImgBmapCmd( ClientData clientData, /* Information about the image master. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const bmapOptions[] = {"cget", "configure", NULL}; BitmapMaster *masterPtr = clientData; int index; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], bmapOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { case 0: /* cget */ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, (char *) masterPtr, Tcl_GetString(objv[2]), 0); case 1: /* configure */ if (objc == 2) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), configSpecs, (char *) masterPtr, NULL, 0); } else if (objc == 3) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), configSpecs, (char *) masterPtr, Tcl_GetString(objv[2]), 0); } else { return ImgBmapConfigureMaster(masterPtr, objc-2, objv+2, TK_CONFIG_ARGV_ONLY); } default: Tcl_Panic("bad const entries to bmapOptions in ImgBmapCmd"); return TCL_OK; } }
static int paxwidget_widget_cmd(ClientData data, Tcl_Interp * interp, int argc, char** argv) { PaxWidget * paxwidget = (PaxWidget*)data; int result = TCL_OK; size_t length; char c; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", (char *) NULL); return TCL_ERROR; } Tk_Preserve((ClientData) paxwidget); c = argv[1][0]; length = strlen(argv[1]); if (c == 'b' && strncmp(argv[1], "bgpixel", length) == 0) { sprintf(Tcl_GetStringResult(interp), "%ld", Tk_3DBorderColor(paxwidget->background)->pixel); } else if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0) && (length >= 2)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " cget option\"", (char *) NULL); goto error; } result = Tk_ConfigureValue(interp, paxwidget->tkwin, configSpecs, (char *) paxwidget, argv[2], 0); } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0) && (length >= 2)) { if (argc == 2) { result = Tk_ConfigureInfo(interp, paxwidget->tkwin, configSpecs, (char *) paxwidget, (char *) NULL, 0); } else if (argc == 3) { result = Tk_ConfigureInfo(interp, paxwidget->tkwin, configSpecs, (char *) paxwidget, argv[2], 0); } else { result = PaxWidgetConfigure(interp, paxwidget, argc-2, argv+2, TK_CONFIG_ARGV_ONLY); } } else if ((c == 'm') && (strncmp(argv[1], "motionhints", length) == 0)) { XSetWindowAttributes* attr; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " motionhints\"", (char *) NULL); goto error; } attr = Tk_Attributes(paxwidget->tkwin); XSelectInput(Tk_Display(paxwidget->tkwin), Tk_WindowId(paxwidget->tkwin), attr->event_mask | PointerMotionHintMask); } else if ((c == 'u') && (strncmp(argv[1], "update", length) == 0)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " update\"", (char *) NULL); goto error; } PaxWidget_RegisterUpdate(paxwidget); } else if ((c == 'x') && (strncmp(argv[1], "xview", length) == 0)) { int count, type; double fraction; type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count); switch (type) { case TK_SCROLL_ERROR: goto error; case TK_SCROLL_MOVETO: paxWidget_CallMethodArgs(paxwidget->obj, ScrollXMoveIdx, Py_BuildValue("(d)", fraction)); break; case TK_SCROLL_PAGES: paxWidget_CallMethodArgs(paxwidget->obj, ScrollXPagesIdx, Py_BuildValue("(i)", count)); break; case TK_SCROLL_UNITS: paxWidget_CallMethodArgs(paxwidget->obj, ScrollXUnitsIdx, Py_BuildValue("(i)", count)); break; } } else if ((c == 'y') && (strncmp(argv[1], "yview", length) == 0)) { int count, type; double fraction; type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count); switch (type) { case TK_SCROLL_ERROR: goto error; case TK_SCROLL_MOVETO: paxWidget_CallMethodArgs(paxwidget->obj, ScrollYMoveIdx, Py_BuildValue("(d)", fraction)); break; case TK_SCROLL_PAGES: paxWidget_CallMethodArgs(paxwidget->obj, ScrollYPagesIdx, Py_BuildValue("(i)", count)); break; case TK_SCROLL_UNITS: paxWidget_CallMethodArgs(paxwidget->obj, ScrollYUnitsIdx, Py_BuildValue("(i)", count)); break; } } Tk_Release((ClientData) paxwidget); return result; error: Tk_Release((ClientData) paxwidget); return TCL_ERROR; }
static int OpenGLWidgetCmd(ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char** argv) { OpenGLClientData *OpenGLPtr = (OpenGLClientData *) clientData; int result = TCL_OK; size_t length; // int id; char c; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", (char *) NULL); return TCL_ERROR; } Tk_Preserve((ClientData) OpenGLPtr); c = argv[1][0]; length = strlen(argv[1]); if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { if (argc == 2) { result = Tk_ConfigureInfo(interp, OpenGLPtr->tkwin, configSpecs, (char *) OpenGLPtr, (char *) NULL, 0); } else if (argc == 3) { result = Tk_ConfigureInfo(interp, OpenGLPtr->tkwin, configSpecs, (char *) OpenGLPtr, argv[2], 0); } else { result = OpenGLConfigure(interp, OpenGLPtr, argc-2, argv+2, TK_CONFIG_ARGV_ONLY); } } else if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0)) { if (argc == 3) { result = Tk_ConfigureValue(interp, OpenGLPtr->tkwin, configSpecs, (char *) OpenGLPtr, argv[2], 0); } else { Tcl_AppendResult(interp, "bad cget command \"", argv[1], "", (char *) NULL); result = TCL_ERROR; } } else if ((c == 'l') && (strncmp(argv[1], "listvisuals", length) == 0)) { result = OpenGLListVisuals(interp, OpenGLPtr); } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be configure, cget, position, or size", (char *) NULL); result = TCL_ERROR; } Tk_Release((ClientData) OpenGLPtr); return result; }
static int imfsample_widget_cmd(ClientData cldata, Tcl_Interp *interp, int argc, char **argv) { Imfsample *imfsample = (Imfsample *) cldata; int result = TCL_OK; size_t cmdlength; char c; int x, y, col, row, n; char tclbuf[100]; int rslt; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", (char *) NULL); return TCL_ERROR; } Tcl_Preserve((ClientData) imfsample); c = argv[1][0]; cmdlength = strlen(argv[1]); if ((c == 'c') && (strncmp(argv[1], "cget", cmdlength) == 0) && (cmdlength >= 2)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " cget option\"", (char *) NULL); goto error; } result = Tk_ConfigureValue(interp, imfsample->tkwin, config_specs, (char *) imfsample, argv[2], 0); } else if ((c == 'c') && (strncmp(argv[1], "configure", cmdlength) == 0) && (cmdlength >= 2)) { if (argc == 2) { result = Tk_ConfigureInfo(interp, imfsample->tkwin, config_specs, (char *) imfsample, (char *) NULL, 0); } else if (argc == 3) { result = Tk_ConfigureInfo(interp, imfsample->tkwin, config_specs, (char *) imfsample, argv[2], 0); } else { result = imfsample_configure(interp, imfsample, argc-2, argv+2, TK_CONFIG_ARGV_ONLY); } } else if ((c == 'c') && (strncmp(argv[1], "curselection", cmdlength) == 0) && (cmdlength >= 2)) { sprintf(Tcl_GetStringResult(interp), "%d", imfsample->selected); } else if ((c == 'a') && (strncmp(argv[1], "add", cmdlength) == 0) && (cmdlength >= 2)) { if (strcmp(argv[2], "imf") == 0) { imfsample_add_imf(imfsample, argv[3]); } else if (strcmp(argv[2], "all") == 0) { imfsample_add_imf(imfsample, "-all"); } } else if ((c == 'e') && (strncmp(argv[1], "emblem", cmdlength) == 0) && (cmdlength >= 2)) { n = strtol(argv[2], NULL, 10); imfsample->with_emblem = n; } else if ((c == 'r') && (strncmp(argv[1], "redraw", cmdlength) == 0) && (cmdlength >= 2)) { imfsample->redraw = TRUE; if (!imfsample->update_pending) { Tcl_DoWhenIdle(imfsample_display, cldata); imfsample->update_pending = 1; } } else if ((c == 'r') && (strncmp(argv[1], "replace", cmdlength) == 0) && (cmdlength >= 2)) { if (strcmp(argv[2], "imf") == 0) { imfsample_replace_imf(imfsample, argv[3]); } else if (strcmp(argv[2], "emblem") == 0) { imfsample_replace_emblem(imfsample, argv[3]); } } else if ((c == 'r') && (strncmp(argv[1], "remove", cmdlength) == 0) && (cmdlength >= 2)) { if (strcmp(argv[2], "imf") == 0) { imfsample_remove_imf(imfsample, argv[3]); } else if (strcmp(argv[2], "emblem") == 0) { imfsample->numimages = 1; } else if (strcmp(argv[2], "all") == 0) { imfsample_remove_imf(imfsample, "-all"); if (imfsample->imfapp) { imfsample->selected = -1; imfsample->previous = -1; /* Turn off the scrollbar. */ sprintf(tclbuf, ".images.scroll set 0 1"); rslt = Tcl_Eval(interp, tclbuf); if (rslt == TCL_ERROR) { fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp)); } } } } else if ((c == 's') && (strncmp(argv[1], "select", cmdlength) == 0) && (cmdlength >= 2)) { if (imfsample->numimages) { x = strtol(argv[2], NULL, 10); y = strtol(argv[3], NULL, 10); col = x / imfsample->eltw; row = y / imfsample->elth + imfsample->firstvisrow; n = row * imfsample->cols + col; if (n < 0 || n >= imfsample->numimages || col >= imfsample->cols) { n = -1; } /* This rather complicated scheme is to ensure that we can both select images and then deselect them by clicking a second time on the image or by clicking in an empty region. */ if (imfsample->selected != n) { imfsample->previous = imfsample->selected; imfsample->selected = n; } else if (n == -1) { imfsample->selected = -1; } else { imfsample->previous = n; imfsample->selected = -1; } } } else if ((c == 't') && (strncmp(argv[1], "terrain", cmdlength) == 0) && (cmdlength >= 2)) { n = strtol(argv[2], NULL, 10); imfsample->with_terrain = n; } else if ((c == 'x') && (strncmp(argv[1], "xview", cmdlength) == 0)) { } else if ((c == 'y') && (strncmp(argv[1], "yview", cmdlength) == 0)) { int count, type, nrow = imfsample->firstvisrow; double fraction, fraction2; type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count); switch (type) { case TK_SCROLL_ERROR: goto error; case TK_SCROLL_MOVETO: nrow = fraction * imfsample->rows; break; case TK_SCROLL_PAGES: nrow += (count * imfsample->numvisrows * 4) / 5; break; case TK_SCROLL_UNITS: nrow += count; break; } /* Don't allow negative row numbers. */ imfsample->firstvisrow = max(0, nrow); /* Compute the bounds of the visible window. */ fraction = (double) imfsample->firstvisrow / imfsample->rows; fraction2 = (double) (imfsample->firstvisrow + imfsample->numvisrows) / imfsample->rows; if (imfsample->imfapp) { /* We must set the scrollbar explicitly since the imfsample widget lacks a built-in yscrollcommand. */ sprintf(tclbuf, ".images.scroll set %f %f", fraction, fraction2); rslt = Tcl_Eval(interp, tclbuf); if (rslt == TCL_ERROR) { fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp)); } } } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be cget, configure, position, replace, remove, select", (char *) NULL); goto error; } if (!imfsample->update_pending) { Tcl_DoWhenIdle(imfsample_display, (ClientData) imfsample); imfsample->update_pending = 1; } Tcl_Release((ClientData) imfsample); return result; error: Tcl_Release((ClientData) imfsample); return TCL_ERROR; }