July 9, 1996

Overview of Item Types


The sections below describe the various types of items supported by Pad++ (grid, group, handle, html, image, kpl, line, polygon, portal, rectangle, spline, tcl, text, and textfile). Each item type is characterized by two things: first, the form of the command used to create instances of the type; and second, a set of itemconfiguration options for items of that type, which may be used in the create and itemconfigure widget commands. See the itemconfigure command for the syntax to use these options.

These are the options that are supported by all item types:

[1] -alwaysrender boolean

(available only for all item types)


The rendering engine may decide to not render an item for reasons of efficiency (although it may get rendered at higher levels of refinement). When this flag is set (i.e., equals 1), the item will be rendered no matter how big it is (as long as it is bigger than its -minsize. Defaults to false (0).

[2] -anchor anchorPos

(available only for all item types)


AnchorPos tells how to position the object relative to the positioning point for the item (see -place); it may have any of the forms accepted by Tk_GetAnchor. For example, if anchorPos is "center" then the object is centered on the point; if anchorPos is "n" then the object will be drawn so that its top center point is at the positioning point. This option defaults to center.

[3] -clipping boolean

(available only for all item types)

By default, built-in items (such as lines, text, etc.) do not get clipped to their bounding box, and procedural items (items with -renderscripts) do. This flag turns clipping on or off. Be warned, that turning off clipping for a procedural object is dangerous. If you draw outside the object's bounding box, you can end up with screen garbage. Defaults to true (1) for items with -renderscripts, and false (0) for all other items.

[4] -events boolean

(available only for all item types)


Controls whether an item receives input events. If set to false (0), it does not respond to events. Defaults to true (1).

[5] -faderange value

(available only for all item types)


Controls over how long a period an item fades out as it approaches its minimum or maximum size. value specifies this period as a percentage of the object's size (from 0.0 to 1.0). Where 0.0 means that the item doesn't fade out all, it just blinks off when its extreme is reached, and 1.0 means that it slowly fades out over its entire range of sizes. Defaults to 0.3. (Also see the -minsize and -maxsize itemconfigure options.)

[6] -height height

(available only for all item types)


By default, the height of every item is automatically computed based on its contents. If the -height option is set, however, then this overrides the automatically computed value. Items are centered within the specified height. If the dimensions are specified as smaller than the default values, the item is clipped to those dimensions. (Also see the -width itemconfigure option.)


[7] -info info

(available only for all item types)


A generic info field where the user may place any string. (See the find withinfo command).


[8] -layer layer

(available only for all item types)

Specifies the layer the item is on. Every item sits on a layer (which is specified by a string), and each view (top-level window and portals) specifies which layers are visible within that view. This gives control over objects are visible where and can be used with portals to implement very simple filters. (See the -visiblelayers itemconfigure option of portals and the top-level window which is specified by the surface (item 1). Defaults to "main".

[9] -lock lock

(available only for all item types)

When an item is locked, it can not be deleted or modified (except for changing the lock status). Note that attempting to modify or delete a locked item does not generate an error. It fails silently. This is so it is easy to modify all items associated with a tag and if certain items are locked they will just not get modified. The restricted commands on locked items are: coords, delete, itemconfigure, scale, slide, and text.

[10] -maxsize size

(available only for all item types)


Specifies the maximum size (in current units) this item should be rendered at. That is, if the view is such that the largest dimension of this object is greater than size units, it will not be displayed. When an object is not displayed because it is too large, it does not receive events. When an object approaches its maximum size it will fade out until it completely disappears when it reaches its maximum size. If size is -1, then it has no maximum size and will never disappear because it is too large. See the -faderange itemconfigure option to control how quickly an item fades out.

size may also be specified as a percentage of the view it is visible in (top-level window or portal). To specify size as a percentage, it should be in the range from 0 to 100 and end with a "%". Example:


		.pad ic 5 -minsize 55%

size defaults to 10,000 pixels.

Also note that the rendering engine may decide to not display an item for reasons of efficiency if it is reasonably small. See the -alwaysrender flag to avoid this.

[11] -minsize size

(available only for all item types)


Specifies the minimum size (in current units) this item should be rendered at. That is, if the view is such that the largest dimension of this object is less than size units, it will not be displayed. When an object is not displayed because it is too small, it does not receive events. When an object approaches its minimum size it will fade out until it completely disappears when it reaches its minium size. See the -faderange itemconfigure option to control how quickly an item fades out.

size may also be specified as a percentage of the view it is visible in (top-level window or portal). To specify size as a percentage, it should be in the range from 0 to 100 and end with a "%". Example:


		.pad ic 5 -minsize 55%

size defaults to 0.

Also note that the rendering engine may decide to not display an item for reasons of efficiency if it is reasonably small. See the -alwaysrender flag to avoid this.

[12] -place: Place sets the anchor position of the object.

(available only for all item types)

Every object has a -place which specifies the anchor point of that object (see -anchor). The place specifies the object's position and size. The size is multiplicitive. Place can be one of:

			.pad ic 22 -place -150 150 1


			.pad ic 22 -place "-50 20 0.5"
 
A synonym for the third (z) component of -place.

[13] -renderscript TclScript

(available only for all item types)


Specifies a Tcl script that will be evaluated every time the object is rendered. The script gets executed when the object normally would have been rendered. By default, the object will not get rendered. The script may call the renderitem function at any point to render the object. An example is:

		.pad itemconfigure 22 -renderscript {
			puts "Before"
			.pad renderitem
			puts "After" 
		}

It would be possible to get in an endless render loop with the -renderscript option. If a

-renderscript callback triggers a render which causes that item to be redrawn, the system will be in an endless render loop. To avoid this problem, items do not implicitly trigger damage within a

-renderscript callback. If you do want to explicitly damage an item within a -renderscript callback, you must use the damage command. Be very careful to avoid infinite render loops.

[14] -sticky boolean

(available only for all item types)

Specifies if this item should be "sticky". Sticky items are rendered independent of the current view. That is, as the view pans and zooms, sticky items appear effectively stuck to the screen. All sticky items are rendered after non-sticky items, thus sticky items always are on top of non-sticky items. (See the getview and moveto commands.) Defaults to 0 (false).

[15] -tags tagList

(available only for all item types)


Specifies a set of tags to apply to the item. TagList consists of a list of tag names, which replace any existing tags for the item. TagList may be an empty list.

[16] -timerrate rate

(available only for all item types)


Specifies the frequency in milliseconds that the object's timerscript should be evaluated. If it is set to 0, the timer is turned off. Defaults to off (0). (see -timerscript).


[17] -timerscript TclScript

(available only for all item types)


Specifies a Tcl script that will be evaluated regularly, every rate milliseconds as specified by -timerrate (if -timerrate is greater than zero). This evaluation is independent of rendering and events. Returns the current TclScript for the object. (see -timerrate).


[18] -transparency value

(available only for all item types)


Specifies the transparency an item is drawn with. value must be a value between 0.0 and 1.0 where 0.0 is completely transparent and 1.0 is completely opaque. 1.0 is the default. If a portal or group is partially transparent, all of its member or visible objects, respectively, will have their transparency multiplied by the portals or groups.

[19] -viewscript TclScript

(available only for all item types)


Specifies a Tcl script that will be evaluated every time the view onto the Pad++ surface is changed. This script gets executed after the view coordinates have changed, but before the new scene gets rendered. Returns the current viewscript.

[20] -visible boolean

(available only for all item types)


WARNING: -visible is an obsolete option and will be removed in the next release. Replace all uses of the -visible option with -transparency which is more general.

Specifies whether this item is visible. Note that invisible items receive events and respond to commands such as find. Defaults to true.


[21] -width width

(available only for all item types)


By default, the width of every item is automatically computed based on its contents. If the -width option is set, however, then this overrides the automatically computed value. Items are centered within the specified width. If the dimensions are specified as smaller than the default values, the item is clipped to those dimensions. (Also see the -height itemconfigure option.)


[22] -x x

(available only for all item types)

A synonym for the first (x) component of -place.


[23] -y y

(available only for all item types)


A synonym for the second (y) component of -place.


[24] -zoomaction {size growScript shrinkScript}

(available only for all item types)

Specifies a pair of Tcl scripts that gets evaluated when an item grows or shrinks so that its size crosses size. This is a simple way of making "semantically zoomable" objects - that is, objects that look different when the are rendered at different sizes. When the item grows larger than size, growScript is evaluated, and when it shrinks smaller than size, shrinkScript is evaluated.

Any number of pairs of scripts may be associated with different sizes. Each use of -zoomaction may specify a different size, or modify scripts for an existing size. If both scripts are empty strings, then that zoomaction is deleted. This returns a list of zoomaction size, growScript, shrinkScript triplets.

The script gets executed when the object normally would have been rendered. By default, the object will not get rendered. The script may call the renderitem function at any point to render the object. See the description of -renderscript for an example. The deletion of items during a zoomaction is delayed until after the current render is finished.

Here is an example that turns a rectangle into an image when it is zoomed in, and back into the rectangle when zoomed out:

		proc grow {} {
			.pad ic rect -visible 0
			.pad pushcoordframe rect
			set image_token [.pad allocimage images/unm_logo_orig.gif]
			.pad create image -image $image_token -anchor sw -tags "image"
			.pad popcoordframe
			.pad renderitem  
		}

		proc shrink {} {
			.pad ic rect -visible 1
			set image_id [.pad find withtag image]
			if {$image_id != ""} {
				set image_token [.pad ic image -image]
				.pad freeimage $image_token
				.pad delete image
			}
			.pad renderitem
		}

		proc testzoomaction {} {
			.pad create rectangle 0 0 341 222 -pen black -fill yellow3 \
			-zoomaction {250 grow shrink} -tags "rect"
		}

[25] -z z

(available only for all item types)


A synonym for the third (z) component of -place

Grid Items
Group Items
Handle Items
HTML Items
IMAGE ITEMS
KPL Items
Line Items
Pad Items
Polygon Items
Portal Items
Rectangle Items
Spline Items
TCL Items
Text Items
Textfile Items

July 9, 1996 - 9 JUL 1996

Generated with Harlequin WebMaker

Web Accessibility