PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Pltk_Init.c
Go to the documentation of this file.
1 // Copyright (C) 2004 Joao Cardoso
2 //
3 // This file is part of PLplot.
4 //
5 // PLplot is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // PLplot is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public License
16 // along with PLplot; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 //
20 // This file is derived from the old tkshell.c, and implements the Pltk init
21 // function. It can be loaded into any Tcl7.5 interpreter, and requires some
22 // .tcl library files to be in known places. Set your environment variables
23 // to make sure of this.
24 //
25 // Old changes see 'tkshell.c'. This file should be used _instead_ of
26 // tkshell.c, if building the 'libPltk.so' shared library for dynamic loading
27 // into Tcl.
28 //
29 
30 //
31 // tkshell.c
32 // Maurice LeBrun
33 // 6-May-93
34 //
35 // A miscellaneous assortment of Tcl support functions.
36 //
37 
38 #include "plserver.h"
39 
40 extern int Matrix_Init( Tcl_Interp* interp );
41 
42 //--------------------------------------------------------------------------
43 // Pltk_Init
44 //
45 // Initialization routine for extended wish'es.
46 // Creates the plframe, matrix, and host_id (w/Tcl-DP only)
47 // commands. Also sets the auto_path variable.
48 //--------------------------------------------------------------------------
49 
50 int
51 Pltk_Init( Tcl_Interp *interp )
52 {
53  // This must be before any other Tcl related calls
54  if ( PlbasicInit( interp ) != TCL_OK )
55  {
56  return TCL_ERROR;
57  }
58 
59 #ifdef USE_TK_STUBS
60  //
61  // We hard-wire 8.1 here, rather than TCL_VERSION, TK_VERSION because
62  // we really don't mind which version of Tcl, Tk we use as long as it
63  // is 8.1 or newer. Otherwise if we compiled against 8.2, we couldn't
64  // be loaded into 8.1
65  //
66  Tk_InitStubs( interp, "8.1", 0 );
67 #endif
68 
69 // plframe -- PLplot graphing widget
70 
71  Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plFrameCmd,
72  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
73 
74 // host_id -- returns host IP number. Only for use with Tcl-DP
75 
76 #ifdef PLD_dp
77  Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc *) plHost_ID,
78  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
79 #endif
80 
81 // Set up auto_path
82 
83  if ( pls_auto_path( interp ) == TCL_ERROR )
84  return TCL_ERROR;
85 
86 // Save initial RGB colormap components
87 // Disabled for now
88 
89 #if 0
90  {
91  Display *display;
92  Colormap map;
93 
94  display = Tk_Display( mainWindow );
95  map = DefaultColormap( display, DefaultScreen( display ) );
96 
97 // Convert this to use esc function if it's going to be used
98 // SaveColormap(display, map);
99  }
100 #endif
101 
102  Tcl_PkgProvide( interp, "Pltk", PLPLOT_VERSION );
103 
104  return TCL_OK;
105 }