home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Docs / ModuleNote / PopUps < prev    next >
Encoding:
Text File  |  1993-07-05  |  3.4 KB  |  115 lines

  1. Using PopUps from within DeskLib applications
  2. =============================================
  3.  
  4. The following message was posted to usenet by Philip Colmer.
  5. One note. The 'OpenPopUp' function decribed in the first part is needed
  6. for use of ANY type of MENU PopUp, not just the ProgInfo one.
  7.  
  8. ---
  9.  
  10. From comp.sys.acorn.tech Thu Jun 24 08:30:27 1993
  11. Newsgroups: comp.sys.acorn.tech
  12. Subject: Re: DeskLib PopUps from within C
  13. Message-ID: <24432@acorn.co.uk>
  14. From: pcolmer@acorn.co.uk(Philip Colmer)
  15. Date: Thu Jun 24 08:30:27 1993
  16. References: <209mrv$7j@cezanne.ecs.soton.ac.uk>
  17. Organisation: Acorn Computers Ltd, Cambridge, England
  18. Lines: 93
  19.  
  20. In article <209mrv$7j@cezanne.ecs.soton.ac.uk> Graeme Foster writes:
  21.  
  22. >Can anyone (Jason?) supply some example C source which will demonstrate how
  23. > to use PopUps from within C?
  24.  
  25. Hope the following helps.
  26.  
  27. --Fil.
  28.  
  29.  
  30.  
  31. To use the ProgInfo PopUp
  32. =========================
  33.  
  34.  1. Call EventMsg_Claim(message_POPUPREQUEST, event_ANY, OpenPopup, NULL)
  35.     at some point in your initialisation. The OpenPopup routine is:
  36.  
  37. BOOL OpenPopup(event_pollblock *event, void *reference)
  38. {
  39.   message_popuprequest *request = (message_popuprequest *)
  40.                                   &event->data.message.data;
  41.  
  42.   Wimp_CreateSubMenu((menu_block *)request->window,
  43.                      request->openpos.x, request->openpos.y);
  44.  
  45.   return TRUE;
  46. }
  47.  
  48.     This gets called when the PopUp server needs your application to open
  49.     the window for it.
  50.  
  51.  
  52.  2. You would normally open the info dbox on a submenu warning, so call:
  53.  
  54.     EventMsg_Claim(message_MENUWARNING, event_ANY, InfoRequest, NULL);
  55.  
  56.     somewhere in your initialisation code, where InfoRequest is:
  57.  
  58. BOOL InfoRequest(event_pollblock *event, void *reference)
  59. {
  60.   popup_data info;
  61.  
  62.   Msgs_Lookup("app.name", info.proginfo.appname, 32);
  63.   Msgs_Lookup("app.purpose", info.proginfo.purpose, 32);
  64.   Msgs_Lookup("app.author", info.proginfo.author, 32);
  65.   Msgs_Lookup("app.version", info.proginfo.version, 32);
  66.  
  67.   PopUp_ShowMenuLeaf("ProgInfo", &info, &event->data.message.data.menuwarn);
  68.   return TRUE;
  69. }
  70.  
  71.     If you have more than one submenu warning set, you will need to check
  72.     the hit code returned, eg
  73.  
  74.     switch (event->data.message.data.menuwarn.selection[0])
  75.     {
  76.       case iconmenu_INFO:
  77.         ...
  78.  
  79.  
  80. To use the SaveAs PopUp
  81. =======================
  82.  
  83.  1. Call EventMsg_Claim(message_POPUPSTATE, event_ANY, PopUpState, NULL) at
  84.     some point in your initialisation. PopUpState will be called when the
  85.     drag of the icon from the SaveAs box has been finished. Your
  86.     application must then start the normal data transfer protocol.
  87.     PopupState is defined as:
  88.  
  89. BOOL PopUpState(event_pollblock *event, void *reference)
  90. {
  91.   /* do a GetPointerInfo and build a datasave block */
  92.   message_block message;
  93.   mouse_block ptrinfo;
  94.  
  95.   Wimp_GetPointerInfo(&ptrinfo);
  96.   memcpy(&message, &event->data, sizeof(message_block));
  97.   message.header.yourref = 0;
  98.   message.header.action = message_DATASAVE;
  99.   message.data.datasave.window = ptrinfo.window;
  100.   message.data.datasave.icon = ptrinfo.icon;
  101.   message.data.datasave.pos = ptrinfo.pos;
  102.   message.data.datasave.estsize = -1;
  103.   message.data.datasave.filetype = 0xFFF;
  104.   Wimp_SendMessage(event_SEND, &message, ptrinfo.window, ptrinfo.icon);
  105.  
  106.   return TRUE;
  107. }
  108.  
  109.  
  110.  2. When you want the SaveAs PopUp to appear, go:
  111.  
  112.     strcpy(saveas.saveas.iconsprite, "file_fff");
  113.     strcpy(saveas.saveas.filename, "FileName");
  114.     PopUp_ShowStandalone("SaveAs", &saveas);
  115.