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