# libsx - Simple X Library

- Introduction to libsx
- Local Libsx Information
- General Overview of libsx
- List of libsx Functions
- Acknowledgements

## Introduction to libsx

Welcome to libsx, the simple X library. Libsx is an attempt to simplify the vagaries of programming under X windows, making it simple to create user interfaces for programs. With libsx, 10 lines of code may be all you need to create a user-interface complete with many different types of widgets.

Libsx is layered on top of the Athena widget set and basically acts as a front end to all the Athena and Xlib garbage so that programming reasonable interfaces isn't so painful. For example, libsx has a simple to use one-line string entry widget that you can create with a single function call (it's based on the Athena text widget but hides all the gory details). Libsx encapsulates the common operations people usually want to perform in a window system and makes them easy to accomplish (at the loss of some flexibility).

If you've ever wanted to just open a window with a few buttons and draw some graphics, but were turned away by the complexity of trying to do that, then libsx may be your ticket. Libsx is capable of easily creating many types of user-interface components each with a single function call of a few arguments. The library supports the following Athena ``widgets'':

        - Labels
        - Buttons
        - Toggle buttons and Radio buttons
        - String Entry areas
        - Scrolling Lists
        - Menus
        - Scrollbars
        - Drawing Areas
        - Text Edit boxes

The goal of libsx was to make the creation and manipulation of each of these items as simple as possible. The standard simplicity litmus test is a "Hello World" program, which in libsx is:

    #include "libsx.h"
    main()
    {
      MakeLabel("Hello World");
      MainLoop();
    }

More complicated interfaces use a similar style of creation and complete applications usually require less than 30 lines of code to create an entire user interface complete with menus, buttons, string entry widgets, etc. For example, to create an application that opens a window with a drawing area and a ``Quit'' button, all one must do is:

    #include "libsx.h"

    main()
    {
      Widget quit_button, draw_area;

      quit_button = MakeButton("Quit",     quit,       NULL);
      draw_area   = MakeDrawArea(500, 500, draw_stuff, NULL);

      SetWidgetPos(draw_area, PLACE_UNDER, quit_button, NO_CARE, NULL);

      MainLoop();
    }

So in only a handful of lines of code, we created a simple X application that would have required inordinate amounts of code using traditional methods. All that is required now is for the user to write the routines ``quit'' and ``draw_stuff''.

## Acknowledgements

Libsx was developed by Dominic Giampaolo. Quoting from the author:

"I developed libsx over the course of about 2 years while in graduate school at Worcester Polytech (in good ole Worcester, Mass.) It all started when I took the grad course in Computer Graphics. I wanted a nice library of routines to deal with all the X crap so I could concentrate on my graphics code. Soon the library started evolving into a much more sophisticated thing and when I became the TA for the graphics course, I beefed it up a lot. When you have 65 undergrads beating on a library you've written, it's got to be solid. The next time that I was TA, I polished up some more rough edges in the library (the stuff the students complained about) and it went through the ringer a second time with about 45 more students. Finally, during the summer of 1993 I added a ton of more functionality to the library so a friend of mine could write his 3-D editor the way it should be written and so I could do some stuff I wanted to do. In September of 1993 I was hired at SGI and I've done a little bit more work on libsx since I've been here (mainly little cleanups and the rudimentary OpenGL support). That is effectively what you see today."

"I've spent a lot of time deciding how to structure libsx so it would be easy to use but still be open ended. Libsx doesn't try to hide all of X, it just tries to make it more digestable. The library has gotten pretty big at this point, but it should be sufficient to write most types of GUI programs without lots of fuss."

"I've also spent a lot of time deciding what should and shouldn't be in libsx. It's too easy to throw in everything just because it's easy to do so. Unfortunately that's almost never the right reason to include something. I've tried to pare the design down to the essentials needed to write a useful application. Comments and critiques of the design/approach are welcome (I'd like to hear what others have to say about it or how they would have done it)."

In the past year (1994) I've received quite a bit of e-mail regarding libsx. I've received all kinds of comments, suggestions, and bug-fixes from a large number of people out there. If I had kept better track of everything I'd launch into a big spiel thanking all the individuals. Alas, I didn't keep track of everything, so I'll just have to offer a general thanks to all the folks who sent me comments, asked for fixes, and offered replacement code, etc. Thanks folks, I do appreciate it.

          Dominic Giampaolo
          dbg@sgi.com

Libsx includes David Nedde's Athena drawing area widget and encapsulates it so that a simple program to open a window and draw some graphics is now reduced to only a few lines of code.

The HTML documentation was done by Winston Holmes (winston@nestor.engr.utk.edu) by adding the HTML formatting codes to the doc files shipped with libsx.