PLplot  5.15.0
Pltk_Init.c
Go to the documentation of this file.
1 // Copyright (C) 2004 Joao Cardoso
2 // Copyright (C) 2017 Alan W. Irwin
3 
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 //--------------------------------------------------------------------------
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 }
int plFrameCmd(ClientData, Tcl_Interp *, int, const char **)
int Pltk_Init(Tcl_Interp *interp)
Definition: Pltk_Init.c:51
PLDLLIMPEXP_TCLTK int pls_auto_path(Tcl_Interp *interp)
Definition: tclAPI.c:716
#define PLPLOT_VERSION
Definition: plConfig.h:54
int plHost_ID(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv)
PLDLLIMPEXP_TCLTK int PlbasicInit(Tcl_Interp *interp)
Definition: tclAPI.c:418
static const char * display
Definition: tkMain.c:136
static Tcl_Interp * interp
Definition: tkMain.c:120