<--Last Chapter | Table of Contents | Next Chapter--> |
If you are writing an application that will run on several different operating systems, Florist provides a level of operating system independence. Once you install gnat and Florist on your new platform, you should be able to recompile a Florist application without having to worry about variations in system calls.
Florist is designed for gnat and runs on Linux as well as Solaris, OFS1, AIX, IRIX and HP-UNIX. Florist works closely with the gnat run-time system: you must compile Florist against a particular gnat installation. If you change your gnat installation, you will need to recompile Florist.
Older versions of Florist for Gnat 3.11 work best
with a version of Gnat compiled for FSU threads. Native threads
require some patching to work, and not all Florist features are
supported--see the Florist documentation for details. For more
information on FSU threads, read the multitasking section above.
Newer versions of Florist, such as the ALT RPM, works with the normal (native threads) version of Gnat. |
Commercial support for Florist is available form ACT.
Because the Linux kernel largely adheres to the POSIX standard, many of Florist functions have the same parameters as their Linux counterparts.
Florist divides the POSIX functions into a set of 73 Ada packages, all prefixed with the name "posix". The main package is called "posix.ads" and contains the definition of data types and many of the basic POSIX functions.
To write Florist applications, you'll need to link in the Florist library with "-lposix" (check?) and, if necessary, use "-I" to indicate where you've installed the package specifications.
[Incomplete]
This is the same package used to implement TIA.
[to be rewritten—KB]
2. The Ada files should compile when you build your project with Gnatmake. If TextTools are installed in a different directory than your project, you will need to use the gnatmake -I switch.
When linking, you'll need to include the "-lm" and "-lcurses" switches as well as the object files from C_code. TextTools uses the C math library and ncurses 4.0. For example,
gnatlink -lm -lncurses C_code/*.o ...
Everything in TextTools is drawn in a window. Everything in a window is a control (sometimes called a "widget"). To display a window, you must create a window, fill in the window with controls to display, and run the window manager's DoDialog command.
The following program opens a simple window.
-------------------------------------------------------------------
with common, os, userio, controls, windows;
procedure ttdemo is
-- Define Window Controls
OKButton : aliased ASimpleButton;
-- The Dialog Record
DT : ADialogTaskRecord;
begin
-- Start TextTools
StartupCommon( "demo", "demo" );
-- Create a new window. The window will not appear until the
OpenWindow( To255( "Demo Window" ), -- title at top of window
-- Setup the controls in the window
-- OK Button located near bottom of window
Init( OKButton,
-- Message at top of window in bright red
Init( MessageLine,
-- Display the window and handle any input events. When dialog
loop
-- close the window
CloseWindow;
-- Shutdown TextTools
ShutdownWindows;
end ttdemo;
-------------------------------------------------------------------
Package Overview
TextTools is broken into 5 main packages, based on what they do.
Common - this package contains all the basic data types
used by TextTools, plus subprograms that work with those types. In
particular, two important types are defined:
OS - this package contains subprograms for working with the Linux operating system: that is, for reading the current time, deleting files, and the like. Texttools pathnames are defined in this package. A path is a Str255 string. The OS package can define path prefixes, beginning with a "$". For example, "$HOME" is predefined as the user's home directory. To delete a file called "temp.txt" from the user's home directory, you can use the OS erase command:
Erase( To255( "$HOME/temp.txt" ) );
$SYS is another predefined prefix. This refers to a directory in the user's home directory named with the "short name" you specify in the StartupCommon procedure. Sounds, keyboard macros and the session_log file are located here.
UserIO - this package contains all the input/output routines for TextTools: it handles mouse clicks, draws text, and so forth. Normally, only people writing controls will need access to this package. However, the pen colours, beep sounds and text styles, are also defined here.
Controls - this package contains all the window controls
and related subprograms. Currently defined controls are:
Each package is started with a "Startup" procedure, and shutdown
with a "Shutdown" procedure. The only procedure to take parameters
is StartupCommon: you need to specify a program name and a short
name to use for temporary files.
OpenWindow - this procedure creates a new window. Each window has a title, coordinates on the screen, a "style", and an optional info bar.
AddControl - adds a control to the current window. If IsGlobal is false, the coordinates you specified in the control's Init call will be treated as relative to the top-left corner of the window, as opposed to the top left corner of the screen.
CloseWindow - closes the last window you created
DoDialog - this procedure displays the window and handles
all interaction between the user and the window. It has one
parameter, ADialogTaskRecord, which lets you set up callbacks (if
necessary) and returns the number of the control which terminated
the dialog.
ShellOut will close the windows, run a shell command, and reopen the windows.
RefreshDesktop will redraw all the windows on the screen.
SetWindowTimeout will set a default control to be
selected if there is no response after a certain amount of
time.
NoteAlert - displays a message with an "OK" button. The status sound is played, if installed.
CautionAlert - displays a message with an "OK" button. The text is drawn to emphasize the message. The warning sound is played, if installed.
StopAlert - displays a message with an "OK" button. The text is drawn to emphasize the message. The warning sound is played, if installed.
YesAlert - display a message with "yes" (default) and "no" buttons. Plays an optional sound.
NoAlert - display a message with "yes" and "no" (default) buttons. Plays an optional sound.
CancelAlert - display a message with cancel button and a customized button (default). Plays an optional sound.
YesCancelAlert - display a message with "yes", "no", and "cancel" buttons and returns the number of the button selected. Plays an optional sound.
Example:
NoteAlert( "The database has been updated"
);
SelectSaveFile - displays a dialog for saving files. It has one parameter, ASelectSaveFileRec. You have to fill in certain details before displaying this window.
ShowListInfo - displays a Str255List list in a window
EditListInfo - displays a Str255List list in a window and let's the user edit the list.
Example:
sof : ASelectOpenFileRec;
Control Overview
Every control must be initialized with the Init procedure. Init positions the control in the window and assigns a "hot key", a short cut key for moving to the control.
You can turn a control off (make it unselectable) using SetStatus. Setting the control's status to Standby will make it selectable. Some controls are automatically turned off, such as the static line control.
The following controls can be used in a TextTools window:
Thermometer
This is a thermometer bar graph. It shows the percentage between the maximum value and the current value, and is filled based on the percentage
ScrollBar
This is a scroll bar. A thumb is drawn at the relative location of the thumb value to the maximum value of the bar. The bar will be horizontal or vertical depending on the shape specified in the Init procedure.
StaticLine
This is an unchanging line of text.
EditLine (and family)
This is an editable line of text.
AdvanceMode - if set, the cursor will move to the next control when the edit field is full. This is useful in business applications where fixed-length product numbers are typed in.
BlindMode - if set, hides the characters typed. This is useful for typing in passwords.
SimpleButton
This is a button that, when selected, terminates the dialog.
Instant - if set, the button acts like a menu item. Pressing the hot key will immediately select the button and terminate the dialog. Otherwise, pressing the hot key only moves the cursor to the button.
CheckBox
A check box is an option which may be turned on or off.
RadioButton
A radio button is one of a set of options which may be turned on or off. Every radio button has a family number defined in the Init procedure. When a radio button is turned on, all other buttons in the family are turned off.
WindowButton
Loads a window from disk and displays it. The window must have been saved with the Window Manager's SaveWindow procedure.
Rectangle
A box which can be drawn around controls.
Line
A line--what else would it be--drawn between two corners of the enclosing rectangle defined by the Init procedure.
HorizontalSep
A horizontal line, often used to separate controls into groups.
VerticalSep
A vertical line, often used to separate controls into groups.
StaticList
A scrollable box of unchanging text.
CheckList
A scrollable box of check boxes.
RadioList
A scrollable box of radio buttons.
EditList
A scrollable box of editable text.
SourceCodeList (used by PegaSoft's TIA)
A scrollable box containing source code.
OS Package
This package contains various calls for working with the
operating system. All calls support path prefixes as described
above. Here are some of the subprograms:
Beep( Startup ); -- play startup sound
Keyboard Macros
UserIO will load a set of keyboard macros at startup. These must be saved in the $SYS directory, in a file called macro_file. The first letter of each line is the key for the macro, and the rest of the line is the expanded macro. For example, if a line in macro_file contained
pPegaSoft
then typing control-A followed by "p" would put the word
"PegaSoft" in the input queue as if the person had typed
"PegaSoft".
Basic Keyboard Shortcuts:
Movement Keys
Up/Down Arrow - move up or down to the next menu item
Left/Right Arrows - move left or right to the next menu item
Page Up (or Control-P) - move up one page in a list
Page Down (or Control-N) - move down one page in a list
Home Key (or Control-Y) - move to the top of a list
End Key (or Control-E) - move to the bottom of a list
Tab Key - move to the next item in the window
Control-T - move to the previous item in the window
Return Key (or Spacebar) - activate a button
When inside of a list box, the movement keys move you around the list. If you are on the Linux console, pressing alt and the hilighted letter will always jump to the appropriate object, even if you're inside a list box or the notepad.
Editing Keys
Control-6 - mark text
Control-X - clear text
Control-B - copy text
Control-V - paste text
Misc. Keys
ESC Key (or F1) - bring up the accessories menu
[not finished]
GTK+ also contains 2D drawing operations.
GTK+ is available for download from the GTK web site at http://www.gtk.org.
GtkAda can be downloaded from the ALT web site, or from its home page at http://ada.eu.org/gtkada/.
GtkAda is an Ada95 binding of Gtk+ version 1.2.0. It allows you to develop graphical applications in Ada95 using Gtk+. General GTK+ documentation and a tutorial written with examples in C are available from the GTK web site.
[not finished]
Motif (pronounced "Moe-Teef") is an X Windows widget standard created by the Open Software Foundation (OSF), a group of several UNIX companies. Motif is built for the stanadard X Windows library Xt. With Motif, you can create windows and dialog boxes menus, buttons, scrolling lists and the like. Motif is a registered trademark of OSF.
LessTif (pronounced "Less-Teef") is an open source compatible version of Motif 1.2 with some extensions, licenced under LGPL. It is available for download from the LessTif web site at http://www.lesstif.org. This site also includes documentation on compiling and installing LessTif.
There are no Ada bindings for LessTif, but there are Ada bindings for Motif which should work equally well for Lesstif. The bindings are available from the Home for Brave Ada Programmers, http://www.adahome.com.
Motif (and LessTif) have not proven to be very popular. Motif programs tend to be very large, with widgets layouts that are difficult to design, and have a heavy reliance on Motif's cumbersome resource files. Even small Motif programs typically require contain several hundred lines of source code to set up their initial window. Toolsets such as Qt (used in KDE) and GTK+ (used in GNOME) have larger followings, and Motif support is primarily for older applications being ported to Linux.
However, Motif, as a standard, is continuing to evolve.
http://tash.calspan.com/
TASH also comes with its own TCL shell interpreter which functions like tclsh but is written in Ada.
You can use Mesa under GTK+ by using a GTK+ "GL Area" widget and draw graphics inside using Mesa.
Engine_3D is a real-time 3D drawing package written entirely in Ada. It includes a Physics child package for reactions between 3D objects. The Linux port is by Duncan Sands. The Engine_3D package is at http://www.mysunrise.ch/users/gdm/e3d.htm.
APQ is a comprehensive binding to the Postgres database libpq library. APQ is very easy to use and offers complete access to Postgres, including full support for BLOB, DATE and TIME data types. It is a thick binding that uses tagged records, exceptions for errors and Ada streams for BLOB data.
APQ is open source and available for download at http://home.cogeco.ca/~ve3wwg.
PDF refers to the Portable Document Format. The PDF library enables one to generate PDF files or data streams on the fly. The binding is in the style of an OpenGL programming interface. If you know how to handle context scopes, etc. you should feel at home using it. The binding is small but allows for fonts, rotations, skewing, filling, URL links, and other features.
GNU.PDF is available at http://umn.edu/~puk.
This is a binding against the http://www.pdflib.com/pdflib library. The static library is named libpdf.a.
Gwindows is a set of open source Ada packages for Microsoft Windows programming, database integration and ActiveX control support. It is a thick binding which takes advantage of Ada's features, ideal for developing Ada applications under Windows.
GWindows is available at http://www.adapower.com/gwindows.
DirectX (which as a COM library as are most new Win32 APIs) is availble using GNATCOM - http://www.adapower.com/gnatcom. It is compatible with GWindows.
Graph is a os-independent package for drawing scientific graphs. It uses floating-point coordinates and vector fonts. The package is loosely based on Borland Pascal graph unit.
Graph is available at http://www.mysunrise.ch/users/gdm/graph.htm.
<--Last Chapter | Table of Contents | Next Chapter--> |