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.CreatDstry.c
- Author: Copyright © 1993 Tim Browse and Jason Williams
- Version: 1.00 (10 Jul 1993)
- Purpose: Very high level window (dialogue) handling -
- Creating and destroying dialogues
- */
-
- #include <stdlib.h>
-
- #include "DeskLib:Wimp.h"
- #include "DeskLib:WimpSWIs.h"
-
- #include "DeskLib:Dialog.h"
- #include "DeskLib:Event.h"
- #include "DeskLib:Window.h"
-
-
- static BOOL EventHandler(event_pollblock *event, void *reference)
- {
- dialog_record *dbox = (dialog_record *) reference;
-
- switch (event->type)
- {
- case event_CLOSE:
- /* User has clicked on close icon - We just close the window, as
- * Dialog_WaitForClick will notice this and take appropriate action
- */
- Window_Hide(dbox->window);
- return(TRUE);
-
- case event_CLICK:
- dbox->lastclicked = event->data.mouse.icon;
- dbox->state.persist = event->data.mouse.button.data.adjust;
- return(TRUE);
- }
-
- return(FALSE); /* Allow other event handlers to handle this event */
- }
-
-
- extern dialog Dialog_Create(char *template_name, int maxtitlesize)
- /* Returns a pointer to a dialog record, or NULL if it fails */
- {
- window_handle window;
- dialog d;
-
- window = Window_Create(template_name, maxtitlesize);
- if (window == NULL) return(NULL);
-
- d = (dialog) malloc(sizeof(dialog_record));
- if (d == NULL) return(NULL);
-
- d->window = window;
- d->lastclicked = dialog_NOCHOICE;
- d->state.persist = TRUE;
- d->state.isstatic = d->state.stillopen = FALSE;
-
- /* Attach the event handler */
- Event_Claim(event_ANY, window, event_ANY, EventHandler, d);
-
- return(d);
- }
-
-
- extern void Dialog_Destroy(dialog dbox)
- {
- if (dbox != NULL)
- {
- /* Remove event handler */
- Event_Release(event_ANY, dbox->window, event_ANY, EventHandler, dbox);
-
- if (!dbox->state.isstatic)
- Wimp_CreateMenu((menu_block *) -1, 0, 0);
-
- Window_Delete(dbox->window);
- free(dbox);
- }
- }
-