V—A Free C++ GUI Framework for X

Dr. Wampler introdces us to V, an excellent GUI framework for writing applications that work with Linux and X Windows.
V C++ Objects

V is a C++ framework, and therefore, consists of several C++ base classes you can use to derive your own classes. The core class is vApp, which is used as the main foundation of the rest of the application. A minimal application has a command window derived from the vCommandWindow class containing at least a menu and a drawing canvas. The command window can also contain tool and status bars. When the user selects menu items or activates command objects on the tool bar, V sends messages to your derived vCommandWindow object which your program then interprets. Your program usually shows its output on a canvas object, derived from a vCanvas class. Mouse input is handled by sending messages to your derived canvas class.

While it is possible to build an application using only the vApp, vCommandWindow, and vCanvas classes, most applications will also use dialogs. The dialog controls supported by V currently include:

  • standard push button

  • push button with icon and color

  • toggle buttons

  • labels

  • icons

  • check box

  • radio button

  • combo box

  • list

  • spinners

  • slider

  • progress bar

  • text in

  • multi-line text

  • frame (box)

  • toggle frames (similar to tabs)

The layout of controls in a dialog is determined by specifying a position for each control relative to other controls in the dialog. For example, you might specify one control is to the right and below another control. All dialog controls can also be used on the tool bar of a command window.

V also includes several standard dialogs that implement common operations. One of the most useful is the file open dialog, which lets the user select files and directories interactively. Since no standard X file open dialog exists, V implements its own. The MS-Windows version of V uses the standard Windows file dialog. Other standard dialogs include font selection, yes/no response and a message box. Using standard dialogs helps ensure that your application will match the look and feel of the native platform.

Building Your First V Application

The first step to using V is obtaining the latest release. The primary source for V is my web page, http://www.cs.unm.edu/~wampler/. V is also available for anonymous ftp from ftp://ftp.cs.unm.edu/pub/wampler. Unpack the distribution, decide where you want to keep the source and libraries, modify the makefile to reflect this decision and execute make.

After you've built V, read the documentation. You can either print it, or use xdvi or ghostscript to view the provided dvi or ps files. You then typically start your own application by modifying one of the examples provided. Most new V users find it very easy to modify the example to get a good start on their own. The entire process of downloading, building, reading the manual and building a first custom V application has been done by several current V users (already familiar with the Internet, Linux and C++) in just four or five hours.

Summary

Since its release to the world in February 1996, V has been in use by my software engineering class and received considerable interest and positive response from the user community. If you've put off writing a GUI application because X programming is just too hard to learn, V may be the solution you need. If you've been putting off learning C++, again V may be just what you need. V is a very elegant, small and well-designed C++ class library. GUIs are one of the most naturally object-oriented applications around and are a good way to get started with object-oriented programming.

Bruce E. Wampler, PhD (wampler@cs.unm.edu) has been involved in the PC industry since its earliest days. In fact, he founded two successful software companies, Aspen Software and Reference Software International, and was the principal designer and author of the well-known grammar checker Grammatik. He is currently an Adjunct Professor of Computer Science at the University of New Mexico.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix