home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Dialog.h
- Author: Copyright © 1993 Tim Browse, with modifications by JW
- Version: 1.00 (10 Jul 1993)
- Purpose: Very high-level window (dialogue box) handling
- */
-
- #ifndef __dl_dialog_h
- #define __dl_dialog_h
-
- #ifndef __dl_wimp_h
- #include "Wimp.h"
- #endif
-
- #ifndef __dl_window_h
- #include "Window.h"
- #endif
-
-
- /* A dialogue is a window that is popped open to get user choices and
- * then goes away - They can act like menus (go away when you click outside
- * them) if opened with Dialog_Show(), or can be permanent windows if
- * you open them using Dialog_ShowStatic().
- * This code simplifies popping up such dialogues, as it handles opening,
- * closing and simple processing of the window for you.
- *
- * To use Dialog, you do something like the following:
- * (Assuming a window where icon 0 is the 'OK' button, and icon 1 is the
- * 'Cancel' button)
- *
- * {
- * dialog dlog;
- *
- * dlog = Dialog_Create("template", 0); |* Create the window *|
- * Dialog_ShowStatic(dlog, open_UNDERPOINTER); |* Pop up under pointer *|
- *
- * while (Dialog_WaitForClick(dlog) > 1 || Dialog_Persist(dlog))
- * |* Busy wait loop *| ; |* Wait for OK/Cancel *|
- *
- * Window_Hide(dlog); |* Hide the window before we start processing *|
- *
- * if (Dialog_LastClicked(dlog) == 0)
- * ProcessTheData(); |* OK was clicked, so go ahead with processing *|
- *
- * Dialog_Destroy(dlog);
- * }
- */
-
-
- typedef struct
- {
- window_handle window; /* The window handle of this dialogue window */
- icon_handle lastclicked; /* The icon handle of the last icon that was
- * clicked, or dialog_NOCHOICE if no icons
- * have been clicked yet.
- */
- struct
- {
- unsigned int stillopen : 1; /* The dialogue window is still open */
- unsigned int persist : 1; /* It should persist (adjust was clicked) */
- unsigned int isstatic : 1; /* It is a static (permanent) dialogue */
- } state;
- } dialog_record;
-
- typedef dialog_record *dialog;
-
-
- /* Returned by Dialog_WaitForClick when user causes dialogue box to be
- * closed by clicking outside window or clicking on close icon.
- */
- #define dialog_CLOSE ((icon_handle) -1)
-
-
- /* The setting returned by Dialog_LastClicked() when the user has not yet
- * done anything (i.e. no icons have been clicked and the window is open)
- */
- #define dialog_NOCHOICE ((icon_handle) -2)
-
-
- /* Dialog_Create
- * Creates (but does not show) a dialog box from a named template.
- */
- extern dialog Dialog_Create(char *template_name, int maxtitlesize);
-
-
- /* Dialog_Destroy
- * Removes from display and deletes a dialogue box structure.
- * NOTE that the dialog structure is free'd by this, so you cannot call
- * any dialogue functions (except Create of course) with it after a Destroy
- */
- extern void Dialog_Destroy(dialog d);
-
-
- /* Dialog_Show
- * Shows a dialogue box in the centre of the screen, as a submenu window.
- * (i.e. clicking outside the window or pressing escape will remove it)
- */
- extern void Dialog_Show(dialog d);
-
-
- /* Dialog_ShowStatic
- * As Dialog_Show(), but more permanent - only a click on the close icon
- * (if present) will close it. Of course it may be closed by other means
- * if the application assigns special meaning to an icon - e.g. a cancel
- * button - and closes it itself when this icon is clicked on.
- * Opens the window at the position requested (see Window.h), of:
- * open_ WHEREVER, CENTERED, OVERCARET, UNDERPOINTER, NEARLAST
- *
- * (It is very convenient if dialogues always appear under the mouse pointer
- * especially as mouse-movement distances (screen sizes) increase)
- */
- extern void Dialog_ShowStatic(dialog d, window_openpos openpos);
-
-
- /* Dialog_WaitForClick
- * Waits for an icon to be clicked in the dialogue box. All other events
- * are processed as usual. If the user closes the window, dialog_CLOSE
- * is returned.
- * Note that Dialog_LastClicked can be called at any time up until you call
- * Dialog_Destroy() to find out what the last valid icon click was (i.e.
- * the last positive value that WaitForClick returned)
- */
- extern int Dialog_WaitForClick(dialog d);
-
-
- /* Dialog_WindowHandle
- * Returns the RISC OS Wimp window handle associated with this dialogue box.
- * This allows filling in of fields using, e.g. DeskLib's 'Icon' module.
- *
- * extern window_handle Dialog_WindowHandle(dialog d);
- */
- #define Dialog_WindowHandle(D) ((D)->window)
-
-
- /* Dialog_Persist
- * Returns TRUE if the last choice made for this dialogue box was made with
- * adjust, and the dialogue window is still open - i.e. the user wants
- * the dialogue to stay open.
- * Unlike RISC OS Lib, this remembers the last click rather than just
- * checking if Adjust is down when called, so will work even after an
- * indentation delay.
- *
- * extern BOOL Dialog_Persist(dialog d);
- */
- #define Dialog_Persist(D) ((D)->state.persist && (D)->lastclicked >= 0)
-
-
- /* Dialog_LastClicked
- * Returns the icon number of the last icon which was clicked in the
- * dialogue window. If no icons have been clicked yet, returns
- * dialog_NOCHOICE.
- *
- * extern icon_handle Dialog_LastClicked(dialog d);
- */
- #define Dialog_LastClicked(D) ((D)->lastclicked)
-
-
- /* Dialog_StillOpen
- * Returns TRUE if the dialogue window is still open
- *
- * extern BOOL Dialog_StillOpen(dialog d);
- */
- #define Dialog_StillOpen(D) ((D)->state.stillopen)
-
-
- #endif
-