root/tk-8.0/trunk/win/tkWinInit.c @ 1217

Revision 1217, 4.9 KB (checked in by ucaccsp, 15 years ago)

Merging unix fixes to the init scripts into the windows port...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * tkWinInit.c --
3 *
4 *      This file contains Windows-specific interpreter initialization
5 *      functions.
6 *
7 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
8 *
9 * See the file "license.terms" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 *
12 * SCCS: @(#) tkWinInit.c 1.29 97/07/24 14:46:35
13 */
14
15#include "tkWinInt.h"
16
17/*
18 * The Init script (common to Windows and Unix platforms) is
19 * defined in tkInitScript.h
20 */
21#include "tkInitScript.h"
22
23extern char lib_tk[];
24extern char lib_button[];
25extern char lib_entry[];
26extern char lib_listbox[];
27extern char lib_menu[];
28extern char lib_scale[];
29extern char lib_scrlbar[];
30extern char lib_text[];
31
32extern char lib_bgerror[];
33extern char lib_clrpick[];
34extern char lib_comdlg[];
35extern char lib_dialog[];
36extern char lib_focus[];
37extern char lib_msgbox[];
38extern char lib_obsolete[];
39extern char lib_optMenu[];
40extern char lib_palette[];
41extern char lib_safetk[];
42extern char lib_tearoff[];
43extern char lib_tkfbox[];
44extern char lib_xmfbox[];
45
46
47/*
48 *----------------------------------------------------------------------
49 *
50 * TkpInit --
51 *
52 *      Performs Windows-specific interpreter initialization related to the
53 *      tk_library variable.
54 *
55 * Results:
56 *      A standard Tcl completion code (TCL_OK or TCL_ERROR).  Also
57 *      leaves information in interp->result.
58 *
59 * Side effects:
60 *      Sets "tk_library" Tcl variable, runs "tk.tcl" script.
61 *
62 *----------------------------------------------------------------------
63 */
64
65int
66TkpInit(interp)
67    Tcl_Interp *interp;
68{
69    if (Tcl_Eval(interp, lib_bgerror) != TCL_OK) {
70        return TCL_ERROR;
71    }
72    if (Tcl_Eval(interp, lib_clrpick) != TCL_OK) {
73        return TCL_ERROR;
74    }
75    if (Tcl_Eval(interp, lib_comdlg) != TCL_OK) {
76        return TCL_ERROR;
77    }
78    if (Tcl_Eval(interp, lib_dialog) != TCL_OK) {
79        return TCL_ERROR;
80    }
81    if (Tcl_Eval(interp, lib_focus) != TCL_OK) {
82        return TCL_ERROR;
83    }
84    if (Tcl_Eval(interp, lib_msgbox) != TCL_OK) {
85        return TCL_ERROR;
86    }
87    if (Tcl_Eval(interp, lib_obsolete) != TCL_OK) {
88        return TCL_ERROR;
89    }
90    if (Tcl_Eval(interp, lib_optMenu) != TCL_OK) {
91        return TCL_ERROR;
92    }
93    if (Tcl_Eval(interp, lib_palette) != TCL_OK) {
94        return TCL_ERROR;
95    }
96    if (Tcl_Eval(interp, lib_safetk) != TCL_OK) {
97        return TCL_ERROR;
98    }
99    if (Tcl_Eval(interp, lib_tearoff) != TCL_OK) {
100        return TCL_ERROR;
101    }
102    if (Tcl_Eval(interp, lib_tkfbox) != TCL_OK) {
103        return TCL_ERROR;
104    }
105    if (Tcl_Eval(interp, lib_xmfbox) != TCL_OK) {
106        return TCL_ERROR;
107    }
108
109    if (Tcl_Eval(interp, initScript) != TCL_OK) {
110        return TCL_ERROR;
111    }
112    if (Tcl_Eval(interp, lib_tk) != TCL_OK) {
113        return TCL_ERROR;
114    }
115    if (Tcl_Eval(interp, lib_button) != TCL_OK) {
116        return TCL_ERROR;
117    }
118    if (Tcl_Eval(interp, lib_entry) != TCL_OK) {
119        return TCL_ERROR;
120    }
121    if (Tcl_Eval(interp, lib_listbox) != TCL_OK) {
122        return TCL_ERROR;
123    }
124    if (Tcl_Eval(interp, lib_menu) != TCL_OK) {
125        return TCL_ERROR;
126    }
127    if (Tcl_Eval(interp, lib_scale) != TCL_OK) {
128        return TCL_ERROR;
129    }
130    if (Tcl_Eval(interp, lib_scrlbar) != TCL_OK) {
131        return TCL_ERROR;
132    }
133    if (Tcl_Eval(interp, lib_text) != TCL_OK) {
134        return TCL_ERROR;
135    }
136    return TCL_OK;
137}
138
139/*
140 *----------------------------------------------------------------------
141 *
142 * TkpGetAppName --
143 *
144 *      Retrieves the name of the current application from a platform
145 *      specific location.  For Windows, the application name is the
146 *      root of the tail of the path contained in the tcl variable argv0.
147 *
148 * Results:
149 *      Returns the application name in the given Tcl_DString.
150 *
151 * Side effects:
152 *      None.
153 *
154 *----------------------------------------------------------------------
155 */
156
157void
158TkpGetAppName(interp, namePtr)
159    Tcl_Interp *interp;
160    Tcl_DString *namePtr;       /* A previously initialized Tcl_DString. */
161{
162    int argc;
163    char **argv = NULL, *name, *p;
164
165    name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
166    if (name != NULL) {
167        Tcl_SplitPath(name, &argc, &argv);
168        if (argc > 0) {
169            name = argv[argc-1];
170            p = strrchr(name, '.');
171            if (p != NULL) {
172                *p = '\0';
173            }
174        } else {
175            name = NULL;
176        }
177    }
178    if ((name == NULL) || (*name == 0)) {
179        name = "tk";
180    }
181    Tcl_DStringAppend(namePtr, name, -1);
182    if (argv != NULL) {
183        ckfree((char *)argv);
184    }
185}
186
187/*
188 *----------------------------------------------------------------------
189 *
190 * TkpDisplayWarning --
191 *
192 *      This routines is called from Tk_Main to display warning
193 *      messages that occur during startup.
194 *
195 * Results:
196 *      None.
197 *
198 * Side effects:
199 *      Displays a message box.
200 *
201 *----------------------------------------------------------------------
202 */
203
204void
205TkpDisplayWarning(msg, title)
206    char *msg;                  /* Message to be displayed. */
207    char *title;                /* Title of warning. */
208{
209    MessageBox(NULL, msg, title, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
210            | MB_SETFOREGROUND | MB_TOPMOST);
211}
Note: See TracBrowser for help on using the browser.