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, Jason Williams, Julian Smith.
- Version: 1.02 (14 Nov 1995)
- Purpose: Very high level window (dialogue) handling -
- Creating and destroying dialogues
- History: 1.01 (02 Mar 1993) TB and JW
- 1.02 (14 Nov 1995) JS Made SDLS compatible
- */
-
- #include <stdlib.h>
-
- #include "Desk.Wimp.h"
- #include "Desk.WimpSWIs.h"
- #include "Desk.DeskMem.h"
-
- #include "Desk.Dialog.h"
- #include "Desk.Event.h"
- #include "Desk.Window.h"
-
- Desk_SDLS_PtrFn(
- static,
- Desk_bool,
- Desk_Dialog__EventHandler(Desk_event_pollblock *event, void *reference)
- )
- /*static Desk_bool EventHandler(Desk_event_pollblock *event, void *reference)*/
- {
- Desk_dialog_record *dbox = (Desk_dialog_record *) reference;
-
- switch (event->type)
- {
- case Desk_event_CLOSE:
- /* User has clicked on close icon - We just close the window, as
- * Desk_Dialog_WaitForClick will notice this and take appropriate action
- */
- Desk_Window_Hide(dbox->window);
- return(Desk_bool_TRUE);
-
- case Desk_event_CLICK:
- /* Ignore work-area click events */
- if (event->data.mouse.icon >= 0)
- {
- dbox->lastclicked = event->data.mouse.icon;
- dbox->button.value = event->data.mouse.button.value;
- dbox->state.persist = event->data.mouse.button.data.adjust;
- return(Desk_bool_TRUE);
- }
- break;
- }
-
- return(Desk_bool_FALSE); /* Allow other event handlers to handle this event */
- }
-
-
- extern dialog Desk_Dialog_Create(char *Desk_template_name, int maxtitlesize)
- /* Returns a pointer to a dialog record, or NULL if it fails */
- {
- Desk_window_handle window;
- dialog d;
-
- window = Desk_Window_Create(Desk_template_name, maxtitlesize);
- if (window == NULL) return(NULL);
-
- d = (dialog) Desk_DeskMem_Malloc(sizeof(Desk_dialog_record));
-
- d->window = window;
- d->lastclicked = Desk_dialog_NOCHOICE;
- d->state.persist = Desk_bool_TRUE;
- d->state.isstatic = d->state.stillopen = Desk_bool_FALSE;
-
- /* Attach the event handler */
- Desk_Event_Claim(Desk_event_NULL, Desk_event_ANY, Desk_event_ANY, Desk_SDLS_dllEntry( Desk_Dialog__EventHandler), d);
- Desk_Event_Claim(Desk_event_ANY, window, Desk_event_ANY, Desk_SDLS_dllEntry( Desk_Dialog__EventHandler), d);
-
- return(d);
- }
-
-
- extern void Desk_Dialog_Destroy(dialog dbox)
- {
- if (dbox != NULL)
- {
- Desk_Event_Poll(); /* for RO3 bug */
-
- /* Remove event handler */
- Desk_Event_Release(Desk_event_NULL, Desk_event_ANY, Desk_event_ANY, Desk_SDLS_dllEntry( Desk_Dialog__EventHandler), dbox);
- Desk_Event_Release(Desk_event_ANY, dbox->window, Desk_event_ANY, Desk_SDLS_dllEntry( Desk_Dialog__EventHandler), dbox);
-
- Desk_Dialog_Hide(dbox);
- Desk_Window_Delete(dbox->window);
- Desk_DeskMem_Free(dbox);
- }
- }
-