[tail]

Chapter 7
Labels, label formats and fields

TkZinc was initially developed for building interactive radar image working on X server. This requires very good performances, for displaying many hundred tracks and moving them every few second. Tracks are typically composed of some geometric parts and some textual parts. These two parts are connected together with a leader. The geometric parts are subject to scaling. For example the speed vector length in pixel depends on the scale. But the textual part must not be zoomed. Managing parts which are scaled and others which are not, can be a real challenge. Usual toolkits or widget are not suited to such behaviours, but TkZinc is.

To be able to manage many items mixing geometric parts and non-geometric parts, TkZinc introduces the concepts of label, labelformat, fields and fields attributes.

7.1 Labels and labelformats

A label is a set of rectangular fields attached to the following item types : track , waypoint and tabular . The fields of a label may contain either text or bitmaps or images. A label cannot be identified or manipulated by itself; There is no function nor method to get or manipulate a label as an object or an item. A label is always associated to an item and is manipulated through this item.

Some label global characteristics are set/get at the item level:

Characteristics of each individual field are called field attributes. They are all described in next section Attributes for fields . They may be set or get with the itemcget and itemconfigure command. These commands require as a second argument the field number. By configuring field attributes you can modify :

As an example:

 # this should display "Hello World" in white on black in field 0  
 $zinc->itemconfigure($track, 0, -text => 'Hello World',  
                                 -color => 'white',  
                                 -backcolor => 'black',  
                                 -filled => 1);

It is possible to bind callbacks to fields, with the command bind and special tags (described Tags and bindings ). As an example:

 # this binds &acallback to field 1  
 $zinc->bind("$track:1", '<1>', \&acallback);

Inside a callback function, it is possible to know which field the mouse cursor is over with the command currentpart .

A Perl module, called Tk::Zinc::Text (see the section Tk::Zinc::Text ) is provided for easing text input in text fields (it can also be used for easing text input in text item).

7.2 Attributes for fields

Fields are item parts of items supporting labelformat (i.e. track , waypoint and tabular ). They can be configured in a similar way of items themselves, with the command itemconfigure , but this command requires an additionnal parameter (in second position) the fieldId. To get the value of a field attribute, you can use the command itemcget with the fieldId as an additionnal second parameter.
NB: Field attributes cannot be configured at item creation with the command add .

Applicable attributes for fields are:

-alignment alignment

The horizontal alignment of both the text and the image. The default value is left.

-autoalignment autoalignment

The dynamic horizontal alignments used depending on the label orientation. The default value is "-" which means do not use dynamic alignment.

-backcolor gradient

The field background color. The default value is the current value of the widget option -backcolor .

-border edgelist

The border description edge by edge. The border is a one pixel wide outline that is drawn around the field outside the relief. Some border edges can be omitted, this attribute describes the edges that should be displayed as part of the border. The default value is "".

-bordercolor gradient

The border uniform (possibly transparent) color. The first color of a real gradient color will be used. The default value is the current value of the widget option -forecolor .

-color gradient

The text uniform (possibly transparent) color. The first color of a real gradient color will be used. The default value is the current value of the widget option -forecolor .

-filled boolean

Specifies if the field background should be filled. The default value is false.

-fillpattern bitmap

The fill pattern used when filling the background. This attribute is overrided by the tile attribute. The default value is "".

-font font

The text font. The default value is the current value of the widget option -font .

-image image

An image to be displayed in the field. The image will be centered vertically in the field. The default value is "".

-relief relief

Specifies the relief to be drawn around the field, inside the border. The color of the relief is derived from the color in -backcolor . The default value is flat.

-reliefthickness dimension

Width of the relief drawn around the field. The default value is 0 which means that no relief should be drawn around the field.

-sensitive boolean

Specifies if the field should react to input events. The default value is true.

-text string

A line of text to be displayed in the field. The text will be centered vertically in the field. The default value is "".

-tile image

Specifies an image that will be tiled over the field background is the field is filled. This attribute has precedence over the -fillpattern attribute. The default value is "".

-visible boolean

Specifies if the field is displayed. The default value is true.

[front]