Preface

The Motif Widget Writer's Guide describes how to create Motif® widgets. Widgets are objects from which applications programmers build Motif® applications. The guide explains (primarily through examples) how to write an Intrinsics-based widget that conforms to Motif specifications.

Audience

This guide is aimed at experienced programmers who wish to write their own Motif widgets.

The ideal reader will have as prerequisite some experience writing Intrinsics-based widgets. Failing that, the reader must have at least a general understanding of the X Window System, plus a good grasp of Xlib and Xt. The reader should also understand Motif programming topics such as resources, actions, and keyboard traversal. Finally, the more the reader understands about object-oriented programming, the better.

This guide assumes that the reader is familiar with the American National Standards Institute (ANSI) C programming language or with the C++ programming language.

Applicability

This is Revision 1.0 of this guide. It applies to Release 2.0 of the Motif software system.

Purpose

After reading this guide, you should know how to write a subclass of either a Primitive or Manager Motif widget. In addition, you will also know how to make your new widget(s) accessible to Motif application programmers.

This guide does not explain the Intrinsics.

Document Usage

This guide is organized into two parts. Part 1, covering Chapters 1 through 15, is a programmer's guide. The chapters are arranged as follows:

  • Chapter 1 explains the software and prerequisite knowledge you will need in order to write a Motif widget.

  • Chapter 2 takes you step by step through the mechanics of creating a Motif widget in the C language. This chapter also includes information on writing multithread-safe widgets.

  • Chapter 3 details how to write the class record for a Motif primitive widget.

  • Chapter 4 details how to write the class record for a Motif manager widget.

  • Chapter 5 explains how to use traits.

  • Chapter 6 describes how to create resources and synthetic resources.

  • Chapter 7 explains how to set up translations and actions and explains several important action routines of Primitive and Manager.

  • Chapter 8 explains how to use the Xme widget-writing routines.

  • Chapter 9 describes how to handle textual data.

  • Chapter 10 describes the Uniform Transfer Method (UTM) for transferring data between widgets.

  • Chapter 11 explains how to write a Motif button widget.

  • Chapter 12 describes geometry management.

  • Chapter 13 details how to write a Motif widget in C++.

  • Chapter 14 explains how to extend UIL to interpret your new Motif widgets.

  • Chapter 15 describes miscellaneous features of Motif widget writing such as internationalization.

  • Chapter 16 discusses widget printing.

Part 2 of the guide includes Chapters 17 through 19. This part consists of pure reference documentation categorized as follows:

  • Chapter 17 details all the Xme widget-writer routines.

  • Chapter 18 details all Motif traits and trait methods.

  • Chapter 19 details all the Exm demonstration widgets that we are providing to serve as good examples of small Motif widgets.

Multithread Safety of Code Examples

The code examples that appear throughout this manual are not guaranteed to be multithread-safe.

Related Documents

For additional information about Motif, refer to the following documents:

  • The Motif Programmer's Reference provides detailed reference information for programmers writing Motif applications.

  • The Application Environment Specification — User Environment Volume defines a stable set of routines for creating user interface applications.

  • The Motif Style Guide explains the principles of user interface design for application developers.

  • The Motif User's Guide explains how to interact with Motif applications.

For additional information about Xlib and Xt, refer to the following X Window System documents:

  • Xlib—C Language X Interface is the specification for Xlib.

  • X Toolkit Intrinsics—C Language Interface is the specification for Xt.

What DocBook SGML Markup Means

This book is written in the Structured Generalized Markup Language (SGML) using the DocBook Document Type Definition (DTD). The following table describes the DocBook markup used for various semantic elements.

Table 1. DocBook SGML Markup

Markup Appearance

Semantic Element(s)

Example

AaBbCc123

The names of commands.

Use the ls command to list files.

AaBbCc123

The names of command options.

Use ls −a to list all files.

AaBbCc123

Command-line placeholder: replace with a real name or value.

To delete a file, type rm filename.

AaBbCc123

The names of files and directories.

Edit your .login file.

AaBbCc123

Book titles, new words or terms, or words to be emphasized.

Read Chapter 6 in User's Guide. These are called class options. You must be root to do this.


Terminology Conventions

We use the term primitive to mean any subclass of XmPrimitive. We use the term manager to mean any subclass of XmManager. Note that both of these terms are in lowercase.

Keyboard Conventions

Because not all keyboards are the same, it is difficult to specify keys that are correct for every manufacturer's keyboard. To solve this problem, this guide describes keys that use a virtual key mechanism. The term virtual implies that the keys as described do not necessarily correspond to a fixed set of actual keys. Instead, virtual keys are linked to actual keys by means of virtual bindings. A given virtual key may be bound to different physical keys for different keyboards.

See Chapter 2 of this guide for information on the mechanism for binding virtual keys to actual keys. For details, see the VirtualBindings(3) reference page in the Motif Programmer's Reference.

Mouse Conventions

In this guide, mouse buttons are described using a virtual button mechanism to better describe behavior independent from the number of buttons on the mouse. This guide assumes a 3-button mouse. On a 3-button mouse, the leftmost mouse button is usually defined as BSelect, the middle mouse button is usually defined as BTransfer, and the rightmost mouse button is usually defined as BMenu. For details about how virtual mouse buttons are usually defined, see the VirtualBindings(3) reference page in the Motif Programmer's Reference.

Problem Reporting

If you have any problems with the software or documentation, please contact your software vendor's customer service department.