home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / h / hp11 / Amiga_Code / c / menufrag < prev    next >
Encoding:
Text File  |  1992-05-07  |  1.9 KB  |  74 lines

  1. /****************************** MENU FUNCTIONS ******************************/
  2.  
  3. /*--- Set the state of the menu.         ---*/
  4. /*--- Called when the menu is displayed. ---*/
  5. static menu hp11_menumaker(void *handle)
  6. {
  7.   hp11_data *d = (hp11_data *)handle;
  8.  
  9.   /* Shade the save entry if there is no file loaded */
  10.   menu_setflags(d->menu, hp11_menu_save, 0, !d->loaded);
  11.  
  12.   return d->menu;
  13. }
  14.  
  15. /****************************** EVENT HANDLERS ******************************/
  16. /*--- Event handler for the menu. 'handle' is a pointer to the diagram. ---*/
  17. static void hp11_menuproc(void *handle, char *hit)
  18. {
  19.   hp11_data *d = (hp11_data *)handle;
  20.  
  21.   /* Find which menu item was hit and take action as appropriate */
  22.   switch (hit[0])
  23.   {
  24.  
  25.     case hp11_menu_save:
  26.       /* Initiate save operation */
  27.       hp11_save_window = d->whandle;
  28.       saveas(hp11_drawtype, d->file, d->diagram.length, hp11_saver, 
  29.                hp11_sender, 0 /* No printer procedure */, d);
  30.       hp11_save_window = -1;
  31.       break;
  32.  
  33.   }
  34. }
  35.  
  36. /*--- Event handler for window. 'handle' is a pointer to the diagram. ---*/
  37. static void hp11_event_handler(wimp_eventstr *e, void *handle)
  38. {
  39.   hp11_data *d = (hp11_data *)handle;
  40.  
  41.   /* Deal with event */
  42.   switch (e->e)
  43.   {
  44.     case wimp_EREDRAW:
  45.       hp11_redraw_window(e->data.o.w, d);
  46.       break;
  47.  
  48.     case wimp_ESEND:
  49.     case wimp_ESENDWANTACK:
  50.     {
  51.       /* We deal only with messages for loading and saving files here, using
  52.          essentially the skeleton code given in the manual
  53.       */
  54.       switch (e->data.msg.hdr.action)
  55.       {
  56.         case wimp_MDATASAVE:   /* import data */
  57.           hp11_load_ram(d);
  58.           break;
  59.  
  60.         case wimp_MDATALOAD:   /* insert data */
  61.         case wimp_MDATAOPEN:
  62.           hp11_load_file(d);
  63.           break;
  64.  
  65.         default: break;        /* ignore other messages */
  66.       }
  67.     }
  68.  
  69.     default:   /* Ignore any other event */
  70.       break;
  71.   }
  72. }
  73.  
  74.