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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

bitmap

A bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget’s internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.) If this bitmap is one bit deep then the 1’s will be rendered in the foreground color, and the 0’s in the background color. If bitmap has a depth greater than one, it is copied directly into the window.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

A list of routines to be called when the notify action is invoked.

colormap

The colormap that this widget will use.

cornerRoundPercent

When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

encoding

The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the widget’s colormap to derive the foreground color of the widget’s window. This color is also used to render all 1’s in a bitmap one plane deep.

height

width

The height and width of this widget in pixels.

highlightThickness

The thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

Specifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.

label

Specifies the text string to be displayed in the widget’s window if no bitmap is specified. The default is the name of this widget. Regardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.

leftBitmap

Specifies a bitmap to display to the left of the graphic in the widget’s window.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

resize

Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shapeStyle

Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.1.2. Command Actions

The Command widget supports the following actions:

Switching the button’s interior between the foreground and background colors with set, unset, and reset.

Processing application callbacks with notify

Switching the internal border between highlighted and unhighlighted states with highlight and unhighlight

The following are the default translation bindings used by the Command widget:

<EnterWindow>:

highlight()

<LeaveWindow>:

reset()

<Btn1Down>:

set()

<Btn1Up>:

notify() unset()

The full list of actions supported by Command is:

highlight(condition)

Displays the internal highlight border in the color (foreground or background ) that contrasts with the interior color of the Command widget. The conditions WhenUnset and Always are understood by this action procedure. If no argument is passed, WhenUnset is assumed.

unhighlight()

Displays the internal highlight border in the color (foreground or background ) that matches the interior color of the Command widget.

set()

Enters the set state, in which notify is possible. This action causes the button to display its interior in the foreground color. The label or bitmap is displayed in the background color.

unset()

Cancels the set state and displays the interior of the button in the background color. The label or bitmap is displayed in the foreground color.

reset()

Cancels any set or highlight and displays the interior of the button in the background color, with the label or bitmap displayed in the foreground color.

notify()

When the button is in the set state this action calls all functions in the callback list named by the callback resource. The value of the call_data argument passed to these functions is undefined.

A very common alternative to registering callbacks is to augment a Command’s translations with an action performing the desired function. This often takes the form of:

*Myapp*save.translations: #augment <Btn1Down>,<Btn1Up>: Save()

Note

When a bitmap of depth greater that one (1) is specified the set(), unset(), and reset() actions have no effect, since there are no foreground and background colors used in a multi-plane pixmap.

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

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

Image widgets4.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

All routines on this list are called whenever the GripAction action routine is invoked. The call_data contains all information passed to the action routine. A detailed description is given below in the Grip Actions section.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

foreground

A pixel value which indexes the widget’s colormap to derive the color used to flood fill the entire Grip widget.

height

width

The height and width of this widget in pixels.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.2.2. Grip Actions

The Grip widget does not declare any default event translation bindings, but it does declare a single action routine named GripAction. The client specifies an arbitrary event translation table, optionally giving parameters to the GripAction routine.

The GripAction routine executes the callbacks on the callback list, passing as call_data a pointer to a XawGripCallData structure, defined in the Grip widget’s application header file.

typedef struct _XawGripCallData {

XEvent *event;

String *params;

Cardinal num_params;

} XawGripCallDataRec, *XawGripCallData,
GripCallDataRec, *GripCallData; /* supported for R4 compatibility */

In this structure, the event is a pointer to the input event that triggered the action. params and num_params give the string parameters specified in the translation table for the particular event binding.

The following is an example of a translation table that uses the GripAction:

<Btn1Down>:

GripAction(press)

<Btn1Motion>:

GripAction(move)

<Btn1Up>:

GripAction(release)

For a complete description of the format of translation tables, see the X Toolkit Intrinsics — C Language Interface.

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

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

Image widgets5.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

bitmap

A bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget’s internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.) If this bitmap is one bit deep then the 1’s will be rendered in the foreground color, and the 0’s in the background color. If bitmap has a depth greater than one, it is copied directly into the window.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

encoding

The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the widget’s colormap to derive the foreground color of the widget’s window. This color is also used to render all 1’s in a bitmap one plane deep.

height

width

The height and width of this widget in pixels.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

Specifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.

label

Specifies the text string to be displayed in the widget’s window if no bitmap is specified. The default is the name of this widget. Regardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.

leftBitmap

Specifies a bitmap to display to the left of the graphic in the widget’s window.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

resize

Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.4. List Widget

Application header file<X11/Xaw/List.h>

Class header file

<X11/Xaw/ListP.h>

Class

listWidgetClass

Class Name

List

Superclass

Simple

The List widget contains a list of strings formatted into rows and columns. When one of the strings is selected, it is highlighted, and the List widget’s Notify action is invoked, calling all routines on its callback list. Only one string may be selected at a time.

3.4.1. Resources

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

Image widgets6.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

All functions on this list are called whenever the notify action is invoked. The call_data argument contains information about the element selected and is described in detail in the List Callbacks section.

colormap

The colormap that this widget will use.

columnSpacing

rowSpacing

The amount of space, in pixels, between each of the rows and columns in the list.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

defaultColumns

The default number of columns. This value is used when neither the width nor the height of the List widget is specified or when forceColumns is True.

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

font

The text font to use when displaying the list, when the international resource is false.

fontSet

The text font set to use when displaying the list, when the international resource is true.

forceColumns

Forces the default number of columns to be used regardless of the List widget’s current size.

foreground

A pixel value which indexes the widget’s colormap to derive the color used to paint the text of the list elements.

height

width

The height and width of this widget in pixels.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The margin, in pixels, between the edges of the list and the corresponding edge of the List widget’s window.

list

An array of text strings displayed in the List widget. If numberStrings is zero (the default) then the list must be NULL terminated. If a value is not specified for the list, then numberStrings is set to 1, and the name of the widget is used as the list, and longest is set to the length of the name of the widget. The list is used in place, and must be available to the List widget for the lifetime of this widget, or until it is changed with XtSetValues or XawListChange.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

longest

Specifies the width, in pixels, of the longest string in the current list. The List widget will compute this value if zero (the default) is specified. If this resource is set by hand, entries longer than this will be clipped to fit.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

numberStrings

The number of strings in the current list. If a value of zero (the default) is specified, the List widget will compute it. When computing the number of strings the List widget assumes that the list is NULL terminated.

pasteBuffer

If this resource is set to True then the name of the currently selected list element will be put into CUT_BUFFER_0.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

verticalList

If this resource is set to True then the list elements will be presented in column major order.

x

y

The location of the upper left outside corner of this widget in its parent.

3.4.2. List Actions

The List widget supports the following actions:

Highlighting and unhighlighting the list element under the pointer with Set and Unset

Processing application callbacks with Notify

The following is the default translation table used by the List Widget:

<Btn1Down>,<Btn1Up>:

Set() Notify()

The full list of actions supported by List widget is:

Set()

Sets the list element that is currently under the pointer. To inform the user that this element is currently set, it is drawn with foreground and background colors reversed. If this action is called when there is no list element under the cursor, the currently set element will be unset.

Unset()

Cancels the set state of the element under the pointer, and redraws it with normal foreground and background colors.

Notify()

Calls all callbacks on the List widget’s callback list. Information about the currently selected list element is passed in the call_data argument (see List Callbacks below).

3.4.3. List Callbacks

All procedures on the List widget’s callback list will have a XawListReturnStruct passed to them as call_data. The structure is defined in the List widget’s application header file.

typedef struct _XawListReturnStruct {

String string;

/* string shown in the list. */

int list_index;

/* index of the item selected. */

} XawListReturnStruct;

Note

The list_index item used to be called simply index. Unfortunately, this name collided with a global name defined on some operating systems, and had to be changed.

3.4.4. Changing the List

To change the list that is displayed, use XawListChange.
void XawListChange(w, list, nitems, longest, resize)
Widget w;
String * list;
int nitems, longest;
Boolean resize;

w

Specifies the List widget.

list

Specifies the new list for the List widget to display.

nitems

Specifies the number of items in the list. If a value less than 1 is specified, list must be NULL terminated, and the number of items will be calculated by the List widget.

longest

Specifies the length of the longest item in the list in pixels. If a value less than 1 is specified, the List widget will calculate the value.

resize

Specifies a Boolean value that if True indicates that the List widget should try to resize itself after making the change. The constraints of the List widget’s parent are always enforced, regardless of the value specified here.

XawListChange will unset all list elements that are currently set before the list is actually changed. The list is used in place, and must remain usable for the lifetime of the List widget, or until list has been changed again with this function or with XtSetValues.

3.4.5. Highlighting an Item

To highlight an item in the list, use XawListHighlight.
void XawListHighlight(w, item)
Widget w;
int item;

w

Specifies the List widget.

item

Specifies an index into the current list that indicates the item to be highlighted.

Only one item can be highlighted at a time. If an item is already highlighted when XawListHighlight is called, the highlighted item is unhighlighted before the new item is highlighted.

3.4.6. Unhighlighting an Item

To unhighlight the currently highlighted item in the list, use XawListUnhighlight.
void XawListUnhighlight(w)
Widget w;

w

Specifies the List widget.

3.4.7. Retrieving the Currently Selected Item

To retrieve the list element that is currently set, use XawListShowCurrent.
XawListReturnStruct *XawListShowCurrent(w)
Widget w;

w

Specifies the List widget.

XawListShowCurrent returns a pointer to an XawListReturnStruct structure, containing the currently highlighted item. If the value of the index member is XAW_LIST_NONE, the string member is undefined, and no item is currently selected.

3.4.8. Restrictions

Many programmers create a ‘‘scrolled list’’ by putting a List widget with many entries as a child of a Viewport widget. The List continues to create a window as big as its contents, but that big window is only visible where it intersects the parent Viewport’s window. (I.e., it is ‘‘clipped.’’)

While this is a useful technique, there is a serious drawback. X does not support windows above 32,767 pixels in width or height, but this height limit will be exceeded by a List’s window when the List has many entries (i.e., with a 12 point font, about 3000 entries would be too many.)

3.5. Panner Widget

Application header file<X11/Xaw/Panner.h>

Class header file

<X11/Xaw/PannerP.h>

Class

pannerWidgetClass

Class Name

Panner

Superclass

Simple

A Panner widget is a rectangle, called the ‘‘canvas,’’ on which another rectangle, the ‘‘slider,’’ moves in two dimensions. It is often used with a Porthole widget to move, or ‘‘scroll,’’ a third widget in two dimensions, in which case the slider’s size and position gives feedback as to what portion of the third widget is visible.

The slider may be scrolled around the canvas by pressing, dragging, and releasing Button1; the default translation also enables scrolling via arrow keys and some other keys. While scrolling is in progress, the application receives notification through callback procedures. Notification may be done either continuously whenever the slider moves or discretely whenever the slider has been given a new location.

3.5.1. Resources

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

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

allowOff

Whether to allow the edges of the slider to go off the edges of the canvas.

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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

backgroundStipple

The name of a bitmap pattern to be used as the background for the area representing the canvas.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

canvasHeight

canvasWidth

The size of the canvas.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

defaultScale

The percentage size that the Panner widget should have relative to the size of the canvas.

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

foreground

A pixel value which indexes the widget’s colormap to derive the color used to draw the slider.

height

width

The height and width of this widget in pixels.

internalSpace

The width of internal border in pixels between a slider representing the full size of the canvas and the edge of the Panner widget.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

lineWidth

The width of the lines in the rubberbanding rectangle when rubberbanding is in effect instead of continuous scrolling. The default is 0.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

reportCallback

All functions on this callback list are called when the notify action is invoked. See the Panner Actions section for details.

resize

Whether or not to resize the panner whenever the canvas size is changed so that the defaultScale is maintained.

rubberBand

Whether or not scrolling should be discrete (only moving a rubberbanded rectangle until the scrolling is done) or continuous (moving the slider itself). This controls whether or not the move action procedure also invokes the notify action procedure.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shadowColor

The color of the shadow underneath the slider.

shadowThickness

The width of the shadow underneath the slider.

sliderX

sliderY

The location of the slider in the coordinates of the canvas.

sliderHeight

sliderWidth

The size of the slider.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.5.2. Panner Actions

The actions supported by the Panner widget are:

start()

This action begins movement of the slider.

stop()

This action ends movement of the slider.

abort()

This action ends movement of the slider and restores it to the position it held when the start action was invoked.

move()

This action moves the outline of the slider (if the rubberBand resource is True) or the slider itself (by invoking the notify action procedure).

page(xamount,

yamount)

This action moves the slider by the specified amounts. The format for the amounts is a signed or unsigned floating-point number (e.g., +1.0 or −.5) followed by either p indicating pages (slider sizes), or c indicating canvas sizes. Thus, page(+0,+.5p) represents vertical movement down one-half the height of the slider and page(0,0) represents moving to the upper left corner of the canvas.

notify()

This action informs the application of the slider’s current position by invoking the reportCallback functions registered by the application.

set(what,value)

This action changes the behavior of the Panner. The what argument must currently be the string rubberband and controls the value of the rubberBand resource. The value argument may have one of the values on, off, or toggle.

The default bindings for Panner are:

<Btn1Down>:

start()

<Btn1Motion>:move()

<Btn1Up>:

notify() stop()

<Btn2Down>:

abort()

<Key>KP_Enter:set(rubberband,toggle)

<Key>space:

page(+1p,+1p)

<Key>Delete:page(−1p,−1p)

<Key>BackSpace:page(−1p,−1p)

<Key>Left:

page(−.5p,+0)

<Key>Right:

page(+.5p,+0)

<Key>Up:

page(+0,−.5p)

<Key>Down:

page(+0,+.5p)

<Key>Home:

page(0,0)

3.5.3. Panner Callbacks

The functions registered on the reportCallback list are invoked by the notify action as follows:
void ReportProc(panner, client_data, report)

Widget panner;

XtPointer client_data;

XtPointer report; /* (XawPannerReport *) */

panner

Specifies the Panner widget.

client_data

Specifies the client data.

report

Specifies a pointer to an XawPannerReport structure containing the location and size of the slider and the size of the canvas.

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

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

Image widgets8.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

bitmap

A bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget’s internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.) If this bitmap is one bit deep then the 1’s will be rendered in the foreground color, and the 0’s in the background color. If bitmap has a depth greater than one, it is copied directly into the window.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

A list of routines to be called when the notify action is invoked.

colormap

The colormap that this widget will use.

cornerRoundPercent

When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

decay

The number of milliseconds that should be subtracted from each succeeding interval while the Repeater button is being held down until the interval has reached minimumDelay milliseconds.

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

encoding

The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.

flash

Whether or not to flash the Repeater button whenever the timer goes off.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the widget’s colormap to derive the foreground color of the widget’s window. This color is also used to render all 1’s in a bitmap one plane deep.

height

width

The height and width of this widget in pixels.

highlightThickness

The thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.

initialDelay

The number of milliseconds between the beginning of the Repeater button being held down and the first invocation of the callback function.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

Specifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.

label

Specifies the text string to be displayed in the widget’s window if no bitmap is specified. The default is the name of this widget. Regardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.

leftBitmap

Specifies a bitmap to display to the left of the graphic in the widget’s window.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

minimumDelay

The minimum time between callbacks in milliseconds.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

repeatDelay

The number of milliseconds between each callback after the first (minus an increasing number of decays).

resize

Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shapeStyle

Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.

startCallback

The list of functions to invoke by the start action (typically when the Repeater button is first pressed). The callback data parameter is set to NULL.

stopCallback

The list of functions to invoke by the stop action (typically when the Repeater button is released). The callback data parameter is set to NULL.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.6.2. Repeater Actions

The Repeater widget supports the following actions beyond those of the Command button:

start()

This invokes the functions on the startCallback and callback lists and sets a timer to go off in initialDelay milliseconds. The timer will cause the callback functions to be invoked with increasing frequency until the stop action occurs.

stop()

This invokes the functions on the stopCallback list and prevents any further timers from occuring until the next start action.

The following are the default translation bindings used by the Repeater widget:

<EnterWindow>:

highlight()

<LeaveWindow>:

unhighlight()

<Btn1Down>:

set() start()

<Btn1Up>:

stop() unset()

3.7. Scrollbar Widget

Application header file<X11/Xaw/Scrollbar.h>

Class header file

<X11/Xaw/ScrollbarP.h>

Class

scrollbarWidgetClass

Class Name

Scrollbar

Superclass

Simple

A Scrollbar widget is a rectangle, called the ‘‘canvas,’’ on which another rectangle, the ‘‘thumb,’’ moves in one dimension, either vertically or horizontally. A Scrollbar can be used alone, as a value generator, or it can be used within a composite widget (for example, a Viewport). When a Scrollbar is used to move, or ‘‘scroll,’’ the contents of another widget, the size and the position of the thumb usually give feedback as to what portion of the other widget’s contents are visible.

Each pointer button invokes a specific action. Pointer buttons 1 and 3 do not move the thumb automatically. Instead, they return the pixel position of the cursor on the scroll region. When pointer button 2 is clicked, the thumb moves to the current pointer position. When pointer button 2 is held down and the pointer is moved, the thumb follows the pointer.

The pointer cursor in the scroll region changes depending on the current action. When no pointer button is pressed, the cursor appears as a double-headed arrow that points in the direction that scrolling can occur. When pointer button 1 or 3 is pressed, the cursor appears as a single-headed arrow that points in the logical direction that the thumb will move. When pointer button 2 is pressed, the cursor appears as an arrow that points to the top or the left of the thumb.

When the user scrolls, the application receives notification through callback procedures. For both discrete scrolling actions, the callback returns the Scrollbar widget, the client_data, and the pixel position of the pointer when the button was released. For continuous scrolling, the callback routine returns the scroll bar widget, the client data, and the current relative position of the thumb. When the thumb is moved using pointer button 2, the callback procedure is invoked continuously. When either button 1 or 3 is pressed, the callback procedure is invoked only when the button is released and the client callback procedure is responsible for moving the thumb.

3.7.1. Resources

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

Image widgets9.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

foreground

A pixel value which indexes the widget’s colormap to derive the color used to draw the thumb.

height

width

The height and width of this widget in pixels.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

jumpProc

All functions on this callback list are called when the NotifyThumb action is invoked. See the Scrollbar Actions section for details.

length

The height of a vertical scrollbar or the width of a horizontal scrollbar.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

minimumThumb

The smallest size, in pixels, to which the thumb can shrink.

orientation

The orientation is the direction that the thumb will be allowed to move. This value can be either XtorientVertical or XtorientHorizontal. A converter is registered for this resource that will convert the following strings: vertical and horizontal.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

scrollDCursor

This cursor is used when scrolling backward in a vertical scrollbar.

scrollHCursor

This cursor is used when a horizontal scrollbar is inactive.

scrollLCursor

This cursor is used when scrolling forward in a horizontal scrollbar.

scrollProc

All functions on this callback list may be called when the NotifyScroll action is invoked. See the Scrollbar Actions section for details.

scrollRCursor

This cursor is used when scrolling backward in a horizontal scrollbar, or when thumbing a vertical scrollbar.

scrollUCursor

This cursor is used when scrolling forward in a vertical scrollbar, or when thumbing a horizontal scrollbar.

scrollVCursor

This cursor is used when a vertical scrollbar is inactive.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shown

This is the size of the thumb, expressed as a percentage (0.0 - 1.0) of the length of the scrollbar.

thickness

The width of a vertical scrollbar or the height of a horizontal scrollbar.

thumb

This pixmap is used to tile (or stipple) the thumb of the scrollbar. If no tiling is desired, then set this resource to None. This resource will accept either a bitmap or a pixmap that is the same depth as the window. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.)

topOfThumb

The location of the top of the thumb, as a percentage (0.0 - 1.0) of the length of the scrollbar. This resource was called top in previous versions of the Athena widget set. The name collided with the a Form widget constraint resource, and had to be changed.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.7.2. Scrollbar Actions

The actions supported by the Scrollbar widget are:

StartScroll(value)

The possible values are Forward, Backward, or Continuous. This must be the first action to begin a new movement.

NotifyScroll(value)

The possible values are Proportional or FullLength. If the argument to StartScroll was Forward or Backward, NotifyScroll executes the scrollProc callbacks and passes either; the position of the pointer, if value is Proportional, or the full length of the scroll bar, if value is FullLength. If the argument to StartScroll was Continuous, NotifyScroll returns without executing any callbacks.

EndScroll()

This must be the last action after a movement is complete.

MoveThumb()

Repositions the Scrollbar’s thumb to the current pointer location.

NotifyThumb

()   

Calls the jumpProc callbacks and passes the relative position of the pointer as a percentage of the scroll bar length.

The default bindings for Scrollbar are:

<Btn1Down>:

StartScroll(Forward)

<Btn2Down>:

StartScroll(Continuous) MoveThumb() NotifyThumb()

<Btn3Down>:

StartScroll(Backward)

<Btn2Motion>:MoveThumb() NotifyThumb()

<BtnUp>:

NotifyScroll(Proportional) EndScroll()

Examples of additional bindings a user might wish to specify in a resource file are:

*Scrollbar.Translations: \

~Meta<Key>space:

StartScroll(Forward) NotifyScroll(FullLength) \n\

Meta<Key>space:

StartScroll(Backward) NotifyScroll(FullLength) \n\

EndScroll()

3.7.3. Scrollbar Callbacks

There are two callback lists provided by the Scrollbar widget. The procedural interface for these functions is described here.

The calling interface to the scrollProc callback procedure is:
void ScrollProc(scrollbar, client_data, position)
Widget scrollbar;
XtPointer client_data;
XtPointer position; /* int */

scrollbar

Specifies the Scrollbar widget.

client_data

Specifies the client data.

position

Specifies a pixel position in integer form.

The scrollProc callback is used for incremental scrolling and is called by the NotifyScroll action. The position argument is a signed quantity and should be cast to an int when used. Using the default button bindings, button 1 returns a positive value, and button 3 returns a negative value. In both cases, the magnitude of the value is the distance of the pointer in pixels from the top (or left) of the Scrollbar. The value will never be greater than the length of the Scrollbar.

The calling interface to the jumpProc callback procedure is:
void JumpProc(scrollbar, client_data, percent)
Widget scrollbar;
XtPointer client_data;
XtPointer percent_ptr; /* float* */

scrollbar

Specifies the ID of the scroll bar widget.

client_data

Specifies the client data.

percent_ptr

Specifies the floating point position of the thumb (0.0 − 1.0).

The jumpProc callback is used to implement smooth scrolling and is called by the NotifyThumb action. Percent_ptr must be cast to a pointer to float before use; i.e.

float percent = *(float*)percent_ptr;

With the default button bindings, button 2 moves the thumb interactively, and the jumpProc is called on each new position of the pointer, while the pointer button remains down. The value specified by percent_ptr is the current location of the thumb (from the top or left of the Scrollbar) expressed as a percentage of the length of the Scrollbar.

3.7.4. Convenience Routines

To set the position and length of a Scrollbar thumb, use XawScrollbarSetThumb.
void XawScrollbarSetThumb(w, top, shown)
Widget w;
float top;
float shown;

w

Specifies the Scrollbar widget.

top

Specifies the position of the top of the thumb as a fraction of the length of the Scrollbar.

shown

Specifies the length of the thumb as a fraction of the total length of the Scrollbar.

XawScrollbarThumb moves the visible thumb to a new position (0.0 − 1.0) and length (0.0 − 1.0). Either the top or shown arguments can be specified as −1.0, in which case the current value is left unchanged. Values greater than 1.0 are truncated to 1.0.

If called from jumpProc, XawScrollbarSetThumb has no effect.

3.7.5. Setting Float Resources

The shown and topOfThumb resources are of type float. These resources can be difficult to get into an argument list. The reason is that C performs an automatic cast of the float value to an integer value, usually truncating the important information. The following code fragment is one portable method of getting a float into an argument list.

top = 0.5;

if (sizeof(float) > sizeof(XtArgVal)) {

/*

 * If a float is larger than an XtArgVal then pass this

 * resource value by reference.

 */

XtSetArg(args[0], XtNshown, &top);

}

else {

/*

 * Convince C not to perform an automatic conversion, which

 * would truncate 0.5 to 0.

 */

XtArgVal * l_top = (XtArgVal *) &top;

XtSetArg(args[0], XtNshown, *l_top);

}

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

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

Image widgets10.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

height

width

The height and width of this widget in pixels.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

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

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

Image widgets11.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

colormap

The colormap that this widget will use.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

foreground

A pixel value which indexes the widget’s colormap to derive the color that will be used to draw the graph.

getValue

A list of callback functions to call every update seconds. This list should contain one function, which returns the value to be graphed by the StripChart widget. The following section describes the procedural interface. Behavior when this list has more than one function is undefined.

height

width

The height and width of this widget in pixels.

highlight

A pixel value which indexes the widget’s colormap to derive the color that will be used to draw the scale lines on the graph.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

jumpScroll

When the graph reaches the right edge of the window it must be scrolled to the left. This resource specifies the number of pixels it will jump. Smooth scrolling can be achieved by setting this resource to 1.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

minScale

The minimum scale for the graph. The number of divisions on the graph will always be greater than or equal to this value.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

update

The number of seconds between graph updates. Each update is represented on the graph as a 1 pixel wide line. Every update seconds the getValue procedure will be used to get a new graph point, and this point will be added to the right end of the StripChart.

x

y

The location of the upper left outside corner of this widget in its parent.

3.9.2. Getting the StripChart Value

The StripChart widget will call the application routine passed to it as the getValue callback function every update seconds to obtain another point for the StripChart graph.

The calling interface for the getValue callback is:
void (*getValueProc)(w, client_data, value)
Widget w;
XtPointer client_data;
XtPointer value; /* double * */

w

Specifies the StripChart widget.

client_data

Specifies the client data.

value

Returns a pointer to a double. The application should set the address pointed to by this argument to a double containing the value to be graphed on the StripChart.

This function is used by the StripChart to call an application routine. The routine will pass the value to be graphed back to the the StripChart in the value field of this routine.

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

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

Image widgets12.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

bitmap

A bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget’s internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.) If this bitmap is one bit deep then the 1’s will be rendered in the foreground color, and the 0’s in the background color. If bitmap has a depth greater than one, it is copied directly into the window.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

A list of routines to be called when the notify action is invoked.

colormap

The colormap that this widget will use.

cornerRoundPercent

When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

encoding

The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the widget’s colormap to derive the foreground color of the widget’s window. This color is also used to render all 1’s in a bitmap one plane deep.

height

width

The height and width of this widget in pixels.

highlightThickness

The thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

Specifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.

label

Specifies the text string to be displayed in the widget’s window if no bitmap is specified. The default is the name of this widget. Regardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.

leftBitmap

Specifies a bitmap to display to the left of the graphic in the widget’s window.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

radioData

Specifies the data that will be returned by XawToggleGetCurrent when this is the currently set widget in the radio group. This value is also used to identify the Toggle that will be set by a call to XawToggleSetCurrent. The value NULL will be returned by XawToggleGetCurrent if no widget in a radio group is currently set. Programmers must not specify NULL (or Zero) as radioData.

radioGroup

Specifies another Toggle widget that is in the radio group to which this Toggle widget should be added. A radio group is a group of at least two Toggle widgets, only one of which may be set at a time. If this value is NULL (the default) then the Toggle will not be part of any radio group and can change state without affecting any other Toggle widgets. If the widget specified in this resource is not already in a radio group then a new radio group will be created containing these two Toggle widgets. No Toggle widget can be in multiple radio groups. The behavior of a radio group of one toggle is undefined. A converter is registered which will convert widget names to widgets without caching.

resize

Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shapeStyle

Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.

state

Specifies whether the Toggle widget is set (True) or unset (False).

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

3.10.2. Toggle Actions

The Toggle widget supports the following actions:

Switching the Toggle widget between the foreground and background colors with set and unset and toggle

Processing application callbacks with notify

Switching the internal border between highlighted and unhighlighted states with highlight and unhighlight

The following are the default translation bindings used by the Toggle widget:

<EnterWindow>:

highlight(Always)

<LeaveWindow>:

unhighlight()

<Btn1Down>,<Btn1Up>:toggle() notify()

3.10.3. Toggle Actions

The full list of actions supported by Toggle is:

highlight(condition)

Displays the internal highlight border in the color (foreground or background ) that contrasts with the interior color of the Toggle widget. The conditions WhenUnset and Always are understood by this action procedure. If no argument is passed then WhenUnset is assumed.

unhighlight()

Displays the internal highlight border in the color (foreground or background ) that matches the interior color of the Toggle widget.

set()

Enters the set state, in which notify is possible. This action causes the Toggle widget to display its interior in the foreground color. The label or bitmap is displayed in the background color.

unset()

Cancels the set state and displays the interior of the Toggle widget in the background color. The label or bitmap is displayed in the foreground color.

toggle()

Changes the current state of the Toggle widget, causing to be set if it was previously unset, and unset if it was previously set. If the widget is to be set, and is in a radio group then this procedure may unset another Toggle widget causing all routines on its callback list to be invoked. The callback routines for the Toggle that is to be unset will be called before the one that is to be set.

reset()

Cancels any set or highlight and displays the interior of the Toggle widget in the background color, with the label displayed in the foreground color.

notify()

When the Toggle widget is in the set state this action calls all functions in the callback list named by the callback resource. The value of the call_data argument in these callback functions is undefined.

Note

When a bitmap of depth greater that one (1) is specified the set(), unset(), and reset() actions have no effect, since there are no foreground and background colors used in a multi-plane pixmap.

3.10.4. Radio Groups

There are typically two types of radio groups desired by applications. The default translations for the Toggle widget implement a "zero or one of many" radio group. This means that there may be no more than one Toggle widget active, but there need not be any Toggle widgets active.

The other type of radio group is "one of many" and has the more strict policy that there will always be exactly one radio button active. Toggle widgets can be used to provide this interface with a slight modification to the translation table of each Toggle in the group.

<EnterWindow>:

highlight(Always)

<LeaveWindow>:

unhighlight()

<Btn1Down>,<Btn1Up>:set() notify()

This translation table will not allow any Toggle to be unset except as a result of another Toggle becoming set. It is the application programmer’s responsibility to choose an initial state for the radio group by setting the state resource of one of its member widgets to True.

3.10.5. Convenience Routines

The following functions allow easy access to the Toggle widget’s radio group functionality.

3.10.5.1. Changing the Toggle’s Radio Group.

To enable an application to change the Toggle’s radio group, add the Toggle to a radio group, or remove the Toggle from a radio group, use XawToggleChangeRadioGroup.
void XawToggleChangeRadioGroup(w, radio_group)
Widget w, radio_group;

w

Specifies the Toggle widget.

radio_group

Specifies any Toggle in the new radio group. If NULL then the Toggle will be removed from any radio group of which it is a member.

If a Toggle is already set in the new radio group, and the Toggle to be added is also set then the previously set Toggle in the radio group is unset and its callback procedures are invoked.

Finding the Currently selected Toggle in a radio group ofToggles

To find the currently selected Toggle in a radio group of Toggle widgets use XawToggleGetCurrent.
XtPointer XawToggleGetCurrent(radio_group);
Widget radio_group;

radio_group

Specifies any Toggle widget in the radio group.

The value returned by this function is the radioData of the Toggle in this radio group that is currently set. The default value for radioData is the name of that Toggle widget. If no Toggle is set in the radio group specified then NULL is returned.

Changing the Toggle that is set in a radio group.

To change the Toggle that is currently set in a radio group use XawToggleSetCurrent.
void XawToggleSetCurrent(radio_group, radio_data);
Widget radio_group;
XtPointer radio_data;

radio_group

Specifies any Toggle widget in the radio group.

radio_data

Specifies the radioData identifying the Toggle that should be set in the radio group specified by the radio_group argument.

XawToggleSetCurrent locates the Toggle widget to be set by matching radio_data against the radioData for each Toggle in the radio group. If none match, XawToggleSetCurrent returns without making any changes. If more than one Toggle matches, XawToggleSetCurrent will choose a Toggle to set arbitrarily. If this causes any Toggle widgets to change state, all routines in their callback lists will be invoked. The callback routines for a Toggle that is to be unset will be called before the one that is to be set.

Unsetting all Toggles in a radio group.

To unset all Toggle widgets in a radio group use XawToggleUnsetCurrent.
void XawToggleUnsetCurrent(radio_group);
Widget radio_group;

radio_group

Specifies any Toggle widget in the radio group.

If this causes a Toggle widget to change state, all routines on its callback list will be invoked.

Chapter 4

Menus

The Athena widget set provides support for single paned non-hierarchical popup and pulldown menus. Since menus are such a common user interface tool, support for them must be provided in even the most basic widget sets. In menuing as in other areas, the Athena Widget Set provides only basic functionality.

Menus in the Athena widget set are implemented as a menu container (the SimpleMenu widget) and a collection of objects that comprise the menu entries. The SimpleMenu widget is itself a direct subclass of the OverrideShell widget class, so no other shell is necessary when creating a menu. The managed children of a SimpleMenu must be subclasses of the Sme (Simple Menu Entry) object.

The Athena widget set provides three classes of Sme objects that may be used to build menus.

Sme

The base class of all menu entries. It may be used as a menu entry itself to provide blank space in a menu. ‘‘Sme’’ means ‘‘Simple Menu Entry.’’

SmeBSB

This menu entry provides a selectable entry containing a text string. A bitmap may also be placed in the left and right margins. ‘‘BSB’’ means ‘‘Bitmap String Bitmap.’’

SmeLine

This menu entry provides an unselectable entry containing a separator line.

The SimpleMenu widget informs the window manager that it should ignore its window by setting the Override Redirect flag. This is the correct behavior for the press-drag-release style of menu operation. If click-move-click or ‘‘pinable’’’ menus are desired it is the responsibility of the application programmer, using the SimpleMenu resources, to inform the window manager of the menu.

To allow easy creation of pulldown menus, a MenuButton widget is also provided as part of the Athena widget set.

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

The resources associated with the SimpleMenu widget control aspects that will affect the entire menu.

Image widgets13.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.

backingStore

Determines what type of backing store will be used for the menu. Legal values for this resource are NotUseful, WhenMapped, and Always. These values are the backing-store integers defined in <X11/X.h>. A converter is registered for this resource that will convert the following strings: notUseful, whenMapped, always, and default. If default is specified (the default behavior) the server will use whatever it thinks is appropriate.

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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

bottomMargin

topMargin

The amount of space between the top or bottom of the menu and the menu entry closest to that edge.

children

A list of all this composite widget’s current children.

colormap

The colormap that this widget will use.

cursor

The shape of the mouse pointer whenever it is in this widget.

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

geometry

If this resource is specified it will override the x, y, width and height of this widget. The format of this string is [<width>x<height>][{+ -} <xoffset> {+ -}<yoffset>].

height

width

The height and width of this widget in pixels.

label

This label will be placed at the top of the SimpleMenu, and may not be highlighted. The name of the label object is menuLabel. Using this name it is possible to modify the label’s attributes through the resource database. When the label is created, the label is hard coded to the value of label, and justify is hard coded as XtJustifyCenter.

labelClass

Specifies the type of Sme object created as the menu label.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

menuOnScreen

If the menu is automatically positioned under the cursor with the XawPositionSimpleMenu action, and this resource is True, then the menu will always be fully visible on the screen.

numChildren

The number of children in this composite widget.

overrideRedirect

Determines the value of the override_redirect attribute of the SimpleMenu’s window. The override_redirect attribute of a window determines whether or not a window manager may interpose itself between this window and the root window of the display. For more information see the Interclient Communications Conventions Manual.

popdownCallback

popupCallback

These callback functions are called by the Xt Intrinsics whenever the shell is popped up or down (See X Toolkit Intrinsics — C Language Interface for details).

popupOnEntry

The XawPositionSimpleMenu action will, by default, popup the SimpleMenu with its label (or first entry) directly under the pointer. To popup the menu under another entry, set this resource to the menu entry that should be under the pointer, when the menu is popped up. This allows the application to offer the user a default menu entry that can be selected with out moving the pointer.

rowHeight

If this resources is zero (the default) then each menu entry will be given its desired height. If this resource has any other value then all menu entries will be forced to be rowHeight pixels high.

saveUnder

If this is True then save unders will be active on the menu’s window.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

4.2.2. SimpleMenu Actions

The SimpleMenu widget supports the following actions:

Switching the entry under the mouse pointer between the foreground and background colors with highlight and unhighlight

Processing menu entry callbacks with notify

The following are the default translation bindings used by the SimpleMenu widget:

<EnterWindow>:

highlight()

<LeaveWindow>:

unhighlight()

<BtnMotion>:

highlight()

<BtnUp>:

MenuPopdown() notify() unhighlight()

The user can pop down the menu without activating any of the callback functions by releasing the pointer button when no menu item is highlighted.

The full list of actions supported by SimpleMenu is:

highlight()

Highlight the menu entry that is currently under the pointer. Only a item that is highlighted will be notified when the notify action is invoked. The look of a highlighted entry is determined by the menu entry.

unhighlight()

Unhighlights the currently highlighted menu item, and returns it to its normal look.

notify()

Notifies the menu entry that is currently highlighted that is has been selected. It is the responsibility of the menu entry to take the appropriate action.

MenuPopdown(

menu)

This action is defined in X Toolkit Intrinsics — C Language Interface.

4.2.3. Positioning the SimpleMenu

If the SimpleMenu widget is to be used as a pulldown menu then the MenuButton widget, or some other outside means should be used to place the menu when it is popped up.

If popup menus are desired it will be necessary to add the XawPositionSimpleMenu and MenuPopup actions to the translation table of the widget that will be popping up the menu. The MenuPopup action is described in X Toolkit Intrinsics — C Language Interface. XawPositionSimpleMenu is a global action procedure registered by the SimpleMenu widget when the first one is created or the convenience routine XawSimpleMenuAddGlobalActions is called.

Translation writers should be aware that Xt does not register grabs on ‘‘don’t care’’ modifiers, and therefore the left hand side of the production should be written to exclude unspecified modifiers. For example these are the translations needed to popup some of xterm’s menus:

!Ctrl<Btn1Down>: XawPositionSimpleMenu(xterm) MenuPopup(xterm)

!Ctrl<Btn2Down>: XawPositionSimpleMenu(modes) MenuPopup(modes)

XawPositionSimpleMenu(menu)

The XawPositionSimpleMenu routine will search for the menu name passed to it using XtNameToWidget starting with the widget invoking the action as the reference widget. If it is unsuccessful it will continue up the widget tree using each of the invoking widget’s ancestors as the reference widget. If it is still unsuccessful it will print a warning message and give up. XawPositionSimpleMenu will position the menu directly under the pointer cursor. The menu will be placed so that the pointer cursor is centered on the entry named by the popupOnEntry resource. If the menuOnScreen resource is True then the menu will always be fully visible on the screen.

4.2.4. Convenience Routines

4.2.4.1. Registering the Global Action Routines

The XawPositionSimpleMenu action routine may often be invoked before any menus have been created. This can occur when an application uses dynamic menu creation. In these cases an application will need to register this global action routine by calling XawSimpleMenuAddGlobalActions:
void XawSimpleMenuAddGlobalActions(app_con)
XtAppContext app_con;

app_con

Specifies the application context in which this action should be registered.

This function need only be called once per application and must be called before any widget that uses XawPositionSimpleMenu action is realized.

4.2.4.2. Getting and Clearing the Current Menu Entry

To get the currently highlighted menu entry use XawSimpleMenuGetActiveEntry:
Widget XawSimpleMenuGetActiveEntry(w)
Widget w;

w

Specifies the SimpleMenu widget.

This function returns the menu entry that is currently highlighted, or NULL if no entry is highlighted.

To clear the SimpleMenu widget’s internal information about the currently highlighted menu entry use XawSimpleMenuClearActiveEntry:
Widget XawSimpleMenuClearActiveEntry(w)
Widget w;

w

Specifies the SimpleMenu widget.

This function unsets all internal references to the currently highlighted menu entry. It does not unhighlight or otherwise alter the appearance of the active entry. This function is primarily for use by implementors of menu entries.

4.3. SmeBSB Object

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

Class Header file

<X11/Xaw/SmeBSBP.h>

Class

smeBSBObjectClass

Class Name

SmeBSB

Superclass

Sme

The SmeBSB object is used to create a menu entry that contains a string, and optional bitmaps in its left and right margins. Since each menu entry is an independent object, the application is able to change the font, color, height, and other attributes of the menu entries, on an entry by entry basis. The format of the string may either be the encoding of the 8 bit font utilized, or in a multi-byte encoding for use with a fontSet.

4.3.1. Resources

The resources associated with the SmeBSB object are defined in this section, and affect only the single menu entry specified by this object.

Image widgets14.png

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.

callback

All callback functions on this list are called when the SimpleMenu notifies this entry that the user has selected it.

destroyCallback

All functions on this list are called when this widget is destroyed.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the SimpleMenu’s colormap to derive the foreground color of the menu entry’s window. This color is also used to render all 1’s in the left and right bitmaps.

height

width

The height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force the width of all menu entries to be the width of the longest entry.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

How the label is to be rendered between the left and right margins when the space is wider than the actual text. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. When specifying the justification from a resource file the values left, center, or right may be used.

label

This is a the string that will be displayed in the menu entry. The exact location of this string within the bounds of the menu entry is controlled by the leftMargin, rightMargin, vertSpace, and justify resources.

leftBitmap

rightBitmap

This is a name of a bitmap to display in the left or right margin of the menu entry. All 1’s in the bitmap will be rendered in the foreground color, and all 0’s will be drawn in the background color of the SimpleMenu widget. It is the programmers’ responsibility to make sure that the menu entry is tall enough, and the appropriate margin wide enough to accept the bitmap. If care is not taken the bitmap may extend into another menu entry, or into this entry’s label.

leftMargin

rightMargin

This is the amount of space (in pixels) that will be left between the edge of the menu entry and the label string.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

vertSpace

This is the amount of vertical padding, expressed as a percentage of the height of the font, that is to be placed around the label of a menu entry.. The label and bitmaps are always centered vertically within the menu. The default value for this resource (25) causes the default height to be 125% of the height of the font.

4.4. SmeLine Object

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

Class Header file

<X11/Xaw/SmeLineP.h>

Class

smeLineObjectClass

Class Name

SmeLine

Superclass

Sme

The SmeLine object is used to add a horizontal line or menu separator to a menu. Since each SmeLine is an independent object, the application is able to change the color, height, and other attributes of the SmeLine objects on an entry by entry basis. This object is not selectable, and will not highlight when the pointer cursor is over it.

4.4.1. Resources

The resources associated with the SmeLine object are defined in this section, and affect only the single menu entry specified by this object.

Image widgets15.png

destroyCallback

All functions on this list are called when this widget is destroyed.

foreground

A pixel value which indexes the SimpleMenu’s colormap to derive the foreground color used to draw the separator line.

height

width

The height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force all menu items to be the width of the widest entry. Thus, setting the width is generally not very important.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

lineWidth

The width of the horizontal line that is to be displayed.

stipple

If a bitmap is specified for this resource, the line will be stippled through it. This allows the menu separator to be rendered as something more exciting than just a line. For instance, if you define a stipple that is a chain link, then your menu separators will look like chains.

4.5. Sme Object

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

Class Header file

<X11/Xaw/SmeP.h>

Class

smeObjectClass

Class Name

Sme

Superclass

RectObj

The Sme object is the base class for all menu entries. While this object is mainly intended to be subclassed, it may be used in a menu to add blank space between menu entries.

4.5.1. Resources

The resources associated with the SmeLine object are defined in this section, and affect only the single menu entry specified by this object. There are no new resources added for this class, as it picks up all its resources from the RectObj class.

Image widgets16.png

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.

destroyCallback

All functions on this list are called when this widget is destroyed.

height

width

The height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force all menu items to be the width of the widest entry.

international

This is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

4.5.2. Subclassing the Sme Object

To Create a new Sme object class you will need to define three class methods. These methods allow the SimpleMenu to highlight and unhighlight the menu entry as the pointer cursor moves over it, as well as notify the entry when the user has selected it. All of these methods may be inherited from the Sme object, although the default semantics are not very interesting.

Highlight()

Called to put the menu entry into the highlighted state.

Unhighlight()

Called to return the widget to its normal (unhighlighted) state.

Notify()

Called when the user selects this menu entry.

Other then these methods, creating a new object is straight forward. Here is some information that may help you avoid some common mistakes.

1)

Objects can be zero pixels high.

2)

Objects draw on their parent’s window, therefore the Drawing dimensions are different from those of widgets. For instance, y locations vary from y to y + height, not 0 to height.

3)

XtSetValues calls may come from the application while the Sme is highlighted, and if the SetValues method returns True, will result in an expose event. The SimpleMenu may later call the menu entry’s unhighlight procedure. However, due to the asynchronous nature of X, the expose event generated by XtSetValues will come after this unhighlight.

4)

Remember that your subclass of the Sme does not own the window. Share the space with other menu entries, and refrain from drawing outside the subclass’s own section of the menu.

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

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

Image widgets17.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 this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.

bitmap

A bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget’s internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See Converting Bitmaps for details.) If this bitmap is one bit deep then the 1’s will be rendered in the foreground color, and the 0’s in the background color. If bitmap has a depth greater than one, it is copied directly into the window.

borderColor

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

borderPixmap

The border pixmap of this widget’s window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.

borderWidth

The width of this widget’s window border.

callback

A list of routines to be called when the notify action is invoked.

colormap

The colormap that this widget will use.

cornerRoundPercent

When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.

cursor

The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.

cursorName

The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)

depth

The depth of this widget’s window.

destroyCallback

All functions on this list are called when this widget is destroyed.

font

The text font to use when displaying the label, when the international resource is false.

fontSet

The text font set to use when displaying the label, when the international resource is true.

foreground

A pixel value which indexes the widget’s colormap to derive the foreground color of the widget’s window. This color is also used to render all 1’s in a bitmap one plane deep.

height

width

The height and width of this widget in pixels.

highlightThickness

The thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.

insensitiveBorder

This pixmap will be tiled into the widget’s border if the widget becomes insensitive.

internalHeight

internalWidth

The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.

international

This is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.

justify

Specifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.

label

Specifies the text string to be displayed in the widget’s window if no bitmap is specified. The default is the name of this widget. Regardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.

mappedWhenManaged

If this resource is True, then the widget’s window will automatically be mapped by the Toolkit when it is realized and managed.

menuName

The name of a popup shell to popup as a menu. The MenuButton will search for this name using XtNameToWidget starting with itself as the reference widget. If the search is unsuccessful the widget will continue up the widget tree using each of its ancestors as the reference widget passed to XtNameToWidget. If no widget of called menuName is found by this algorithm, the widget will print a warning message and give up. When the menu is found it will be popped up exclusive and spring_loaded. The MenuButton widget does not copy the value of this resource into newly allocated memory. The application programmer must pass the resource value in nonvolatile memory.

pointerColor

A pixel value which indexes the widget’s colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.

pointerColorBackground

A pixel value which indexes the widget’s colormap to derive the background color of the pointer symbol specified by the cursorName resource.

resize

Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.

screen

The screen on which this widget is displayed. This is not a settable resource.

sensitive

Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

shapeStyle

Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.

translations

The event bindings associated with this widget.

x

y

The location of the upper left outside corner of this widget in its parent.

4.6.2. MenuButton Actions

The MenuButton widget supports the following actions:

Switching the button between the foreground and background colors with set and unset

Processing application callbacks with notify

Switching the internal border between highlighted and unhighlighted states with highlight and unhighlight

Popping up a menu with PopupMenu

The following are the default translation bindings used by the MenuButton widget:

<EnterWindow>:

highlight()

<LeaveWindow>:

reset()

<BtnDown>:

reset() PopupMenu(

4.6.3. MenuButton Actions

The full list of actions supported by MenuButton is:

highlight(condition)

Displays the internal highlight border in the color (foreground or background ) that contrasts with the interior color of the Command widget. The conditions WhenUnset and Always are understood by this action procedure. If no argument is passed, WhenUnset is assumed.

unhighlight()

Displays the internal highlight border in the color (XtNforeground or background ) that matches the interior color of the MenuButton widget.

set()

Enters the set state, in which notify is possible. This action causes the button to display its interior in the foreground color. The label or bitmap is displayed in the background color.

unset()

Cancels the set state and displays the interior of the button in the background color. The label or bitmap is displayed in the foreground color.

reset()

Cancels any set or highlight and displays the interior of the button in the background color, with the label displayed in the foreground color.

notify()

When the button is in the set state this action calls all functions in the callback list named by the callback resource. The value of the call_data argument in these callback functions is undefined.

PopupMenu()

Pops up the menu specified by the menuName resource.

The MenuButton widget does not place a server grab on itself. Instead, PopupMenu is registered as a grab action. As a result, clients which popup menus without using XtMenuPopup or MenuPopup or PopupMenu in translations will fail to have a grab active. They should make a call to XtRegisterGrabAction on the appropriate action in the application initialization routine, or use a different translation.

Chapter 5

Text Widgets

The Text widget provides a window that will allow an application to display and edit one or more lines of text. Options are provided to allow the user to add Scrollbars to its window, search for a specific string, and modify the text in the buffer.

The Text widget is made up of a number of pieces; it was modularized to ease customization. The AsciiText widget class (actually not limited to ASCII but so named for compatibility) is be general enough to most needs. If more flexibility, special features, or extra functionality is needed, they can be added by implementing a new TextSource or TextSink, or by subclassing the Text Widget (See Section 5.8 for customization details.)

The words insertion point are used in this chapter to refer to the text caret. This is the symbol that is displayed between two characters in the file. The insertion point marks the location where any new characters will be added to the file. To avoid confusion the pointer cursor will always be referred to as the pointer.

The text widget supports three edit modes, controlling the types of modifications a user is allowed to make:

Append-only

Editable

Read-only

Read-only mode does not allow the user or the programmer to modify the text in the widget. While the entire string may be reset in read-only mode with XtSetValues, it cannot be modified via with XawTextReplace. Append-only and editable modes allow the text at the insertion point to be modified. The only difference is that text may only be added to or removed from the end of a buffer in append-only mode.

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

The default key bindings are patterned after those in the EMACS text editor:

Ctrl-a

Beginning Of Line

Meta-b

Backward Word

Ctrl-b

Backward Character

Meta-f

Forward Word

Ctrl-d

Delete Next Character

Meta-iInsert File

Ctrl-e

End Of Line

Meta-k

Kill To End Of Paragraph

Ctrl-f

Forward Character

Meta-q

Form Paragraph

Ctrl-g

Multiply Reset

Meta-v

Previous Page

Ctrl-h

Delete Previous Character

Meta-yInsert Current Selection

Ctrl-j

Newline And Indent

Meta-z

Scroll One Line Down

Ctrl-k

Kill To End Of Line

Meta-d

Delete Next Word

Ctrl-l

Redraw Display

Meta-D

Kill Word

Ctrl-m

Newline

Meta-h

Delete Previous Word

Ctrl-n

Next Line

Meta-H

Backward Kill Word

Ctrl-o

Newline And Backup

Meta-<

Beginning Of File

Ctrl-p

Previous Line

Meta->

End Of File

Ctrl-r

Search/Replace Backward

Meta-]Forward Paragraph

Ctrl-s

Search/Replace Forward

Meta-[Backward Paragraph

Ctrl-t

Transpose Characters

Ctrl-u

Multiply by 4

Meta-Delete

Delete Previous Word

Ctrl-v

Next Page

Meta-Shift DeleteKill Previous Word

Ctrl-w

Kill Selection

Meta-Backspace

Delete Previous Word

Ctrl-y

Unkill

Meta-Shift BackspaceKill Previous Word

Ctrl-z

Scroll One Line Up

Ctrl-\

Reconnect to input method

Kanji

Reconnect to input method

In addition, the pointer may be used to cut and paste text:

Button 1 Down

Start Selection

Button 1 MotionAdjust Selection

Button 1 Up

End Selection (cut)

Button 2 Down

Insert Current Selection (paste)

Button 3 Down

Extend Current Selection

Button 3 MotionAdjust Selection

Button 3 Up

End Selection (cut)

Since all of these key and pointer bindings are set through the translations and resource manager, the user and the application programmer can modify them by changing the Text widget’s translations resource.

5.1.2. Search and Replace

The Text widget provides a search popup that can be used to search for a string within the current Text widget. The popup can be activated by typing either Control-r or Control-s. If Control-s is used the search will be forward in the file from the current location of the insertion point; if Control-r is used the search will be backward. The activated popup is placed under the pointer. It has a number of buttons that allow both text searches and text replacements to be performed.

At the top of the search popup are two toggle buttons labeled backward and forward. One of these buttons will always be highlighted; this is the direction in which the search will be performed. The user can change the direction at any time by clicking on the appropriate button.

Directly under the buttons there are two text areas, one labeled Search for: and the other labeled Replace with:. If this is a read-only Text widget the Replace with: field will be insensitive and no replacements will be allowed. After each of these labels will be a text field. This field will allow the user to enter a string to search for and the string to replace it with. Only one of these text fields will have a window border around it; this is the active text field. Any key presses that occur when the focus in in the search popup will be directed to the active text field. There are also a few special key sequences:

Carriage Return:

Execute the action, and pop down the search widget.

Tab:

Execute the action, then move to the next field.

Shift Carriage Return:Execute the action, then move to the next field.

Control-q Tab:

Enter a Tab into a text field.

Control-c:

Pop down the search popup.

Using these special key sequences should allow simple searches without ever removing one’s hands from the keyboard.

Near the bottom of the search popup is a row of buttons. These buttons allow the same actions to to be performed as the key sequences, but the buttons will leave the popup active. This can be quite useful if many searches are being performed, as the popup will be left on the display. Since the search popup is a transient window, it may be picked up with the window manager and pulled off to the side for use at a later time.

Search

Search for the specified string.

Replace

Replace the currently highlighted string with the string in the Replace with text field, and move onto the next occurrence of the Search for text field. The functionality is commonly referred to as query-replace.

Replace-All

Replace all occurrences of the search string with the replace string from the current insertion point position to the end (or beginning) of the file. There is no key sequence to perform this action.

Cancel

Remove the search popup from the screen.

Finally, when international resource is true, there may be a pre-edit buffer below the button row, for composing input. Its presence is determined by the X locale in use and the VendorShell’s preeditType resource.

The widget hierarchy for the search popup is show below, all widgets are listed by class and instance name.

Text <name of Text widget>

TransientShell search

Form form

Label label1

Label label2

Toggle backwards

Toggle forwards

Label searchLabel

Text searchText

Label replaceLabel

Text replaceText

Command search

Command replaceOne

Command replaceAll

Command cancel

5.1.3. File Insertion

To insert a file into a text widget, type the key sequence Meta-i, which will activate the file insert popup. This popup will appear under the pointer, and any text typed while the focus is in this popup will be redirected to the text field used for the filename. When the desired filename has been entered, click on Insert File, or type Carriage Return. The named file will then be inserted in the text widget beginning at the insertion point position. If an error occurs when opening the file, an error message will be printed, prompting the user to enter the filename again. The file insert may be aborted by clicking on Cancel. If Meta-i is typed at a text widget that is read-only, it will beep, as no file insertion is allowed.

The widget hierarchy for the file insert popup is show below; all widgets are listed by class and instance name.

Text <name of Text widget>

TransientShell insertFile

Form form

Label label

Text text

Command insert

Command cancel

5.1.4. Text Selections for Users

The text widgets have a text selection mechanism that allows the user to copy pieces of the text into the PRIMARY selection, and paste into the text widget some text that another application (or text widget) has put in the PRIMARY selection.

One method of selecting text is to press pointer button 1 on the beginning of the text to be selected, drag the pointer until all of the desired text is highlighted, and then release the button to activate the selection. Another method is to click pointer button 1 at one end of the text to be selected, then click pointer button 3 at the other end.

To modify a currently active selection, press pointer button 3 near either the end of the selection that you want to adjust. This end of the selection may be moved while holding down pointer button 3. When the proper area has been highlighted release the pointer button to activate the selection.

The selected text may now be pasted into another application, and will remain active until some other client makes a selection. To paste text that some other application has put into the PRIMARY selection use pointer button 2. First place the insertion point where you would like the text to be inserted, then click and release pointer button 2.

Rapidly clicking pointer button 1 the following number of times will adjust the selection as described.

Two

Select the word under the pointer. A word boundary is defined by the Text widget to be a Space, Tab, or Carriage Return.

Three

Select the line under the pointer.

Four

Select the paragraph under the pointer. A paragraph boundary is defined by the text widget as two Carriage Returns in a row with only Spaces or Tabs between them.

Five

Select the entire text buffer.

To unset the text selection, click pointer button 1 without moving it.

5.2. Text Widget Actions

All editing functions are performed by translation manager actions that may be specified through the translations resource in the Text widget.

Insert Point Movement

Delete

forward-character

delete-next-character

backward-character

delete-previous-character

forward-word

delete-next-word

backward-word

delete-previous-word

forward-paragraph

delete-selection

backward-paragraph

beginning-of-line

end-of-line

Selection

next-line

select-word

previous-line

select-all

next-page

select-start

previous-page

select-adjust

beginning-of-file

select-end

end-of-file

extend-start

scroll-one-line-up

extend-adjust

scroll-one-line-down

extend-end

insert-selection

Miscellaneous

New Line

redraw-display

newline-and-indent

insert-file

newline-and-backup

insert-char

newline

insert-string

display-caret

focus-in

Kill

focus-in

kill-word

search

backward-kill-word

multiply

kill-selection

form-paragraph

kill-to-end-of-line

transpose-characters

kill-paragraph

no-op

kill-to-end-of-paragraph

XawWMProtocols

reconnect-im

Most of the actions take no arguments, and unless otherwise noted you may assume this to be the case.

5.2.1. Cursor Movement Actions

forward-character()

backward-character()

These actions move the insert point forward or backward one character in the buffer. If the insert point is at the end or beginning of a line this action will move the insert point to the next (or previous) line.

forward-word()

backward-word()

These actions move the insert point to the next or previous word boundary. A word boundary is defined as a Space, Tab or Carriage Return.

forward-paragraph()

backward-paragraph()

These actions move the insert point to the next or previous paragraph boundary. A paragraph boundary is defined as two Carriage Returns in a row with only Spaces or Tabs between them.

beginning-of-line()

end-of-line()

These actions move to the beginning or end of the current line. If the insert point is already at the end or beginning of the line then no action is taken.

next-line()

previous-line()

These actions move the insert point up or down one line. If the insert point is currently N characters from the beginning of the line then it will be N characters from the beginning of the next or previous line. If N is past the end of the line, the insert point is placed at the end of the line.

next-page()

previous-page()

These actions move the insert point up or down one page in the file. One page is defined as the current height of the text widget. The insert point is always placed at the first character of the top line by this action.

beginning-of-file()

end-of-file()

These actions place the insert point at the beginning or end of the current text buffer. The text widget is then scrolled the minimum amount necessary to make the new insert point location visible.

scroll-one-line-up()

scroll-one-line-down()

These actions scroll the current text field up or down by one line. They do not move the insert point. Other than the scrollbars this is the only way that the insert point may be moved off of the visible text area. The widget will be scrolled so that the insert point is back on the screen as soon as some other action is executed.

5.2.2. Delete Actions

delete-next-character()

delete-previous-character()

These actions remove the character immediately before or after the insert point. If a Carriage Return is removed then the next line is appended to the end of the current line.

delete-next-word()

delete-previous-word()

These actions remove all characters between the insert point location and the next word boundary. A word boundary is defined as a Space, Tab or Carriage Return.

delete-selection()

This action removes all characters in the current selection. The selection can be set with the selection actions.

5.2.3. Selection Actions

select-word()

This action selects the word in which the insert point is currently located. If the insert point is between words then it will select the previous word.

select-all()

This action selects the entire text buffer.

select-start()

This action sets the insert point to the current pointer location (if triggered by a button event) or text cursor location (if triggered by a key event). It will then begin a selection at this location. If many of these selection actions occur quickly in succession then the selection count mechanism will be invoked (see the section titled Text Selections for Application Programmers for details).

select-adjust()

This action allows a selection started with the select-start action to be modified, as described above.

select-end(name[,

name,...])

This action ends a text selection that began with the select-start action, and asserts ownership of the selection or selections specified. A name can be a selection (e.g., PRIMARY) or a cut buffer (e.g., CUT_BUFFER0). Note that case is important. If no names are specified, PRIMARY is asserted.

extend-start()

This action finds the nearest end of the current selection, and moves it to the current pointer location (if triggered by a button event) or text cursor location (if triggered by a key event).

extend-adjust()

This action allows a selection started with an extend-start action to be modified.

extend-end(name[,

name,...])

This action ends a text selection that began with the extend-start action, and asserts ownership of the selection or selections specified. A name can be a selection (e.g. PRIMARY) or a cut buffer (e.g CUT_BUFFER0). Note that case is important. If no names are given, PRIMARY is asserted.

insert-selection(

name[,name,...])

This action retrieves the value of the first (left-most) named selection that exists or the cut buffer that is not empty and inserts it into the Text widget at the current insert point location. A name can be a selection (e.g. PRIMARY) or a cut buffer (e.g CUT_BUFFER0). Note that case is important.

5.2.4. The New Line Actions

newline-and-indent()

This action inserts a newline into the text and adds spaces to that line to indent it to match the previous line.

newline-and-backup()

This action inserts a newline into the text after the insert point.

newline()

This action inserts a newline into the text before the insert point.

5.2.5. Kill and Actions

kill-word()

backward-kill-word()

These actions act exactly like the delete-next-word and delete-previous-word actions, but they stuff the word that was killed into the kill buffer (CUT_BUFFER_1).

kill-selection()

This action deletes the current selection and stuffs the deleted text into the kill buffer (CUT_BUFFER_1).

kill-to-end-of-line()

This action deletes the entire line to the right of the insert point position, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1).

kill-paragraph()

This action deletes the current paragraph, if between paragraphs it deletes the paragraph above the insert point, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1).

kill-to-end-of-paragraph()

This action deletes everything between the current insert point location and the next paragraph boundary, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1).

5.2.6. Miscellaneous Actions

redraw-display()

This action recomputes the location of all the text lines on the display, scrolls the text to vertically center the line containing the insert point on the screen, clears the entire screen, and redisplays it.

insert-file([

filename])

This action activates the insert file popup. The filename option specifies the default filename to put in the filename buffer of the popup. If no filename is specified the buffer is empty at startup.

insert-char()

This action may only be attached to a key event. When the international resource is false, this action calls XLookupString to translate the event into a (rebindable) Latin-1 character (sequence) and inserts it into the text at the insert point. When the international resource is true, characters are passed to the input method via XwcLookupString, and any committed string returned is inserted into the text at the insert point.

insert-string(string

[,string,...])

This action inserts each string into the text at the insert point location. Any string beginning with the characters "0x" followed by an even number of hexadecimal digits is interpreted as a hexadecimal constant and the corresponding string is inserted instead. This hexadecimal string may represent up to 50 8-bit characters.

When theinternational resource is true, a hexadecimal string is intrepeted as being in a multi-byte encoding, and a hexadecimal or regular string will result in an error message if it is not legal in the current locale.

display-caret(state,when)

This action allows the insert point to be turned on and off. The state argument specifies the desired state of the insert point. This value may be any of the string values accepted for Boolean resources (e.g. on, True, off, False, etc.). If no arguments are specified, the default value is True. The when argument specifies, for EnterNotify or LeaveNotify events whether or not the focus field in the event is to be examined. If the second argument is not specified, or specified as something other than always then if the action is bound to an EnterNotify or LeaveNotify event, the action will be taken only if the focus field is True. An augmented binding that might be useful is:

*Text.Translations: #override \

<FocusIn>:

display-caret(on) \n\

<FocusOut>:

display-caret(off)

focus-in()

focus-out()

These actions do not currently do anything.

search(direction,[

string])

This action activates the search popup. The direction must be specified as either forward or backward. The string is optional and is used as an initial value for the Search for: string. For further explanation of the search widget see the section on Text Searches.

multiply(value)

The multiply action allows the user to multiply the effects of many of the text actions. Thus the following action sequence multiply(10) delete-next-word() will delete 10 words. It does not matter whether these actions take place in one event or many events. Using the default translations the key sequence Control-u, Control-d will delete 4 characters. Multiply actions can be chained, thus multiply(5) multiply(5) is the same as multiply(25). If the string reset is passed to the multiply action the effects of all previous multiplies are removed and a beep is sent to the display.

form-paragraph()

This action removes all the Carriage Returns from the current paragraph and reinserts them so that each line is as long as possible, while still fitting on the current screen. Lines are broken at word boundaries if at all possible. This action currently works only on Text widgets that use ASCII text.

transpose-characters()

This action will swap the position of the character to the left of the insert point with the character to the right of the insert point. The insert point will then be advanced one character.

no-op([action])

The no-op action makes no change to the text widget, and is mainly used to override translations. This action takes one optional argument. If this argument is RingBell then a beep is sent to the display.

XawWMProtocols([

wm_protocol_name])

This action is written specifically for the file insertion and the search and replace dialog boxes. This action is attached to those shells by the Text widget, in order to handle ClientMessage events with the WM_PROTOCOLS atom in the detail field. This action supports WM_DELETE_WINDOW on the Text widget popups, and may support other window manager protocols if necessary in the future. The popup will be dismissed if the window manager sends a WM_DELETE_WINDOW request and there are no parameters in the action call, which is the default. The popup will also be dismissed if the parameters include the string ‘‘wm_delete_window,’’ and the event is a ClientMessage event requesting dismissal or is not a ClientMessage event. This action is not sensitive to the case of the strings passed as parameters.

reconnect-im()

When the international resource is true, input is usually passed to an input method, a separate process, for composing. Sometimes the connection to this process gets severed; this action will attempt to reconnect it. Causes for severage include network trouble, and the user explicitly killing one input method and starting a new one. This action may also establish first connection when the application is started before the input method.

5.2.7. Text Selections for Application Programmers

The default behavior of the text selection array is described in the section called Text Selections for Users. To modify the selections a programmer must construct a XawTextSelectType array (called the selection array), containing the selections desired, and pass this as the new value for the selectionTypes resource. The selection array may also be modified using the XawTextSetSelectionArray function. All selection arrays must end with the value XawselectNull. The selectionTypes resource has no converter registered and cannot be modified through the resource manager.

The array contains a list of entries that will be called when the user attempts to select text in rapid succession with the select-start action (usually by clicking a pointer button). The first entry in the selection array will be used when the select-start action is initially called. The next entry will be used when select-start is called again, and so on. If a timeout value (1/10 of a second) is exceeded, the the next select-start action will begin at the top of the selection array. When XawselectNull is reached the array is recycled beginning with the first element.

Image widgets18.png

The default selectType array is:

{XawselectPosition, XawselectWord, XawselectLine, XawselectParagraph, XawselectAll, XawselectNull}

The selection array is not copied by the text widgets. The application must allocate space for the array and cannot deallocate or change it until the text widget is destroyed or until a new selection array is set.

5.3. Default Translation Bindings

The following translations are defaults built into every Text widget. They can be overridden, or replaced by specifying a new value for the Text widget’s translations resource.

Ctrl<Key>A:

beginning-of-line() \n\

Ctrl<Key>B:

backward-character() \n\

Ctrl<Key>D:

delete-next-character() \n\

Ctrl<Key>E:

end-of-line() \n\

Ctrl<Key>F:

forward-character() \n\

Ctrl<Key>G:

multiply(Reset) \n\

Ctrl<Key>H:

delete-previous-character() \n\

Ctrl<Key>J:

newline-and-indent() \n\

Ctrl<Key>K:

kill-to-end-of-line() \n\

Ctrl<Key>L:

redraw-display() \n\

Ctrl<Key>M:

newline() \n\

Ctrl<Key>N:

next-line() \n\

Ctrl<Key>O:

newline-and-backup() \n\

Ctrl<Key>P:

previous-line() \n\

Ctrl<Key>R:

search(backward) \n\

Ctrl<Key>S:

search(forward) \n\

Ctrl<Key>T:

transpose-characters() \n\

Ctrl<Key>U:

multiply(4) \n\

Ctrl<Key>V:

next-page() \n\

Ctrl<Key>W:

kill-selection() \n\

Ctrl<Key>Y:

insert-selection(CUT_BUFFER1) \n\

Ctrl<Key>Z:

scroll-one-line-up() \n\

Ctrl<Key>\:

reconnect-im() \n\

Meta<Key>B:

backward-word() \n\

Meta<Key>F:

forward-word() \n\

Meta<Key>I:

insert-file() \n\

Meta<Key>K:

kill-to-end-of-paragraph() \n\

Meta<Key>Q:

form-paragraph() \n\

Meta<Key>V:

previous-page() \n\

Meta<Key>Y:

insert-selection(PRIMARY, CUT_BUFFER0) \n\

Meta<Key>Z:

scroll-one-line-down() \n\

:Meta<Key>d:

delete-next-word() \n\

:Meta<Key>D:

kill-word() \n\

:Meta<Key>h:

delete-previous-word() \n\

:Meta<Key>H:

backward-kill-word() \n\

:Meta<Key>\<:

beginning-of-file() \n\

:Meta<Key>\>:

end-of-file() \n\

:Meta<Key>]:

forward-paragraph() \n\

:Meta<Key>[:

backward-paragraph() \n\

~Shift Meta<Key>Delete:delete-previous-word() \n\

 Shift Meta<Key>Delete:backward-kill-word() \n\

~Shift Meta<Key>Backspace:delete-previous-word() \n\

 Shift Meta<Key>Backspace:backward-kill-word() \n\

<Key>Right:

forward-character() \n\

<Key>Left:

backward-character() \n\

<Key>Down:

next-line() \n\

<Key>Up:

previous-line() \n\

<Key>Delete:

delete-previous-character() \n\

<Key>BackSpace:

delete-previous-character() \n\

<Key>Linefeed:

newline-and-indent() \n\

<Key>Return:

newline() \n\

<Key>:

insert-char() \n\

<Key>Kanji:

reconnect-im() \n\

<FocusIn>:

focus-in() \n\

<FocusOut>:

focus-out() \n\

<Btn1Down>:

select-start() \n\

<Btn1Motion>:

extend-adjust() \n\

<Btn1Up>:

extend-end(PRIMARY, CUT_BUFFER0) \n\

<Btn2Down>:

insert-selection(PRIMARY, CUT_BUFFER0) \n\

<Btn3Down>:

extend-start() \n\

<Btn3Motion>:

extend-adjust() \n\

<Btn3Up>:

extend-end(PRIMARY, CUT_BUFFER0) \n

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

To select a piece of text, use XawTextSetSelection:
void XawTextSetSelection(w, left, right)
Widget w;
XawTextPosition left, right;

w

Specifies the Text widget.

left

Specifies the character position at which the selection begins.

right

Specifies the character position at which the selection ends.

See section 5.4 for a description of XawTextPosition. If redisplay is enabled, this function highlights the text and makes it the PRIMARY selection. This function does not have any effect on CUT_BUFFER0.

5.4.2. Unhighlighting Text

To unhighlight previously highlighted text in a widget, use XawTextUnsetSelection:
void XawTextUnsetSelection(w)
Widget w;

w

Specifies the Text widget.

5.4.3. Getting Current Text Selection

To retrieve the text that has been selected by this text widget use XawTextGetSelectionPos:
void XawTextGetSelectionPos(w, begin_return, end_return)
Widget w;
XawTextPosition *begin_return, *end_return;

w

Specifies the Text widget.

begin_return

Returns the beginning of the text selection.

end_return

Returns the end of the text selection.

See section 5.4 for a description of XawTextPosition. If the returned values are equal, no text is currently selected.

5.4.4. Replacing Text

To modify the text in an editable Text widget use XawTextReplace:
int XawTextReplace(w, start, end, text)
Widget w;
XawTextPosition start, end;
XawTextBlock *text;

w

Specifies the Text widget.

start

Specifies the starting character position of the text replacement.

end

Specifies the ending character position of the text replacement.

text

Specifies the text to be inserted into the file.

This function will not be able to replace text in read-only text widgets. It will also only be able to append text to an append-only text widget.

See section 5.4 for a description of XawTextPosition and XawTextBlock.

This function may return the following values:

XawEditDone

The text replacement was successful.

XawPositionError

The edit mode is XawtextAppend and start is not the position of the last character of the source.

XawEditError

Either the Source was read-only or the range to be deleted is larger than the length of the Source.

The XawTextReplace arguments start and end represent the text source character positions for the existing text that is to be replaced by the text in the text block. The characters from start up to but not including end are deleted, and the characters specified on the text block are inserted in their place. If start and end are equal, no text is deleted and the new text is inserted after start.

5.4.5. Searching for Text

To search for a string in the Text widget, use XawTextSearch:
XawTextPosition XawTextSearch(w, dir, text)
Widget w;
XawTextScanDirection dir;
XawTextBlock * text;

w

Specifies the Text widget.

dir

Specifies the direction to search in. Legal values are XawsdLeft and XawsdRight.

text

Specifies a text block structure that contains the text to search for.

See section 5.4 for a description of XawTextPosition and XawTextBlock. The XawTextSearch function will begin at the insertion point and search in the direction specified for a string that matches the one passed in text. If the string is found the location of the first character in the string is returned. If the string could not be found then the value XawTextSearchError is returned.

5.4.6. Redisplaying Text

To redisplay a range of characters, use XawTextInvalidate:
void XawTextInvalidate(w, from, to)
Widget w;
XawTextPosition from, to;

w

Specifies the Text widget.

from

Specifies the start of the text to redisplay.

to

Specifies the end of the text to redisplay.

See section 5.4 for a description of XawTextPosition. The XawTextInvalidate function causes the specified range of characters to be redisplayed immediately if redisplay is enabled or the next time that redisplay is enabled.

To enable redisplay, use XawTextEnableRedisplay:
void XawTextEnableRedisplay(w)
Widget w;

w

Specifies the Text widget.

The XawTextEnableRedisplay function flushes any changes due to batched updates when XawTextDisableRedisplay was called and allows future changes to be reflected immediately.

To disable redisplay while making several changes, use XawTextDisableRedisplay.
void XawTextDisableRedisplay(w)
Widget w;

w

Specifies the Text widget.

The XawTextDisableRedisplay function causes all changes to be batched until either XawTextDisplay or XawTextEnableRedisplay is called.

To display batched updates, use XawTextDisplay:
void XawTextDisplay(w)
Widget w;

w

Specifies the Text widget.

The XawTextDisplay function forces any accumulated updates to be displayed.

5.4.7. Resources Convenience Routines

To obtain the character position of the left-most character on the first line displayed in the widget (the value of the displayPosition resource), use XawTextTopPosition.
XawTextPosition XawTextTopPosition(w)
Widget w;

w

Specifies the Text widget.

To assign a new selection array to a text widget use XawTextSetSelectionArray:
void XawTextSetSelectionArray(w, sarray)
Widget w;
XawTextSelectType * sarray;

w

Specifies the Text widget.

sarray

Specifies a selection array as defined in the section called Text Selections for Application Programmers.

Calling this function is equivalent to setting the value of the selectionTypes resource.

To move the insertion point to the specified source position, use XawTextSetInsertionPoint:
void XawTextSetInsertionPoint(w, position)
Widget w;
XawTextPosition position;

w

Specifies the Text widget.

position

Specifies the new position for the insertion point.

See section 5.4 for a description of XawTextPosition. The text will be scrolled vertically if necessary to make the line containing the insertion point visible. Calling this function is equivalent to setting the insertPosition resource.

To obtain the current position of the insertion point, use XawTextGetInsertionPoint:
XawTextPosition XawTextGetInsertionPoint(w)
Widget w;

w

Specifies the Text widget.

See section 5.4 for a description of XawTextPosition. The result is equivalent to retrieving the value of the insertPosition resource.

To replace the text source in the specified widget, use XawTextSetSource:
void XawTextSetSource(w, source, position)
Widget w;
Widget source;
XawTextPosition position;

w

Specifies the Text widget.

source

Specifies the text source object.

position

Specifies character position that will become the upper left hand corner of the displayed text. This is usually set to zero.

See section 5.4 for a description of XawTextPosition. A display update will be performed if redisplay is enabled.

To obtain the current text source for the specified widget, use XawTextGetSource:
Widget XawTextGetSource(w)
Widget w;

w

Specifies the Text widget.

This function returns the text source that this Text widget is currently using.

To enable and disable the insertion point, use XawTextDisplayCaret:
void XawTextDisplayCaret(w, visible)
Widget w;
Boolean visible;

w

Specifies the Text widget.

visible

Specifies whether or not the caret should be displayed.

If visible is False the insertion point will be disabled. The marker is re-enabled either by setting visible to True, by calling XtSetValues, or by executing the display-caret action routine.

5.5. Ascii Text Widget

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

ClassHeader file

<X11/Xaw/AsciiTextP.h>

Class

asciiTextWidgetClass

Class Name

Text

Superclass

Text

Sink Name

textSink

Source Name

</