home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
594b.lha
/
Precognition_rel1
/
Precognition.doc
< prev
next >
Wrap
Text File
|
1991-12-09
|
12KB
|
305 lines
Precognition: A step beyond Intuition
Release 1, December 1991
Precognition is an interface builder program for Intuition that allows
you to create attractive, 3D-style interfaces like Workbench 2.0, but
under AmigaDos 1.3!
You use Precognition as if it were a structured drawing or paint program,
i.e. simply drag the desired gadgets on to the window, size and move
them using the mouse. When you're done, Precognition writes the C code
to generate that window.
Unlike other Amiga interface-building programs, Precognition not only
writes the declarations for the gadgets, but also writes the code for
opening and closing the window, and the event loop itself. (For any
non-trivial interface, the event loop is usually the hardest part to
write.)
Precognition is also a set of programming utilities for use with
Intuition that make manipulating gadgets easier. The code generated by
the Precognition Interface builder relies heavily on the Precognition
utilities.
FOR ADVANCED AMIGA PROGRAMMERS: Unlike Intuition, Precognition is not a
separate process on the Amiga. It is merely a collection of functions
which manipulate gadgets and windows. i.e. it's designed to extend
Intuition, not replace it.
Starting the Program from Workbench
Simply double-click the Precognition icon.
Starting the Program from the CLI
Set the stack to AT LEAST 40,000. Then type "Precognition"
Interlace vs. Non-Interlace
Precognition normally opens a screen with the same resolution as the
Workbench screen. You can force the screen to be (or not to be)
interlaced via the tooltype "INTERLACE=". Use "INTERLACE=YES" for
interlace, "INTERLACE=NO" for non-interlace.
The Application Window
Occupying most of the screen is a window titled "Application". This is
the window which you are designing. You will add gadgets and graphics to
this window by dragging them over from the "Gadgets" and "Graphics"
windows.
To change the properties of the application window, select "Window
Properties" from the "Edit" menu. This will bring up the Window
Properties requestor. Using this requester, you can change the window
title, the variable name, and the window gadgets (close, drag,
front/back, resize).
The Gadget Window
At the lower right side of the screen, there will be the "Gadgets" window
which contains a set of buttons labelled with the different gadget types.
To add one of these gadgets to the application window, simply move the
mouse over the name of the gadget you wish, press and hold the left
mousebutton. A gadget icon will be attached to your mouse pointer. Drag
the gadget icon into the application window, and release the left
mousebutton.
The Graphics Window
To the left of the "Gadgets" window is the "Graphics" window which
contains a set of buttons labelled with the different window graphics
which can be added to the window. S Currently, there aren't very many
graphics. S You add these to the window the same way you add a gadget,
i.e. drag them.
Selecting Objects
To move, resize, or edit an object in the application window, you must
first select it. To select an object, move the mouse pointer over that
object, and press and release the left mousebutton. The object should
now be displayed in inverse video.
Multiple objects can be selected at the same time by holding down either
shift key while pressing the left mousebutton.
Objects can be selected by lasso-ing them. Hold the left mousebutton
down on an area of the window where there are no objects. Now move the
mouse. A selection box will follow your mouse. When you release the
mouse, any and all objects completely within the selection box will be
selected.
Changing the Size of an Object
To change the size of an object, move the mouse pointer to the edge or
corner of the object, press and hold the left mousebutton. The pointer
image should change to a triangular arrow. Now drag the corner or edge
of the object to its new size and release the left mousebutton.
You can cancel a size-change by pressing by pressing the right
mousebutton before releasing the left mousebutton.
NOTE: The size of some objects cannot be changed, e.g. a CheckBox is a
fixed size.
If the pointer image becomes a hand you're not close enough to the edge
of the object, or else this object does not size.
NOTE: You can only change the size of one object at a time.
Moving Objects
You move objects on the application window the same way you move icons on
the workbench screen.
To move one or more objects, first select the objects, and then move the
mouse pointer to the center of one of the objects, press and hold the
left mousebutton. The pointer image will become a hand. Now drag the
objects to their new location, and release the left mousebutton.
You can cancel a size-change by pressing by pressing the right
mousebutton before releasing the left mousebutton.
If the pointer image becomes a triangular arrow instead of a hand you're
too close to the edge of the object.
Editing an Object
To edit the properties of an object, select the object, and then select
Object Properties from the Edit menu. This will bring up the object's
property requestor. This requestor will allow you to change the variable
name for this object, its displayable title (if any), its size and
location, and any other property which is applicable.
Aligning Objects
You can align a set of objects by selecting those objects, and then
selecting the appropriate option from the Align submenu of the Edit menu.
Grid Snap
You can also force alignment by turning on the Grid Snap. Selecting Grid
Snap Controls from the Edit menu will display the Grid Snap requestor,
which allows you to set the grid snap parameters.
There are actually two separate grid snaps:
Location Snap will force the upper-left corner of an object to be
on a grid when you drag it.
Size Snap will force the corner or edge of an object to be on a
grid when you size it.
Deleting Objects
To delete one or more objects, select those objects, and then select
Delete from the Edit menu.
WARNING: Once you delete an object, its gone for good.
Sooner or later I'll get around to adding Cut/Copy/Paste instead of
Delete. (Sigh. So many improvements, so little time...)
Generating Code
To generate code for the application window, select "Write Code" from the
"Project" menu. This will bring up a file requester for the C source
code. Type or select a filename, and press the "OK" gadget. Precognition
will then write the C source code declarations for your window.
The name of the C function source code which Precognition generates will
be "do_<Window_Name>()" where <Window_Name> is the variable name of the
application window. (Unless you change it, the application window is
named "window", and so the function name is "do_window()".)
About the Generated Code...
Precognition does not generate standard Intuition variables and function
calls. (This is because 1.3 Intuition does not have built-in 3-D buttons
and scrolling lists and such) Instead Precognition generates code which
use special Precognition data types and functions. In order for your
program to use these functions, you must link your code with the file
"Precognition.o", which contains all the special Precognition calls.
Throughout the code you will say lines which say "/* YOUR CODE HERE */".
These are the areas which you the programmer must fill in. Precognition
inserts these statements to indicate that a User-interface event has
occurred, and you should take the appropriate action. EXAMPLE: If
you create a window with an "OK" button, Precognition will generate the
following statements:
if (Respond( (Interactor*) &OK_button, &event) & CHANGED_STATE)
{ /* OK_button was hit. */
; /* YOUR CODE HERE */
}
You, the programmer, need to supply the code to take the appropriate
action when the OK button is pressed. (Precognition doesn't know what
you want to happen when "OK" is hit.)
The code as written should be compilable and linkable, although it
won't do anything except have pretty buttons until you fill in the
/* YOUR CODE HERE */ areas. (NOTE: If you do not include a closebox
on your window, then the event loop is infinite until you modify the
code.) Also included is the file "std_main.c" which supplies an
example of a standard Amiga "main.c" file, including opening the
appropriate libraries.
There's not a whole lot of documentation in the header files, and I
apologize for that. But I know that I won't have much free time in the
next few months, and I wanted to get this release out the door. So
here's a few clues to get you started.
Precognition uses an OO paradigm via pointers-to-functions, which allows
the same function to do different things to different objects
("polymorphism"). e.g.
SetLocation(&BoolGadget, 10, 10 );
sets the location of a boolean gadget to be 10,10 in its window, while
SetLocation( &pcgWindow, 10, 10 );
sets the location of the window to be 10, 10 on its screen.
All header files (most header files?) have an 'object genealogy' at the
top of the file which describes the parents of the object. e.g.
Object<GraphicObject<OutlineBox
Says that object class OutlineBox is a descendent of class GraphicObject,
which is a descendent of class Object. Any function you can call on an
Object or a GraphicObject, you can call on an OutlineBox. To find out
what operations an object supports, look at the prototypes in the objects
header files, and all parent header files.
Pre-Planned Product Improvements
This section describes the bells and whistles I plan on adding, but
haven't gotten around to yet.
* Cut/Copy/Paste
* Radio Buttons
* The ability to load and save a Precognition window in a non-source
code form.
* More Graphic types, including a text object.
* a Precognition shareable library.
How many out there would like to see a 2.0 version of Precognition (one
that generated GadTools and/or BOOPSI calls instead of custom
Precognition calls)? How many would rather see Precognition stay 1.3
compatible? (I've only got so much free time folks, so please don't
saying "both!")
About the Author
("He's a mild mannered defense contractor by day, but by night he turns
into AMIGA MAN!")
I wrote Precognition over the course of the last year (1991) to
* make programming Intuition easier (for me).
* to experiment with object-oriented programming. OO works very well
on user interface software.
* to try and duplicate as much as possible the functionality of the
NeXT interface builder. (I've never used the NeXT IB, but I've read
about it and saw a demo. It looks slick.)
You can get in touch with me on USENET via:
Lee_Robert_Willis@cup.portal.com
I'm also a member a few other Amiga BBS, but USENET is the only one I
check regularly.
Or, when all else fails, you can reach me via U.S mail at:
Lee Willis
590 Eleanora Dr.
Cuyagoga Falls, Ohio USA
44223-2732