1.1. Introduction to the X Toolkit
1.2. Terminology
1.3. Underlying Model
1.4. Conventions Used in this Manual
1.5. Format of the Widget Reference Chapters
1.6. Input FocusThe Intrinsics define a resource on all Shell widgets thatinteract with the window manager called input. Thisresource requests the assistance of window manager inacquiring the input focus. The resource defaults to Falsein the Intrinsics, but is redefined to default to True whenan application is using the Athena widget set. Anapplication programmer may override this default and set theresource back to False if the application does not need thewindow manager to give it the input focus. See the XToolkit Intrinsics — C Language Interface for details on theinput resource.
2.1. Setting the Locale
2.2. Initializing the Toolkit
2.3. Creating a Widget
2.4. Common ResourcesAlthough a widget can have unique arguments that itunderstands, all widgets have common arguments that providesome regularity of operation. The common arguments allowarbitrary widgets to be managed by higher-level componentswithout regard for the individual widget type. Widgets willignore any argument that they do not understand.The following resources are retrieved from the argument listor from the resource database by all of the Athena widgets:The following additional resources are retrieved from theargument list or from the resource database by many of theAthena widgets:2.5. Resource ConversionsMost resources in the Athena widget set have a converterregistered that will translate the string in a resource fileto the correct internal representation. While some areobvious (string to integer, for example), others needspecific mention of the allowable values. Three generalconverters are described here:• Cursor• Pixel• BitmapMany widgets have defined special converters that apply onlyto that widget. When these occur, the documentation sectionfor that widget will describe the converter.2.5.1. Cursor Conversion
2.5.2. Pixel Conversion
2.5.3. Bitmap Conversion
2.6. Realizing a Widget
2.7. Processing Events
2.8. Standard Widget Manipulation FunctionsAfter a widget has been created, a client can interact withthat widget by calling one of the standard widgetmanipulation routines provided by the Intrinsics, or awidget class-specific manipulation routine.The Intrinsics provide generic routines to give theapplication programmer access to a set of standard widgetfunctions. The common widget routines let an application orcomposite widget perform the following operations on widgetswithout requiring explicit knowledge of the widget type.• Control the mapping of widget windows• Destroy a widget instance• Obtain an argument value• Set an argument value2.8.1. Mapping Widgets
2.8.2. Destroying Widgets
2.8.3. Retrieving Widget Resource Values
2.8.4. Modifying Widget Resource Values
2.9. Using the Client Callback Interface
2.10. Programming Considerations
2.10.1. Writing Applications
2.10.2. Changing Resource Values
2.10.2.1. Specifying Resources
2.10.2.2. Creating Argument Lists
2.11. Example ProgramsThe best way to understand how to use any programminglibrary is by trying some simple examples. A collection ofexample programs that introduces each of the widgets in thatAthena widget set, as well as many important toolkitprogramming concepts, is available in the X11R6 release asdistributed by the X Consortium. It can be found in thedistribution directory contrib/examples/mit/Xaw, but seeyour site administrator for the exact location of thesefiles on your system. See the README file from thatdirectory for a guide to the examples.
3.1. Command WidgetApplication header file<X11/Xaw/Command.h>Class header file <X11/Xaw/CommandP.h>Class commandWidgetClassClass Name CommandSuperclass LabelThe Command widget is an area, often rectangular, thatcontains text or a graphical image. Command widgets areoften referred to as ‘‘push buttons.’’ When the pointer isover a Command widget, the widget becomes highlighted bydrawing a rectangle around its perimeter. This highlightingindicates that the widget is ready for selection. Whenmouse button 1 is pressed, the Command widget indicates thatit has been selected by reversing its foreground andbackground colors. When the mouse button is released, theCommand widget’s notify action is invoked, calling allfunctions on its callback list. If the pointer is moved offof the widget before the pointer button is released, thewidget reverts to its normal foreground and backgroundcolors, and releasing the pointer button has no effect.This behavior allows the user to cancel an action.3.1.1. Resources
3.1.2. Command Actions
3.2. Grip WidgetApplication header file<X11/Xaw/Grip.h>Class header file <X11/Xaw/GripP.h>Class gripWidgetClassClass Name GripSuperclass SimpleThe Grip widget provides a small rectangular region in whichuser input events (such as ButtonPress or ButtonRelease) maybe handled. The most common use for the Grip widget is asan attachment point for visually repositioning an object,such as the pane border in a Paned widget.3.2.1. Resources
3.2.2. Grip Actions
3.3. Label WidgetApplication header file<X11/Xaw/Label.h>Class header file <X11/Xaw/LabelP.h>Class labelWidgetClassClass Name LabelSuperclass SimpleA Label widget holds a graphic displayed within arectangular region of the screen. The graphic may be a textstring containing multiple lines of characters in an 8 bitor 16 bit character set (to be displayed with a font), or ina multi-byte encoding (for use with a fontset). The graphicmay also be a bitmap or pixmap. The Label widget will allowits graphic to be left, right, or center justified.Normally, this widget can be neither selected nor directlyedited by the user. It is intended for use as an outputdevice only.3.3.1. Resources
3.4. List Widget
3.4.1. Resources
3.4.2. List Actions
3.4.3. List Callbacks
3.4.4. Changing the List
3.4.5. Highlighting an Item
3.4.6. Unhighlighting an Item
3.4.7. Retrieving the Currently Selected Item
3.4.8. Restrictions
3.5. Panner Widget
3.5.1. Resources
3.5.2. Panner Actions
3.5.3. Panner Callbacks
3.6. Repeater WidgetApplication header file<X11/Xaw/Repeater.h>Class header file <X11/Xaw/RepeaterP.h>Class repeaterWidgetClassClass Name RepeaterSuperclass CommandThe Repeater widget is a subclass of the Command widget; seethe Command documentation for details. The difference isthat the Repeater can call its registered callbacksrepeatedly, at an increasing rate. The default translationdoes so for the duration the user holds down pointer button1 while the pointer is on the Repeater.3.6.1. Resources
3.6.2. Repeater Actions
3.7. Scrollbar Widget
3.7.1. Resources
3.7.2. Scrollbar Actions
3.7.3. Scrollbar Callbacks
3.7.4. Convenience Routines
3.7.5. Setting Float Resources
3.8. Simple WidgetApplication Header file<Xaw/Simple.h>Class Header file <Xaw/SimpleP.h>Class simpleWidgetClassClass Name SimpleSuperclass CoreThe Simple widget is not very useful by itself, as it has nosemantics of its own. It main purpose is to be used as acommon superclass for the other simple Athena widgets. Thiswidget adds six resources to the resource list provided bythe Core widget and its superclasses.3.8.1. Resources
3.9. StripChart WidgetApplication Header file<Xaw/StripChart.h>Class Header file <Xaw/StripCharP.h>Class stripChartWidgetClassClass Name StripChartSuperclass SimpleThe StripChart widget is used to provide a roughly real timegraphical chart of a single value. For example, it is usedby the common client program xload to provide a graph ofprocessor load. The StripChart reads data from anapplication, and updates the chart at the update intervalspecified.3.9.1. Resources
3.9.2. Getting the StripChart Value
3.10. Toggle WidgetApplication Header file<Xaw/Toggle.h>Class Header file <Xaw/ToggleP.h>Class toggleWidgetClassClass Name ToggleSuperclass CommandThe Toggle widget is an area, often rectangular, thatdisplays a graphic. The graphic may be a text stringcontaining multiple lines of characters in an 8 bit or 16bit character set (to be displayed with a font), or in amulti-byte encoding (for use with a fontset). The graphicmay also be a bitmap or pixmap.This widget maintains a Boolean state (e.g. True/False orOn/Off) and changes state whenever it is selected. When thepointer is on the Toggle widget, the Toggle widget maybecome highlighted by drawing a rectangle around itsperimeter. This highlighting indicates that the Togglewidget is ready for selection. When pointer button 1 ispressed and released, the Toggle widget indicates that ithas changed state by reversing its foreground and backgroundcolors, and its notify action is invoked, calling allfunctions on its callback list. If the pointer is moved offof the widget before the pointer button is released, theToggle widget reverts to its previous foreground andbackground colors, and releasing the pointer button has noeffect. This behavior allows the user to cancel theoperation.Toggle widgets may also be part of a ‘‘radio group.’’ Aradio group is a list of at least two Toggle widgets inwhich no more than one Toggle may be set at any time. Aradio group is identified by the widget ID of any one of itsmembers. The convenience routine XawToggleGetCurrent willreturn information about the Toggle widget in the radiogroup.Toggle widget state is preserved across changes insensitivity.3.10.1. Resources
3.10.2. Toggle Actions
3.10.3. Toggle Actions
3.10.4. Radio Groups
3.10.5. Convenience Routines
3.10.5.1. Changing the Toggle’s Radio Group.
Finding the Currently selected Toggle in a radio group ofToggles
Changing the Toggle that is set in a radio group.
Unsetting all Toggles in a radio group.
4.1. Using the MenusThe default configuration for the menus ispress-drag-release. The menus will typically be activatedby clicking a pointer button while the pointer is over aMenuButton, causing the menu to appear in a fixed locationrelative to that button; this is a pulldown menu. Menus mayalso be activated when a specific pointer and/or keysequence is used anywhere in the application; this is apopup menu (e.g. clicking Ctrl-<pointer button 1> in thecommon application xterm). In this case the menu should bepositioned under the cursor. Typically menus will be placedso the pointer cursor is on the first menu entry, or thelast entry selected by the user.The menu remains on the screen as long as the pointer buttonis held down. Moving the pointer will highlight differentmenu items. If the pointer leaves the menu, or moves overan entry that cannot be selected then no menu entry willhighlighted. When the desired menu entry has beenhighlighted, releasing the pointer button removes the menu,and causes any mechanism associated with this entry to beinvoked.4.2. SimpleMenu WidgetApplication Header file<X11/Xaw/SimpleMenu.h>Class Header file <X11/Xaw/SimpleMenP.h>Class simpleMenuWidgetClassClass Name SimpleMenuSuperclass OverrideShellThe SimpleMenu widget is a container for the menu entries.It is a direct subclass of shell, and is should be createdwith XtCreatePopupShell, not XtCreateManagedWidget. This isthe only part of the menu that actually is associated with awindow. The SimpleMenu serves as the glue to bind theindividual menu entries together into a menu.4.2.1. Resources
4.2.2. SimpleMenu Actions
4.2.3. Positioning the SimpleMenu
4.2.4. Convenience Routines
4.2.4.1. Registering the Global Action Routines
4.2.4.2. Getting and Clearing the Current Menu Entry
4.3. SmeBSB Object
4.3.1. Resources
4.4. SmeLine Object
4.4.1. Resources
4.5. Sme Object
4.5.1. Resources
4.5.2. Subclassing the Sme Object
4.6. MenuButton WidgetApplication Header file<X11/Xaw/MenuButton.h>Class Header file <X11/Xaw/MenuButtonP.h>Class menuButtonWidgetClassClass Name MenuButtonSuperclass CommandThe MenuButton widget is an area, often rectangular, thatdisplays a graphic. The graphic may be a text stringcontaining multiple lines of characters in an 8 bit or 16bit character set (to be displayed with a font), or in amulti-byte encoding (for use with a fontset). The graphicmay also be a bitmap or pixmap.When the pointer cursor is on a MenuButton widget, theMenuButton becomes highlighted by drawing a rectangle aroundits perimeter. This highlighting indicates that theMenuButton is ready for selection. When a pointer button ispressed, the MenuButton widget will pop up the menu named inthe menuName resource.4.6.1. Resources
4.6.2. MenuButton Actions
4.6.3. MenuButton Actions
5.1. Text Widget for UsersThe Text widget provides many of the common keyboard editingcommands. These commands allow users to move around andedit the buffer. If an illegal operation is attempted,(such as deleting characters in a read-only text widget),the X server will beep.5.1.1. Default Key Bindings
5.1.2. Search and Replace
5.1.3. File Insertion
5.1.4. Text Selections for Users
5.2. Text Widget Actions
5.2.1. Cursor Movement Actions
5.2.2. Delete Actions
5.2.3. Selection Actions
5.2.4. The New Line Actions
5.2.5. Kill and Actions
5.2.6. Miscellaneous Actions
5.2.7. Text Selections for Application Programmers
5.3. Default Translation Bindings
5.4. Text FunctionsThe following functions are provided as convenience routinesfor use with the Text widget. Although many of theseactions can be performed by modifying resources, theseinterfaces are frequently more efficient.These data structures are defined in the Text widget’spublic header file, <X11/Xaw/Text.h>.typedef long XawTextPosition;Character positions in the Text widget begin at 0 and end atn, where n is the number of characters in the Text sourcewidget.typedef struct {int firstPos;int length;char *ptr;unsigned long format;} XawTextBlock, *XawTextBlockPtr;firstPos The first position, or index, to use within theptr field. The value is commonly zero.length The number of characters to be used from the ptrfield. The number of characters used is commonlythe number of characters in ptr, and must not begreater than the length of the string in ptr.ptr Contains the string to be referenced by the Textwidget.format This flag indicates whether the data pointed to byptr is char or wchar_t. When the associatedwidget has international set to false this fieldmust be XawFmt8Bit. When the associated widgethas international set to true this field must beeither XawFmt8Bit or XawFmtWide.Note: Previous versions of Xaw used FMT8BIT, which has beenretained for backwards compatibility. FMT8BIT is deprecatedand will eventually be removed from the implementation.5.4.1. Selecting Text
5.4.2. Unhighlighting Text
5.4.3. Getting Current Text Selection
5.4.4. Replacing Text
5.4.5. Searching for Text
5.4.6. Redisplaying Text
5.4.7. Resources Convenience Routines
5.5. Ascii Text Widget
5.5.1. Resources
5.6. Ascii Source Object and Multi Source Object
5.6.1. Resources
5.6.2. Convenience Routines
5.6.2.1. Conserving Memory
5.6.2.2. Saving Files
5.6.2.3. Seeing if the Source has Changed
5.7. Ascii Sink Object and Multi Sink Object
5.7.1. Resources
5.8. Customizing the Text Widget
5.9. Text Widget
5.9.1. Resources
5.10. TextSrc Object
5.10.1. Resources
5.10.2. Subclassing the TextSrc
5.10.2.1. Reading Text.
5.10.2.2. Replacing Text.
5.10.2.3. Scanning the TextSrc
5.10.2.4. Searching through a TextSrc
5.10.2.5. Text Selections
5.11. TextSink Object
5.11.1. Resources
5.11.2. Subclassing the TextSink
5.11.2.1. Displaying Text
5.11.2.2. Displaying the Insert Point
5.11.2.3. Clearing Portions of the Text window
5.11.2.4. Finding a Text Position Given Pixel Values
5.11.2.5. Finding the Distance Between two Text Positions
5.11.2.6. Finding the Size of the Drawing area
5.11.2.7. Setting the Tab Stops
5.11.2.8. Getting the Insert Point’s Size and Location
6.0.1. A Brief Note on Geometry Management
6.1. Box Widget
6.1.1. Resources
6.1.2. Layout Semantics
6.2. Dialog Widget
6.2.1. Resources
6.2.2. Constraint Resources
6.2.3. Layout Semantics
6.2.3.1. Example
6.2.3.2. Special Considerations
6.2.4. Automatically Created Children.
6.2.5. Convenience Routines
6.3. Form Widget
6.3.1. Resources
6.3.2. Constraint Resources
6.3.3. Layout Semantics
6.3.3.1. Example
6.3.4. Convenience Routines
6.4. Paned Widget
6.4.1. Using the Paned Widget
6.4.2. Resources
6.4.3. Constraint Resources
6.4.4. Layout Semantics
6.4.4.1. Resizing Panes from a Grip Action
6.4.4.2. Resizing Panes after the Paned widget is resized.
6.4.4.3. Managing Children and Geometry Management
6.4.4.4. Special Considerations
6.4.5. Grip Translations
6.4.6. Convenience Routines
6.5. Porthole Widget
6.5.1. Resources
6.5.2. Layout Semantics
6.5.3. Porthole Callbacks
6.6. Tree Widget
6.6.1. Resources
6.6.2. Constraint Resources
6.6.3. Layout Semantics
6.6.4. Convenience Routines
6.7. Viewport Widget
6.7.1. Resources
6.7.2. Layout Semantics
7.1. Public Header File
7.2. Private Header File
7.3. Widget Source File

Athena Widget Set — C Language Interface

X Window System

X Version 11, Release 6.4

Chris D. Peterson
formerly MIT X Consortium

X Window System is a trademark of X Consortium, Inc.

Copyright © 1985, 1986, 1987, 1988, 1989, 1991, 1994 X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘‘Software’’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘‘AS IS’’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.

Copyright © 1985, 1986, 1987, 1988, 1989, 1991 Digital Equipment Corporation, Maynard, Massachusetts.

Permission to use, copy, modify and distribute this documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Digital makes no representations about the suitability of the software described herein for any purpose. It is provided ‘‘as is’’ without express or implied warranty.

Acknowledgments

Many thanks go to Ralph Swick (Project Athena / Digital) who has contributed much time and effort to this widget set. Previous versions of the widget set are largely due to his time and effort. Many of the improvements that I have been able to make are because he provided a solid foundation to build upon. While much of the effort has been Ralph’s, many other people have contributed to the code.

Mark Ackerman (formerly Project Athena)
Donna Converse (MIT X Consortium)
Jim Fulton (formerly MIT X Consortium)
Loretta Guarino-Reid (Digital WSL)
Charles Haynes (Digital WSL)
Rich Hyde (Digital WSL)
Mary Larson (Digital UEG)
Joel McCormack (Digital WSL)
Ron Newman (formerly Project Athena)
Jeanne Rich (Digital WSL)
Terry Weissman (formerly Digital WSL)

While not much remains of the X10 toolkit, many of the ideas for this widget set come from that original version. The design and implementation of the X10 toolkit were done by:

Mike Gancarz (formerly Digital UEG)
Charles Haynes (Digital WSL)
Phil Karlton (formerly Digital WSL)
Kathleen Langone (Digital UEG)
Mary Larson (Digital UEG)
Ram Rao (Digital UEG)
Smokey Wallace (formerly Digital WSL)
Terry Weissman (formerly Digital WSL)

I have used the formatting ideas, and some of the words from previous versions of this document. The X11R3 Athena widget document was written by:

Ralph R. Swick (Project Athena/ Digital)
Terry Weissman (formerly Digital WSL)
Al Mento (Digital UEG)

Putting this manual together was a major task in and of itself. I would like to thank Ralph Swick, Donna Converse, and Jim Fulton for taking the time to help convert my technical knowledge into legible text. A special thanks to Jean Diaz (O’Reilly and Associates) for spending nearly a month with me working out all the annoying little details.

Chris D. Peterson
MIT X Consortium 1989

The R5 edition of this document has been edited by the research staff of the MIT X Consortium, with significant contributions by Jim Fulton (NCD).

Donna Converse
MIT X Consortium 1991

The R6 edition of this document has been edited to reflect changes brought about by research staff of the Omron Corporation, with special recognition to Li Yuhong, Seiji Kuwari, and Hiroshi Kuribayashi for the X11R5/contrib/lib/Xaw internationalization that inspired this version.

Frank Sheeran
Omron Corporation 1994

Chapter 1

Athena Widgets and The Intrinsics

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.

1.1. Introduction to the X Toolkit

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.

The remainder of this chapter discusses the X Toolkit and Athena widget set:

Terminology

Model

Conventions used in this manual

Format of the Widget Reference Chapters

1.2. Terminology

In addition to the terms already defined for X programming (see Xlib — C Language X Interface), the following terms are specific to the Intrinsics and Athena widget set and used throughout this document.

Application programmer

A programmer who uses the X Toolkit to produce an application user interface.

Child

A widget that is contained within another "parent" widget.

Class

The general group to which a specific object belongs.

Client

A function that uses a widget in an application or for composing other widgets.

FullName

The name of a widget instance appended to the full name of its parent.

Instance

A specific widget object as opposed to a general widget class.

Method

A function or procedure implemented by a widget class.

Name

The name that is specific to an instance of a widget for a given client. This name is specified at creation time and cannot be modified.

Object

A data abstraction consisting of private data and private and public functions that operate on the private data. Users of the abstraction can interact with the object only through calls to the object’s public functions. In the X Toolkit, some of the object’s public functions are called directly by the application, while others are called indirectly when the application calls the common Intrinsics functions. In general, if a function is common to all widgets, an application uses a single Intrinsics function to invoke the function for all types of widgets. If a function is unique to a single widget type, the widget exports the function.

Parent

A widget that contains at least one other ("child") widget. A parent widget is also known as a composite widget.

Resource

A named piece of data in a widget that can be set by a client, by an application, or by user defaults.

Superclass

A larger class of which a specific class is a member. All members of a class are also members of the superclass.

User

A person interacting with a workstation.

Widget

An object providing a user-interface abstraction (for example, a Scrollbar widget).

Widget class

The general group to which a specific widget belongs, otherwise known as the type of the widget.

Widget programmer

A programmer who adds new widgets to the X Toolkit.

1.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.

1.4. Conventions Used in this Manual

All resources available to the widgets are listed with each widget. Many of these are available to more than one widget class due to the object oriented nature of the Intrinsics. The new resources for each widget are listed in bold text, and the inherited resources are listed in plain text.

Global symbols are printed in bold and can be function names, symbols defined in include files, or structure names. Arguments are printed in italics.

Each function is introduced by a general discussion that distinguishes it from other functions. The function declaration itself follows, and each argument is specifically explained. General discussion of the function, if any is required, follows the arguments. Where applicable, the last paragraph of the explanation lists the return values of the function.

To eliminate any ambiguity between those arguments that you pass and those that a function returns to you, the explanations for all arguments that you pass start with the word specifies or, in the case of multiple arguments, the word specify. The explanations for all arguments that are returned to you start with the word returns or, in the case of multiple arguments, the word return. The explanations for all arguments that you can pass and are returned start with the words specifies and returns.

Any pointer to a structure that is used to return a value is designated as such by the _return suffix as part of its name. All other pointers passed to these functions are used for reading only. A few arguments use pointers to structures that are used for both input and output and are indicated by using the _in_out suffix.

1.5. Format of the Widget Reference Chapters

The majority of this document is a reference guide for the Athena widget set. Chapters three through six give the programmer all information necessary to use the widgets. The layout of the chapters follows a specific pattern to allow the programmer to easily find the desired information.

The first few pages of every chapter give an overview of the widgets in that section. Widgets are grouped into chapters by functionality.

Chapter 3
Simple Widgets
Chapter 4
Menus
Chapter 5
Text Widgets
Chapter 6
Composite and Constraint Widget

Following the introduction will be a description of each widget in that chapter. When no functional grouping is obvious the widgets are listed in alphabetical order, such as in chapters three and six.

The first section of each widget’s description is a table that contains general information about this widget class. Here is the table for the Box widget, and an explanation of all the entries.

Application Header file<X11/Xaw/Box.h>

Class Header file <X11/Xaw/BoxP.h>
Class boxWidgetClass
Class Name Box
Superclass Composite
Application Header File
This file must be included when an application uses this widget. It usually contains the class definition, and some resource macros. This is often called the ‘‘public’’ header file.
Class Header File This file will only be used by widget programmers. It will need to be included by any widget that subclasses this widget. This is often called the ‘‘private’’ header file.

Class

This is the widget class of this widget. This global symbol is passed to XtCreateWidget so that the Intrinsics will know which type of widget to create.

Class Name

This is the resource name of this class. This name can be used in a resource file to match any widget of this class.

Superclass

This is the superclass that this widget class is descended from. If you understand how the superclass works it will allow you to more quickly understand what this widget does, since much of its functionality may be inherited from its superclass.

After this table follows a general description of the default behavior of this widget, as seen by the user. In many cases this functionality may be overridden by the application programmer, or by the user.

The next section is a table showing the name, class, type and default value of each resource that is available to this widget. There is also a column containing notes describing special restrictions placed upon individual resources.

A This resource may be automatically adjusted when another resource is changed.

C

This resource is only settable at widget creation time, and may not be modified with XtSetValues.

D

Do not modify this resource. While setting this resource will work, it can cause unexpected behavior. When this symbol appears there is another, preferred, interface provided by the X Toolkit.

R

This resource is READ-ONLY, and may not be modified.

After the resource table is a detailed description of every resource available to that widget. Many of these are redundant, but printing them with each widget saves page flipping. The names of the resources that are inherited are printed in plain text, while the names of the resources that are new to this class are printed in bold. If you have already read the description of the superclass you need only pay attention to the resources printed in bold.

For each composite widget there is a section on layout semantics that follows the resource description. This section will describe the effect of constraint resources on the layout of the children, as well as a general description of where it prefers to place its children.

Descriptions of default translations and action routines come next, for widgets to which they apply. The last item in each widget’s documentation is the description of all convenience routines provided by the widget.

1.6. Input FocusThe Intrinsics define a resource on all Shell widgets thatinteract with the window manager called input. Thisresource requests the assistance of window manager inacquiring the input focus. The resource defaults to Falsein the Intrinsics, but is redefined to default to True whenan application is using the Athena widget set. Anapplication programmer may override this default and set theresource back to False if the application does not need thewindow manager to give it the input focus. See the XToolkit Intrinsics — C Language Interface for details on theinput resource.

Chapter 2

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).

The remaining chapters explain the widgets that are provided by the Athena widget set. These user-interface components serve as an interface for application programmers who do not want to implement their own widgets. In addition, they serve as a starting point for those widget programmers who, using the Intrinsics mechanisms, want to implement alternative application programming interfaces.

This chapter is a brief introduction to widget programming. The examples provided use the Athena widgets, though most of the concepts will apply to all widget sets. Although there are several programming interfaces to the X Toolkit, only one is described here. A full description of the programming interface is provided in the document X Toolkit Intrinsics — C Language Interface.

2.1. Setting the Locale

If it is desirable that the application take advantage of internationalization (i18n), you must establish locale with XtSetLanguageProc before XtDisplayInitialize or XtAppInitialize is called. For full details, please refer to the document X Toolkit Intrinsics — C Language Interface, section 2.2. However, the following simplest-case call is sufficient in many or most applications.

XtSetLanguageProc(NULL, NULL, NULL);

Most notably, this will affect the Standard C locale, determine which resource files will be loaded, and what fonts will be required of FontSet specifications. In many cases, the addition of this line is the only source change required to internationalize Xaw programs, and will not disturb the function of programs in the default "C" locale.

2.2. Initializing the Toolkit

You must call a toolkit initialization function before invoking any other toolkit routines (besides locale setting, above). XtAppInitialize opens the X server connection, parses the command line, and creates an initial widget that will serve as the root of a tree of widgets created by this application.
Widget XtAppInitialize(app_context_return, application_class, options, num_options,

argc_in_out, argv_in_out, fallback_resources, args, num_args)
XtAppContext *app_context_return;
String application_class;
XrmOptionDescRec options[];
Cardinal num_options;
int *argc_in_out;
String *argv_in_out[];
String *fallback_resources;
ArgList args;
Cardinal num_args;
app_con_return Returns the application context of this application, if non-NULL.

application_class

Specifies the class name of this application, which is usually the generic name for all instances of this application. A useful convention is to form the class name by capitalizing the first letter of the application name. For example, the application named ‘‘xman’’ has a class name of ‘‘Xman’’.

options

Specifies how to parse the command line for any application-specific resources. The options argument is passed as a parameter to XrmParseCommand. For further information, see Xlib — C Language X Interface.

num_options

Specifies the number of entries in the options list.

argc_in_out

Specifies a pointer to the number of command line parameters.

argv_in_out

Specifies the command line parameters.

fallback_resources

Specifies resource values to be used if the site-wide application class defaults file cannot be opened, or NULL.

args

Specifies the argument list to use when creating the Application shell.

num_args

Specifies the number of arguments in args.

This function will remove the command line arguments that the toolkit reads from argc_in_out, and argv_in_out. It will then attempt to open the display. If the display cannot be opened, an error message is issued and XtAppInitialize terminates the application. Once the display is opened, all resources are read from the locations specified by the Intrinsics. This function returns an ApplicationShell widget to be used as the root of the application’s widget tree.

2.3. Creating a Widget

Creating a widget is a three-step process. First, the widget instance is allocated, and various instance-specific attributes are set by using XtCreateWidget. Second, the widget’s parent is informed of the new child by using XtManageChild. Finally, X windows are created for the parent and all its children by using XtRealizeWidget and specifying the top-most widget. The first two steps can be combined by using XtCreateManagedWidget. In addition, XtRealizeWidget is automatically called when the child becomes managed if the parent is already realized.

To allocate, initialize, and manage a widget, use XtCreateManagedWidget.
Widget XtCreateManagedWidget(name, widget_class, parent, args, num_args)
String name;
WidgetClass widget_class;
Widget parent;
ArgList args;
Cardinal num_args;

name Specifies the instance name for the created widget that is used for retrieving widget resources.

widget_class

Specifies the widget class pointer for the created widget.

parent

Specifies the parent widget ID.

args

Specifies the argument list. The argument list is a variable-length list composed of name and value pairs that contain information pertaining to the specific widget instance being created. For further information, see Section 2.7.2.

num_args

Specifies the number of arguments in the argument list. If the num_args is zero, the argument list is never referenced.

When a widget instance is successfully created, the widget identifier is returned to the application. If an error is encountered, the XtError routine is invoked to inform the user of the error.

For further information, see X Toolkit Intrinsics — C Language Interface.

2.4. Common ResourcesAlthough a widget can have unique arguments that itunderstands, all widgets have common arguments that providesome regularity of operation. The common arguments allowarbitrary widgets to be managed by higher-level componentswithout regard for the individual widget type. Widgets willignore any argument that they do not understand.The following resources are retrieved from the argument listor from the resource database by all of the Athena widgets:The following additional resources are retrieved from theargument list or from the resource database by many of theAthena widgets:2.5. Resource ConversionsMost resources in the Athena widget set have a converterregistered that will translate the string in a resource fileto the correct internal representation. While some areobvious (string to integer, for example), others needspecific mention of the allowable values. Three generalconverters are described here:• Cursor• Pixel• BitmapMany widgets have defined special converters that apply onlyto that widget. When these occur, the documentation sectionfor that widget will describe the converter.2.5.1. Cursor Conversion

The value for the cursorName resource is specified in the resource database as a string, and is of the following forms:

A standard X cursor name from < X11/cursorfont.h >. The names in cursorfont.h each describe a specific cursor. The resource names for these cursors are exactly like the names in this file except the XC_ is not used. The cursor definition XC_gumby has a resource name of gumby.

Glyphs, as in FONT font-name glyph-index [[ font-name ] glyph-index ]. The first font and glyph specify the cursor source pixmap. The second font and glyph specify the cursor mask pixmap. The mask font defaults to the source font, and the mask glyph index defaults to the source glyph index.

A relative or absolute file name. If a relative or absolute file name is specified, that file is used to create the source pixmap. Then the string "Mask" is appended to locate the cursor mask pixmap. If the "Mask" file does not exist, the suffix "msk" is tried. If "msk" fails, no cursor mask will be used. If the filename does not start with ’/’ or ’./’ the the bitmap file path is used (see section 2.4.3).

2.5.2. Pixel Conversion

The string-to-pixel converter takes any name that is acceptable to XParseColor (see Xlib — C Language X Interface). In addition this routine understands the special toolkit symbols ‘XtDefaultForeground’ and ‘XtDefaultBackground’, described in X Toolkit Intrinsics — C Language Interface. In short the acceptable pixel names are:

Any color name for the rgb.txt file (typically in the directory /usr/lib/X11 on POSIX systems).

A numeric specification of the form #<red><green><blue> where these numeric values are hexadecimal digits (both upper and lower case).

The special strings ‘XtDefaultForeground’ and ‘XtDefaultBackground’

2.5.3. Bitmap Conversion

The string-to-bitmap converter attempts to locate a file containing bitmap data whose name is specified by the input string. If the file name is relative (i.e. does not begin with / or ./), the directories to be searched are specified in the bitmapFilePath resource--class BitmapFilePath. This resource specifies a colon (:) separated list of directories that will be searched for the named bitmap or cursor glyph (see section 2.4.1). The bitmapFilePath resource is global to the application, and may not be specified differently for each widget that wishes to convert a cursor to bitmap. In addition to the directories specified in the bitmapFilePath resource a default directory is searched. When using POSIX the default directory is /usr/include/X11/bitmaps.

2.6. Realizing a Widget

The XtRealizeWidget function performs two tasks:

Calculates the geometry constraints of all managed descendants of this widget. The actual calculation is put off until realize time for performance reasons.

Creates an X window for the widget and, if it is a composite widget, realizes each of its managed children.

void XtRealizeWidget(w)
Widget w;

w Specifies the widget.

For further information about this function, see the X Toolkit Intrinsics — C Language Interface.

2.7. Processing Events

Now that the application has created, managed and realized its widgets, it is ready to process the events that will be delivered by the X Server to this client. A function call that will process the events is XtAppMainLoop.
void XtAppMainLoop(app_context)
XtAppContext app_context;

app_context
Specifies the application context of this application. The value is normally returned by XtAppInitialize.

This function never returns: it is an infinite loop that processes the X events. User input can be handled through callback procedures and application defined action routines. More details are provided in X Toolkit Intrinsics — C Language Interface.

2.8. Standard Widget Manipulation FunctionsAfter a widget has been created, a client can interact withthat widget by calling one of the standard widgetmanipulation routines provided by the Intrinsics, or awidget class-specific manipulation routine.The Intrinsics provide generic routines to give theapplication programmer access to a set of standard widgetfunctions. The common widget routines let an application orcomposite widget perform the following operations on widgetswithout requiring explicit knowledge of the widget type.• Control the mapping of widget windows• Destroy a widget instance• Obtain an argument value• Set an argument value2.8.1. Mapping Widgets

By default, widget windows are mapped (made viewable) automatically by XtRealizeWidget. This behavior can be disabled by using XtSetMappedWhenManaged, making the client responsible for calling XtMapWidget to make the widget viewable.
void XtSetMappedWhenManaged(w, map_when_managed)
Widget w;
Boolean map_when_managed;

w Specifies the widget.

map_when_managed

Specifies the new value. If map_when_managed is True, the widget is mapped automatically when it is realized. If map_when_managed is False, the client must call XtMapWidget or make a second call to XtSetMappedWhenManaged to cause the child window to be mapped.

The definition for XtMapWidget is:
void XtMapWidget(w)
Widget w;

w Specifies the widget.

When you are creating several children in sequence for a previously realized common parent it is generally more efficient to construct a list of children as they are created (using XtCreateWidget) and then use XtManageChildren to request that their parent managed them all at once. By managing a list of children at one time, the parent can avoid wasteful duplication of geometry processing and the associated ‘‘screen flash’’.
void XtManageChildren(children, num_children)
WidgetList children;
Cardinal num_children;

children Specifies a list of children to add.

num_children

Specifies the number of children to add.

If the parent is already visible on the screen, it is especially important to batch updates so that the minimum amount of visible window reconfiguration is performed.

For further information about these functions, see the X Toolkit Intrinsics — C Language Interface.

2.8.2. Destroying Widgets

To destroy a widget instance of any type, use XtDestroyWidget.
void XtDestroyWidget(w)
Widget w;

w Specifies the widget.

XtDestroyWidget destroys the widget and recursively destroys any children that it may have, including the windows created by its children. After calling XtDestroyWidget, no further references should be made to the widget or any children that the destroyed widget may have had.

2.8.3. Retrieving Widget Resource Values

To retrieve the current value of a resource attribute associated with a widget instance, use XtGetValues.
void XtGetValues(w, args, num_args)
Widget w;
ArgList args;
Cardinal num_args;

w Specifies the widget.

args

Specifies a variable-length argument list of name and address pairs that contain the resource name and the address into which the resource value is stored.

num_args

Specifies the number of arguments in the argument list.

The arguments and values passed in the argument list are dependent on the widget. Note that the caller is responsible for providing space into which the returned resource value is copied; the ArgList contains a pointer to this storage (e.g. x and y must be allocated as Position). For further information, see the X Toolkit Intrinsics — C Language Interface.

2.8.4. Modifying Widget Resource Values

To modify the current value of a resource attribute associated with a widget instance, use XtSetValues.
void XtSetValues(w, args, num_args)
Widget w;
ArgList args;
Cardinal num_args;

w Specifies the widget.

args

Specifies an array of name and value pairs that contain the arguments to be modified and their new values.

num_args

Specifies the number of arguments in the argument list.

The arguments and values that are passed will depend on the widget being modified. Some widgets may not allow certain resources to be modified after the widget instance has been created or realized. No notification is given if any part of a XtSetValues request is ignored.

For further information about these functions, see the X Toolkit Intrinsics — C Language Interface.

Note

The argument list entry for XtGetValues specifies the address to which the caller wants the value copied. The argument list entry for XtSetValues, however, contains the new value itself, if the size of value is less than sizeof(XtArgVal) (architecture dependent, but at least sizeof(long)); otherwise, it is a pointer to the value. String resources are always passed as pointers, regardless of the length of the string.

2.9. Using the Client Callback Interface

Widgets can communicate changes in their state to their clients by means of a callback facility. The format for a client’s callback handler is:
void CallbackProc(w, client_data, call_data)
Widget w;
XtPointer client_data;
XtPointer call_data;

w Specifies widget for which the callback is registered.

client_data

Specifies arbitrary client-supplied data that the widget should pass back to the client when the widget executes the client’s callback procedure. This is a way for the client registering the callback to also register client-specific data: a pointer to additional information about the widget, a reason for invoking the callback, and so on. If no additional information is necessary, NULL may be passed as this argument. This field is also frequently known as the closure.

call_data

Specifies any callback-specific data the widget wants to pass to the client. For example, when Scrollbar executes its jumpProc callback list, it passes the current position of the thumb in call_data.

Callbacks can be registered either by creating an argument containing the callback list described below or by using the special convenience routines XtAddCallback and XtAddCallbacks. When the widget is created, a pointer to a list of callback procedure and data pairs can be passed in the argument list to XtCreateWidget. The list is of type XtCallbackList:

typedef struct {

XtCallbackProc callback;
XtPointer closure;
} XtCallbackRec, *XtCallbackList;

The callback list must be allocated and initialized before calling XtCreateWidget. The end of the list is identified by an entry containing NULL in callback and closure. Once the widget is created, the client can change or de-allocate this list; the widget itself makes no further reference to it. The closure field contains the client_data passed to the callback when the callback list is executed.

The second method for registering callbacks is to use XtAddCallback after the widget has been created.
void XtAddCallback(w, callback_name, callback, client_data)
Widget w;
String callback_name;
XtCallbackProc callback;
XtPointer client_data;

w Specifies the widget to add the callback to.

callback_name

Specifies the callback list within the widget to append to.

callback

Specifies the callback procedure to add.

client_data

Specifies the data to be passed to the callback when it is invoked.

XtAddCallback adds the specified callback to the list for the named widget.

All widgets provide a callback list named destroyCallback where clients can register procedures that are to be executed when the widget is destroyed. The destroy callbacks are executed when the widget or an ancestor is destroyed. The call_data argument is unused for destroy callbacks.

2.10. Programming Considerations

This section provides some guidelines on how to set up an application program that uses the X Toolkit.

2.10.1. Writing Applications

When writing an application that uses the X Toolkit, you should make sure that your application performs the following:

1. Include <X11/Intrinsic.h> in your application programs. This header file automatically includes <X11/Xlib.h>, so all Xlib functions also are defined. It may also be necessary to include < X11/StringDefs.h > when setting up argument lists, as many of the XtNsomething definitions are only defined in this file.

2.

Include the widget-specific header files for each widget type that you need to use. For example, <X11/Xaw/Label.h> and <X11/Xaw/Command.h>.

3.

Call the XtAppInitialize function before invoking any other toolkit or Xlib functions. For further information, see Section 2.1 and the X Toolkit Intrinsics — C Language Interface.

4.

To pass attributes to the widget creation routines that will override any site or user customizations, set up argument lists. In this document, a list of valid argument names is provided in the discussion of each widget. The names each have a global symbol defined that begins with XtN to help catch spelling errors. For example, XtNlabel is defined for the label resource of many widgets.

For further information, see Section 2.9.2.2.
5. When the argument list is set up, create the widget with the XtCreateManagedWidget function. For further information, see Section 2.2 and the X Toolkit Intrinsics — C Language Interface.

6.

If the widget has any callback routines, set by the XtNcallback argument or the XtAddCallback function, declare these routines within the application.

7.

After creating the initial widget hierarchy, windows must be created for each widget by calling XtRealizeWidget on the top level widget.

8.

Most applications now sit in a loop processing events using XtAppMainLoop, for example:

XtCreateManagedWidget(name, class, parent, args, num_args);
XtRealizeWidget(shell);
XtAppMainLoop(app_context);
For information about this function, see the X Toolkit Intrinsics — C Language Interface.
9. Link your application with libXaw (the Athena widgets), libXmu (miscellaneous utilities), libXt (the X Toolkit Intrinsics), libSM (Session Management), libICE (Inter-Client Exchange), libXext (the extension library needed for the shape extension code which allows rounded Command buttons), and libX11 (the core X library). The following provides a sample command line:
cc -o application application.c −lXaw −lXmu −lXt −lSM −lICE −lXext −lX11

2.10.2. Changing Resource Values

The Intrinsics support two methods of changing the default resource values; the resource manager, and an argument list passed into XtCreateWidget. While resources values will get updated no matter which method you use, the two methods provide slightly different functionality.

Resource Manager
This method picks up resource definitions described in Xlib — C Language X Interface from many different locations at run time. The locations most important to the application programmer are the fallback resources and the app-defaults file, (see X Toolkit Intrinsics — C Language Interface for the complete list). Since these resource are loaded at run time, they can be overridden by the user, allowing an application to be customized to fit the particular needs of each individual user. These values can also be modified without the need to rebuild the application, allowing rapid prototyping of user interfaces. Application programmers should use resources in preference to hard-coded values whenever possible.
Argument Lists The values passed into the widget at creation time via an argument list cannot be modified by the user, and allow no opportunity for customization. It is used to set resources that cannot be specified as strings (e.g. callback lists) or resources that should not be overridden (e.g. window depth) by the user.
2.10.2.1. Specifying Resources

It is important for all X Toolkit application programmers to understand how to use the X Resource Manager to specify resources for widgets in an X application. This section will describe the most common methods used to specify these resources, and how to use the X Resource manager.

Xrdb The xrdb utility may be used to load a file containing resources into the X server. Once the resources are loaded, the resources will affect any new applications started on the display that they were loaded onto.

Application

Defaults

The application defaults (app-defaults) file (normally in /usr/lib/X11/app-defaults/classname) for an application is loaded whenever the application is started.

The resource specification has two colon-separated parts, a name, and a value. The value is a string whose format is dependent on the resource specified by name. Name is constructed by appending a resource name to a full widget name.

The full widget name is a list of the name of every ancestor of the desired widget separated by periods (.). Each widget also has a class associated with it. A class is a type of widget (e.g. Label or Scrollbar or Box). Notice that class names, by convention, begin with capital letters and instance names begin with lower case letters. The class of any widget may be used in place of its name in a resource specification. Here are a few examples:

xman.form.button1
This is a fully specified resource name, and will affect only widgets called button1 that are children of widgets called form that are children of applications named xman. (Note that while typically two widgets that are siblings will have different names, it is not prohibited.)
Xman.Form.Command
This will match any Command widget that is a child of a Form widget that is itself a child of an application of class Xman.
Xman.Form.button1
This is a mixed resource name with both widget names and classes specified.

This syntax allows an application programmer to specify any widget in the widget tree. To match more than one widget (for example a user may want to make all Command buttons blue), use an asterisk (*) instead of a period. When an asterisk is used, any number of widgets (including zero) may exist between the two widget names. For example:

Xman*Command This matches all Command widgets in the Xman application.

Foo*button1

This matches any widget in the Foo application that is named button1.

The root of all application widget trees is the widget returned by XtAppInitialize. Even though this is actually an ApplicationShell widget, the toolkit replaces its widget class with the class name of the application. The name of this widget is either the name used to invoke the application (argv[0]) or the name of the application specified using the standard -name command line option supported by the Intrinsics.

The last step in constructing the resource name is to append the name of the resource with either a period or asterisk to the full or partial widget name already constructed.

*foreground:Blue Specifies that all widgets in all applications will have a foreground color of blue.

Xman*borderWidth:10

Specifies that all widgets in an application whose class is Xman will have a border width of 10 (pixels).

xman.form.button1.label:Testing

Specifies that a particular widget in the xman application will have a label named Testing.

An exclamation point (!) in the first column of a line indicates that the rest of the line should be treated as a comment.

Final Words

The Resource manager is a powerful tool that can be used very effectively to customize X Toolkit applications at run time by either the application programmer or the user. Some final points to note:

An application programmer may add new resources to their application. These resources are associated with the global application, and not any particular widget. The X Toolkit function used for adding the application resources is XtGetApplicationResources.

Be careful when creating resource files. Since widgets will ignore resources that they do not understand, any spelling errors will cause a resource to have no effect.

Only one resource line will match any given resource. There is a set of precedence rules, which take the following general stance.

More specific overrides less specific, thus period always overrides asterisk.

Names on the left are more specific and override names on the right.

When resource specifications are exactly the same, user defaults

will override program defaults.

For a complete explanation of the rules of precedence, and other specific topics see X Toolkit Intrinsics — C Language Interface and Xlib — C Language X Interface.

2.10.2.2. Creating Argument Lists

To set up an argument list for the inline specification of widget attributes, you may use any of the four approaches discussed in this section. Each resource name has a global symbol associated with it. This global symbol has the form XtNresource name. For example, the symbol for ‘‘foreground’’ is XtNforeground. For further information, see the X Toolkit Intrinsics — C Language Interface.

Argument are specified by using the following structure:

typedef struct {

String name;
XtArgVal value;
} Arg, *ArgList;

The first approach is to statically initialize the argument list. For example:

static Arg arglist[] = {

{XtNwidth, (XtArgVal) 400},
{XtNheight, (XtArgVal) 300},
};

This approach is convenient for lists that do not need to be computed at runtime and makes adding or deleting new elements easy. The XtNumber macro is used to compute the number of elements in the argument list, preventing simple programming errors:

XtCreateWidget(name, class, parent, arglist, XtNumber(arglist));

The second approach is to use the XtSetArg macro. For example:

Arg arglist[10];
XtSetArg(arglist[1], XtNwidth, 400);
XtSetArg(arglist[2], XtNheight, 300);

To make it easier to insert and delete entries, you also can use a variable index:

Arg arglist[10];
Cardinal i=0;
XtSetArg(arglist[i], XtNwidth, 400); i++;
XtSetArg(arglist[i], XtNheight, 300); i++;

The i variable can then be used as the argument list count in the widget create function. In this example, XtNumber would return 10, not 2, and therefore is not useful.

Note

You should not use auto-increment or auto-decrement within the first argument to XtSetArg. As it is currently implemented, XtSetArg is a macro that dereferences the first argument twice.

The third approach is to individually set the elements of the argument list array:

Arg arglist[10];
arglist[0].name = XtNwidth;
arglist[0].value = (XtArgVal) 400;
arglist[1].name = XtNheight;
arglist[1].value = (XtArgVal) 300;

Note that in this example, as in the previous example, XtNumber would return 10, not 2, and therefore would not be useful.

The fourth approach is to use a mixture of the first and third approaches: you can statically define the argument list but modify some entries at runtime. For example:

static Arg arglist[] = {

{XtNwidth, (XtArgVal) 400},
{XtNheight, (XtArgVal) NULL},
};
arglist[1].value = (XtArgVal) 300;

In this example, XtNumber can be used, as in the first approach, for easier code maintenance.

2.11. Example ProgramsThe best way to understand how to use any programminglibrary is by trying some simple examples. A collection ofexample programs that introduces each of the widgets in thatAthena widget set, as well as many important toolkitprogramming concepts, is available in the X11R6 release asdistributed by the X Consortium. It can be found in thedistribution directory contrib/examples/mit/Xaw, but seeyour site administrator for the exact location of thesefiles on your system. See the README file from thatdirectory for a guide to the examples.

Chapter 3

Simple Widgets

Each of these widgets performs a specific user interface function. They are simple because they cannot have widget children—they may only be used as leaves of the widget tree. These widgets display information or take user input.

Command A push button that, when selected, may cause a specific action to take place. This widget can display a multi-line string or a bitmap or pixmap image.

Grip

A rectangle that, when selected, will cause an action to take place.

Label

A rectangle that can display a multi-line string or a bitmap or pixmap image.

List

A list of text strings presented in row column format that may be individually selected. When an element is selected an action may take place.

Panner

A rectangular area containing a slider that may be moved in two dimensions. Notification of movement may be continuous or discrete.

Repeater

A push button that triggers an action at an increasing rate when selected. This widget can display a multi-line string or a bitmap or pixmap image.

Scrollbar

A rectangular area containing a thumb that when slid along one dimension may cause a specific action to take place. The Scrollbar may be oriented horizontally or vertically.

Simple

The base class for most of the simple widgets. Provides a rectangular area with a settable mouse cursor and special border.

StripChart

A real time data graph that will automatically update and scroll.

Toggle

A push button that contains state information. Toggles may also be used as ‘‘radio buttons’’ to implement a ‘‘one of many’’ or ‘‘zero or one of many’’ group of buttons. This widget can display a multi-line string or a bitmap or pixmap image.

3.1. Command WidgetApplication header file<X11/Xaw/Command.h>Class header file <X11/Xaw/CommandP.h>Class commandWidgetClassClass Name CommandSuperclass LabelThe Command widget is an area, often rectangular, thatcontains text or a graphical image. Command widgets areoften referred to as ‘‘push buttons.’’ When the pointer isover a Command widget, the widget becomes highlighted bydrawing a rectangle around its perimeter. This highlightingindicates that the widget is ready for selection. Whenmouse button 1 is pressed, the Command widget indicates thatit has been selected by reversing its foreground andbackground colors. When the mouse button is released, theCommand widget’s notify action is invoked, calling allfunctions on its callback list. If the pointer is moved offof the widget before the pointer button is released, thewidget reverts to its normal foreground and backgroundcolors, and releasing the pointer button has no effect.This behavior allows the user to cancel an action.3.1.1. Resources

When creating a Command widget instance, the following resources are retrieved from the argument list or from the resource database:

Image widgets3.png

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics — C Language Interface for details).

ancestorSensitive

The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.

background

A pixel value which indexes the widget’s colormap to derive the background color of the widget’s window.

backgroundPixmap

The background pixmap of this widget’s window. If th