PLplot  5.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Plplotter_Init.c
Go to the documentation of this file.
1 // $Id: Plplotter_Init.c 12222 2012-08-23 18:40:38Z airwin $
2 //
3 // Copyright (C) 2004 Joao Cardoso
4 //
5 // This file is part of PLplot.
6 //
7 // PLplot is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU Library General Public License as published
9 // by the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // PLplot is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with PLplot; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // This file is derived from the old tkshell.c, and implements the Pltk init
22 // function. It can be loaded into any Tcl7.5 interpreter, and requires some
23 // .tcl library files to be in known places. Set your environment variables
24 // to make sure of this.
25 //
26 // Old changes see 'tkshell.c'. This file should be used _instead_ of
27 // tkshell.c, if building the 'libPltk.so' shared library for dynamic loading
28 // into Tcl.
29 //
30 
31 //
32 // tkshell.c
33 // Maurice LeBrun
34 // 6-May-93
35 //
36 // A miscellaneous assortment of Tcl support functions.
37 //
38 
39 #include "plserver.h"
40 
41 #ifdef BUILD_Plplot
42 #undef TCL_STORAGE_CLASS
43 #define TCL_STORAGE_CLASS DLLEXPORT
44 #endif // BUILD_Vfs
45 
46 //--------------------------------------------------------------------------
47 // Plplotter_Init
48 //
49 // Initialization routine for extended wish'es.
50 // Creates the plframe, wait_until, and host_id (w/Tcl-DP only)
51 // commands. The more basic Plplot-Tcl initialization is handled by
52 // the Plbasicinit function called from here.
53 //--------------------------------------------------------------------------
54 
55 PLDLLIMPEXP_DRIVER EXTERN int
56 Plplotter_Init( Tcl_Interp *interp )
57 {
58 #ifdef USE_TCL_STUBS
59  //
60  // We hard-wire 8.1 here, rather than TCL_VERSION, TK_VERSION because
61  // we really don't mind which version of Tcl, Tk we use as long as it
62  // is 8.1 or newer. Otherwise if we compiled against 8.2, we couldn't
63  // be loaded into 8.1
64  //
65  Tcl_InitStubs( interp, "8.1", 0 );
66 #endif
67 #ifdef USE_TK_STUBS
68  Tk_InitStubs( interp, "8.1", 0 );
69 #endif
70  // This must be before any other Tcl related calls
71  if ( PlbasicInit( interp ) != TCL_OK )
72  {
73  return TCL_ERROR;
74  }
75 
76  //
77  // Note, the old technique of:
78  // main = Tk_MainWindow(interp);
79  // and then passing main to 'plframe' as the clientdata can
80  // cause unusual problems, probably due to bugs in Tk on
81  // some platforms, when the 'main window' doesn't yet exist
82  // properly by the time we are called. Since plframe only
83  // uses the value in one place (each time a new frame is
84  // created), we simply use 'Tk_MainWindow' in plframe, and
85  // avoid the startup problems.
86  //
87 
88 // plframe -- PLplot graphing widget
89 
90  Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plPlotterCmd,
91  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
92 
93  Tcl_PkgProvide( interp, "Plplotter", VERSION );
94  return TCL_OK;
95 }
96