tkAppInit.cc
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /* 
  2.  * tkAppInit.c --
  3.  *
  4.  * Provides a default version of the Tcl_AppInit procedure for
  5.  * use in wish and similar Tk-based applications.
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tkAppInit.c 1.21 96/03/26 16:47:07
  14.  */
  15. #include "tk.h"
  16. #include "tclcl.h"
  17. extern "C" {
  18. #include <otcl.h>
  19. }
  20. /*
  21.  * The following variable is a special hack that is needed in order for
  22.  * Sun shared libraries to be used for Tcl.
  23.  */
  24. extern "C"  {
  25. extern int matherr();
  26. int *tclDummyMathPtr = (int *) matherr;
  27. }
  28. extern "C" {
  29. /* override the platform init routine in the tk library */
  30. int
  31. TkPlatformInit(Tcl_Interp *interp)
  32. {
  33. extern void TkCreateXEventSource(void);
  34. Tcl_SetVar(interp, "tk_library", ".", TCL_GLOBAL_ONLY);
  35. #ifndef WIN32
  36. TkCreateXEventSource();
  37. #endif
  38. return (TCL_OK);
  39. }
  40. }
  41. #ifdef TK_TEST
  42. EXTERN int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  43. #endif /* TK_TEST */
  44. /*
  45.  *----------------------------------------------------------------------
  46.  *
  47.  * main --
  48.  *
  49.  * This is the main program for the application.
  50.  *
  51.  * Results:
  52.  * None: Tk_Main never returns here, so this procedure never
  53.  * returns either.
  54.  *
  55.  * Side effects:
  56.  * Whatever the application does.
  57.  *
  58.  *----------------------------------------------------------------------
  59.  */
  60. int
  61. main(int argc, char** argv)
  62. {
  63.     Tk_Main(argc, argv, Tcl_AppInit);
  64.     return 0; /* Needed only to prevent compiler warning. */
  65. }
  66. extern int Tk_BargraphCmd();
  67. /*
  68.  *----------------------------------------------------------------------
  69.  *
  70.  * Tcl_AppInit --
  71.  *
  72.  * This procedure performs application-specific initialization.
  73.  * Most applications, especially those that incorporate additional
  74.  * packages, will have their own version of this procedure.
  75.  *
  76.  * Results:
  77.  * Returns a standard Tcl completion code, and leaves an error
  78.  * message in interp->result if an error occurs.
  79.  *
  80.  * Side effects:
  81.  * Depends on the startup script.
  82.  *
  83.  *----------------------------------------------------------------------
  84.  */
  85. /*XXX*/
  86. int use_shm = 0;
  87. int
  88. Tcl_AppInit(Tcl_Interp *interp)
  89. {
  90. #ifdef notdef
  91.     if (Tcl_Init(interp) == TCL_ERROR) {
  92. return TCL_ERROR;
  93.     }
  94. #endif
  95.     if (Tk_Init(interp) == TCL_ERROR) {
  96. return TCL_ERROR;
  97.     }
  98.     Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
  99. #ifdef TK_TEST
  100.     if (Tktest_Init(interp) == TCL_ERROR) {
  101. return TCL_ERROR;
  102.     }
  103.     Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
  104.             (Tcl_PackageInitProc *) NULL);
  105. #endif /* TK_TEST */
  106.     /*
  107.      * Call the init procedures for included packages.  Each call should
  108.      * look like this:
  109.      *
  110.      * if (Mod_Init(interp) == TCL_ERROR) {
  111.      *     return TCL_ERROR;
  112.      * }
  113.      *
  114.      * where "Mod" is the name of the module.
  115.      */
  116.     if (Otcl_Init(interp) == TCL_ERROR)
  117.     return TCL_ERROR;
  118.     Tcl::init(interp, "mash");
  119.     Tcl::instance().tkmain(Tk_MainWindow(interp));
  120.     extern EmbeddedTcl et_tk;
  121.     et_tk.load();
  122.     /*
  123.      * Call Tcl_CreateCommand for application-specific commands, if
  124.      * they weren't already created by the init procedures called above.
  125.      */
  126.     /*
  127.      * Specify a user-specific startup file to invoke if the application
  128.      * is run interactively.  Typically the startup file is "~/.apprc"
  129.      * where "app" is the name of the application.  If this line is deleted
  130.      * then no user-specific startup file will be run under any conditions.
  131.      */
  132.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
  133.     return TCL_OK;
  134. }