7. Intrinsic Library - Xt ©


The Intrinsics are a programming library tailored to the special requirements of user interface construction within a network window system, specifically the X Window System. The Intrinsics and a widget set make up an X Toolkit.

The Intrinsics provide the base mechanism necessary to build a wide variety of interoperating widget sets and application environments. The Intrinsics are a layer on top of Xlib, the C Library X Interface. They extend the fundamental abstractions provided by the X Window System while still remaining independent of any particular user interface policy or style.

The Intrinsics use object-oriented programming techniques to supply a consistent architecture for constructing and composing user interface components, known as widgets. This allows programmers to extend a widget set in new ways, either by deriving new widgets from existing ones (subclassing), or by writing entirely new widgets following the established conventions.

When the Intrinsics were first conceived, the root of the object hierarchy was a widget class named Core. In release 4 of the Intrinsics, three nonwidget superclasses were added above Core. The name of the class now at the root of the Intrinsics class hierarchy is Object. The remainder of this specification refers uniformly to widgets and Core as if they were the base class for all Intrinsics operations.

The Intrinsics are intended to be used for two programming purposes. Programmers writing widgets will be using most of the facilities provided by the Intrinsics to construct user interface components from the simple, such as buttons and scrollbars, to the complex, such as control panels and property sheets. Application programmers will use a much smaller subset of the Intrinsics procedures in combination with one or more sets of widgets to construct and present complete user interfaces on an X display. The Intrinsics programming interfaces primarily intended for application use are designed to be callable from most procedural programming languages. Therefore, most arguments are passed by reference rather than by value. The interfaces primarily intended for widget programmers are expected to be used principally from the C language. In these cases, the usual C programming conventions apply. In this specification, the term client refers to any module, widget, or application that calls an Intrinsics procedure.

Applications that use the Intrinsics mechanisms must include the header files <X11/Intrinsic.h> and <X11/StringDefs.h>, or their equivalent, and they may also include <X11/Xatoms.h> and <X11/Shell.h>. In addition, widget implementations should include <X11/IntrinsicP.h> instead of <X11/Intrinsic.h>. The applications must also include the additional header files for each widget class that they are to use (for example, <X11/Xaw/Label.h> or <X11/Xaw/Scrollbar.h>). On a POSIX-based system, the Intrinsics object library file is named libXt.a and is usually referenced as - lXt when linking the application.

The fundamental abstraction and data type of the X Toolkit is the widget, which is a combination of an X window and its associated input and display semantics and which is dynamically allocated and contains state information. Some widgets display information (for example, text or graphics), and others are merely containers for other widgets (for example, a menu box). Some widgets are output-only and do not react to pointer or keyboard input, and others change their display in response to input and can invoke functions that an application has attached to them.

Every widget belongs to exactly one widget class, which is statically allocated and initialized and which contains the operations allowable on widgets of that class. Logically, a widget class is the procedures and data associated with all widgets belonging to that class. These procedures and data can be inherited by subclasses. Physically, a widget class is a pointer to a structure. The contents of this structure are constant for all widgets of the widget class but will vary from class to class. (Here, ``constant'' means the class structure is initialized at compile time and never changed, except for a one-time class initialization and in-place compilation of resource lists, which takes place when the first widget of the class or subclass is created.)

The distribution of the declarations and code for a new widget class is amongst a public .h file for application programmer use, a private .h file for widget programmer use, and the implementation .c file. The predefined widget classes adhere to these conventions.


 
 A widget instance is composed of two parts:

  `A data structure which contains instance-specific values.'
  `A class structure which contains information that is applicable
     to all widgets of that class.'




Much of the input/output of a widget (for example, fonts, colors, sizes, border widths, and so on) is customizable by users.


7.1. Intrinsic Widget Library - Xaw

The X Toolkit is made up of two distinct pieces, the Xt Intrinsics and a widget set. The Athena widget set is a sample implementation of a widget set built upon the Intrinsics. In the X Toolkit, a widget is the combination of an X window or subwindow and its associated input and output semantics.

Because the Intrinsics provide the same basic functionality to all widget sets it may be possible to use widgets from the Athena widget set with other widget sets based upon the Intrinsics. Since widget sets may also implement private protocols, all functionality may not be available when mixing and matching widget sets. For information about the Intrinsics, see the X Toolkit Intrinsics - C Language Interface.

The Athena widget set is a library package layered on top of the Intrinsics and Xlib that provides a set of user interface tools sufficient to build a wide variety of applications. This layer extends the basic abstractions provided by X and provides the next layer of functionality primarily by supplying a cohesive set of sample widgets. Although the Intrinsics are a Consortium standard, there is no standard widget set.

To the extent possible, the Intrinsics are "policy-free". The application environment and widget set, not the Intrinsics, define, implement, and enforce:


 
  Policy
  Consistency
  Style
                                                                 



Each individual widget implementation defines its own policy. The X Toolkit design allows for, but does not necessarily encourage, the free mixing of radically differing widget implementations. The X Toolkit provides tools that simplify the design of application user interfaces in the X Window System programming environment. It assists application programmers by providing a set of common underlying user- interface functions. It also lets widget programmers modify existing widgets, by subclassing, or add new widgets. By using the X Toolkit in their applications, programmers can present a similar user interface across applications to all workstation users.

The X Toolkit consists of:


 
  A set of Intrinsics functions for building widgets
  An architectural model for constructing widgets
  A widget set for application programming
                                                                 



While the majority of the Intrinsics functions are intended for the widget programmer, a subset of the Intrinsics functions are to be used by application programmers (see X Toolkit Intrinsics - C Language Interface). The architectural model lets the widget programmer design new widgets by using the Intrinsics and by combining other widgets. The application interface layers built on top of the X Toolkit include a coordinated set of widgets and composition policies. Some of these widgets and policies are specific to a single application domain, and others are common to a variety of applications.


7.2. Terminology

In addition to the terms already defined for X programming (see Xlib - C Language X Interface), a set of terms which are specific to the Intrinsics and Athena widget set are used throughout this document. The details are given here.


7.3. Underlying Model

The underlying architectural model is based on the following premises:


`Widgets are X windows'
  • Every user-interface widget is associated with an X window. `The X window ID for a widget is readily available from the widget. Standard Xlib calls can be used by widgets for many of their input and output operations.'
`Information hiding'
  • The data for every widget is private to the widget and its subclasses. `That is, the data is neither directly accessible nor visible outside of the module implementing the widget. All program interaction with the widget is performed by a set of operations (methods) that are defined for the widget.'
`Widget semantics and widget layout geometry'
  • Widget semantics are clearly separated from widget layout geometry. Widgets are concerned with implementing specific user-interface semantics. `They have little control over issues such as their size or placement relative to other widget peers. Mechanisms are provided for associating geometric managers with widgets and for widgets to make suggestions about their own geometry.'



7.4. Input Focus

The Intrinsics define a resource on all Shell widgets that interact with the window manager called input. This resource requests the assistance of window manager in acquiring the input focus. The resource defaults to False in the Intrinsics, but is redefined to default to True when an application is using the Athena widget set. An application programmer may override this default and set the resource back to False if the application does not need the window manager to give it the input focus. See the X Toolkit Intrinsics - C Language Interface for details on the input resource.


7.5. Using Widgets

Widgets serve as the primary tools for building a user interface or application environment. The Athena widget set consists of primitive widgets that contain no children (for example, a command button) and composite widgets which may contain one or more widget children (for example, a Box widget).