/* AttachMenu.h */

#include "DeskLib:Wimp.h"
#include "DeskLib:Menu.h"

/* Menu handler. Differances from RISC_OSLib
  
  1. Selection returned as int array.
  
  2. Selections start from 0. NOT 1!      
  
  3. If you need to remove a menu attachment, you must store the
pointer that is returned, then call Event_RemoveMenu. You should also
use Event_RemoveMenu if you want to replace one menu with another.

  4. Pop up menus can be attached to icons using Event_AttachPopUp.
  
  5. There is no way to attach menu makers, although it should be
quite easy to implement this. If you do, remember to dispose of the
menu blocks when you have finished with them.
  
*/

typedef void (*menu_handler)(void *handle,int *sel);

typedef struct {
  window_handle MenuWind;
  icon_handle   MenuIcon;
  menu_ptr      ThisMenu;
  menu_handler  HandleProc;
  void          *Handle;
} Menu_Attachment;



/* Attachmenu_Initialise should be called at application startup
   (But after EventMsg_Initialise). */

void AttachMenu_Initialise(void);




/* Attach menu_ptr to window_handle, calling menu_handler when selections
   are made. Returns attachment pointer. Store the pointer if you need
   to use Event_RemoveMenu. */

Menu_Attachment *Event_AttachMenu(window_handle,menu_ptr,menu_handler,void *ref);




/* Attach menu_ptr as pop up menu to icon_handle in window_handle.
   Menu appears if ANY mouse button is pressed. */

Menu_Attachment *Event_AttachPopUp(window_handle,icon_handle,menu_ptr,menu_handler,void *ref);




/* Remove attachment */

void Event_RemoveMenu(Menu_Attachment *); 

                  


/* Pop up a window attached to the menu tree. ONLY call from
   within a menu handler */

void Window_ShowAsMenu(window_handle);




/* The following functions are for internal use ONLY. Do not call them! */

BOOL Attachment_Click(event_pollblock *,void *);
BOOL Attachment_Select(event_pollblock *,void *);
BOOL Attachment_Warn(event_pollblock *,void *);



