Debian Codegraph @

pTk/mTk/unix/tkUnixDialog.c

raw symbols SCIP
1 /*
2 * tkUnixDialog.c --
3 *
4 * Contains the Unix implementation of the common dialog boxes:
5 *
6 * Copyright (c) 1996 Sun Microsystems, Inc.
7 *
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 *
11 * RCS: @(#) $Id: tkUnixDialog.c,v 1.3 2001/08/01 16:21:12 dgp Exp $
12 *
13 */
14
15 #include "tkPort.h"
16 #include "tkInt.h"
17 #include "tkUnixInt.h"
18
19 /*
20 *----------------------------------------------------------------------
21 *
22 * EvalArgv --
23 *
24 * Invokes the Tcl procedure with the arguments. argv[0] is set by
25 * the caller of this function. It may be different than cmdName.
26 * The TCL command will see argv[0], not cmdName, as its name if it
27 * invokes [lindex [info level 0] 0]
28 *
29 * Results:
30 * TCL_ERROR if the command does not exist and cannot be autoloaded.
31 * Otherwise, return the result of the evaluation of the command.
32 *
33 * Side effects:
34 * The command may be autoloaded.
35 *
36 *----------------------------------------------------------------------
37 */
38
39 #if 0
40
41 static int EvalArgv(interp, cmdName, argc, argv)
42 Tcl_Interp *interp; /* Current interpreter. */
43 char * cmdName; /* Name of the TCL command to call */
44 int argc; /* Number of arguments. */
45 char **argv; /* Argument strings. */
46 {
47 Tcl_CmdInfo cmdInfo;
48
49 if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
50 char * cmdArgv[2];
51
52 /*
53 * This comand is not in the interpreter yet -- looks like we
54 * have to auto-load it
55 */
56 if (!Tcl_GetCommandInfo(interp, "auto_load", &cmdInfo)) {
57 Tcl_ResetResult(interp);
58 Tcl_AppendResult(interp, "cannot execute command \"auto_load\"",
59 NULL);
60 return TCL_ERROR;
61 }
62
63 cmdArgv[0] = "auto_load";
64 cmdArgv[1] = cmdName;
65
66 if ((*cmdInfo.proc)(cmdInfo.clientData, interp, 2, cmdArgv)!= TCL_OK){
67 return TCL_ERROR;
68 }
69
70 if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
71 Tcl_ResetResult(interp);
72 Tcl_AppendResult(interp, "cannot auto-load command \"",
73 cmdName, "\"",NULL);
74 return TCL_ERROR;
75 }
76 }
77
78 return (*cmdInfo.proc)(cmdInfo.clientData, interp, argc, argv);
79 }
80
81
82 #else
83
84 #define EvalArgv(interp,sub,argc,args) Lang_CallWithArgs(interp,sub, argc, args)
85
86 #endif
87
88
89 /*
90 *----------------------------------------------------------------------
91 *
92 * Tk_ChooseColorCmd --
93 *
94 * This procedure implements the color dialog box for the Unix
95 * platform. See the user documentation for details on what it
96 * does.
97 *
98 * Results:
99 * See user documentation.
100 *
101 * Side effects:
102 * A dialog window is created the first time this procedure is called.
103 * This window is not destroyed and will be reused the next time the
104 * application invokes the "tk_chooseColor" command.
105 *
106 *----------------------------------------------------------------------
107 */
108
109 int
110 Tk_ChooseColorCmd(clientData, interp, argc, argv)
111 ClientData clientData; /* Main window associated with interpreter. */
112 Tcl_Interp *interp; /* Current interpreter. */
113 int argc; /* Number of arguments. */
114 char **argv; /* Argument strings. */
115 {
116 return EvalArgv(interp, "tk::ColorDialog", argc, argv);
117 }
118
119 /*
120 *----------------------------------------------------------------------
121 *
122 * Tk_GetOpenFileCmd --
123 *
124 * This procedure implements the "open file" dialog box for the
125 * Unix platform. See the user documentation for details on what
126 * it does.
127 *
128 * Results:
129 * See user documentation.
130 *
131 * Side effects:
132 * A dialog window is created the first this procedure is called.
133 * This window is not destroyed and will be reused the next time
134 * the application invokes the "tk_getOpenFile" or
135 * "tk_getSaveFile" command.
136 *
137 *----------------------------------------------------------------------
138 */
139
140 int
141 Tk_GetOpenFileCmd(clientData, interp, argc, argv)
142 ClientData clientData; /* Main window associated with interpreter. */
143 Tcl_Interp *interp; /* Current interpreter. */
144 int argc; /* Number of arguments. */
145 char **argv; /* Argument strings. */
146 {
147 Tk_Window tkwin = (Tk_Window)clientData;
148
149 if (Tk_StrictMotif(tkwin)) {
150 return EvalArgv(interp, "tk::MotifFDialog", argc, argv);
151 } else {
152 return EvalArgv(interp, "tk::FDialog", argc, argv);
153 }
154 }
155
156 /*
157 *----------------------------------------------------------------------
158 *
159 * Tk_GetSaveFileCmd --
160 *
161 * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box
162 * instead
163 *
164 * Results:
165 * Same as Tk_GetOpenFileCmd.
166 *
167 * Side effects:
168 * Same as Tk_GetOpenFileCmd.
169 *
170 *----------------------------------------------------------------------
171 */
172
173 int
174 Tk_GetSaveFileCmd(clientData, interp, argc, argv)
175 ClientData clientData; /* Main window associated with interpreter. */
176 Tcl_Interp *interp; /* Current interpreter. */
177 int argc; /* Number of arguments. */
178 char **argv; /* Argument strings. */
179 {
180 Tk_Window tkwin = (Tk_Window)clientData;
181
182 if (Tk_StrictMotif(tkwin)) {
183 return EvalArgv(interp, "tk::MotifFDialog", argc, argv);
184 } else {
185 return EvalArgv(interp, "tk::FDialog", argc, argv);
186 }
187 }
188
189 /*
190 *----------------------------------------------------------------------
191 *
192 * Tk_MessageBoxCmd --
193 *
194 * This procedure implements the MessageBox window for the
195 * Unix platform. See the user documentation for details on what
196 * it does.
197 *
198 * Results:
199 * See user documentation.
200 *
201 * Side effects:
202 * None. The MessageBox window will be destroy before this procedure
203 * returns.
204 *
205 *----------------------------------------------------------------------
206 */
207
208 int
209 Tk_MessageBoxCmd(clientData, interp, argc, argv)
210 ClientData clientData; /* Main window associated with interpreter. */
211 Tcl_Interp *interp; /* Current interpreter. */
212 int argc; /* Number of arguments. */
213 char **argv; /* Argument strings. */
214 {
215 return EvalArgv(interp, "tk::MessageBox", argc, argv);
216 }
217