Little X - Graphical User Interface Toolkit & Library

For Unix or PC's

James Trevelyan jamest@mech.uwa.edu.au 23rd Sptember 1996

Frequently Asked Questions

Read Me File: lxread-me.txt

For PC's: lx.zip

For Unix: snakes.tar.Z

Manual: lxman.rtf

Little-X is a library of functions which provides a nice graphical user interface for a C or C++ program on a PC Computer running under DOS. The library is fully compatible with X-Windows on any Unix computer (IBM, HP, Sun,DEC etc) so programs are portable, with minor restrictions. The library has simple functions and is aimed at the programmer who wants to write quickly. Yet it offers the simulated 3-D controls, mouse operations and multiple overlapping windows now expected by users.

This software is free to research and educational users. Send us Email if you would like to try it. It comes with extensive tutorial programs and we can send you a printed manual. The current revision level is 2.01. Unlike Tcl/Tk, this is a fully compiled toolkit of modest size and is intended for first-time C users (i.e. it is very simple to use) and research programmers alike. It offers great flexibility in layout, and makes screen/mouse interactions easy.

An Introduction to X-Windows and Little-X

Most of us are now familiar with computer screens like Macintosh ; computers, with windows and a mouse-driven pointer. The general term for this is a graphical user interface; or GUI;. The little-X toolkit has been designed to enable you to write programs with a nice graphical user interface with aminimum of learning effort beforehand. Your programs will run happily on smaller and older PC; computers without needing huge amounts of memory or disc space. At the same time you will be learning to use the standard X-Windows; system which is common to most Unix computers today. Your programs should be portable to any Unix; machine running X-Windows provided you take the Unix version of the toolkit library with you.

Little-X has been designed for people who want to get their programs working quickly without having to read and understand the subtleties of the normal GUI's.

There are three major software systems in use for commercial GUI's - Microsoft Windows; for PC Computers, the Macintosh Tookbox for Macintosh computers and OSF/Motif for Unix computers. While they all share common principles, all three are highly complex, and the details of their implementation are quite different. While we are accustomed to using software built like this, the inner complexities of programming represent a formidable barrier to anyone who wants to write their own software with a GUI. The differences between them are such that transforming software for a Mac, for example, to run under Microsoft Windows is almost as daunting as writing the original software. Manuals typically run to several volumes with hundreds of pages each.

Another common feature is a thirst for memory and disc space. All require lots of memory and disc space to operate well. Unix operating systems present a further challenge. Their graphics are based ona standard system known as X-Windows. For all its own complexities, X provides only basic facilities. To make a GUI, you need another layer of software called a toolkit. There are several available for X: the principal ones are Open-Look XView; (promoted by Sun Microsystems) and OSF Motif; promoted by the other Unix vendors (IBM, HP, DEC, etc). Transforming between these is comparable to the Mac to Windows problem itself.

 

X-Windows

X-Windows is a library of functions which enables programs to use graphics displays and mouse pointer controls. It works with a huge variety of different display hardware. It is a standard developed to the stage where there are low-cost terminals (called X-terminals) specifically engineered for use with X. It is the standard used in nearly all Unix operating systems today.

What then, is special about X-Windows? It has been developed by MIT and standard X software is available at no charge from MIT on Internet. It was designed to work across a network so it is possible to access several different computer systems from the one screen. In its normal form, X operates with three components:-

 

  1. The X-Library of graphics functions with your application program which generates a stream of graphics output to one or more screens, and receives input from them. The technical term for your program is 'the client'.
  2. A communication link between the computer with your program and the screen in front of the user.
  3. A server - a program which operates the computer running the user's screen. The server receives the graphics output from your program, displays it, andsends back mouse pointer actions and other signals.

It is this structure which distinguishes X from the other windowing systems.

However, most of the time, X applications run with the server on the same computer, and access only one display and pointer. This is the situation which Little-X simulates. Little-X provides basic X-Windows features in a small and convenient form.

 

Design of Programs

There are two aspects to program design for a GUI. First, the 'guts' of the program with the computing algorithms, data storage, access to files etc. will be almost exactly the same. Some minor changes may beneeded, depending on how well you designed these parts.

The interactive part will be quite different to what you will find in all but the most recent texts. This is not the place for a detailed descussion, but the following steps are very important.

 

  1. Decide how you would like the GUI to appear on the screen. If there are several windows, sketch each of them, and write notes beside each sketch to explain how the user will pass from one window to the next.
  2. List the controls on each window, and write notes to explain how each control will interact with the program.

Once you have done these steps, and presuming that you have learned how to use each of the main tools provided in Little-X, you should beable to proceed to write your program code quite quickly. The tools are explained in the accompanying toolkit manual which you should read before writing your own programs.

Need for simplicity

Years ago, when I wrote programs for computers, I was accustomed to simple input and output statements like the following example:

In Fortran:

write(1,901); 901 format("Enter number of equations'); read(1,902) 902 format(I3)

or in Pascal:

write('Enter number of equations:'); readln(n);

or in C:

printf;("Enter number of equations:"); scanf;("%d",&n);

Times have changed. Users now expect software to have buttons, windows, and all the ease of use that Macintosh; computers have. Yet writing programs to use windowing software can be a horrendous exercise. Not only are tens of pages of code required for the simplest of (useful) programs, but the programs are large, typically needing at least 800k to 1MByte of memory for code and more for dynamic data structures.

And there are further complications too. If you write in the windowing systems old for Sun computers (XView or Sun View), you will find that Hewlett Packard; IBM; and almost everyone else uses a different system called Motif. While XView; programs are horrendously long and tortuous, Motif; programsare indescribable. One of the best books on Motif carries the following warningin several places:

"Take care with this function, as incorrect argumentscan lead to a system crash!"

I learned to write XView programs, and then I thought that there had to be a better way. If it takes two lines of code for old fashioned input/output, why does it have ot take hundreds of function calls with numerous arcane parameters for modern input and output?

The software houses have produced their answer - large and complex packages which allow you to design your windows on the screen, with all the buttons you want. These programs generate the windowing code automatically. The problem for the user is, that one still needs to understand the underlying software insome depth, and the resulting programs are larger and more cumbersome than the hand-coded equivalents. These packages are also expensive -up to AUD$10,000.

There is a simpler solution.

My contribution is an X-Windows; based tool kit which is simple to program and comfortable to use. And it should run in any X-Windows environment. Little-X offers the additional advantage of running your program on a low-cost PC computer.

It owes much to a well written book: X Window Applications Programming, 2nd Edition, by Eric F Johnson and Kevin Reichard, from MIS:Press, ISBN1-55828-178-9. Their book taught me the basics of X-Windows, and provided the basis of the code for the toolkit.

|Robotics and Automation Lab| Dept. M &M Engineering| UWA Home Page|