Tutorial One: Simple Actions
In this tutorial, you will create a BulletinBoard with two PushButtons. Clicking one PushButton displays an xterm, while clicking the other exits the application.
Starting Builder Xcessory
Start Builder Xcessory by entering the following command on the command line:
% bx50
Builder Xcessory, the Palette, Browser, and Resource Editor, are displayed. Refer to Starting Builder Xcessory for more detailed information about starting Builder Xcessory.
Note: By default, Builder Xcessory starts with an interface named uil.uil. If you are creating a new interface, you can keep this name or rename the interface upon saving it (Browser:File:Save As).
Clearing an Interface
If a current Builder Xcessory is already running, clear the interface as follows:
The remainder of this example assumes you have chosen C.
Creating and Resizing a Widget Instance
To create and resize an instance of the BulletinBoard widget, use the following procedure:
Resized BulletinBoard
Placing a Child Widget
Placing an Automatically Resized Widget
Place a second PushButton, without resizing it, inside the BulletinBoard to the right of the first PushButton.
Notice that the second PushButton is created with the same height and width as pushButton. This is pushButton1. Your interface should look like the following figure:
BulletinBoard with Two PushButtons
Selecting a Widget
To make pushButton the currently selected widget, click MB1 on pushButton. You can click on the object either in the interface itself, or on the Browser display.
Updating the Resource Editor
To update the Resource Editor for pushButton1, double-click MB1 on pushButton1.
You can select the object either in the interface itself, or on the Browser display. You can also select Automatic Update from the Resource Editor Options menu, forcing the Resource Editor to update whenever a widget is selected. This is not recommended for very large interfaces, because it slows Builder Xcessory significantly.
Resource Editor Forms
You can customize the resources displayed on the Resource Editor by selecting an item from the View menu. Available options allow you to display All Resources, Simple Resources, Programmer Resources, Modified Resources, or Not Equal Resources. Refer to View Menu for a description of these categories.
Confirm that the Resource Editor is displaying all of the resources of the currently selected widget by selecting All Resources from the Resource Editor View menu.
Searching the Resource Editor
Confirm that pushButton1 is the currently selected widget. Its name should be displayed in the Resource Editor Instance Name field. Locate the labelString resource:
You can also locate a resource by using the scrollbar to the right of the Resource Editor.
Setting a Resource
Now that you have assembled the elements of the interface, the next step is to set the resources of these widgets.
You can set a widget resource with one of the following procedures:
· Type the value directly into the text window to the right of the resource name in the Resource Editor.
· Apply the value to the resource using the appropriate extended editor.
Using an Extended Editor
Setting a resource value
To set the value of the labelString resource of pushButton1 to "EXIT":
Setting a Resource in Multiple Widgets
A major advantage of extended editors is that they allow you to apply resource values to a series of widgets without updating the Resource Editor.
To set the value of the labelString resource of pushButton to XTERM:
Your interface should appear as follows:
Labeled PushButtons
Setting Callback Resources
Callback resources are set like any other resource in Builder Xcessory. You could type the callback information into the text window to the right of the resource in the Resource Editor. However, because you will change this resource for more than one widget, you should again use an extended editor, in this case, the Callback Editor.
Updating callback resources
This time start with the PushButton labeled XTERM, since it is the currently selected widget.
AppCallback
client_data
, to the system call, system
, which in turn passes its parameter to the operating system. This transaction is the same as typing the parameter on the command line, and results in an xterm being created when AppCallback is called.Do not dismiss the Callback Editor; you will use it for pushButton1.
Using Predefined Callbacks
Builder Xcessory has a number of predefined callbacks to save you the time and effort of continually rewriting certain common callbacks. Predefined callbacks are also active in Play Mode, enabling you to observe the effect of the callback without having to build the executable.
Setting a callback resource
To set the callback resource for the PushButton labeled EXIT:
BxExitCB(0)
should now be displayed for activateCallback in the Resource Editor.Generating Code
You have constructed the interface and set up the callbacks. The next step is to write out the code for the interface. You will then edit the code and test the interface.
You will probably wish to change the destination directory to Tut1
. If you have questions about how to do this, review Changing the Destination Directory .
uil
. uil
(the default interface name; see Starting Builder Xcessory ), which can be read back into Builder Xcessory to reconstruct the collection.callbacks-c.c
file each time.Reviewing the Callback Structures
To review the callback structures, do the following:
callbacks-c.c
file should contain the following procedures (not necessarily in this order):<tutorial_path>/Tut1/callbacks-c.c
into a text editor (for example, vi , or emacs).Compiling and Running
You are ready to compile the C code in order to implement the callbacks that you set up. To compile the code:
-I/usr/include/Xm -D_NO_PROTO
Your interface should appear on the screen.
Testing the Interface
If you click MB1 on the PushButton labeled XTERM, an outline of an xterm should appear on your display. If you click on the PushButton labeled EXIT, your interface should disappear and the program should exit.
Note: On some systems, exit does not kill the parent process before all of its children have been killed. This means that you are not able to kill your interface before you exit out of all of the xterms that you created with the interface. To avoid this situation, kill all of the xterms before you select the EXIT button.
You have now completed Tutorial One.