This is a tutorial that will help you with
the basic parts of GUI. GUI is an abreviation for graphical user interface.
It is a way to make programs more user friendly for the average person.
GUI can be a powerful tool. The scope of its power is more than this tutorial
addresses.
First, you will need to create a new directory
to save all of your work in. It is best if this directory is completely
empty.
Display a terminal window, and type "workshop &" in the command
line. Hit the return button.
Go to the tools option, and click. The menu bar will drop down. Go
to "workshop visual," and then to "new".
A new window will appear:
This is the main GUI window that we will
base everything from.
To begin our GUI interface, you will need
to go to the tools menu bar and select "AppGuru," and then "default templates".
The following window will appear:
Make sure that the following options are selected:
File dialogs
Tool palette
About Box
Status bar
Toolbar
Menu bar
And then click on "OK".
The following window will appear:
You will notice that underneath each of the
large named boxes, there are small boxes with dots in them. Click on a
box, and see what happens. Click on the box again and see what happens
upon the second time of clicking the same box.
You need to click on the small box underneath the File Menu box, when you do, the following screen will be seen:
We are going to set up a widget, so that when we open our project, we are able to exit from the screen that appears. We are going to edit the quitItem widget. Before we attempt to build the widget, we are going to need to generate our interface, and we need to save our project. Save your project in your empty directory. Next generate the interface. On the tool bar, go to Generate, and bring down the file menu. Click on generate. The following screen will appear, make sure to add your blank directory to the directory box. And then click on the generate button. This will generate your interface. After your interface has been generated, click on the close button. Now we are ready to build our quitItem widget.
Click once on the quitItem box in under the file menu option. Go to "Widget" on the file menu. Pull down the menu, and choose "Callbacks". The following screen will appear:
Change
"Method Name" to "Function Name" by clicking on "Method Name". Click on
"OnFileQuit(docShell)," and then click on "Edit Code." A text editor will
appear, in this case emacs. And the widget code will be opened:
We are going to be editing the code. You
need to make sure that the text editor has opened up to "Void OnFileQuit
(Widget w, XtPointer client_data, XtPointer xt_call_data)". Before the
closing "}" type in, "exit (0);". And then save your work. Click on the
hammer, we are going to build the interface. Make sure that the directory
is appropriate, and also make sure that the builder says that the interface
was built.
Now we are going to test our work. Return to the original terminal window. Change to the appropriate directory. And type in the name of your file, for example: "tutorial". A new window should appear with the name that you gave it.
If you click on fileCB, and then on quit,
the window should close.
Now let's see if we can't get rid of the
CB's at the end of the file.
Go back to the generate screen, but this time, go to the "Options" button. And change the "Strings" button from "Resource File" to "Code".
Click "Ok". You will need to rebuild the interface. And then check if it worked. It should have.