InitTclTk.h File Reference

#include "TCL_Global.h"

Include dependency graph for InitTclTk.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void initTCLTK (void)
int OpenTCLsci (void)
int CloseTCLsci (void)


Function Documentation

int CloseTCLsci ( void   ) 

TODO : comment

Returns:

Definition at line 170 of file InitTclTk.c.

Referenced by C2F(), and TerminateTclTk().

00171 {
00172         int bOK=0;
00173         if ( GetWITH_GUI() )
00174         {
00175                 if (TK_Started)
00176                 {
00177                         Tcl_DeleteInterp(TCLinterp);
00178                         TCLinterp=NULL;
00179                         TKmainWindow=NULL;
00180                         bOK=1;
00181                         TK_Started=0;
00182                 }
00183         }
00184         return bOK;
00185 }

Here is the caller graph for this function:

void initTCLTK ( void   ) 

TODO : comment

Definition at line 32 of file InitTclTk.c.

00033 {
00034         if ( GetWITH_GUI() )
00035         {
00036                 if ( OpenTCLsci()==0 ) 
00037                 {
00038                         TK_Started=1;
00039                 }
00040                 else
00041                 {
00042                         TK_Started=0;
00043                 }
00044         }
00045         else
00046         {
00047                 TK_Started=0;
00048         }
00049 }

int OpenTCLsci ( void   ) 

TODO : comment

Returns:

Definition at line 51 of file InitTclTk.c.

References DIR, flushTKEvents(), FREE, GetSciPath(), NULL, sciprint(), TCL_ERROR1, TCL_ERROR2, TCL_ERROR3, TCL_ERROR4, TCL_EvalScilabCmd(), TCL_WARNING1, TCL_WARNING2, TCLinterp, TKmainWindow, tmpdir, and XTKsocket.

Referenced by initTCLTK().

00054 {
00055   char *SciPath=NULL;
00056   char TkScriptpath[2048];
00057   char MyCommand[2048];
00058 
00059 #ifndef _MSC_VER
00060   DIR *tmpdir=NULL;
00061   Display *XTKdisplay;
00062 #endif
00063 
00064   FILE *tmpfile2=NULL;
00065 
00066 #ifdef TCL_MAJOR_VERSION
00067   #ifdef TCL_MINOR_VERSION
00068     #if TCL_MAJOR_VERSION >= 8
00069       #if TCL_MINOR_VERSION > 0
00070          Tcl_FindExecutable(" ");
00071       #endif
00072     #endif
00073   #endif
00074 #endif
00075   SciPath=GetSciPath();
00076   
00077   /* test SCI validity */
00078   if (SciPath==NULL)
00079     {
00080       sciprint(TCL_WARNING1);
00081       return(1);
00082     }
00083 
00084 #ifdef _MSC_VER
00085   strcpy(TkScriptpath, SciPath);
00086   strcat(TkScriptpath, "/modules/tclsci/tcl/TK_Scilab.tcl");
00087 
00088   tmpfile2 = fopen(TkScriptpath,"r");
00089   if (tmpfile2==NULL) 
00090     {
00091       sciprint(TCL_WARNING2);
00092       return(1);
00093     }
00094   else fclose(tmpfile2);
00095 #else
00096   tmpdir=opendir(SciPath);
00097   if (tmpdir==NULL) 
00098     {
00099       sciprint(TCL_WARNING1);
00100       return(1);
00101     }
00102   else closedir(tmpdir);
00103   strcpy(TkScriptpath,SciPath);
00104   strcat(TkScriptpath, "/modules/tclsci/tcl/TK_Scilab.tcl");
00105   tmpfile2 = fopen(TkScriptpath,"r");
00106   if (tmpfile2==NULL) 
00107     {
00108       sciprint(TCL_WARNING2);
00109       return(1);
00110     }
00111   else fclose(tmpfile2);
00112 #endif /* _MSC_VER */ 
00113   
00114   if (TCLinterp == NULL) 
00115     {
00116       TCLinterp = Tcl_CreateInterp();
00117           if ( TCLinterp == NULL )
00118           {
00119             Scierror(999,TCL_ERROR1);
00120                 return (1);
00121           }
00122 
00123       if ( Tcl_Init(TCLinterp) == TCL_ERROR)
00124           {
00125                 Scierror(999,TCL_ERROR2);
00126                 return (1);
00127           }
00128 
00129       if ( Tk_Init(TCLinterp) == TCL_ERROR)
00130           {
00131                 Scierror(999,TCL_ERROR3);
00132                 return (1);
00133           }
00134 
00135       sprintf(MyCommand, "set SciPath \"%s\";",SciPath); 
00136       
00137           if ( Tcl_Eval(TCLinterp,MyCommand) == TCL_ERROR  )
00138           {
00139                 Scierror(999,TCL_ERROR4,TCLinterp->result);
00140                 return (1);
00141           }
00142       
00143           Tcl_CreateCommand(TCLinterp,"ScilabEval",TCL_EvalScilabCmd,(ClientData)1,NULL);
00144     }
00145    
00146   if (TKmainWindow == NULL)
00147     {
00148       TKmainWindow = Tk_MainWindow(TCLinterp);
00149           #ifndef _MSC_VER
00150         XTKdisplay=Tk_Display(TKmainWindow);
00151         XTKsocket = ConnectionNumber(XTKdisplay);
00152           #endif
00153       
00154       Tk_GeometryRequest(TKmainWindow,2,2);
00155 
00156           if ( Tcl_EvalFile(TCLinterp,TkScriptpath) == TCL_ERROR  )
00157           {
00158                 Scierror(999,TCL_ERROR4,TCLinterp->result);
00159                 return (1);
00160           }
00161 
00162       flushTKEvents();
00163     }
00164 
00165   if (SciPath) {FREE(SciPath);SciPath=NULL;}
00166   return(0);
00167 
00168 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 16:13:26 2007 for Scilab [trunk] by  doxygen 1.5.1