| 1 | // |
| 2 | // $Header: /cvsroot/swig/SWIG/Lib/tcl/wish.i,v 1.3 2002/11/30 22:10:09 beazley Exp $ |
| 3 | // |
| 4 | // SWIG File for making wish |
| 5 | // Dave Beazley |
| 6 | // April 25, 1996 |
| 7 | // |
| 8 | /* Revision History |
| 9 | * $Log: wish.i,v $ |
| 10 | * Revision 1.3 2002/11/30 22:10:09 beazley |
| 11 | * *** empty log message *** |
| 12 | * |
| 13 | * Revision 1.1.2.1 2001/06/20 11:47:29 mkoeppe |
| 14 | * Portability fixes |
| 15 | * |
| 16 | * Revision 1.1 2000/01/11 21:15:54 beazley |
| 17 | * Added files |
| 18 | * |
| 19 | * Revision 1.2 1999/11/05 21:45:14 beazley |
| 20 | * Minor Changes |
| 21 | * |
| 22 | * Revision 1.1.1.1 1999/02/28 02:00:56 beazley |
| 23 | * Swig1.1 |
| 24 | * |
| 25 | * Revision 1.1 1996/05/22 19:47:45 beazley |
| 26 | * Initial revision |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | #ifdef AUTODOC |
| 31 | %subsection "wish.i" |
| 32 | %text %{ |
| 33 | This module provides the Tk_AppInit() function needed to build a |
| 34 | new version of the wish executable. Like tclsh.i, this file should |
| 35 | not be used with dynamic loading. To make an interface file work with |
| 36 | both static and dynamic loading, put something like this in your |
| 37 | interface file : |
| 38 | |
| 39 | #ifdef STATIC |
| 40 | %include wish.i |
| 41 | #endif |
| 42 | |
| 43 | A startup file may be specified by defining the symbol SWIG_RcFileName |
| 44 | as follows (this should be included in a code-block) : |
| 45 | |
| 46 | #define SWIG_RcFileName "~/.mywishrc" |
| 47 | %} |
| 48 | #endif |
| 49 | |
| 50 | %{ |
| 51 | |
| 52 | |
| 53 | /* Initialization code for wish */ |
| 54 | |
| 55 | #include <tk.h> |
| 56 | |
| 57 | #ifndef SWIG_RcFileName |
| 58 | char *SWIG_RcFileName = "~/.wishrc"; |
| 59 | #endif |
| 60 | |
| 61 | #ifdef MAC_TCL |
| 62 | extern int MacintoshInit _ANSI_ARGS_((void)); |
| 63 | extern int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp)); |
| 64 | #endif |
| 65 | |
| 66 | /* |
| 67 | *---------------------------------------------------------------------- |
| 68 | * |
| 69 | * Tcl_AppInit -- |
| 70 | * |
| 71 | * This procedure performs application-specific initialization. |
| 72 | * Most applications, especially those that incorporate additional |
| 73 | * packages, will have their own version of this procedure. |
| 74 | * |
| 75 | * Results: |
| 76 | * Returns a standard Tcl completion code, and leaves an error |
| 77 | * message in interp->result if an error occurs. |
| 78 | * |
| 79 | * Side effects: |
| 80 | * Depends on the startup script. |
| 81 | * |
| 82 | *---------------------------------------------------------------------- |
| 83 | */ |
| 84 | |
| 85 | int Tcl_AppInit(Tcl_Interp *interp) |
| 86 | { |
| 87 | #ifndef MAC_TCL |
| 88 | Tk_Window main; |
| 89 | main = Tk_MainWindow(interp); |
| 90 | #endif |
| 91 | /* |
| 92 | * Call the init procedures for included packages. Each call should |
| 93 | * look like this: |
| 94 | * |
| 95 | * if (Mod_Init(interp) == TCL_ERROR) { |
| 96 | * return TCL_ERROR; |
| 97 | * } |
| 98 | * |
| 99 | * where "Mod" is the name of the module. |
| 100 | */ |
| 101 | |
| 102 | if (Tcl_Init(interp) == TCL_ERROR) { |
| 103 | return TCL_ERROR; |
| 104 | } |
| 105 | |
| 106 | if (Tk_Init(interp) == TCL_ERROR) { |
| 107 | return TCL_ERROR; |
| 108 | } |
| 109 | |
| 110 | /* |
| 111 | * Call Tcl_CreateCommand for application-specific commands, if |
| 112 | * they weren't already created by the init procedures called above. |
| 113 | */ |
| 114 | |
| 115 | if (SWIG_init(interp) == TCL_ERROR) { |
| 116 | return TCL_ERROR; |
| 117 | } |
| 118 | |
| 119 | #ifdef MAC_TCL |
| 120 | SetupMainInterp(interp); |
| 121 | #endif |
| 122 | |
| 123 | /* |
| 124 | * Specify a user-specific startup file to invoke if the application |
| 125 | * is run interactively. Typically the startup file is "~/.apprc" |
| 126 | * where "app" is the name of the application. If this line is deleted |
| 127 | * then no user-specific startup file will be run under any conditions. |
| 128 | */ |
| 129 | |
| 130 | #if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 |
| 131 | Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); |
| 132 | #else |
| 133 | tcl_RcFileName = SWIG_RcFileName; |
| 134 | #endif |
| 135 | |
| 136 | /* For Macintosh might also want this */ |
| 137 | |
| 138 | #ifdef MAC_TCL |
| 139 | #ifdef SWIG_RcRsrcName |
| 140 | Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY); |
| 141 | #endif |
| 142 | #endif |
| 143 | return TCL_OK; |
| 144 | } |
| 145 | |
| 146 | #if TK_MAJOR_VERSION >= 4 |
| 147 | int main(int argc, char **argv) { |
| 148 | |
| 149 | #ifdef MAC_TCL |
| 150 | char *newArgv[2]; |
| 151 | if (MacintoshInit() != TCL_OK) { |
| 152 | Tcl_Exit(1); |
| 153 | } |
| 154 | argc = 1; |
| 155 | newArgv[0] = "Wish"; |
| 156 | newArgv[1] = NULL; |
| 157 | argv = newArgv; |
| 158 | #endif |
| 159 | Tk_Main(argc, argv, Tcl_AppInit); |
| 160 | return(0); |
| 161 | } |
| 162 | #else |
| 163 | extern int main(); |
| 164 | #endif |
| 165 | |
| 166 | %} |
| 167 | |
| 168 | |
| 169 | |