[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP DECwindows Motif for OpenVMS
Release Notes


Previous Contents Index

B.4 Helloint Example Program

V1.2

This example is a simple UIL/Xm program with a label and a push button.

With this version, you can choose a Kanji, Hebrew, French, or English interface at run time.

The program uses the file LOCALSTRINGS.UID for all language-specific interfaces. To change languages, copy one of the LOCALSTRINGS_*.UID files to DECW$USER_DEFAULTS:LOCALSTRINGS.UID. Then, use the logical name LANG or the xnlLanguage resource to set the locale. Set the LOCALSTRINGS suffix and the locale name to one of the following:

Locale Interface Type
Japan Kanji
Hebrew Hebrew
French French
English Standard English

To define the xnlLanguage resource, add the following line to your DECW$XDEFAULTS.DAT file:


*xnlLanguage:locale

The following fonts are needed for the helloint example program:

Locale Font Name
French -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1
English -adobe-times-medium-r-normal--14-100-100-100-p-74-iso8859-1
Hebrew -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-8
Japan -*-JISX0208.1983-1
  -*-JISX0201.1976-0

If you do not have these fonts installed on your system, either change the UIL files to reference other fonts or install the *.DECW$BDF fonts provided in the DECW$EXAMPLES directory. See Managing DECwindows Motif for OpenVMS Systems for instructions on how to install new fonts.

B.5 Hellomotif Example Program

V1.2

This example is a simple UIL/Xm program with a label and a push button.

B.6 Motifanim Example Program

V1.1

The motifanim program demonstrates the following OSF/Motif features:

  • Declaration of icon/bitmap using UIL for portability across visuals
  • Exchange of value between UIL and C using Mrm
  • Use of the Motif form widget
  • Background procedure running while the client process is waiting for input (Xt intrinsics feature)

This example lets you animate a set of pixmaps in an X window. The pixmaps are not fixed by motifanim but are read at startup from existing UID files.

The syntax of all the animation.uid files can add a new set of pixmaps to be animated using motifanim. Some tree examples of animation data files include:

dog.uil
plane.uil

The default animation is dog. To run the example with the other animations, use the following commands:


$ SET DEFAULT DECW$EXAMPLES
$ motifanim := "$DECW$EXAMPLES:motifanim"
$ motifanim -anim plane

The files motiflogo.uil, motifanim.uil, and motifanim.c are the core components of the program.

B.7 Motifgif and Pict Viewing Programs

V1.2

The following .gif files are provided:

  • TOUCAN.GIF, which is a picture of a tropical bird.
  • CHALLENGER.GIF, which is a picture of the space shuttle Challenger.

V1.1

The motifgif and pict programs work together to display a .gif formatted picture. The motifgif program displays a .gif file within Motif constructs. The motifgif program looks for .gif files in the current directory.

The motifgif program has three significant components:

  • motifgif The source and executable code in this directory is a Motif program driving the display of a .gif picture.
  • pict The program called by motifgif that displays a bitmap of a .gif picture file. This program used to be xgif but has since been converted to Motif.

The following problems exist with motifgif:

  • Resizing a picture does not work.
  • The -d option is not used when calling pict, so remote displays must set the DISPLAY environment variable.

B.8 Motifshell Example Program

V1.2

The motifshell program is an example of an environment created using Motif. The purpose of the example is to show how Motif may be used as a standalone environment for dispatching other programs and utilities.

The motifshell program is written in C code. There are no UIL references.

Note

Displaying a file listing or process status takes some time. These operations are accomplished by spawning a DCL command, capturing the output in a file, and then reading the file.

The default font is proportionally spaced. Some listings are more readable if a fixed space font is used, such as Courier. Use the Font option to select a different font.

B.9 Periodic Example Program

V1.2

The periodic example is a demonstration of the displayable widgets in Motif. The program displays Motif widgets in a periodic chart format.

B.10 Textedit Example Program

V1.2

The textedit program is a primitive text editor based on the Motif XmText widget that makes use of its XmNsource resource to allow multiple views of the same underlying text.

Table B-1 describes the View menu options.

Table B-1 View Menu Options
Option Description
Split Pane Adds a new independently scrollable view of the text.
Remove Pane Removes a designated pane.
One Pane Removes all panes except the designated pane.

The designated pane is determined in the following way:

  • If using an explicit focus policy, it is the last view which had focus.
  • If using a pointer focus policy, it is the last view with which the user interacted.

The designated pane is also the one whose clipboard contents are pasted when Paste is selected from the Edit Menu.

The textedit sources are separated into independent layers. Textedit contains the source files listed in Table B-2.

Table B-2 Textedit Source Files
File Name Description
tfile.c The code to read, write, and remove files. Hides any operating system or filesystem dependencies.
app.c Uses tfile.c to provide all the code to manipulate files and their related buffers. This is toolkit-dependent.
tk.c Isolates dependencies on the Xm Toolkit.

The first half of the file provides utility routines and a toolkit-independent (but application-specific) interface that can be used by the toolkit-independent dialog layer of the application.

The second half of the file defines all the callback routines. Many of these update state internal to this layer; others perform additional actions. Those actions unambiguously correspond to toolkit-specific action routines defined in the first half of the file. Otherwise, an upcall is made to the toolkit-independent dialog layer to decide what to do.

dlg.c Uses tk.c to manage dialog with the user. The code is toolkit-independent.
textedit.c Initializes the application and instantiates widget hierarchies. The code hides the use of UIL and Mrm from the rest of the application.

Note

Moving and removing files is not currently implemented.

B.10.1 Additional Translations

V1.2

Users familiar with emacs may want to add the following translations to their DECW$XDEFAULTS.DAT files:



*XmText.translations:     Mod1<Btn3Down>: scroll-cursor-vertically()\n\
  Mod1<Btn3Motion>: scroll-cursor-vertically()\n\
 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: beep()\n\
 Ctrl<key>h: delete-previous-character()\n\
 Ctrl<key>i: cut-primary()\n\
 Ctrl<key>j: newline-and-indent()\n\
 Ctrl<key>k: set-anchor() end-of-line() key-select() cut-clipboard()\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>v: next-page()\n\
 Ctrl<key>w: cut-clipboard()\n\
 Ctrl<key>y: paste-clipboard()\n\
 Ctrl<key>z: scroll-one-line-up()\n\
 Mod1<key>b: backward-word()\n\
 Mod1<key>d: delete-next-word()\n\
 Mod1<key>f: forward-word()\n\
 Mod1<key>h: delete-previous-word()\n\
 Mod1<key>i: copy-primary()\n\
 Mod1<key>k: delete-to-end-of-line()\n\
 Mod1<key>v: previous-page()\n\
 Mod1<key>w: copy-clipboard()\n\
 Mod1<key>z: scroll-one-line-down()\n\
 Mod1 Shift<key>greater: end-of-file()\n\
 Mod1<key>less: beginning-of-file()\n\
 Mod1<key>]: forward-paragraph()\n\
 Mod1<key>[: backward-paragraph()

B.11 View Example Program

V1.2

The view program is similar to the DCL command TYPE/PAGE using Motif with internationalization support. It allows you to view files in several languages.

The command file DECW$EXAMPLES:FILEVIEW.COM is provided, which allows you to select a language. Valid languages are French, English, and German. To select a language, perform the following commands:


$ SET DEFAULT DECW$USER_DEFAULTS
$ @DECW$EXAMPLES:FILEVIEW language

This command file copies the .UID and .DAT files to the current directory. It sets the appropriate locale and executes the file viewing example program.

When the application is started, a primary top-level shell is created. From the primary top-level shell, you can create secondary shells.

Each top-level shell is a parent of a Main Window, the work area of which is a PanedWindow.

The menu bar has the following entries:

  • File---opening and closing files, creating new shells, and exiting
  • View---controlling the panes in the pane window

File Menu

The file menu contains the following options:

  • Open New File
    A file selection box is mapped to choose the file. If OpenFile is successful, the current file is closed, all existing panes are destroyed, and the new file is displayed.
  • Open New Shell
    Creates a secondary shell similar to the primary shell. Files can be viewed in each shell independently.
  • Close
    This entry only exists on the secondary windows. It destroys the top-level shell and closes the file.
  • Exit
    This entry only exists on the primary shell; it closes the file and the shell.

View Menu

The view menu contains the following options:

  • New Pane
    Creates a new pane in the paned window.
  • Delete Pane
    Deletes the current pane.
  • Search
    Causes a dialog box to pop up for searching text in the file. The OK callback of the dialog box searches the string. If the string is found, it is displayed in the current pane. If the string is not found, then the dialog box pops up.

Opening a second file in a window causes the application to end abruptly. The View options do not work correctly.

B.12 Xmpiano Example Program

V1.2

The xmpiano program shows how to write a Motif Interface to Dumb Instruments (MIDI) application. Both a staff, for writing music, and keyboard are provided.

At the bottom of the window is a set of notes that may be used on the staff. Selecting one of these note buttons changes the active note accordingly. The selected note is also displayed as the new mouse cursor.

Though the note selection is limited, it is possible to play sharps as well as naturals. The program interface has not been written to play flats. The staff automatically resizes larger as notes are added past the right side of the staff. To see these notes, scroll the score window as needed.

To use this application, press the right mouse button on a staff that is visible. The following menu items are displayed:

  • Add Voice
    Connects another display to a new staff. After selecting this command, you are prompted for the display to connect. Any music written in the new staff plays to this display. Note that pressing the right mouse button on the new staff shows the name of the display in the menu title. In addition, the menu commands in the menu bar relate to the staff that is being displayed.
  • Remove Voice
    Removes the staff as well as the connection to the corresponding display. There is no undo for this command---all music written in this staff is deleted.
  • Clear Voice
    Erases all notes on the staff. This does not affect the display connection.
  • Play Voice
    Plays the voice of the staff in which the right mouse was pressed. If the voice is the same as the local host, the keys on the keyboard that correspond to the notes appear as though they are being pressed as the notes are played. It is possible to make the keyboard play along with all voices at the same time; however, the code must be compiled with the -DCHORDS option. Note that this can slow down the application significantly on many servers.
  • Play All
    Plays all voices at the same time on each of the specified displays.
  • Save Voice
    Saves the corresponding voice to a file. A FileSelectionDialog is displayed to prompt for the name of the file in which to save the voice. The display connection information is not saved.
  • Load Voice
    Loads (appends) a previously saved voice to the corresponding staff.
  • Quit
    Exits the example program.

This version does not allow editing of notes. To edit, clear the staff and start again, or read the data from a saved file.

To set the color of the notes, change the foreground color of the application. To do this, use the -fg option on the command line. For example:


$ xmpiano :== $DECW$EXAMPLES:xmpiano
$ xmpiano -fg blue

B.13 Xmtravel Example Program

V1.2

The xmtravel example is a front end to a travel agent client and flight database. The program is designed to illustrate various user-interface design concepts as well as be compliant with the OSF/Motif Style Guide.

The program is just an example, many of the functions are either not implemented or use predefined settings.

B.14 Additional Sample Programs

V1.2

Table B-3 lists sample programs showing various Motif Toolkit functionality.

Table B-3 Motif Sample Programs
File Name Description
xmdialogs.c dialog sampler
xmfonts.c font browser
xmeditor.c text editor
xmlist.c list example
xmprotocol.c window manager protocols example
xmter.c shape & animation example
xmform.c form attachment example
xmforc.c form attachment + rowcolumn example
xmmap.c drawingarea + scrolledwindow example
xmgetres.c resource fetching example
xmapdef.c app defined scrolled window example

The following notes apply to these sample programs:

  1. The xmfonts program defaults to displaying the fonts whose name length are less than 10 characters. On some systems, the font path contains only long XLFD font names. It may be necessary either to set the resource XMFONTS*maxLen to a larger number (80), or to specify a numColumns resource of 1.
  2. If you run the program xmter with a window manager other than Motif Window Manager, that window manager has to remove all the window decorations (for example, borders). The program xmter directs Motif Window Manager to remove the window decorations.
  3. The xmform program displays a string made of Motif widgets embedded in a Form. Use the following commands:


    $ xmform :== $DECW$EXAMPLES:xmform
    $ xmform string
    
    The variable string is optional. If string is supplied, the available letters for string are F,I,M,O,T. The string of letters that you use must be in uppercase and enclosed in quotation marks. If string is omitted, xmform returns "MOTIF".
  4. The xmgetres program is an example of how to use XmGetSecondaryResourceData. Use the following commands to invoke xmgetres:


    $ xmgetres :== $DECW$EXAMPLES:xmgetres
    $ xmgetres WidgetClass
    
    The variable WidgetClass is optional. If WidgetClass is omitted, it defaults to a class named "Widget". You can also use the class "All", which displays the resources for all the Xt and the Motif widgets. See the OSF/Motif Programmer's Reference manual for a list of available widget classes.

B.15 Resource Files for Example Programs

V1.2

Many of the example programs have associated resource files for defining various display attributes. To use these files, either copy them from the directory DECW$EXAMPLES to your DECW$USER_DEFAULTS directory, or add their contents to your DECW$XDEFAULTS.DAT file.

The list of example programs and the resource files associated with them is as follows:

Example Program Resource File
DECW$CDPLAYER.EXE DECW$CDPLAYER.DAT
FILEVIEW.EXE FILEVIEW.DAT
PERIODIC.EXE PERIODIC.DAT
MOTIFANM.EXE MOTIFANIM.DAT
XMAPDEF.EXE XMDEMOS.DAT
XMDIALOGS.EXE XMDEMOS.DAT
XMEDITOR.EXE XMDEMOS.DAT
XMFONTS.EXE XMDEMOS.DAT
XMFORC.EXE XMDEMOS.DAT
XMFORM.EXE XMDEMOS.DAT
XMGETRES.EXE XMDEMOS.DAT
XMLIST.EXE XMDEMOS.DAT
XMMAP.EXE XMDEMOS.DAT
XMPROTOCOL.EXE XMDEMOS.DAT
XMTER.EXE XMDEMOS.DAT
XMTRAVEL.EXE XMTRAVEL.DAT

If a resource file is not found, the example programs run, but some of the display attributes may be incorrect.


Index Contents