home *** CD-ROM | disk | FTP | other *** search
- TABLE OF CONTENTS
-
- gauge/--background--
- gauge/DisposeGauge
- gauge/GetGaugeA
- gauge/NewGaugeA
- gauge/SetGaugeA
- gauge/--background-- gauge/--background--
-
- PURPOSE
- The "Amiga User Interface Style Guide" contains an example of how
- a progress requester should look like (page 29), but this example
- has no "teeth". It is just a visual cue, you still have to implement
- the requester yourself. Around Christmas Day, the issue was brought
- up in comp.sys.amiga.programmer how to program these progress
- requesters. This is my attempt at solving the problem.
-
- GOALS
- - The progress requester should be entirely self-contained and
- reentrant.
- - It should be simple to find out if the user has hit the
- "Stop" button.
- - Creation and management of the requester should follow a
- familiar model.
- - The display should be font sensitive.
-
- IMPLEMENTATION
- The implementation consists of a set of BOOPSI objects, which are
- linked together, plus a display element for the gauge. This is
- similar to how Intuition builds system requesters and has the
- advantage of delegating the work load of refreshing and maintaining
- the display to Intuition. The application to create the display
- just has to listen for the user to hit the "Stop" button, it need
- not worry about housekeeping work.
-
- The gauge creation code is reentrant, it was written with SAS/C
- in mind. The only compiler dependant part is the custom class
- dispatcher. You must initialize IntuitionBase, GfxBase,
- UtilityBase and SysBase for the gauge code to work.
-
- COPYRIGHT AND USAGE RESTRICTIONS
- This implementation is Copyright © 1997 by Olaf `Olsen' Barthel.
- It is freely distributable. I place no restrictions on its usage.
- You may use this code in commercial software or shareware programs
- without having to pay royalties to me. An acknowledgement would
- still be nice, though :^) If you find bugs in the code or make
- enhancements, please notify me. I would like to keep this code
- updated, so everyone will be able to take advantage of it.
-
- My electronic mail address:
-
- olsen@sourcery.han.de
-
- My postal address:
-
- Olaf Barthel
- Brabeckstrasse 35
- D-30559 Hannover
- Federal Republic of Germany
-
- gauge/DisposeGauge gauge/DisposeGauge
-
- NAME
- DisposeGauge -- Close a progress requester Window.
-
- SYNOPSIS
- DisposeGauge(Gauge)
-
- VOID DisposeGauge(struct Gauge *);
-
- FUNCTION
- When you are finished with the work the progress gauge represents,
- you should close the gauge Window. This routine will close the
- display opened by NewGaugeA().
-
- INPUTS
- Gauge - Pointer to a Gauge structure as created by NewGaugeA().
- NULL is a valid parameter.
-
- EXAMPLE
- /* Close the gauge display */
-
- DisposeGauge(gauge);
-
- SEE ALSO
- NewGaugeA
-
- gauge/GetGaugeA gauge/GetGaugeA
-
- NAME
- GetGaugeA -- Obtain information about the gauge display.
-
- SYNOPSIS
- Attributes = GetGaugeA(Gauge,TagList)
-
- LONG GetGaugeA(struct Gauge *,struct TagItem *);
-
- Attributes = GetGauge(Gauge,Tags);
-
- LONG GetGauge(struct Gauge *,...);
-
- FUNCTION
- The Gauge structure is meant to be opaque, you should not peek
- inside to find the information you need, such as the pointer
- to the Window the display is built on top of. Rather, use this
- routine to find out about it. This routine also provides means
- to find out if a user has hit the "Stop" button.
-
- INPUTS
- Gauge - Pointer to a Gauge structure as created by NewGaugeA().
- NULL is a valid parameter.
-
- TagList - Pointer to a table of TagItem structures.
- NULL is a valid parameter.
-
- If you provide a tag list, the following item types are valid:
-
- GAUGE_MsgPort (struct MsgPort *) - Pointer to the port IntuiMessages
- arrive at the gauge Window.
-
- GAUGE_Window (struct Window *) - Pointer to the Window the progress
- requester is built on top of. If the gauge display is using a shared
- message arrival port, you can use the Window pointer to find out if
- an input event was meant for the gauge display rather than a different
- Window.
-
- GAUGE_Hit (LONG) - If the user hit the "Stop" button, this routine will
- return TRUE, FALSE otherwise.
-
- GAUGE_SigBit (LONG) - Provides the signal bit of the message arrival
- port the gauge Window uses.
-
- RESULT
- Attributes - Number of attributes this function could provide
- information on.
-
- EXAMPLE
- /* Find out whether the user has hit the "Stop" button. */
-
- LONG stop;
-
- if(GetGauge(gauge,
- GAUGE_Hit,&stop,
- TAG_END) == 1)
- {
- if(stop)
- printf("user wants to stop the work in progress.\n");
- else
- printf("the work in progress can continue.\n");
- }
- else
- {
- printf("something is wrong.\n");
- }
-
- NOTES
- If this function returns a number smaller than the actual number
- of attributes you inquired about, some of the variables you have
- provided will not be initialized.
-
- SEE ALSO
- NewGaugeA
- gadtools.library/GT_GetGadgetAttrs
-
- gauge/NewGaugeA gauge/NewGaugeA
-
- NAME
- NewGaugeA -- Create a progress gauge display requester
-
- SYNOPSIS
- Gauge = NewGaugeA(TagList)
-
- struct Gauge *NewGaugeA(struct TagItem *);
-
- Gauge = NewGauge(Tags);
-
- struct Gauge *NewGauge(Tag firstTag,...);
-
- FUNCTION
- The "Amiga User Interface Style Guide" gives an example of how a
- progress requester should look like (page 29). This example
- lacks "teeth" as it just represents a visual cue, not something
- you can work with--until you implement it. NewGaugeA() will create
- such a progress requester.
-
- INPUTS
- You control the initial attributes of the gauge display with
- tagitems:
-
- GAUGE_Window (struct Window *) - The parent Window to "attach"
- the gauge to. The gauge display will appear on the same Screen
- as the parent Window, centred within the bounds of the Window.
- These are the only relations to the "parent" Window.
-
- GAUGE_Screen (struct Screen *) - The Screen to open the gauge on.
- The gauge will appear centred within the visible part of
- this Screen.
-
- GAUGE_PubScreen (struct Screen *) - Pointer to a Public Screen the
- gauge display should be opened on as a Visitor Window. The gauge
- will appear centred within the visible part of this Screen.
-
- GAUGE_PubScreenName (STRPTR) - Name of a Public Screen the gauge
- display should be opened on as a Visitor Window. If the named
- Screen cannot be found, the display will default to open on the
- Default Public Screen. You can control the fall-back behaviour
- with the GAUGE_PubScreenFallback tag.
-
- GAUGE_PubScreenFallback (BOOL) - If the named Public Screen the
- display is to open on cannot be found, the gauge display will
- default to open on the Default Public Screen. In most cases,
- this will be the Workbench Screen. This tag controls whether
- the fall-back will take place or whether the display will fail
- to open.
- (Default: TRUE)
-
- GAUGE_UserPort (struct MsgPort *) - You can have multiple Windows
- sharing the IntuiMessage arrival MsgPort. If you with to share
- some other Window's arrival port with the gauge display, you
- can specify the port address with this tag.
-
- GAUGE_ButtonLabel (STRPTR) - There is one single button in the
- gauge display, which when hit by the user indicates that
- whatever action in progress the gauge represents should be
- brought to a stop. By default, this button bears the label
- "Stop". You can provide a replacement label, such as for
- localization, using this tag.
- (Default: "Stop")
-
- GAUGE_Title (STRPTR) - The gauge display bears a title which tells
- about the action in progress the display indicates. This title
- will be eventually be the title of the progress Window. Steps
- will be taken to make the progress gauge Window large enough to
- show the complete title.
- (Default: "")
-
- GAUGE_Fill (LONG) - Progress is shown with a bar that grows from
- left to right. You specify how far the bar should grow with this
- tags in percentage, i.e. a value of 0 will show no bar, 50 will
- show a bar that covers half its maximum size and 100 will produce
- the complete bar. Any values outside this range will be truncated
- to the range.
- (Default: 0)
-
- RESULT
- Gauge - Pointer to a Gauge structure that represents the progress
- requester Window and its contents. You should not peek the data
- this structure holds, but use the GetGaugeA() function instead.
- If NewGaugeA() cannot create the progress display, it will return
- NULL.
-
- EXAMPLE
- /* Create the progress report Window and wait for the user to
- * hit the "Stop" button. Make it look like the example in
- * the "Amiga User Interface Style Guide".
- */
-
- struct Gauge *gauge;
- struct MsgPort *port;
-
- gauge = NewGauge(
- GAUGE_Title, "Rendering \"Boing.Ball\"",
- GAUGE_Fill, 40,
- TAG_END);
-
- if(gauge != NULL)
- {
- GetGauge(&gauge,
- GAUGE_MsgPort,&port,
- TAG_END);
-
- WaitPort(port);
-
- DisposeGauge(gauge);
- }
-
- NOTES
- Unless you provide a MsgPort to be used as the IntuiMessage
- arrival port, this function will create one for you. To find
- out about this port, use GetGaugeA().
-
- If this function is not told about the Screen it should open
- the progress requester Window on, it will default to opening
- the Window on the Default Public Screen. Usually, this will
- be the Workbench Screen.
-
- The gauge Window contains one single button the user can
- hit if the action the requester represents should be aborted.
- In this event, an IDCMP_GADGETUP message will be generated.
- This is the *only* type of event the gauge Window can generate.
- Thus, when you receive any kind of input from this Window you
- can be certain that the user wants to stop the work in progress.
-
- SEE ALSO
- intuition.library/OpenWindow
- intuition.library/OpenWindowTagList
-
- gauge/SetGaugeA gauge/SetGaugeA
-
- NAME
- SetGaugeA -- Change the title or the position of the
- progress indicator of the gauge display.
-
- SYNOPSIS
- SetGaugeA(Gauge,TagList)
-
- VOID SetGaugeA(struct Gauge *Gauge,struct TagItem *);
-
- SetGauge(Gauge,Tags);
-
- VOID SetGauge(struct Gauge *,...);
-
- FUNCTION
- After you have opened the progress requester display, you
- will want to change the indicator that shows how far the
- work the requester represents has progressed. Occasionally,
- the requester title may need changing, too, as work progresses
- into a different phase.
-
- INPUTS
- Gauge - Pointer to a Gauge structure as created by NewGaugeA().
- NULL is a valid parameter.
-
- TagList - Pointer to a table of TagItem structures.
- NULL is a valid parameter.
-
- If you provide a tag list, the following item types are valid:
-
- GAUGE_Title (STRPTR) - The gauge display bears a title which tells
- about the action in progress the display indicates. This title
- will be eventually be the title of the progress Window. Steps
- will be taken to make the progress gauge Window large enough to
- show the complete title.
-
- GAUGE_Fill (LONG) - Progress is shown with a bar that grows from
- left to right. You specify how far the bar should grow with this
- tags in percentage, i.e. a value of 0 will show no bar, 50 will
- show a bar that covers half its maximum size and 100 will produce
- the complete bar. Any values outside this range will be truncated
- to the range.
-
- EXAMPLE
- /* Set the fill indicator to 70% */
-
- SetGauge(gauge,
- GAUGE_Fill, 70,
- TAG_END);
-
- SEE ALSO
- NewGaugeA
- intuition.library/SetAttrsA
-
-