english
version "1.0"
identify "wxyz"

# Copyright (c) 1998-1999 by Wayne C. Gramlich.
# All rights reserved.
#
# Permission to use, copy, modify, distribute, and sell this software
# for any purpose is hereby granted without fee provided that the above
# copyright notice and this permission are retained.  The author makes
# no representations about the suitability of this software for any purpose.
# It is provided "as is" without express or implied warranty.

module swit_types

#: This module monitors the traffic between a client and a server
#, communicating via a TCP stream.

define application			#: An application
    routine_types
	procedure initialize_call_back
	    takes application
	    returns_nothing
    record
	black color			#: The color black
	clones vector[clone]		#: Clone list
	debug logical			#: {true}=>debugging on
	event_handlers vector[event_handler] #: Event handlers
	grey color			#: The color grey
	initialize_call_back initialize_call_back #: Initialization call back
	local_server_started logical	#: {true}=>local server started
	master clone			#: Master clone
	name string			#: Application name
	red color			#: Label highlight color
	swit swit			#: Parent {swit} object
	transparent color		#: The transparent color
	uid unsigned			#: Unique identifier counter
	uid2binding table[unsigned, canvas_binding] #: uid=>binding mapping
	uid2item table[unsigned, item]	#: Uid to item mapping table
	white color			#: The color white
	xgenerated_expression1 string	#: Generated expression 1
	xgenerated_field_name1 string	#: Generated field name 1
	xgenerated_imports string	#: Generated imports list
	xgenerated_name string		#: Generated name
	xgenerated_type1 string		#: Generated type 1
	yellow color			#: Highlight color
    generate address_get, allocate, erase, identical, print

define button				#: A button widget
    routine_types
	procedure button_call_back
	    takes button
	    returns_nothing
    record
	button_call_back button_call_back #: Procedure invoked on button press
	event_number unsigned		#: Event number
	mode button_mode		#: Button mode
	text string			#: Button text
	widget widget			#: Widget containing button
	xgenerate_call_back string	#: String for generated call back
    generate address_get, allocate, erase, identical

define button_mode			#: Mode of button
    enumeration
	active				#: The button is highlighted
	disabled			#: The button is unclickable
	normal				#: The button is waiting for a click
    generate equal, print, unsigned_convert

define canvas				#: A canvas to draw in
    record
	bindings vector[canvas_binding]	#: Event bindings for canvas
	black color			#: Black {color}
	group item_group		#: Group containing all canvas items
	image_grab logical		#: {true}=>Grab an image
	image_grab_binding canvas_binding #: Grab image event binding
	transparent color		#: The transparent `color'
	white color			#: White {color}
	widget widget			#: Widget containing canvas
	xborder_width unsigned		#: Border width
	xheight unsigned		#: Desired height
	xwidth unsigned			#: Desired width
    generate address_get, allocate, erase, identical

define canvas_binding			#: A canvas item event binding
    routine_types
	procedure call_back
	    takes item, string, integer, integer
	    returns_nothing
    record
	call_back call_back		#: Callback routine
	event_handler event_handler	#: Event handler
	event_name event_name		#: Event name
	modification_count unsigned	#: Modification count
	parent canvas			#: Parent canvas
	tag string			#: Tag to bind to
	uid unsigned			#: Unique identifier
    generate address_get, allocate, erase, identical, print

define clone				#: An application clone object
    routine_types
	procedure initialize_call_back
	    takes clone
	    returns_nothing
    record
	application application		#: Application being cloned
	channel_pair channel_pair[clone] #: Channel_pair to use
	free_commands vector[tcl_command] #: List of commands to send
	host_name string		#: SWIT server host name
	frame frame			#: Frame of top-level windows
	in_progress_commands vector[tcl_command] #: In progress command list
	initialize_call_back initialize_call_back #: Call back routine
	is_master logical		#: {true}=> is master clone
	line string			#: Receive line
	modification_count unsigned	#: Modification count
	pending_commands vector[tcl_command] #: Pending command list
	port_number unsigned		#: SWIT server port number
	remote_display string		#: Remote X display to use (or "")
 	session_number unsigned		#: Session number on SWIT server
	socket_name string		#: Socket name on SWIT server
	tcl_command tcl_command		#: Current {tcl_command}
    generate address_get, allocate, erase, identical
    
define color				#: A color description
    record
	name string			#: The color name
    generate address_get, allocate, erase, identical, print

define entry				#: A entry widget
    routine_types
	procedure entry_call_back
	    takes entry
	    returns_nothing
    record
	entry_call_back entry_call_back	#: Call back routine for entry
	event_number unsigned		#: Event number
	text string			#: Entry text
	widget widget			#: Widget containing button
	xwidth unsigned			#: Entry width
	xgenerate_call_back string	#: Call back string
    generate address_get, allocate, erase, identical

define event_name			#: Event name
    enumeration
	any_enter			#: Cursor enter
	any_leave			#: Cursor leaves
	button1				#: Button1 depressed
	button1_motion			#: Motion with button1 depressed
	button1_release			#: Button1 released
	button2				#: Button1 depressed
	button2_motion			#: Motion with button1 depressed
	button2_release			#: Button1 released
	special				#: For special events
    generate equal, print, unsigned_convert

define event_handler
    record
	number unsigned			#: Event number
	line string			#: Event data
	widget widget			#: Widget to pass in as an argument
	widgets vector[widget]		#: Cloned widget cache, see event@entry
    generate address_get, allocate, erase, identical, print

define font				#: Font object
    record
	name string			#: Font name
    generate address_get, allocate, erase, identical, print

define frame				#: A frame of widgets
    record
	clone clone			#: Parent {clone} object
	grid_column unsigned		#: Current grid column
	grid_column_weights vector[unsigned] #: Grid column weights for resize
	grid_row unsigned		#: Current grid row
	grid_row_weights vector[unsigned] #: Grid row weights for resizing
	xicon_title string		#: Title for iconified top level frame
	kind frame_kind			#: Frame kind
	xnormal_title string		#: Title for normal top level frame
	widget widget			#: Widget containing frame
	widgets vector[widget]		#: Contained widgets
    generate address_get, allocate, erase, identical

define frame_kind
    enumeration
	application			#: Application level frame
	nested				#: Nested frame
	top_level			#: Top-level frame
    generate equal, print, unsigned_convert

define item				#: Item on canvas
    record
	additional item_additional	#: Additional item information
	level_number unsigned		#: The relative level in display list
	modification_count unsigned	#: Modification count
	parent item_group		#: Parent {item_group}
	tags vector[string]		#: Tags associated with rectangle
	uid unsigned			#: Group unique identifier
	x_absolute integer		#: Absolute X coordinate
	x_relative integer		#: Relative X coordinate
	y_absolute integer		#: Absolute Y coordinate
	y_relative integer		#: Relative Y coordinate
    generate address_get, allocate, erase, identical, print

define item_additional			#: Additional item information
    variant kind item_kind
	gif item_gif			#: GIF (Graphics Interchange Fmt.) Img.
	group item_group		#: A group of items
	line item_line			#: Simple line segment
	rectangle item_rectangle	#: Rectangle
	text item_text			#: Text
    generate address_get, allocate, erase, identical, print

define item_gif				#: A gif image
    record
	gif_data string			#: The data that makes up the GIF
	gif_height unsigned		#: The height of the GIF
	gif_width unsigned		#: The width of the GIF
	item item			#: Item containing point
	photo_name string		#: Photo name (.s{session}.p{uid})
    generate address_get, allocate, erase, identical, print

define item_group			#: A grouping of items
    record
	canvas canvas			#: Parent canvas
	item item			#: Item containing group
	items vector[item]		#: The items in the group
	level_modification_count unsigned #: Modification count for levels
	levels vector[item_level]	#: Various stacking levels of group
    generate address_get, allocate, erase, identical, print

define item_level			#: Level in the group
    record
	number unsigned			#: Level number
	modification_count unsigned	#: Modification count
	parent item_group		#: Parent group
	uids vector[unsigned]		#: Unique ids of items in this level
    generate address_get, allocate, erase, identical, print

define item_line_arrow			#: Arrow mode for line
    enumeration
	none				#: The line has no arrow heads
	x1y1				#: (x1:y1) coordinate has arrow head
	x2y2				#: (x2:y2) coordinate has arrow head
	both				#: (x1:y1) and (x2:y2) have arrow heads
    generate equal, print, unsigned_convert

define item_line			#: Simple line segment
    record
	xarrow_back unsigned		#: Length of back of arrow
	xarrow_front unsigned		#: Length of front of arrow
	xarrow_half_width unsigned	#: Half width of arrow
	xarrow_mode item_line_arrow	#: Arrow mode for line
	item item			#: Item containing point
	line_width unsigned		#: Line width
	outline color			#: Line outline color
	x2_absolute integer		#: Group X2 absolute position
	x2_relative integer		#: Group X2 relative offset
	y2_absolute integer		#: Group Y2 absolute position
	y2_relative integer		#: Group Y2 relative offset
    generate address_get, allocate, erase, identical, print

define item_rectangle			#: Simple rectangle
    record
	fill color			#: Rectangle fill color
	item item			#: Item containing point
	xline_width unsigned		#: Line width
	outline color			#: Rectangle outline color
	x2_absolute integer		#: Group X2 absolute position
	x2_relative integer		#: Group X2 relative offset
	y2_absolute integer		#: Group Y2 absolute position
	y2_relative integer		#: Group Y2 relative offset
    generate address_get, allocate, erase, identical, print

define item_text			#: Some text
    record
	fill color			#: Text fill color
	item item			#: Item containing point
	font font			#: Font to use
	text string			#: Text value
    generate address_get, allocate, erase, identical, print

define label				#: A label widget
    record
	text string			#: Label text
	widget widget			#: Widget containing button
    generate address_get, allocate, erase, identical

define relief				#: Relief of widget
    enumeration
	flat				#: Widget is flat
	groove				#: Widget has a groove around it
	raised				#: Widget is raised
	ridge				#: Widget is surronded by a ridge
	solid				#: Widget looks solid
	sunken				#: Widget looks sunken
    generate equal, print, unsigned_convert

define restore				#: A restore object
    record
	error_count unsigned		#: Number of objects
	error_stream out_stream		#: Error stream
	in_stream in_stream		#: Input stream
	line string			#: Current line buffer
	line_number unsigned		#: Line number
	position unsigned		#: Position in line
	major unsigned			#: Major version number
	minor unsigned			#: Minor version number
    generate address_get, allocate, erase, identical, print

define sticky				#: Grid manager sticky parameters
    enumeration
	none				#: No sticky
	n				#: North
	e				#: East
	w				#: West
	s				#: South
	ns				#: North-south
	ew				#: East-west
	ne				#: North-east
	nw				#: North-west
	se				#: South-east
	sw				#: South-west
	new				#: North-east-west
	nes				#: North-east-south
	nws				#: North-west-south
	ews				#: East-west-south
	news				#: North-east-south-west
    generate equal, print, unsigned_convert

define swit				#: SWIT master object
    record
	applications vector[application] #: Application list
	debug_stream out_stream		#: Debug stream object
	error_stream out_stream		#: Error stream object
	errors errors			#: Errors object
	exit_value unsigned		#: Exit value
	io_dispatcher io_dispatcher[clone] #: I/O dispatcher
	swit_server_executable file_name #: Path to swit server executable
	unix_system unix_system		#: The {unix_system} object
	wish_executable file_name	#: Path to wish executable
    generate address_get, allocate, erase, print

define tcl_command			#: A command to work with
    record
	amount_sent unsigned		#: Number of characters sent
	command string			#: The TCL command to send.
	result string			#: Tcl result
    generate address_get, allocate, erase, identical, print

define widget				#: Common widget information
    record
	additional widget_additional	#: Additional widget info
	grid_column unsigned		#: Grid column containing widget
	grid_column_span unsigned	#: Grid no. of cols. to span
	grid_row unsigned		#: Grid row containing widget
	grid_row_span unsigned		#: Grid no. of rows. to span
	grid_modification_count unsigned#: Grid modification count
	grid_sticky sticky		#: Grid sticky characteristic
	modification_count unsigned	#: Modification count
	parent frame			#: Parent frame
	private_name string		#: Name for GUI builder app.
	uid unsigned			#: Unique identifier of widget
	window_path string		#: Full window path for widget
	xactive color			#: Active color (or ?? for inherit)
	xbackground color		#: Background color (or ?? for inherit)
	xforeground color		#: Foreground color (or ?? for inherit)
	xhighlight logical		#: Widget is to be highlighted
	xrelief relief			#: Widget relief
    generate address_get, allocate, erase, identical
    
define widget_additional		#: Additional widget information
    variant kind widget_kind
	none string			#: A null place holder (name only)
	button button			#: A button
	canvas canvas			#: A canvas widget (may be scrollable)
	entry entry			#: A entry
	frame frame			#: A frame
	label label			#: A label
    generate address_get, allocate, erase, identical, print

define widget_kind			#: Widget kinds
    enumeration
	none 				#: None
	button				#: A button
	canvas				#: A canvas
	entry				#: A entry
	frame				#: A frame
	label				#: A label
    generate equal, print, unsigned_convert


#: Various {print} procedures:

procedure print@button
    takes
	button button
	out_stream out_stream
    returns_nothing

    #: This procedure will print a human readable version of {button}
    #, to {out_stream}.


procedure print@canvas
    takes
	canvas canvas
	out_stream out_stream
    returns_nothing

    #: This procedure will print {canvas} to {out_stream}.


procedure print@clone
    takes
	clone clone
	out_stream out_stream
    returns_nothing

    #: This procedure will print {clone} to {out_stream}.


procedure print@entry
    takes
	entry entry
	out_stream out_stream
    returns_nothing

    #: This procedure will print {entry} to {out_stream}.


procedure print@frame
    takes
	frame frame
	out_stream out_stream
    returns_nothing

    #: This procedure will print {frame} to {out_stream}.


procedure print@label
    takes
	label label
	out_stream out_stream
    returns_nothing

    #: This procedure will print {label} to {out_stream}.


procedure print@widget
    takes
	widget widget
	out_stream out_stream
    returns_nothing

    #: This procedure will print {widget} to {out_stream}.