//
//	$VER: pm.h 7.4 (11.1.98)
//
//	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)
#define PM_LocaleHook		(TAG_USER+93)	// Locale "GetString()" hook. (Not yet implemented)
#define PM_CenterScreen		(TAG_USER+94)	// Center menu on the screen
#define PM_UseLMB		(TAG_USER+95)	// Left mouse button should be used to select an item
						// (right button selects multiple items)
#define PM_SubConstruct		(TAG_USER+96)
#define PM_SubDestruct		(TAG_USER+97)

//
// 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_Object		(TAG_USER+43)	// BOOPSI object
#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_UserDataString	(TAG_USER+46)	// Allocates memory and copies the string.
#define PM_CommKey		(TAG_USER+47)	// Keyboard shortcut for this item.
#define PM_Shadowed		(TAG_USER+48)	// Gives the text a shadow
#define PM_LocaleTitle		(TAG_USER+49)	// Locale string ID (not yet implemented)
#define PM_ColourBox		(TAG_USER+60)	// Filled rectangle

//
// 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

//
// 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 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 PMSimpleSub	PM_Sub, PM_MakeMenu(PM_Dummy, 0
#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 PMNarrowBar	PM_Item, PM_MakeItem(PM_TitleBar, TRUE
#define PMNarrowTitleBar	PMNarrowBar
#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
//

#ifndef PM_NOBASE

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;
};

#endif

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

//
// PopupMenu structure
//
// WARNING!
// This structure may change in future versions.
// Do not rely on anything below "UserData".
//

#ifndef PMPRIV_H

struct PopupMenu {
	struct PopupMenu	*Next;
	struct PopupMenu	*Sub;
	STRPTR			Title;		// Title
	ULONG			Flags;
	ULONG			ID;		// Item ID
	APTR			UserData;	// UserData
	ULONG			TextPen;
	BOOL			*AutoSetPtr;
	struct PM_IDLst		*Exclude;
	LONG			Top;
	LONG			Height;
	struct Image		*SelImg;
	struct Image		*UnSelImg;
	struct Image		*SelIcon;
	struct Image		*UnSelIcon;
	UBYTE			CommKey;
};

#endif

#endif
