Application Kit C++ Class Library
The ApplicationKit Class library consists of several C++ classes that
provide a framework for development of applications with Graphical User
Interfaces (GUI. The classes provide many top-level components for an
application, aiming at setting a loose framework for all applications to fit
into. The classes additionally provide many commonly used user-interface
components for plugging into applications (including numerous different types of
data prompts), as well as interface classes to UNIX processes, and audio.
ApplicationKit utilises, as far as is possible with current C++
compilers, the Standard Template Library (STL), and most other features of the
(Draft) ANSI C++ standard. It uses Motif version 2.0 widgets.
Origin of Class Library
ApplicationKit was written initially to provide the user interface
functionality for the mxNet, mxMail, and mxFTP applications. It was based
around the code documented in the book by Doug Young
"Object-Oriented Programming with C++ and OSF/Motif" 2nd Edition (1995).
The basic framework classes (akComponent, akApp, akWindow) are basically as per
the book (BUT with addition of bubble help, activation/deactivation, busy/ready)
The classes that make up ApplicationKit have been developed purely on a
requirement basis (i.e when something is required, the class is written to
fit into ApplicationKit).
Note that the code from the book has been developed to become the commercial
class library known as ViewKit. A FREE clone of ViewKit is
available from "The Hungry Programmers" at
http://www.hungry.com/products/viewkit.
Requirements
The ApplicationKit class library requires the following :-
- GNU g++ (Ver 2.7.2) compiler and STL implementation (OR an equivalent
compiler/STL that supports at least as much of ANSI C++ as g++ does).
- X11R6 (though X11R5 will probably work fine).
- Motif 2.0 (SOME of the classes require Motif 2.0 widgets - notably
akComboBox).
- XPM (though, if you've got Motif 2.0, XPM will come with it).
- akSound requires Linux (1.2+) since it is kernel-specific.
ApplicationKit Contents
The class library provides :-
- A main routine for the application, catering for the initialisation
of X, and setting up of the event loop.
- A framework providing the application main windows, dialog windows
as well as an abstract class from which to derive ALL GUI components.
- A dialog management facility providing easy generation of INFO, ERROR,
WARNING, WORKING, MESSAGE, QUESTION, and FILE-SELECTION dialogs.
- A document viewing system for On-Line Program Help.
- A large range of data-entry prompts, ranging from data entry fields
prompting for string/int/double data, to Option Menus, Combo Boxes and
Radio Boxes.
- A system providing 'Bubble Help' for GUI component functionality.
- Several utilities, including a UNIX process interface, an audio
file play interface, and a clock
All class library members are prefixed 'ak'.
The class library is made up of the following classes :-
ApplicationKit Framework Classes
akComponent
- A representation of a GUI component, provides storage of base widget and
widget name, as well as manage/unmanage facilities, widget destruction
capability, and the ability to specify and retrieve resources. Additionally,
provides a 'Bubble Help' facility. Used as the base class for all AppKit
AppKit components.
akApp
- A representation of an application. Handles initialisation of X, and event
loop, as well as allowing iconification and setting the applications 'state'.
akWindow
- A representation of a top-level window. Stores shell widget and its child.
Registers the main window with the application. Provides manage/unmanage and
iconify functions, as well as 'state' setting functions.
Shell created is 'applicationShell'.
akDialog
- A representation of a dialog window. Provides a template dialog and requires
all derived classes to have a 'createWorkArea' function to generate the
work area of the dialog. Additionally, buttons can be added to the messagebox
area. Intended to be on the screen for a short period of time. Provides the same
general facilities (manage/unmanage/busy/ready etc) as akWindow.
- akMain
- The application's main routine. Calls the akApp's functions to
initialise X, and to start the event loop. This means that an application
WILL NOT have its own main routine, just a function that creates a
akApp object and akWindow object as globals.
It relies on the user creating a akApp object and at least one
akWindow object globally. For example, have a file containing
the following :-
#include "akApp.h"
#include "HelloWindow.h"
// Instantiate an application object and a top level shell
akApp *helloApp = new akApp("Hello","1.00","A test application");
akWindow *window = new HelloWindow("Hello");
Note that when deriving from the akWindow class, it is instantiated
as a global (i.e BEFORE main is called) so anything in its constructor will
be executed. However, C++ doesn't guarantee the order of initialisation of
global items, and so the constructor for the akWindow-derived class
shouldn't rely on anything else (e.g iostream) already having been initialised.
You can, of course, enforce things be initialized in the order you require
by setting the order of the #include statements etc.
ApplicationKit Dialog Classes
The dialog components are split into two parts - manually instantiated
dialog components, and globally managed dialogs. The 'global' dialogs are
created when the akApp is instantiated - so the programmer just has
to call the dialog managers post member function to display the dialog.
akMessageDialog
- A message dialog component. 'Message' dialogs can be any one of
ERROR, WARNING, INFORMATION, WORKING, MESSAGE or QUESTION. Several
convenience functions are provided to tailor the dialog to the exact
user requirements.
akFileDialog
- A file-selection dialog component. Several convenience functions are provided
to tailor the dialog to the exact user requirements.
akMessageDialogMgr
- A dialog caching function for 'message' dialogs. Similar to akMessageDialog
above except that this is a global object and users simply call the 'post'
function to display them. As a result, dialogs from this object are typically
quicker to generate, but have the disadvantage of less flexibility in the
dialog's characteristics.
akFileDialogMgr
- A file-selection dialog caching function. Provides for simple generation of
file selection dialogs.
akPromptDialog
- A prompt dialog component. Contains a prompt for a character string
and has OK and CANCEL buttons.
ApplicationKit Document-Viewing Classes
These classes are used together to provide a basic (text-only) on-line help
system from a 'reduced-set' HTML document.
akDoc
- A representation of a document. It consists of several sections, a filename,
and a title. Each section consist of a title and some text. It is based around
a HTML document but only using certain HTML tags.
akDocView
- a Motif scrolled text widget based visual representation of the document
It also provides a list of sections to allow jumping between sections.
It is derived from the akWindow class.
ApplicationKit Prompting Classes
The constructor creates the components but DOES NOT manage them.
Call the "manage" function to make the components visible.
-
akPrompt
- an abstract class providing the mechanism for a data-entry prompt.
akPromptInt
- a data-entry field prompting for an integer value.
akPromptInts
- a data-entry field prompting for (multiple) integer values.
akPromptIntRange
- a data-entry field prompting for an integer value within a range.
akPromptDble
- a data-entry field prompting for a double-precision value.
akPromptDbles
- a data-entry field prompting for (multiple) double-precision values.
akPromptDbleRange
- a data-entry field prompting for a double-precision value within a range.
akPromptString
- a data-entry field prompting for a character-string value.
akPromptPassword
- a data-entry field prompting for a character-string value such as a password,
where the entered text is replaced by *'s.
akPromptFile
- a data-entry field prompting for a filename. It additionally includes a
'Select' button which brings up a file selector to ease the input of the
filename. The 'Select' button gives 'Bubble Help'.
akOptionMenu
- an option menu prompt. Requires option names, as well as an optional
callback (with clientData) to be called when an option is selected.
akCheckBox
- a check box prompt. Requires option names, as well as an optional
callback (with clientData) to be called when an option is changed.
As many options as required can be selected at once.
akRadioBox
- a radio box prompt. Requires option names, as well as an optional
callback (with clientData) to be called when an option is changed.
Only one option can be selected at any one time.
akComboBox
- a combo box prompt. Requires option names, as well as an optional
callback (with clientData) to be called when an option is changed.
A single option can be selected.
ApplicationKit Command Classes
The constructor creates the components but DOES NOT manage them.
Call the "manage" function to make the components visible.
akButton
- a push button displaying a string or a pixmap (XBM or XPM)
ApplicationKit Utility Classes
Interface classes to commonly required facilities.
akPixmap
- a representation of a pixmap (XBM or XPM). Also caters for stippling of the
pixmap (to create an insensitive version).
akLabel
- a label displaying a string or a pixmap (XBM or XPM).
akMessageLine
- a message line object to relay information back to users about program status.
akMessageArea
- a message area object to relay information back to users about program status.
akClock
- a clock object that displays the date/time in a similar way to the 'xclock'
program, only in an XmLabel widget.
akCopyright
- a standard "GNU-copyright-based" copyright window. User is allowed to supply
a pixmap to display in the window, together with the company name and year of
the copyright. The Application Name and Title are also displayed
(from akApp object). The copyright message is taken from the GNU Public
License.
akProcess
- an interface to a UNIX process. Sets up pipes to/from the process and sends
the output back to a callback hook function.
akSound
- an interface to an audio sound. Reads in a sound file (in certain supported
formats), and plays it through the audio device. Sound is played in a separate
thread so as not to slow down the application. Currently set up to be Linux
specific and only handles WAV and VOC files.
Future Work
The ApplicationKit class library requires the following work :-
- Change akMessageArea to work from an ofstream.
- Add a scrolled text class using an XmCSText widget - working from XmString's
- Change akDocView to work from this XmCSText based class, and add support for
BOLD,ITALIC,UNDERSCORE tags.
- Add a way of aligning prompts - for example, aligning the prompt label 'end'
and field 'start' of several prompts in a rowcol.