next up previous contents index
Next: 6. Configuring the widget Up: II. Widget Commands Previous: II. Widget Commands   Contents   Index

5. Widget commands overview

After a new sgml widget has been created with the sgml pathname command, widget commands are be used to communicate with the new widget. When a new sgml widget is created with the command sgml pathname, a new Tcl command is established where the name of the command equals the pathname of the new sgml widget.

Widget commands are used to communicate with an existing sgml widget. For example, if you create a new sgml widget with the widget pathname .s, a new Tcl command .s is created that can be used to talk to the sgml widget with the pathname .s. Widget commands are passed as arguments to the .s Tcl command that tell the sgml widget which operations should be performed.

The following command creates a new sgml widget with the widget pathname .s and a new Tcl command .s for communicating with this widget:

  sgml .s

The Tcl command .s can then be used to tell the sgml widget what to do. The requested operation must be a widget command that is understood by the sgml widget. The following command tells the sgml widget .s to load the document example1.sgml by using the load widget command:

  .s load example1.sgml

In this example, the file name example1.sgml for the document is passed as an argument to the load widget command.

5.1 Specifying arguments for widget commands

Most widget commands require additional arguments. This section describes the general types of arguments that can be used with widget commands.


5.1.1 Boolean values

Boolean values are used to express the logical truth values true and false. Boolean values can be expressed as a string that has any of the following forms:

Any of these values may be abbreviated, and upper-case spellings are also acceptable.


5.1.2 Indices

Many of the widget commands for sgml widgets take one or more indices as arguments. An index is a string used to indicate a particular place within a text, such as a place to insert characters or one endpoint of a range of characters to delete. Indices have the syntax

base modifier modifier modifier ...

Where base gives a starting point and the modifiers adjust the index from the starting point (e.g. move forward or backward one character). Every index must contain a base but the modifiers are optional.

The base for an index must have one of the following forms:

If the base could match more than one of the above forms, then the form earlier in the above list takes precedence.

If modifiers follow the base index, each one of them must have one of the forms listed below. Keywords such as chars and wordend may be abbreviated as long as the abbreviation is unambiguous.

If more than one modifier is present then they are applied in left-to-right order. For example, the index end - 1 chars refers to the next-to-last character in the text and insert wordstart - 1 c refers to the character just before the first one in the word containing the insertion cursor.


5.1.3 Colors

5.1.4 Fonts

In the sgml widget, there exists a basic distinction between fonts whichs properties are determined at runtime because of the structure of an SGML document and fonts that are completely specified by the user (or the application).

Fonts of the first type (dynamic fonts) are constructed from different parts of the font description that is collected from various sources. Typically, these bits of information are provided as the values for -family, -size, -weight, and -slant configuration options for SGML elements. Dynamic fonts are constructed when they are needed by combining these pieces of information. Section [*] contains a description of the internals of this combination process.

Fonts of the second type (we call them static fonts) are completely determined by the user (with the possible exception that font details that have not been specified are defaulted by the Tk font system). Typically, static fonts appear as the value of a -font configuration option. See the Tk documentation for a description of the several ways in which fonts may be specified.


5.1.5 Screen distances

Screen distances are expressed by a string that specifies the screen distance as a floating-point number followed by one of the following characters that indicates units:


5.1.6 Bitmaps

Bitmaps are mainly used for combining the background or foreground of text in the sgml widget with a bitmap to alter the visual appearance of the text by stippling.

When a bitmap must be specified as a the value of a configuration option or as a parameter to a widget command, the name of an existing bitmap must be used.

Tk provides a set of predefined bitmaps that are useful for stippling:

In addition to these predefined bitmaps, user-defined bitmaps can be used by specifying their name or by providing the name of a file containing the bitmap in standard X10 or X11 format in the form @filename. Please refer to the Tk documentation for details about defining new bitmaps.


5.1.7 Reliefs

Some widget commands and configuration options expect a relief specification to determine how to draw a 3-D effect. Acceptable relief values are raised, sunken, flat, ridge, solid, and groove.

5.1.8 Handles

Handles are Tcl tokens that are used to manipulate certain objects in the sgml widget, e.g. elements or marked sections. Handles must be obtained from the sgml widget and can not be arbitrarily constructed.

Handles belong to individual instances of the sgml widget and can only be used in the widget that has created the handle. If two or more sgml widgets are created in an application, a handle that has been returned from one of these widgets is not valid in any of the other sgml widgets.


next up previous contents index
Next: 6. Configuring the widget Up: II. Widget Commands Previous: II. Widget Commands   Contents   Index
TkSGML Reference Manual