OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [unix/] [tkUnixDialog.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
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.1.1.1 2002-01-16 10:26:01 markom 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
static int EvalArgv(interp, cmdName, argc, argv)
40
    Tcl_Interp *interp;         /* Current interpreter. */
41
    char * cmdName;             /* Name of the TCL command to call */
42
    int argc;                   /* Number of arguments. */
43
    char **argv;                /* Argument strings. */
44
{
45
    Tcl_CmdInfo cmdInfo;
46
 
47
    if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
48
        char * cmdArgv[2];
49
 
50
        /*
51
         * This comand is not in the interpreter yet -- looks like we
52
         * have to auto-load it
53
         */
54
        if (!Tcl_GetCommandInfo(interp, "auto_load", &cmdInfo)) {
55
            Tcl_ResetResult(interp);
56
            Tcl_AppendResult(interp, "cannot execute command \"auto_load\"",
57
                NULL);
58
            return TCL_ERROR;
59
        }
60
 
61
        cmdArgv[0] = "auto_load";
62
        cmdArgv[1] = cmdName;
63
 
64
        if ((*cmdInfo.proc)(cmdInfo.clientData, interp, 2, cmdArgv)!= TCL_OK){
65
            return TCL_ERROR;
66
        }
67
 
68
        if (!Tcl_GetCommandInfo(interp, cmdName, &cmdInfo)) {
69
            Tcl_ResetResult(interp);
70
            Tcl_AppendResult(interp, "cannot auto-load command \"",
71
                cmdName, "\"",NULL);
72
            return TCL_ERROR;
73
        }
74
    }
75
 
76
    return (*cmdInfo.proc)(cmdInfo.clientData, interp, argc, argv);
77
}
78
 
79
/*
80
 *----------------------------------------------------------------------
81
 *
82
 * Tk_ChooseColorCmd --
83
 *
84
 *      This procedure implements the color dialog box for the Unix
85
 *      platform. See the user documentation for details on what it
86
 *      does.
87
 *
88
 * Results:
89
 *      See user documentation.
90
 *
91
 * Side effects:
92
 *      A dialog window is created the first time this procedure is called.
93
 *      This window is not destroyed and will be reused the next time the
94
 *      application invokes the "tk_chooseColor" command.
95
 *
96
 *----------------------------------------------------------------------
97
 */
98
 
99
int
100
Tk_ChooseColorCmd(clientData, interp, argc, argv)
101
    ClientData clientData;      /* Main window associated with interpreter. */
102
    Tcl_Interp *interp;         /* Current interpreter. */
103
    int argc;                   /* Number of arguments. */
104
    char **argv;                /* Argument strings. */
105
{
106
    return EvalArgv(interp, "tkColorDialog", argc, argv);
107
}
108
 
109
/*
110
 *----------------------------------------------------------------------
111
 *
112
 * Tk_GetOpenFileCmd --
113
 *
114
 *      This procedure implements the "open file" dialog box for the
115
 *      Unix platform. See the user documentation for details on what
116
 *      it does.
117
 *
118
 * Results:
119
 *      See user documentation.
120
 *
121
 * Side effects:
122
 *      A dialog window is created the first this procedure is called.
123
 *      This window is not destroyed and will be reused the next time
124
 *      the application invokes the "tk_getOpenFile" or
125
 *      "tk_getSaveFile" command.
126
 *
127
 *----------------------------------------------------------------------
128
 */
129
int SN_donot_call_motif_filedialog_box = 0;
130
 
131
int
132
Tk_GetOpenFileCmd(clientData, interp, argc, argv)
133
    ClientData clientData;      /* Main window associated with interpreter. */
134
    Tcl_Interp *interp;         /* Current interpreter. */
135
    int argc;                   /* Number of arguments. */
136
    char **argv;                /* Argument strings. */
137
{
138
    Tk_Window tkwin = (Tk_Window)clientData;
139
 
140
    /* Don't use motif dialog box */
141
    if (SN_donot_call_motif_filedialog_box == 0 && Tk_StrictMotif(tkwin)) {
142
        return EvalArgv(interp, "tkMotifFDialog", argc, argv);
143
    } else {
144
        return EvalArgv(interp, "tkFDialog", argc, argv);
145
    }
146
}
147
 
148
/*
149
 *----------------------------------------------------------------------
150
 *
151
 * Tk_GetSaveFileCmd --
152
 *
153
 *      Same as Tk_GetOpenFileCmd but opens a "save file" dialog box
154
 *      instead
155
 *
156
 * Results:
157
 *      Same as Tk_GetOpenFileCmd.
158
 *
159
 * Side effects:
160
 *      Same as Tk_GetOpenFileCmd.
161
 *
162
 *----------------------------------------------------------------------
163
 */
164
 
165
int
166
Tk_GetSaveFileCmd(clientData, interp, argc, argv)
167
    ClientData clientData;      /* Main window associated with interpreter. */
168
    Tcl_Interp *interp;         /* Current interpreter. */
169
    int argc;                   /* Number of arguments. */
170
    char **argv;                /* Argument strings. */
171
{
172
    Tk_Window tkwin = (Tk_Window)clientData;
173
 
174
    /* Don't use motif dialog box */
175
    if (SN_donot_call_motif_filedialog_box == 0 && Tk_StrictMotif(tkwin)) {
176
        return EvalArgv(interp, "tkMotifFDialog", argc, argv);
177
    } else {
178
        return EvalArgv(interp, "tkFDialog", argc, argv);
179
    }
180
}
181
 
182
/*
183
 *----------------------------------------------------------------------
184
 *
185
 * Tk_MessageBoxCmd --
186
 *
187
 *      This procedure implements the MessageBox window for the
188
 *      Unix platform. See the user documentation for details on what
189
 *      it does.
190
 *
191
 * Results:
192
 *      See user documentation.
193
 *
194
 * Side effects:
195
 *      None. The MessageBox window will be destroy before this procedure
196
 *      returns.
197
 *
198
 *----------------------------------------------------------------------
199
 */
200
 
201
int
202
Tk_MessageBoxCmd(clientData, interp, argc, argv)
203
    ClientData clientData;      /* Main window associated with interpreter. */
204
    Tcl_Interp *interp;         /* Current interpreter. */
205
    int argc;                   /* Number of arguments. */
206
    char **argv;                /* Argument strings. */
207
{
208
    return EvalArgv(interp, "tkMessageBox", argc, argv);
209
}
210
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.