cnet's Application Programming Interface

NAME
TCLTK - access cnet's Tck/Tk windowing interface

SYNOPSIS
#include <cnet.h>

void TCLTK(const char *fmt, ...);
void *TCLTK_interp(void);

DESCRIPTION
When running as a GUI-based application, cnet performs all drawing and management of its GUI using the Tcl/Tk toolkit. This enables you to focus on writing and evaluating protocols without having to worry about the GUI. However, there are many occasions when you may wish to interact with, or extend, cnet's GUI. The TCLTK function allows you to do this in a simplified manner.

The arguments to TCLTK are similar to those of C's printf, and the standard format specifiers may be provided in the formatting string. The Tcl/Tk variable $map is available for you to draw things on the main simulation map. For example, the call:

    TCLTK("$map create rectangle %d %d %d %d -fill yellow",
                x, x+WIDTH, y, y+HEIGHT);

will draw a yellow rectangle on the simulation map.

If you really know what you are doing, you may wish to call 'raw' Tcl or Tk library functions from within protocol code (perhaps to provide detailed mapping). The single Tcl/Tk interpreter may be accessed by calling TCLTK_interp(), passing its returned value to Tcl or Tk library functions.

NOTE
cnet's physical coordinates are measured in metres, but coordinates in Tcl/Tk are measured in pixels. You may use CNET_get_mapscale() and CNET_get_mapmargin() to convert between the two:

    #define M2PX(metres)   ((int)(CNET_get_mapmargin() + (metres) / CNET_get_mapscale())

SEE ALSO
The extensive features of Tcl/Tk are not documented with cnet, and so you may like to read Tcl/Tk's online documentation.


 cnet v3.3.4, written by Chris.McDonald@uwa.edu.au
 Last modified: Tue Mar 1 7:43AM 2016