The TkIcon extension Copyright (c) 1993 by Sven Delmas All rights reserved. See the file COPYRIGHT for the copyright notes. Changes: -------- - Some minor bug fixes. What is TkIcon ? ---------------- This small extension to Tk allows the creation of icon and edge items in a canvas widget. These items provide a lot of additional functionality (take a look at the manual pages canvas.n and tkiconpane.n). The tkiconpane widget is a complete implementation of a desktop displayer as well as a graph widget (including a layout mechanism). The advantage of TkIcon is that a big part of the work is done in C, which makes the implementation much faster. Graph layout: ------------- The graph layout is done with a simple tree layouter (named tree), and an ISI layouter. The tree layouter was originally based upon a Tcl algorithm published by Juergen Wagner (J_Wagner@iao.fhg.de or gandalf@csli.stanford.edu) in his "theObjects" package. The ISI layouter was implemented following an explanation published by Anette Kjaer. If someone has interesting other layout algorithms, please let me know. It should not be a big problem to add additional algorithms... Writing new algorithms: ----------------------- In case you want to embed additional algorithms, you can add the code to tkCanvLayout.c. The new layout command is added to the C function named TkCanvLayoutCmd. The new subcommand is added where the dummy command "testing" is located. This piece of code gives a small example of the embedding of new algorithms. The function TkCanvLayoutBuildGraphToString is used to build a string that represents the canvas graph structure. This function returns a string following this format: - {{NodeList} {EdgeList}} - NodeList -------> {Node Node Node ...} - Node ------------> {NodeCanvasId x y width height {ConnectionList}} - ConnectionList ---> {Connection Connection ...} - Connection --------> {FromCanvasId ToCanvasId EdgeCanvasId} - EdgeList -------> {Edge Edge Edge ...} - Edge ------------> {EdgeCanvasId FromCanvasId ToCanvasId} Your new layout algorithm can parse this string to build up his internal representation. The function TkCanvLayoutGraphPlaceNodesFromString shows how to parse the string, and is used to place the icons and edges according to the computed layout. The procedure receives a string following this format: - {{NodeList} {EdgeList}} - NodeList -------> {Node Node Node ...} - Node ------------> {NodeCanvasId x y width height} - EdgeList -------> {Edge Edge Edge ...} - Edge ------------> {EdgeCanvasId x1 y1 x2 y2 ....} Building a patched wish: ------------------------ - Please first take a look into the "Portability" section at the bottom. The installation may require a special handling for your system. - Unpack the Tk distribution and change to the Tk directory. - Unpack the TkIcon distribution in the Tk distribution directory. - Unpack the TkPixmap distribution in the Tk directory. This is necessary, because the Makefile loads the Xpm3 library from the local xpm directory by default. If you have a publically installed Xpm 3.4a library, you can use this library by removing the string "-L$(SRC_DIR)/xpm" from the PIXMAP_LIBS variable and the string "-I$(SRC_DIR)/xpm" from the PIXMAP_CFLAGS variable in the Makefile. - Build the Xpm3 library in the ./xpm subdirectory. This is only necessary if you do not use a public Xpm 3.4a library. It is important to configure the Imakefile. Some systems need -DNEED_STRCASECMP (like mine :-). See the "Portability" section below. By default, a not sharable version is built. Look at the comment in the Imakefile to decide whether you want to make it shareable (which means you have to install it globally) or not. To build the Xpm3 library, type in the xpm directory: xmkmf; make - Patch tkCanvBmap.c, tkCanvas.c tkMenubutton.c, tkMenu.c, tkButton.c, tkConfig.c, tk.h and the doc files with the file tkPixmap3.6.pat. (if you are building Tk 3.2, you have to use tkPixmap3.2.pat and if you are using a japanized Tk you have to use tkPixmap3.2-jp.pat or tkPixmap3.6-jp.pat). On a 14 character limited filesystem, this may cause problems, as tkMenubutton.c is too long. In this case, rename the file to a shorter name and replace this name in the patch file. Don't forget to rename the file to tkMenubutton.c after applying the patch. - On my system, the call of the patch program looks like this: patch -l -p1 < tkPixmap3.6.pat - Patch tkCanvas.c and the doc files with the file tkIcon3.6.pat. This adds the TkIcon support to the canvas widget. - On my system, the call of the patch program looks like this: patch -l -p1 < tkIcon3.6.pat - Configure the Tk distribution by running configure (or use the Makefile3.2.TkPixmap if you are building TK 3.2). And do all the things you usually do to get a working Tk. You can modify the Makefile. Here, you can select which picture formats you want to support, etc.. It is also possible to select additional packages to be included into the wish. You have to uncomment the TKICON variables to add the TkIcon package. - Build Tk (wish) by typing: make If you are building Tk 3.2, you have to specify the Makefile to be used with "-f Makefile3.2.TkPixmap". - You can now install everything by typing this in the Tk build directory: make install This will install the new wish and all the library files and header files. If you just want to install the new wish, you can copy the executable to a new location. By default, the library files are placed in the TK_LIBRARY directory. The original Tk tclIndex has to be changed. It must contain the new command "tkiconpane". Please take care to keep the tclIndex file up to date when you install other packages. The tclIndex file must contain the following line: set auto_index(tkiconpane) "source [set dir]/tkIconPane.tcl" You can add these lines by hand (as described above), or you can use auto_mkindex. Portability: ------------ Linux: - Building shared libraries under Linux seems to be a little complicated. As there seems to be a common source for an adapted (shared) Xpm the included xpm distribution will be built static by default. It is probably a good idea to grab the shared version of Xpm, and ignore the TkPixmap version of Xpm. Esix: - You will probably need -DNEED_STRCASECMP. Availability: ------------- The TkIcon distribution file is named TkIcon3.6?.tar.gz or TkIcon3.6?.tar.Z. The ? represents the current version. TkIcon is available via anonymous ftp at: harbor.ecn.purdue.edu: pub/tcl/extensions/ ftp.ibp.fr: pub/tcl/contrib/extensions/ nic.funet.fi: pub/languages/tcl/extensions/ syd.dit.csiro.au: pub/tk/contrib/extensions/ ftp.cs.tu-berlin.de: pub/tcl/contrib/extensions/ To get a copy of it, just type the following: ftp ftp.cs.tu-berlin.de bin cd pub/tcl/contrib/extensions get TkIcon3.6?.tar.gz To get a copy via ftpmail, just send the following mail to: mail-server@cs.tu-berlin.de To get a help message, send the following body: send HELP end To retrieve TkIcon, send the following body: send pub/tcl/contrib/extensions/TkIcon3.6?.tar.gz end Feedback (Author): ----------------- Sven Delmas TU Berlin, Germany garfield@cs.tu-berlin.de