home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
230.lha
/
SimpleRequest
/
Specs
< prev
next >
Wrap
Text File
|
1989-04-04
|
6KB
|
169 lines
SimpleRequest
NAME
SimpleRequest -- Create and display a requester
SYNOPSIS
SimpleRequest(Hailing_Text, Gadgets_Text, Window, Flags)
FUNCTION
SimpleRequest will take the parameters fed it by the user,
and use them to create and display a 'Requester' (Actually,
just a window with some rendering and some gagdets in it).
The Hailing_Text may be of any length, as may the Gadgets_Text.
The vertical bar character is used as a separator to
delimit the gadgets, and the lines of the requester.
The Window is the window (and derived Screen) to place the
requester into, and to use the font from.
The Flags are:
SR_NOCENTERWINDOW - This will put the Requester Window
at the top left corner of the screen,
rather than centering it.
SR_NOCENTERTEXT - This will Left Justify the text in the
requester, rather than centering it.
SR_NODRAG - Eliminate the drag bar that normally
appears on requesters. This is useful
if you are doing a requester in a window
with no title, (and in other cases).
INPUTS
Hailing_Text - Pointer to a null-terminated string containing
the text to be displayed in the requester. The vertical
bar character will act as a carriage return.
Gadgets_Text - Pointer to a null-terminated string containing
the labels for the gadgets in this requester.
The vertical bar separates gadgets. (See the sample)
Window - Pointer to the window that the requester is
emanating from. The text attributes of that
window will be used to form the text in the
requester.
RESULT
An integer from 0 to however many gadgets you specified, in order
that they were specified.
SAMPLE
SimpleRequest("Please insert volume|Workbench|in any drive",
"Retry|Cancel", SourceWindow, SR_NOCENTERTEXT|SR_NOCENTERWINDOW)
- This will duplicate a system requester asking for a disk
named "Workbench". It will look different, of course.
SimpleRequest("Quit|Are you sure?", "Yes|No", Window, 0);
- This is the kind of usage that SimpleRequest is designed
for. You want an answer from the user - Quit, is it okay
with you? - which can be added using a single line of code.
SimpleRequest("Operation Aborted", "Okay", Window, 0);
- Yet another common type of requester. A single line of
text informing the user that his operation has been
aborted, and a gadget for him to click on, "Okay".
DISCUSSION
SimpleRequest() is my first attempt at providing some additional
functionality to the Intuition programmer. Most programmers who
do anything with Intuition on the Amiga either have to pick up a
copy of one of the commercial Window-design aids, or waste a lot
of time either laying out requesters and such, or designing
routines much like this one to do the work for them.
What It Does:
SimpleRequest starts by finding the longest line in your list of
lines supplied for the text of the requester. The width of the
requester is based on this.
It next determines how long the gadgets would be if they were laid
out across the bottom of the requester horizontally. If this is
less than the width of the screen, then we do it this way, otherwise
we try stacking the gadgets on top of each other.
Note that all gadgets will be the same width and the same height -
it looks better this way. The gadgets will be equally spaced across
the bottom of the window if they are horizontal, or in a straight
vertical line otherwise.
Here's the hard part: SimpleRequest bases all it's calculations
on the font supplied in the RastPort belonging to the Window which is
supplied as an argument. SimpleRequest will look "right" no matter
how big or small (or mono-spaced or proportionally spaced) your font
is. This in itself makes it worth using SimpleRequest over the
current System functions.
Other advantages that SimpleRequest provides:
- It allows any number of gadgets on the requester.
The gadgets will be spaced such that they sit as nicely as
possible at the bottom of the requester (either stacked,
or in a vertical line).
- It is much faster than an AutoRequest() - because it uses
a smart_refresh window, and doesn't use a Requester -
just a window with some rendering and some gadgets in it.
It will take less chip ram, and move quicker, than a system
request.
- SimpleRequest will use whatever font you are using in your
own window, automatically, and correctly.
- It looks nicer.
Once the requester is up, it will wait for one of the gadgets to
be hit, and return a value representing what order that gadget
was supplied in (ie, for "YES|NO", Yes==0, No==1).
Possible Extensions:
As I said, this is my first draft. I present it here to get input
on what this needs - as it is a linkable object currently, whatever
gets added here ultimately gets added to the size of any code using
it. There are a number of things it could use, though:
- The requester should take Keyboard Input. Maybe function
keys from F1, F2, F3, etc for each gadget in order of
appearance? The first letter of the gadget? Return?
Escape?
- For simple "OK" requesters, a flag to tell the requester to
go away by itself after a certain period of time?
Fixed period or user-specifyable?
- Should the requester make any attempt at blocking input
to the calling window? Should this be left up to the
caller, or should it be a flag?
- Should the rendering be different in Interlace?
- How about getting strings? Maybe a flag to indicate
that we want a String gadget on there?
How about other functions? A library of this sort of function would
make for a more "standard" user interface, (to the extent that
AutoRequest does now), and would certainly make life easier for
people using Intuition.
Thanks for listening - Feedback?
Steve Tibbett
Bix: s.tibbett
Plink: STEVEX