perlPort.pod - Notes on Porting tkTable from tcl to perltk
This contains a TCL script that is run when table is loaded. This will probably have to be completly converted to perl. Excluded.
Used by gnu autoconfigure in the TCL scripts. Excluded.
Used for mac port. Don't worry about for now.
Command structure lookup definitions. Called out by tkTable.h
TCL application Init. A similar file is excluded in ../tclUnix, ../tclWin, etc. Excluded.
Main tkTable code/header file.
Functions for the tkTable Cells
Implements general commands of the table widget
Implements editing functions for the table widget.
Implements postscript output for table widgets.
Implements tags for table widgets.
Implements embedded windows for table widgets
As an example, Scale.xs references Tk_ScaleCmd, which is defined in tkScale.c. Should the top leved Table.xs do a similar thing?
These notes are taken from looking at the difference between the tkScale.h and tkScale.c files in the stock tk8.0.5 distribution and the Tk800.022/pTk/mTk distribution.
Add tkVMacro.h to include
Remove UID type references?
Or change to Tk_State type?
Change name of variables from char type to Var type
Change command variables from char type to LangCallback type.
Change any tclMath refs to <math.h>
Add #include "tkVMacro.h"
Before "tkScale.h" or equivalent.
Change Tk_ConfigSpec table
Tk_CONFIG_STRINGS for commands to TK_CONFIG_CALLBACK.
Removed/Change UID type variables
Change TK_CONFIG_STRING to TK_CONFIG_SCALAR_VAR for -variable type entries.
Change XXXVarProc items
From char * name to Var name where appropriate.
Change tkNormalUID states to TK_STATE_NORMAL
Also for disabled (TK_STATE_DISABLED)
Change Tk_SetClass call to TkClassOption calls (Not Needed?)
Change any numeric conversions.
Anything like value = strtod(stringValue, &end) should be converted to a Arg stringValue; type and a (Tcl_GetDouble(interp, stringValue, &value) call.
value = strtod(stringValue, &end)
(Tcl_GetDouble(interp, stringValue, &value)
Change any calls to Tcl_CreateCommand to Lang_CreateWidget
Similar to the way this was changed in the tkCanvas.c file in the main tk distribution.
Modify the command routine to return a value like tkCanvas
Replace Tcl_SetStringObj with Tcl_ArgResult similar to what is in tkCanvas.c
Any calls to Tcl_VarEval are converted to LangDoCallback
Any calls to Tcl_SplitList are changed to Tcl_ListObjGetElements.
Any calls to Tcl_Merge are changed to Tcl_NewListObj.
Any calls to Tcl_GetStringResult are changed to Tcl_GetResult. Tcl_GetStringResult wasn't provided as part of the tkGlue.c parkage and Tcl_GetResult appeared to do the same thing.
The original tktable widget accepts TCL scripts (text) to be used as callbacks (Like for -browsecommand, and the -command options). The tcl/tk code takes the TCL script and performs Expand Percents on it, and then evals it, using Tcl_GlobalEval. To work with perltk, this sequence was changed to a LangDoCallBack.
Files in the lib directory (tkTable.tcl) are equivalent to the .pm files for the widget, so the tkTable.tcl file has to be converted to perl. See the various .pm files in the Tk distribution for examples.
Note the tcl2perl script in the Tk distribution can provided a starting point for the translation. Much hand-editing is still required however.
To install Tk::TableMatrix, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.