#ifndef _MENU_PACK_H
#define _MENU_PACK_H 1

#include "darray.h"
#include "Mintrins.h"
#include "sysdep.h"
#include "useful.h"
#include "ArgPack.h"

typedef struct MenuPack_str  *MenuPack;
typedef struct MenuPackRec_str  *MenuPackRec;

#define MP_PULLDOWN       (1<<0)
#define MP_POPUP          (1<<1)
#define MP_OPTION         (1<<2)
#define MP_SUBMENU        (1<<3)
#define MP_MENUPANE       (1<<4)

MenuPack MenuPack_create_popup PROTOTYPE((Widget, char *));
MenuPack MenuPack_create_cascade PROTOTYPE((Widget, char *));
MenuPack MenuPack_create_pulldown PROTOTYPE((Widget, Widget, char *));
MenuPack MenuPack_create_option PROTOTYPE((Widget, char *, char *));
MenuPack MenuPack_create_option_xm PROTOTYPE((Widget, char *, XmString));
MenuPack MenuPack_create_menupane PROTOTYPE((Widget, char *));
void     MenuPack_destroy PROTOTYPE((MenuPack));
void     MenuPack_add_option PROTOTYPE((char *,MenuPack,
			     XtCallbackProc, caddr_t, ArgPack));
void     MenuPack_add_sub_menu PROTOTYPE((char *,MenuPack, MenuPack));
void     MenuPack_add_separator PROTOTYPE((MenuPack, ArgPack));
void     MenuPack_make_menu PROTOTYPE((MenuPack));
Widget   MenuPack_get_widget PROTOTYPE((MenuPack,char *));
MenuPackRec   MenuPack_get_option PROTOTYPE((MenuPack,char *));
void     MenuPack_attach_to_widget PROTOTYPE((MenuPack,Widget));
Widget   MenuPack_get_top_level_manager PROTOTYPE((MenuPack));
Widget   MenuPack_get_menupane PROTOTYPE((MenuPack));
NORET    MenuPack_add_arg_to_all PROTOTYPE((MenuPack,char*,XtArgVal));
NORET    MenuPack_detach_menu PROTOTYPE((MenuPack));
NORET    MenuPack_reattach_menu PROTOTYPE((MenuPack));
Bool     MenuPack_set_feature PROTOTYPE((MenuPack,char*,char*,XtArgVal));
NORET    MenuPack_set_as_default PROTOTYPE((MenuPack,char*));
NORET    MenuPack_unset_as_default PROTOTYPE((MenuPack,char*));

Widget   MenuPack_option_get_label PROTOTYPE((MenuPack));
Widget   MenuPack_option_get_button PROTOTYPE((MenuPack));
NORET    MenuPack_option_set_args PROTOTYPE((MenuPack,ArgPack));
NORET    MenuPack_set_shadow PROTOTYPE((MenuPack,int));
NORET    MenuPack_set_highlight PROTOTYPE((MenuPack,int));

/*
------------------------ DESCRIPTIONJ OF FUNCTIONS ------------------------

MenuPack MenuPack_create_popup(ParentW, MenuName)
Widget ParentW;
char * MenuName;

  the ParentW can be any Widget (and not a gadget).  When the user moves the
  mouse over the ParentW the cursor will change to a right hand to indicate
  there is a popup.  Mouse Button 2 should activate it.  Popups can have
  multiple cascading submenus.

MenuPack MenuPack_create_pulldown(menubar,cascade,menuname)
Widget menubar, cascade;
char *menuname;

  The menubar is the widget id of the menbuar which contains the cascade
  widget.  This function creates a pulldown menu pane for the cascade
  button.  Cascading menus are supported.

MenuPack MenuPack_create_option(parent,menuname,optionName)
Widget parent;
char *menuname, optionName;

  This function creates an option menu.  The label of the option menu is
  optionName.  Cascading submenus ARE NOT supported for this kind of menu.

void     MenuPack_destroy(MenuPack);
  This function frees all memory associated with the menu but does not
  destroy the widgets of the menu,, i.e. the menu still exists but the
  MenuPack associated with it is destroyed.

void     MenuPack_add_option(menu-option-name, menu-pack, callback, data, args)
char          *menu-option-name;
MenuPack       menu-pack;
XtCallbackProc callback;
caddr_t        user-data; 
ArgPack        args;

  Each menu option is instantiated as a push button gadget.  The
  menu-option-name is the name of the option as it appeaars in the menu.
  The callback is your callback to be called when the option is selected.
  The user-data will be sent to your callback as the second argument (see Xt
  manual for defention of  XtCallBackProc).  The args is an ArgPack of
  arguments which will be used when actually creating the widget.  You can
  do funky things like specify a different border or whatever for the puch
  button gadget with the args.

void     MenuPack_add_sub_menu(sub-menu-identifier, parent-menu, cascade-menu);
char* sub-menu-identifier;
MenuPack parent-menu;
MenuPack cascade-menu;

  This attaches the cascade-menu as a cascading sub menu to the parent-menu.
  The paren-menu will be instantiated with a cascade button gadget with the
  sub-menu-identifier as its label.  Only 

void     MenuPack_make_menu(menu)
MenuPack menu

  This function creates and instantiates the menu.

Widget   MenuPack_get_widget(menu,menu-option-name)
MenuPack menu;
char *menu-option-name;

  This function returns the push button gadget, cascade button gadget, or
  top level shell widget if menu-option-name matches (by strcmp) either an
  option in the menu, a sub menu cascade button label, or a menu name
  respectively.  IF it matches the menu-name of a menu then either the top
  level menupane or the option menu widget is returned depending on what
  type of menu it is.  See the MenuPack_get_top_level_manager function
  below. 

MenuPackRec   MenuPack_get_option(menu, menu-option-name)
MenuPack menu;
char *menu-option-name;

  This is an internal function which may be expanded upon in the future.

void     MenuPack_attach_to_widget(menu, parent)
MenuPack menu;
Widget   parent;

  This function attaches a menu to a widget.  This is useful, for instance,
  if the user wants to create a MenuPack before he has created the widget
  under which the menu will reside.  In this case, he creates the MenuPack
  specifying NULL as the parent widget and prior to calling
  MenuPack_make_menu he 'attaches' the menu to a widget with this function
  call. 

Widget   MenuPack_get_top_level_manager(menu)
MenuPack menu;

  This function will return the menupane of a Popup menu or Pulldown menu or
  it will return the Option Widget of an Option menu.

NORET    MenuPack_add_arg_to_all(menu, resource, value)
MenuPack menu;
char*    resource;
XtArgVal value;

  This function adds the single Widget resource resource to all the push
  button and cascade gadgets in a menu.  The menu can either be instantiated
  or not.

NORET    MenuPack_detach_menu(menu)
MenuPack menu;

  This function detaches an instantiated menu from its parent widget so that
  it will no longer popup or pulldown.  This function has no effect on
  option menus.  THIS FUNCTION IS NOT COMNPLETE YET.

NORET    MenuPack_reattach_menu(menu)
MenuPack menu;

  This function will reattach a dettached menu.  

Bool     MenuPack_set_feature(menu,menu-option-name,resource,value)
MenuPack menu;
char*    menu-option-name;
char*    resource;
XtArgVal value;

  This function finds the associated widget in the same way that
  MenuPack_get_option does.  If the menu is instnatiated it does an
  XtSetValues on that widget with the resource and value specified.  If the
  menu is not specifies it will store the resource and add it to the
  resources used when creating the widget.


NORET    MenuPack_set_as_default(menu,menu-option-name)
MenuPack menu;
char*    menu-option-name;

  This function will set a default option in a menu.  In an option menu this
  will have the effect of also displaying the new default in the cascade
  area (to the left of the label).  In other menu systems this will
  highlight that item in some way.  This highlighting of an item is not
  completed yet. 


*/

#endif






