//
//	$VER: pm.h 6.0 (23.9.97)
//
//	Library base, tags and macro definitions
//	for popupmenu.library.
//
//	©1996-1997 Henrik Isaksson
//	All Rights Reserved.
//

#ifndef LIBRARIES_POPUPMENU_H
#define LIBRARIES_POPUPMENU_H

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

//
// Tags passed to PM_OpenPopupMenuA and PM_FilterIMsgA
//

#define PM_Menu			(TAG_USER+4)	// (struct PopupMenu *) Pointer to menulist initialized by MakeMenu()
#define PM_Top			(TAG_USER+12)	// (LONG) Top (Y) position
#define PM_Left			(TAG_USER+13)	// (LONG) Left (X) position
#define PM_Code			(TAG_USER+14)	// (UWORD) Read the documentation.
//#define PM_Right		(TAG_USER+15)
//#define PM_Bottom		(TAG_USER+16)
//#define PM_MinWidth		(TAG_USER+17)
//#define PM_MinHeight		(TAG_USER+18)
//#define PM_ForceFont		(TAG_USER+19)
#define PM_PullDown		(TAG_USER+90)	// (BOOL) Make the menu a pulldown menu.
#define PM_MenuHandler		(TAG_USER+91)	// (struct Hook *) Hook that is called for each selected item, after the
						// menu has been closed. This tag turns on MultiSelect.
#define PM_AutoPullDown		(TAG_USER+92)	// Make an automatic pulldown menu. (PM_FilterIMsg only)

//
// Tags passed to MakeItem
//

#define PM_Title		(TAG_USER+20)	// Item title
#define PM_UserData		(TAG_USER+21)	// Anything, returned by OpenPopupMenu when this item is selected
#define PM_ID			(TAG_USER+22)	// ID number, if you want to access this item later
#define PM_Sub			(TAG_USER+23)	// Pointer to submenu list (from MakeMenu)
#define PM_Flags		(TAG_USER+24)	// For internal use
#define PM_NoSelect		(TAG_USER+25)	// Make the item unselectable
#define PM_FillPen		(TAG_USER+26)	// Make the item appear in FILLPEN
#define PM_Checkit		(TAG_USER+27)	// Leave space for a checkmark
#define PM_Checked		(TAG_USER+28)	// Make this item is checked
#define PM_Italic		(TAG_USER+29)	// Italic text
#define PM_Bold			(TAG_USER+30)	// Bold text
#define PM_Underlined		(TAG_USER+31)	// Underlined text
#define PM_TitleBar		(TAG_USER+32)	// Horizontal separator bar
#define PM_WideTitleBar		(TAG_USER+33)	// Same as above, but full width
#define PM_ShadowPen		(TAG_USER+34)	// Draw text in SHADOWPEN
#define PM_ShinePen		(TAG_USER+35)	// Draw text in SHINEPEN
#define PM_Center		(TAG_USER+36)	// Center the text of this item
#define PM_Exclude		(TAG_USER+37)	// Items to unselect (or select) when this gets selected
#define PM_Disabled		(TAG_USER+38)	// Disable an item
#define PM_ImageSelected	(TAG_USER+39)	// Image when selected, PM_Title will be render on top of the image
#define PM_ImageUnselected	(TAG_USER+40)	// Image when unselected
#define PM_IconSelected		(TAG_USER+41)	// Icon when selected
#define PM_IconUnselected	(TAG_USER+42)	// Icon when unselected
//#define PM_ImageMode		(TAG_USER+43)
#define PM_AutoStore		(TAG_USER+44)	// Pointer to BOOL reflecting the current state of the item
#define PM_TextPen		(TAG_USER+45)	// Pen number for text colour of this item, if you want to allocate a pen yourself
//#define PM_			(TAG_USER+46)
#define PM_CommKey		(TAG_USER+47)	// Keyboard shortcut for this item.
#define PM_Shadowed		(TAG_USER+48)	// Gives the text a shadow

//
// Tags passed to MakeMenu
//

#define PM_Item			(TAG_USER+50)	// Item pointer from MakeItem
#define PM_Dummy		(TAG_USER+51)	// Sometimes very useful

//
// Tags passed to MakeIDList
//

#define PM_ExcludeID		(TAG_USER+55)	// ID number of menu to deselect when this gets selected
#define PM_IncludeID		(TAG_USER+56)	// ID number of menu to select when this gets selected
#define PM_ReflectID		(TAG_USER+57)	// ID number of menu that should reflect the state of this one
#define PM_InverseID		(TAG_USER+58)	// ID number of menu to inverse reflect the state of this one

//
// PM_AlterState "action" values
//

#define	PMACT_DESELECT		2	// Deselect the item
#define PMACT_SELECT		3	// Select the item

//
// Macros
//

#define PMMenu(t)	PM_MakeMenu(PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
			PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define PMSimpleSub	PM_Sub, PM_MakeMenu(PM_Dummy, 0
#define PMSubMenu(t)	PM_Sub, PM_MakeMenu(PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
			PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define PMItem(t)	PM_Item, PM_MakeItem(PM_Title, t
#define PMInfo(t)	PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE
#define PMBar		PM_Item, PM_MakeItem(PM_TitleBar, TRUE
#define PMTitleBar	PMBar
#define PMMenuTitle(t)	PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
			PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define PMExcl		PM_Exclude, PM_MakeIDList(
#define ExID(id)	PM_ExcludeID, id
#define InID(id)	PM_IncludeID, id
#define RefID(id)	PM_ReflectID, id
#define InvID(id)	PM_InverseID, id
#define PMCheckItem(t,id)	PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE

#define PMEnd		TAG_DONE)

#ifndef End
#define End		TAG_DONE)
#endif

#define PMERR		(-5L)

//
// Library base
//

struct PopupMenuBase {
	struct Library		pmb_Library;
	ULONG			pmb_SegList;
	ULONG			pmb_Flags;
	struct Library		*pmb_ExecBase;
	struct Library		*pmb_UtilityBase;
	struct Library		*pmb_IntuitionBase;
	struct Library		*pmb_GfxBase;
	struct Library		*pmb_DOSBase;
	BOOL			pmb_NewPrefs;
	struct Library		*pmb_CxBase;
};

#define POPUPMENU_VERSION	6L
#define POPUPMENU_NAME		"popupmenu.library"

//
// PopupMenu structure
//

#ifndef PMPRIV_H

struct PopupMenu {
	struct PopupMenu	*Next;
	struct PopupMenu	*Sub;
	STRPTR			Title;		// Title
	ULONG			Flags;
	ULONG			ID;		// Item ID
	APTR			UserData;	// UserData

	// The rest of the structure is private, at least for now!
};

#endif

//
// Obsolete stuff follows....
//

#ifndef PM_NEWNAMES	// The naming has changed from V2, this should provide
			// backwards compatibility. (disable with #define PM_NEWNAMES)
#define MakeItem	PM_MakeItem
#define MakeMenu	PM_MakeMenu
#define MakeItemA	PM_MakeItemA
#define MakeMenuA	PM_MakeMenuA
#define FreePopupMenu	PM_FreePopupMenu
#define OpenPopupMenu	PM_OpenPopupMenu
#define OpenPopupMenuA	PM_OpenPopupMenuA
#define MakeIDList	PM_MakeIDList
#define MakeIDListA	PM_MakeIDListA
#define ItemChecked	PM_ItemChecked
#endif

#define PM_SubMenuTimer		(TAG_USER+1)	// OBSOLETE!
#define PM_RecessSelected	(TAG_USER+2)	// OBSOLETE!
#define PM_WideSelectBar	(TAG_USER+3)	// OBSOLETE!
#define PM_Compact		(TAG_USER+5)	// OBSOLETE!
#define PM_OldLook		(TAG_USER+6)	// OBSOLETE!
#define PM_SameHeight		(TAG_USER+7)	// OBSOLETE!
#define PM_CheckMark		(TAG_USER+8)	// OBSOLETE!
#define PM_ExcludeMark		(TAG_USER+9)	// OBSOLETE!
#define PM_SubMenuMark		(TAG_USER+10)	// OBSOLETE!
#define PM_SmartRefresh		(TAG_USER+11)	// OBSOLETE!

#ifndef LIBRARIES_BGUI_H
#define Menu(t)		MakeMenu(PM_Item, MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
			PM_Item, MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define SubMenu(t)	PM_Sub, MakeMenu(PM_Item, MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
			PM_Item, MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define Item(t)		PM_Item, MakeItem(PM_Title, t
#define TitleBar	PM_Item, MakeItem(PM_WideTitleBar, TRUE
#define NarrowTitleBar	PM_Item, MakeItem(PM_TitleBar, TRUE
#define MenuTitle(t)	PM_Item, MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
			PM_Item, MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
#define Excl		PM_Exclude, MakeIDList(
#define ExID(id)	PM_ExcludeID, id
#define InID(id)	PM_IncludeID, id
#define RefID(id)	PM_ReflectID, id
#define InvID(id)	PM_InverseID, id
#define CheckItem(t,id)	PM_Item, MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE
#endif	/* LIBRARIES_BGUI_H */

#define PMNarrowBar		PM_Item, PM_MakeItem(PM_TitleBar, TRUE
#define PMNarrowTitleBar	PMNarrowBar

#endif
