home *** CD-ROM | disk | FTP | other *** search
- TABLE OF CONTENTS
-
- ged/--background--
- ged/--styles--
- ged/GedWin
- ged/GedWindow
- ged/Ged_Activate
- ged/Ged_Add
- ged/Ged_Create
- ged/Ged_Delete
- ged/Ged_Enable
- ged/Ged_Get
- ged/Ged_GetIMsg
- ged/Ged_Remove
- ged/Ged_Set
- ged/PrepareNW
- ged/zzz
-
-
-
-
- ged/--background-- ged/--background--
-
- What the heck *is* Ged, anyway? Well, I'll tell you...
-
- At the conception of Scan, I realized very quickly that I was going
- to need a way to shorten the time it took to create the gadgets and
- windows and stuff needed for the program. The idea was to come up
- with a 2.0 look and feel, without actually requiring 2.0 to run
- (grumble, grumble). So I quickly hacked together a little gadget
- editor program to make life a little easier.
-
- Well, originally this little gadget editor was just going to spit out
- Gadget structures, but after playing around with it a while I thought
- it would be better to come up with my own GadTools-like system. Hence
- the NewGad structure was born. The idea was to pass an array of
- NewGad structures to a single gadget creating function that would
- return a pointer to a list of Gadget's, suitable for adding to a
- window (sound familiar?).
-
- As these things often do, Ged kinda grew completely out of control.
- In addition to gadgets, I added the ability to specify text, border,
- and even imagery in the list of NewGad's. It also became somewhat
- object-oriented in that each NewGad can specify a function to call
- when that gadget is "fiddled" with (one of the things I find sorely
- lacking in GadTools).
-
- Anyway, the following is an attempt at documenting how the Ged system
- works so that you can use it in creating your own modules for
- Scan (it is required for Scanner, Render, Printer, and some aspects
- of Preview modules). These functions are contained in the scan.library
- function library.
-
- BTW, if you're wondering about the Ged creator program, it's way
- too hacked up and obsolete to be useful anymore.
-
- All of the functions described below are contained in the ImageFX function
- library (scan*.library).
-
-
- ged/--styles-- ged/--styles--
-
- A complete catalog of the types of GUI elements that can be created with
- the Ged system:
-
- Button_ID:
- A standard BOOLGADGET button, with a bevel box border. The label
- always appears inside the gadget.
-
- Toggle_ID:
- Looks like a button, but really toggles between two states. The
- label always appears inside the gadget. I wouldn't use this too
- often, as it isn't really very AUISG compliant.
-
- String_ID:
- A standard string gadget, with the 2.0 look border around it. The
- label always appears to the left of the gadget.
-
- Integer_ID:
- A standard LONGINT string gadget, with the 2.0 look border
- around it. The label always appears to the left of the gadget.
-
- HSlider_ID:
- Horizontal slider (PROPGADGET), with a bevel border. The label
- always appears to the left of the gadget.
-
- VSlider_ID:
- Vertical slider (PROPGADGET), with a bevel border. The label
- always appears above the gadget.
-
- Cycle_ID:
- 2.0-style cycle gadget, for cycling through a list of choices.
- Ged breaks away a little from the style guide here in the way it
- handles these kinds of gadgets. Clicking the right side of the
- gadget cycles upwards, clicking the left side of the gadget cycles
- downwards, and double-clicking in the middle of the gadget brings
- up a list of all the choices in the gadget. A tool type
- (GTCOMPLIANT) in ImageFX will disable all this fancy stuff if
- you're used to standard GadTools-type cycler gadgets.
-
- There is also no way to attach a label to a Ged cycle gadget; you
- have to use a Text_ID item and place a text near it.
-
- Check_ID:
- 2.0-style checkbox gadget. Gadget labels always appears on the
- right side of the checkbox.
-
- MX_ID:
- 2.0-style mutual exclusion (radio) gadget. Note that Ged does
- *NOT* do any mutual exclusion - this gadget behaves just like a
- checkbox gadget. The only difference is the imagery. You must
- still do the mutual exclusion yourself. The label always appears
- on the right side of the gadget.
-
- Border_ID:
- Draw a bevel-box border, raised or recessed.
-
- Text_ID:
- Draw a string of text.
-
- Image_ID:
- Display an Image structure.
-
- End_ID:
- Used to end an array of NewGad structure.
-
- Up_ID: (1.5)
- An up arrow gadget, similar in all respects to a Button_ID.
-
- Down_ID: (1.5)
- A down arrow gadget, similar in all respects to a Button_ID.
-
- List_ID: (2.0)
- A gadtools-style listview gadget. You must initialize an
- EListView structure and place a pointer to it in NewGad->Data1.
- See <scan/ged.h> for details about the EListView structure.
-
-
- The following styles will not be used often, if ever:
-
- QButton_ID:
- Same as Button_ID with no imagery.
-
- QToggle_ID:
- Same as Toggle_ID with no imagery.
-
- QString_ID:
- Same as String_ID with no imagery.
-
- QInteger_ID:
- Same as Integer_ID with no imagery.
-
- QHSlider_ID:
- Same as HSlider_ID with no imagery.
-
- QVSlider_ID:
- Same as VSlider_ID with no imagery.
-
- QCycle_ID:
- Same as Cycle_ID with no imagery.
-
- QCheck_ID:
- Same as Check_ID with no imagery.
-
- QMX_ID:
- Same as MX_ID with no imagery.
-
-
- Special non-GUI styles:
-
- Ignore_ID:
- Not implemented.
-
- Font_ID:
- Not implemented.
-
- Offset_ID:
- Internal use only.
-
- Scale_ID:
- Specify this style as the first in your NewGad array, and layout
- your gadgets based on an 8-point font. The Ged system will
- automatically scale the sizes and positions of your GUI elements
- to fit the font that the user specified for ImageFX. You should
- use this only for opening windows on the ImageFX screen. ImageFX
- itself uses this for most of its displays.
-
-
- ged/GedWin ged/GedWin
-
- NAME
- GedWin -- Somewhat higher-level version of GedWindow().
-
- SYNOPSIS
- returnCode = GedWin ( newWindow, newGadArray, activateID,
- D0.L A0 A1 D0.L
- initCode, cleanupCode, textArray )
- A2 A3 A4
-
- int GedWin ( struct NewWindow *newWindow,
- struct NewGad *newGadArray,
- int activateID,
- int (*initCode)(struct Window *, struct NewGad *),
- int (*cleanupCode)(struct Window *, struct Gadget *),
- char **textArray );
-
- FUNCTION
- Open a new window, add gadgets to it, process the events of the
- window, and return only when the window is closed. This is a
- convenient do-it-all function for opening requesters and such
- containing Ged gadgets.
-
- This function is meant specifically for opening windows on the ImageFX
- screen. It will make sure the ImageFX screen is in front, roll the
- screen up far enough to hold the window, and block all input to other
- ImageFX windows before opening this new window.
-
- In all other respects, this function is identical to GedWindow().
-
- INPUTS
- See GedWindow().
-
- RESULTS
- See GedWindow().
-
- EXAMPLE
- See GedWindow().
-
- NOTES
-
- BUGS
-
- SEE ALSO
- ged/GedWindow,ged/PrepareNW
-
-
- ged/GedWindow ged/GedWindow
-
- NAME
- GedWindow -- Open and handle a window with Ged gadgets.
-
- SYNOPSIS
- returnCode = GedWindow ( newWindow, newGadArray, activateID,
- D0.L A0 A1 D0.L
- initCode, cleanupCode, textArray )
- A2 A3 A4
-
- int GedWindow ( struct NewWindow *newWindow,
- struct NewGad *newGadArray,
- int activateID,
- int (*initCode)(struct Window *, struct NewGad *),
- int (*cleanupCode)(struct Window *, struct Gadget *),
- char **textArray );
-
- FUNCTION
- Open a new window, add gadgets to it, process the events of the
- window, and return only when the window is closed. This is a
- convenient do-it-all function for opening requesters and such
- containing Ged gadgets.
-
- There are two ways to have the window closed. One is to specify a
- close gadget in the NewWindow structure, in which case this function
- will return -1 when the close gadget is pressed. The other way is to
- make sure that one or more of your Ged gadgets have a code pointer
- that returns a non-zero value. You may also specify in the NewGad
- structure of Button_ID gadgets that a non-zero value be returned
- without the need for a user-supplied function.
-
- An alert will be presented if the window open fails, and a -2 will be
- returned.
-
- If this window is opened on the ImageFX screen, pressing the right
- mouse button any time while this window is open will toggle the
- menu panel on or off.
-
- If you are opening this window on the ImageFX screen, you may want to
- consider using the GedWin() function instead.
-
- If you need to do anything fancy (like menus, for example) you will
- not be able to use this function.
-
- INPUTS
- newWindow -- a pointer to a NewWindow structure used to open the
- window. Note that you must make sure that you select the
- proper IDCMP flags for the gadget styles you have chosen
- for this window. You should call PrepareNW() on this
- structure.
-
- newGadArray -- pointer to an array of NewGad structures, each
- element of which describes a UI feature (gadget,
- text, image, or bevel box). The contents of each
- NewGad structure depends on the Style chosen
- (see scan/ged.h for details of the NewGad struct).
-
- activateID -- if non-zero, this should be a string or integer
- gadget ID number to automatically activate when the
- window opens.
-
- initCode -- User-supplied code to call to initialize certain things
- during the process of opening the window. This function
- will actually be called twice during the initialization
- process. The first time, the NewGad * argument will be
- valid. The second time, the Window * argument will be
- valid. The invalid argument will be NULL. Most times you
- will not need to use these functions.
-
- cleanupCode -- User-supplied code to call during the cleanup process.
-
- textArray -- Array of text pointers to be supplied to Ged_Create().
-
-
- RESULTS
- Returns the result code of the gadget that terminated the window,
- or -1 if the close gadget was pressed. This function will not return
- until the window is closed one way or another.
-
- EXAMPLE
-
- /*
- * Simple window with nothing but an Okay and Cancel gadget.
- *
- */
-
- extern struct ScanBase *ScanBase;
-
- /* Text indexes */
- enum {
- G_Okay = 1,
- G_Cancel
- };
-
- /* Text string array */
- char *textArray[] = {
- NULL,
- "_Okay", /* note underscore to make keyboard shortcut */
- "_Cancel"
- };
-
- /* Gadget ID's */
- enum {
- ID_Okay = 100,
- ID_Cancel
- };
-
- /* GUI definition */
- struct NewGad newGads[] = {
- { Button_ID, ID_Okay, 8,18,90,12, G_Okay, NULL,0, NULL, ID_Okay,0,NULL,0 },
- { Button_ID, ID_Cancel, 294,18,90,12, G_Cancel, NULL,0, NULL, ID_Cancel,0,NULL,0 },
- { Border_ID, 0, 0,0,421,34, NULL,NULL,0,NULL, FALSE,TRUE,0,0 },
- { End_ID }
- };
-
- /* Window definition */
- struct NewWindow newWindow = {
- 9,13,421,64,
- 0,1,
- GADGETUP,
- BORDERLESS|ACTIVATE|NOCAREREFRESH|SMART_REFRESH|RMBTRAP,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 40,20,-1,-1,
- CUSTOMSCREEN
- };
-
- void TestGedWindow (void)
- {
- int rc;
-
- rc = GedWindow(&newWindow, boolNewGads, 0, NULL, NULL, textArray);
-
- switch(rc) {
- case ID_Okay :
- printf("ok!\n");
- break;
- case ID_Cancel :
- printf("cancel!\n");
- break;
- default :
- printf("oops.\n");
- break;
- }
- }
-
- NOTES
-
- BUGS
-
- SEE ALSO
- ged/GedWin
-
-
- ged/Ged_Activate ged/Ged_Activate
-
- NAME
- Ged_Activate -- Activate a string or integer gadget.
-
- SYNOPSIS
- Ged_Activate ( window, gadgetid )
- A0 D0.L
-
- void Ged_Activate ( struct Window *window, int gadgetid );
-
- FUNCTION
- Attempts to activate the gadget identified by the ID value
- given in the supplied window. Of course, this only works
- for String_ID and Integer_ID style gadgets.
-
- INPUTS
- window -- pointer to the window where the gadget resides.
- id -- ID value of the gadget to activate.
-
- RESULT
- None.
-
- EXAMPLE
-
- NOTES
-
- SEE ALSO
-
-
-
- ged/Ged_Add ged/Ged_Add
-
- NAME
- Ged_Add -- Add a Ged context to a window.
-
- SYNOPSIS
- Ged_Add ( context, window )
- A0 A1
-
- void Ged_Add ( struct GedContext *context, struct Window *window );
-
- FUNCTION
- Adds (ie. draws) the imagery specified by the supplied GedContext
- to the given window. This includes gadgets, text, bevel borders,
- and images.
-
- INPUTS
- context -- pointer to a GedContext structure, which has been filled
- in by a call to Ged_Create().
- window -- pointer to the Window in which to add the context.
-
- RESULT
- None.
-
- EXAMPLE
-
- NOTES
- The normal procedure to follow is something like this:
-
- if (Ged_Create(&context, newGadArray)) {
- Ged_Add(&context, window);
- /* do window stuff */
- Ged_Remove(&context, window);
- Ged_Delete(&context);
- }
-
- SEE ALSO
- ged/Ged_Create,ged/Ged_Remove
-
-
-
- ged/Ged_Create ged/Ged_Create
-
- NAME
- Ged_Create -- Allocate a complete Ged context based on an input
- array of gadget, text, border, and image
- specifications.
-
- SYNOPSIS
- success = Ged_Create ( context, newGadArray, textArray )
- A0 A1 A2
-
- int Ged_Create ( struct GedContext *context,
- struct NewGad *newGadArray,
- char **textArray );
-
- FUNCTION
- Fills in the supplied GedContext structure with pointers to
- lists of Gadget, IntuiText, Border, and Images suitable for
- adding to a window with Ged_Add(). Dynamically allocates Gadget
- structures based on the information contained in the input array
- of NewGad specifiers; this list also contains information on where
- and how to place text, borders, and images.
-
- INPUTS
- context -- pointer to GedContext structure which is filled
- with a bunch of (read only) information.
-
- newGadArray -- pointer to an array of NewGad structures, each
- element of which describes a UI feature (gadget,
- text, image, or bevel box). The contents of each
- NewGad structure depends on the Style chosen
- (see scan/ged.h for details of the NewGad struct).
-
- textArray -- pointer to an array of text strings. Each NewGad
- should specify it's label as an index into this
- text array, so that they may be internationalized
- fairly easily. If this pointer is NULL, ImageFX
- will assume that each NewGad.Label is really a
- pointer to a (char *) string.
-
- RESULT
- success -- 0 if the function failed, non-zero if successful.
-
- EXAMPLE
-
- NOTES
- The newGadArray must remain valid throughout the entire lifetime of
- the gadgets, as the NewGad structure that created a gadget is
- referenced whenever a gadget is fiddled with. For example, when a
- slider gadget is adjusted, the new value of the slider is stored in
- the NewGad that created the slider.
-
- Also note that each gadget's Pointer argument (as specified in the
- NewGad structure) must remain valid throughout the lifetime of the
- gadgets, as they are updated whenever a gadget is modified. They are
- also initialized immediately.
-
- SEE ALSO
- ged/Ged_Delete,scan/ged.h
-
-
- ged/Ged_Delete ged/Ged_Delete
-
- NAME
- Ged_Delete -- Free all memory associated with a Ged context.
-
- SYNOPSIS
- Ged_Delete ( context )
- A0
-
- void Ged_Delete ( struct GedContext *context );
-
- FUNCTION
- Frees all memory associated with the given GedContext structure.
- When this function returns, all pointers within the GedContext
- structure are invalid.
-
- INPUTS
- context -- pointer to GedContext structure as filled in by
- the Ged_Create() function.
-
- RESULTS
- None.
-
- EXAMPLE
-
- NOTES
-
- BUGS
-
- SEE ALSO
- ged/Ged_Create
-
-
- ged/Ged_Enable ged/Ged_Enable
-
- NAME
- Ged_Enable -- Enable or disable (ghost) a Ged gadget.
-
- SYNOPSIS
- Ged_Enable ( window, gadgetID, enable )
- A0 D0.W D1.W
-
- void Ged_Enable ( struct Window *window,
- short gadgetID,
- short enable );
-
- FUNCTION
- Use this function to enable or disable a Ged gadget. Disabling a
- gadget prevents the user from accessing it. The gadget imagery will
- be refreshed immediately.
-
- INPUTS
- window -- pointer to the Window containing the gadgets.
-
- gadgetID -- the ID number of the gadget you wish to examine.
-
- enable -- flag indication whether you want to enable or disable the
- gadget. Use a non-zero value to enable the gadget, or
- zero to disable (ghost) the gadget.
-
- RESULTS
- None.
-
- EXAMPLE
-
- NOTES
-
- BUGS
-
- SEE ALSO
-
-
- ged/Ged_Get ged/Ged_Get
-
- NAME
- Ged_Get -- return the state of a given Ged gadget.
-
- SYNOPSIS
- value = Ged_Get ( window, gadgetID )
- D0.L A0 D0.W
-
- long Ged_Get ( struct Window *window, short gadgetID );
-
- FUNCTION
- Returns the current state (value) of any Ged gadget in a window.
- The return value will differ depending on the style of gadget you are
- examining (see below).
-
- INPUTS
- window -- pointer to the Window containing the gadgets.
-
- gadgetID -- the ID number of the gadget you wish to examine.
-
- RESULTS
- value -- the current value of the gadget. The returned value and type
- depends on the style of gadget you are examining:
-
- Button_ID (long) Always 0.
- Toggle_ID (long) Selection state (1=on, 0=off).
- MX_ID (long) Selection state (1=on, 0=off).
- Check_ID (long) Selection state (1=on, 0=off).
- String_ID (char *) String contents.
- Integer_ID (long) Integer value.
- HSlider_ID (long) Slider value.
- VSlider_ID (long) Slider value.
- Cycle_ID (long) Cycle index.
-
- EXAMPLE
-
- NOTES
- Examining a gadget's Pointer variable will accomplish the same thing.
-
- BUGS
-
- SEE ALSO
- ged/Ged_Set
-
-
- ged/Ged_GetIMsg ged/Ged_GetIMsg
-
- NAME
- Ged_GetIMsg -- Handle Ged gadget events.
-
- SYNOPSIS
- intuiMsg = Ged_GetIMsg ( window, &returnCode )
- D0.L A0.L A1.L
-
- struct IntuiMessage *Ged_GetIMsg ( struct Window *window,
- short *returnCode );
-
- FUNCTION
- Process events from the given window, filtering out those events which
- pertain only to Ged gadgets. If an event is found to be a Ged event,
- then the event is processed and the results of the processing are
- stored in the variable that returnCode points to.
-
- When Ged gadget activity is detected, the Ged system will update the
- gadget imagery as necessary, then call the optional user-supplied code
- (set with NewGad.Code) for the gadget. The return value from this user-
- supplied code is placed in the variable that returnCode points to. A
- zero result generally means everything went alright.
-
- INPUTS
- window -- pointer to the Window to process.
-
- returnCode -- where to store the return codes from any user-supplied
- code processed by the Ged system.
-
- RESULTS
- intuiMsg -- If this event is not of a type that Ged cares about, then
- the IntuiMessage is returned for you to process normally.
- If Ged did in fact process the event, NULL is returned.
-
- EXAMPLE
-
- NOTES
-
- BUGS
-
- SEE ALSO
-
-
- ged/Ged_Remove ged/Ged_Remove
-
- NAME
- Ged_Remove -- Remove a Ged context from a window.
-
- SYNOPSIS
- Ged_Remove ( context )
- A0
-
- void Ged_Remove ( struct GedContext *context );
-
- FUNCTION
- Remove all the gadgets in the Ged context from the window that
- this context was added to (with Ged_Add()).
-
- INPUTS
- context -- pointer to GedContext as filled in by the Ged_Create()
- function.
-
- RESULTS
- None.
-
- EXAMPLE
-
- NOTES
-
- BUGS
-
- SEE ALSO
- ged/Ged_Add
-
-
- ged/Ged_Set ged/Ged_Set
-
- NAME
- Ged_Set -- Set the state of a Ged gadget.
-
- SYNOPSIS
- Ged_Set ( window, gadgetID, newValue )
- A0 D0.W D1.L
-
- void Ged_Set ( struct Window *window,
- short gadgetID,
- long newValue );
-
- FUNCTION
- Set the state of a gadget, that is, the contents of a string
- or integer gadget, the value of a slider gadget, or the selection state
- of checkbox or toggle gadgets.
-
- INPUTS
- window -- window containing the gadgets.
-
- gadgetID -- the ID number of the gadget you wish to modify.
-
- newValue -- new value to store in the given gadget. The value depends
- on the type of gadget you are modifying:
-
- Button_ID Ignored.
- Toggle_ID (long) Selection state (1=on, 0=off).
- MX_ID (long) Selection state (1=on, 0=off).
- Check_ID (long) Selection state (1=on, 0=off).
- String_ID (char *) New string contents.
- Integer_ID (long) New integer value.
- HSlider_ID (long) New slider value.
- VSlider_ID (long) New slider value.
- Cycle_ID (long) New cycle index.
-
- Note that there is no range checking on the value you
- supply.
-
- The gadget imagery will be refreshed.
-
- The gadget's Pointer variable (if present) will be updated.
-
- RESULTS
- None.
-
- EXAMPLE
-
- NOTES
- For slider gadgets (styles HSlider_ID and VSlider_ID), the gadgets
- Code function will be called when the imagery is refreshed. The is
- because in most cases, the code for a slider gadget is used to update
- a numerical value somewhere near the slider.
-
- BUGS
-
- SEE ALSO
- ged/Ged_Get
-
-
- ged/PrepareNW ged/PrepareNW
-
- NAME
- PrepareNW -- Prepare a NewWindow structre for GedWin().
-
- SYNOPSIS
- PrepareNW ( newwindow, width, height, scale );
- A0 D0.L D1.L D2.L
-
- void PrepareNW ( struct NewWindow *, int, int, BOOL );
-
- FUNCTION
- Initialize a NewWindow structure such that the window will open
- properly on the ImageFX screen.
-
- You should call this function before calling GedWin() or
- GedWindow().
-
- This function takes care of setting the Screen field to the
- right value, depending on whether ImageFX is running on its
- own custom screen, the Workbench, or some public screen.
-
- INPUTS
- newwindow -- pointer to the NewWindow structure to initialize.
-
- width, height -- width and height of the window, in pixels.
-
- scale -- if TRUE, the width and height parameters are scaled
- to take into account the user's preferred font. You will
- almost always want to set this to TRUE.
-
- RESULTS
- None.
-
- EXAMPLE
-
- NOTES
-
- BUGS
-
- SEE ALSO
- ged/GedWin(),ged/GedWindow()
-
- ged/zzz
-