Next | Prev | Up | Top | Contents | Index
The Root Widget
Motif is built upon Xt. The Xt world must be brought into existence explicitly. This allows setting of class and fallback resources, and leaves hooks for things like setting the icon later in the binding. The Xt startup function is XtAppInitialize.
- xtAppInitialize
- This can take parameters of -class and -fallback_resources. If the class option is omitted, Tm will deduce a class by capitalizing the first letter of the application name, and also the second letter if it follows an x.
Several root widget methods exist to deal with Motif features related only to the main application window:
- . mainLoop
- Start the main application loop, waiting for and managing events.
- . getAppResources resource_list
-
Get the application resources. Argument resource_list is a Tcl list of quadruples {name class default var}, where name is the resource name, and class the resource class. For each resource, this method searches for a value in the application default or in the resource database, and sets the Tcl variable var accordingly. If not found, it sets var to default.
- . processEvent
- Process a single event, blocking if none are present. This is useful only if you want to design your own main event loop.
- . addInput fileId perm tclProc
-
This adds an input handler to moat. Argument variable fileId may be either stdin, stdout, stderr, or a valid opened file as returned by open(). Argument variable perm is a single character permission, which might be r, w, or x to indicate read, write, or execute permission, respectively. Argument tclProc is Tcl code that is to be executed when I/O is ready.
For example, the following code adds an interpreter that reads and executes moat commands that are typed in while the interface is running:
# Define the interpret function, that handles errors.
proc interpret {line} {
set code [catch $line result]
if {$code == 1} then {
puts stderr "$result in :\n\t$line"
} else {
if { $result != "" } { puts stderr $result }
}
puts stderr " " nonewline
}
# Bind it as an input handler.
.addInput stdin r {
interpret [gets stdin]
}
# And display the first prompt
puts stderr "%" nonewline
The list below describes additional root widget methods for Motif features related to the main application window:
- . removeInput inputId
-
Remove the input handler specified by the given identifier. Identifiers are unique strings returned by the corresponding addInput call.
- . addTimer interval tclProc
-
Add a timer that triggers the execution of the given Tcl procedure after the specified interval.
- . removeTimer timerId
-
Remove the timer specified by the given identifier timerID, which is a unique string returned by the corresponding call to addTimer.
Next | Prev | Up | Top | Contents | Index