/*1* tkUnixDialog.c --2*3* Contains the Unix implementation of the common dialog boxes:4*5* Copyright (c) 1996 Sun Microsystems, Inc.6*7* See the file "license.terms" for information on usage and redistribution8* of this file, and for a DISCLAIMER OF ALL WARRANTIES.9*10* SCCS: @(#) tkUnixDialog.c 1.5 96/08/28 21:21:0111*12*/1314#include "tkInt.h"15#include "tkUnixInt.h"1617/*18*----------------------------------------------------------------------19*20* EvalArgv --21*22* Invokes the Tcl procedure with the arguments. argv[0] is set by23* the caller of this function. It may be different than cmdName.24* The TCL command will see argv[0], not cmdName, as its name if it25* invokes [lindex [info level 0] 0]26*27* Results:28* TCL_ERROR if the command does not exist and cannot be autoloaded.29* Otherwise, return the result of the evaluation of the command.30*31* Side effects:32* The command may be autoloaded.33*34*----------------------------------------------------------------------35*/3637static int EvalArgv(interp, cmdName, argc, argv)38Tcl_Interp *interp; /* Current interpreter. */39char * cmdName; /* Name of the TCL command to call */40int argc; /* Number of arguments. */41char **argv; /* Argument strings. */42{43Tcl_CmdInfo cmdInfo;4445if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {46char * cmdArgv[2];4748/*49* This comand is not in the interpreter yet -- looks like we50* have to auto-load it51*/52if (!Tcl_GetCommandInfo(interp, "auto_load", &cmdInfo)) {53Tcl_ResetResult(interp);54Tcl_AppendResult(interp, "cannot execute command \"auto_load\"",55NULL);56return TCL_ERROR;57}5859cmdArgv[0] = "auto_load";60cmdArgv[1] = cmdName;6162if ((*cmdInfo.proc)(cmdInfo.clientData, interp, 2, cmdArgv)!= TCL_OK){63return TCL_ERROR;64}6566if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {67Tcl_ResetResult(interp);68Tcl_AppendResult(interp, "cannot auto-load command \"",69cmdName, "\"",NULL);70return TCL_ERROR;71}72}7374return (*cmdInfo.proc)(cmdInfo.clientData, interp, argc, argv);75}7677/*78*----------------------------------------------------------------------79*80* Tk_ChooseColorCmd --81*82* This procedure implements the color dialog box for the Unix83* platform. See the user documentation for details on what it84* does.85*86* Results:87* See user documentation.88*89* Side effects:90* A dialog window is created the first time this procedure is called.91* This window is not destroyed and will be reused the next time the92* application invokes the "tk_chooseColor" command.93*94*----------------------------------------------------------------------95*/9697int98Tk_ChooseColorCmd(clientData, interp, argc, argv)99ClientData clientData; /* Main window associated with interpreter. */100Tcl_Interp *interp; /* Current interpreter. */101int argc; /* Number of arguments. */102char **argv; /* Argument strings. */103{104return EvalArgv(interp, "tkColorDialog", argc, argv);105}106107/*108*----------------------------------------------------------------------109*110* Tk_GetOpenFileCmd --111*112* This procedure implements the "open file" dialog box for the113* Unix platform. See the user documentation for details on what114* it does.115*116* Results:117* See user documentation.118*119* Side effects:120* A dialog window is created the first this procedure is called.121* This window is not destroyed and will be reused the next time122* the application invokes the "tk_getOpenFile" or123* "tk_getSaveFile" command.124*125*----------------------------------------------------------------------126*/127128int129Tk_GetOpenFileCmd(clientData, interp, argc, argv)130ClientData clientData; /* Main window associated with interpreter. */131Tcl_Interp *interp; /* Current interpreter. */132int argc; /* Number of arguments. */133char **argv; /* Argument strings. */134{135Tk_Window tkwin = (Tk_Window)clientData;136137if (Tk_StrictMotif(tkwin)) {138return EvalArgv(interp, "tkMotifFDialog", argc, argv);139} else {140return EvalArgv(interp, "tkFDialog", argc, argv);141}142}143144/*145*----------------------------------------------------------------------146*147* Tk_GetSaveFileCmd --148*149* Same as Tk_GetOpenFileCmd but opens a "save file" dialog box150* instead151*152* Results:153* Same as Tk_GetOpenFileCmd.154*155* Side effects:156* Same as Tk_GetOpenFileCmd.157*158*----------------------------------------------------------------------159*/160161int162Tk_GetSaveFileCmd(clientData, interp, argc, argv)163ClientData clientData; /* Main window associated with interpreter. */164Tcl_Interp *interp; /* Current interpreter. */165int argc; /* Number of arguments. */166char **argv; /* Argument strings. */167{168Tk_Window tkwin = (Tk_Window)clientData;169170if (Tk_StrictMotif(tkwin)) {171return EvalArgv(interp, "tkMotifFDialog", argc, argv);172} else {173return EvalArgv(interp, "tkFDialog", argc, argv);174}175}176177/*178*----------------------------------------------------------------------179*180* Tk_MessageBoxCmd --181*182* This procedure implements the MessageBox window for the183* Unix platform. See the user documentation for details on what184* it does.185*186* Results:187* See user documentation.188*189* Side effects:190* None. The MessageBox window will be destroy before this procedure191* returns.192*193*----------------------------------------------------------------------194*/195196int197Tk_MessageBoxCmd(clientData, interp, argc, argv)198ClientData clientData; /* Main window associated with interpreter. */199Tcl_Interp *interp; /* Current interpreter. */200int argc; /* Number of arguments. */201char **argv; /* Argument strings. */202{203return EvalArgv(interp, "tkMessageBox", argc, argv);204}205206207208