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 // $Id: Pltk_Init.c 12677 2013-11-12 00:54:54Z 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 //
22 // This file is derived from the old tkshell.c, and implements the Pltk init
23 // function. It can be loaded into any Tcl7.5 interpreter, and requires some
24 // .tcl library files to be in known places. Set your environment variables
25 // to make sure of this.
26 //
27 // Old changes see 'tkshell.c'. This file should be used _instead_ of
28 // tkshell.c, if building the 'libPltk.so' shared library for dynamic loading
29 // into Tcl.
30 //
31 
32 //
33 // tkshell.c
34 // Maurice LeBrun
35 // 6-May-93
36 //
37 // A miscellaneous assortment of Tcl support functions.
38 //
39 
40 #include "plserver.h"
41 
42 extern int Matrix_Init( Tcl_Interp* interp );
43 
44 //--------------------------------------------------------------------------
45 // Pltk_Init
46 //
47 // Initialization routine for extended wish'es.
48 // Creates the plframe, matrix, and host_id (w/Tcl-DP only)
49 // commands. Also sets the auto_path variable.
50 //--------------------------------------------------------------------------
51 
52 int
53 Pltk_Init( Tcl_Interp *interp )
54 {
55  // This must be before any other Tcl related calls
56  if ( PlbasicInit( interp ) != TCL_OK )
57  {
58  return TCL_ERROR;
59  }
60 
61 #ifdef USE_TK_STUBS
62  //
63  // We hard-wire 8.1 here, rather than TCL_VERSION, TK_VERSION because
64  // we really don't mind which version of Tcl, Tk we use as long as it
65  // is 8.1 or newer. Otherwise if we compiled against 8.2, we couldn't
66  // be loaded into 8.1
67  //
68  Tk_InitStubs( interp, "8.1", 0 );
69 #endif
70 
71 // plframe -- PLplot graphing widget
72 
73  Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plFrameCmd,
74  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
75 
76 // host_id -- returns host IP number. Only for use with Tcl-DP
77 
78 #ifdef PLD_dp
79  Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc *) plHost_ID,
80  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
81 #endif
82 
83 // Set up auto_path
84 
85  if ( pls_auto_path( interp ) == TCL_ERROR )
86  return TCL_ERROR;
87 
88 // Save initial RGB colormap components
89 // Disabled for now
90 
91 #if 0
92  {
93  Display *display;
94  Colormap map;
95 
96  display = Tk_Display( mainWindow );
97  map = DefaultColormap( display, DefaultScreen( display ) );
98 
99 // Convert this to use esc function if it's going to be used
100 // SaveColormap(display, map);
101  }
102 #endif
103 
104  Tcl_PkgProvide( interp, "Pltk", PLPLOT_VERSION );
105 
106  return TCL_OK;
107 }