home *** CD-ROM | disk | FTP | other *** search
- /* File: _ProgInfo.c
- * Purpose: Supplies functionality for a PopUp
- * Author: © Copyright 1993 Jason Williams
- * All rights reserved
- */
-
- #include "DeskLib:WimpSWIs.h"
- #include "DeskLib:Template.h"
-
- #include "Server.h"
-
-
- typedef struct
- {
- char name[32];
- char purpose[32];
- char author[32];
- char version[32];
- } proginfo_data;
-
-
- /* First of all, we define a handler_info structure for our PopUp handler
- * which describes it to the manager. This is referenced externally
- * by the server to find the procedure to call with events for any PopUp
- * of this type, etc.
- * (We also prototype the handler function so we can reference it here)
- */
-
- static int Handler_ProgInfo(int, ctrl_block *, void *, event_pollblock *);
-
- handler_info HandlerInfo_ProgInfo =
- {
- "ProgInfo", /* PopUp type/name string */
- 0x00000001, /* Flag word */
- Handler_ProgInfo, /* Handler procedure */
- 0 /* Instantiation workspace size */
- };
-
-
-
-
- /* The Handler_ function referenced in the above info struct will handle all
- * calls from the server during normal operation...
- */
-
- static BOOL Handler_ProgInfo(int reasoncode, ctrl_block *ctrl,
- void *privateworkspace, event_pollblock *event)
- {
- switch(reasoncode)
- {
- case REASON_OPEN:
- {
- window_handle windowhandle;
- window_block *window;
- proginfo_data *info;
-
- /* Find the template. NOTE that if you provide a STATIC popup, you
- * MUST support multiple instantiations, so MUST use Template_Clone()
- * Also note that if bringing up a MENU LEAF window, we must clone
- * our template data into the RMA so the WIMP does not crash! ;-(
- */
- if ((ctrl->appflags & APPFLAGS_ISLEAF) == 0)
- window = Template_Find("ProgInfo");
- /* (The close icon is there already) */
- else
- {
- window = Template_RMAFind("ProgInfo");
- window->flags.data.closeicon = FALSE;
- /* (Remove the close icon. NOTE that this is a COPY of the window
- * so does not permanently remove the icon)
- */
- }
-
- if (window == NULL) break;
-
- /* Create the window, and fill in it's icons with the data given
- * to us in the pollblock. (DATA_BASE is defined above)
- */
- Wimp_CreateWindow(window, &windowhandle);
-
- info = (proginfo_data *) (((int)event) + POPUP_DATA_OFFSET);
- SetIconText(windowhandle, 0, info->name);
- SetIconText(windowhandle, 1, info->purpose);
- SetIconText(windowhandle, 2, info->author);
- SetIconText(windowhandle, 3, info->version);
-
- ctrl->pollmask.value = ~(1 << event_CLOSE); /* Mask out all but CLOSE*/
- ctrl->basewindow = windowhandle; /* Let server know windowhandle */
- }
- return(TRUE);
-
-
- case REASON_CLOSE: /* Quietly close our window */
- Wimp_DeleteWindow(ctrl->basewindow); /* Kill window */
- return(TRUE);
-
-
- case REASON_EVENT: /* Handle a WIMP Event */
- switch(event->type)
- {
- case event_CLOSE:
- if (event->data.openblock.window == ctrl->basewindow)
- {
- /* *ONLY* if this is our window, we kill the current menu, kill
- * our window, and return TRUE to indicate that we have processed
- * the event (so no other handlers should get it)
- */
- Wimp_CreateMenu((menu_block *) -1, 0, 0);
- Wimp_DeleteWindow(ctrl->basewindow);
- KillMe(); /* Inform server that we have closed ourselves */
- return(TRUE);
- }
- break;
- }
- break;
- }
-
- return(FALSE); /* If we didn't handle this call, we MUST return 0 */
- }
-
-