2 // $VER: pm.h 10.05 (11.11.00)
4 // Library base, tags and macro definitions
5 // for popupmenu.library.
7 // ©1996-2000 Henrik Isaksson
8 // All Rights Reserved.
12 // 9.00 New PopupMenu structure.
13 // Several new tags and updated macros.
14 // 9.01 Added PM_HintBox
15 // 10.0 Added PM_Toggle, PM_ExcludeShared
16 // Added macro PMMXItem
17 // Added two flags, PM_CHECKIT and PM_CHECKED
18 // 10.05 Changed the PopupMenu structure a bit.
19 // Added typedef for PopupMenu.
20 // Added american english equalients for some tags.
24 #ifndef LIBRARIES_POPUPMENU_H
25 #define LIBRARIES_POPUPMENU_H
28 #include <exec/types.h>
31 #ifndef EXEC_LIBRARIES_H
32 #include <exec/libraries.h>
35 #ifndef UTILITY_TAGITEM_H
36 #include <utility/tagitem.h>
39 #ifndef INTUITION_CLASSUSR_H
40 #include <intuition/classusr.h>
48 // Tags passed to PM_OpenPopupMenuA and PM_FilterIMsgA
51 #define PM_Menu (TAG_USER+4) /* (struct PopupMenu *) Pointer to menulist initialized by MakeMenu() */
52 #define PM_Top (TAG_USER+12) /* (LONG) Top (Y) position */
53 #define PM_Left (TAG_USER+13) /* (LONG) Left (X) position */
54 #define PM_Code (TAG_USER+14) /* (UWORD) Obsolete. */
55 #define PM_Right (TAG_USER+15) /* (LONG) X position relative to right edge */
56 #define PM_Bottom (TAG_USER+16) /* (LONG) Y position relative to bottom edge */
57 #define PM_MinWidth (TAG_USER+17) /* (LONG) Minimum width */
58 #define PM_MinHeight (TAG_USER+18) /* (LONG) Minimum height */
59 #define PM_ForceFont (TAG_USER+19) /* (struct TextFont *tf) Use this font instead of user preferences. */
60 #define PM_PullDown (TAG_USER+90) /* (BOOL) Turn the menu into a pulldown menu. */
61 #define PM_MenuHandler (TAG_USER+91) /* (struct Hook *) Hook that is called for each selected item, after the */
62 /* menu has been closed. This tag turns on MultiSelect. */
63 #define PM_AutoPullDown (TAG_USER+92) /* (BOOL) Automatic pulldown menu. (PM_FilterIMsg only) */
64 #define PM_LocaleHook (TAG_USER+93) /* (struct Hook *) Locale "GetString()" hook. (Not yet implemented) */
65 #define PM_CenterScreen (TAG_USER+94) /* (BOOL) Center menu on the screen */
66 #define PM_UseLMB (TAG_USER+95) /* (BOOL) Left mouse button should be used to select an item */
67 /* (right button selects multiple items) */
68 #define PM_DRIPensOnly (TAG_USER+96) /* (BOOL) Only use the screen's DRI pens, revert to system images if necessary. */
69 /* Use with care as it overrides the user's prefs! */
70 #define PM_HintBox (TAG_USER+97) /* (BOOL) Close the menu when the mouse is moved. */
71 #define PM_RawKey (TAG_USER+98) /* (BOOL) Let PM_FilterIMsgA parse IDCMP_RAWKEY instead of IDCMP_VANILLAKEY. */
74 // Tags passed to MakeItem
77 #define PM_Title (TAG_USER+20) /* (STRPTR) Item title */
78 #define PM_UserData (TAG_USER+21) /* (void *) Anything, returned by OpenPopupMenu when this item is selected */
79 #define PM_ID (TAG_USER+22) /* (ULONG) ID number, if you want an easy way to access this item later */
80 #define PM_CommKey (TAG_USER+47) /* (char) Keyboard shortcut for this item. */
81 #define PM_TitleID (TAG_USER+49) /* (ULONG) Locale string ID */
82 #define PM_Object (TAG_USER+43) /* (Object *) BOOPSI object with the abillity to render this item */
84 /* Submenu & Layout tags */
85 /* PM_Sub & PM_Members are mutally exclusive */
86 #define PM_Sub (TAG_USER+23) /* (PopupMenu *) Pointer to submenu list (from PM_MakeMenu) */
87 #define PM_Members (TAG_USER+65) /* (PopupMenu *) Members for this group (list created by PM_MakeMenu) */
88 #define PM_LayoutMode (TAG_USER+64) /* (ULONG) Layout method (PML_Horizontal / PML_Vertical) */
91 #define PM_FillPen (TAG_USER+26) /* (BOOL) Make the item appear in FILLPEN */
92 #define PM_Italic (TAG_USER+29) /* (BOOL) Italic text */
93 #define PM_Bold (TAG_USER+30) /* (BOOL) Bold text */
94 #define PM_Underlined (TAG_USER+31) /* (BOOL) Underlined text */
95 #define PM_ShadowPen (TAG_USER+34) /* (BOOL) Draw text in SHADOWPEN */
96 #define PM_ShinePen (TAG_USER+35) /* (BOOL) Draw text in SHINEPEN */
97 #define PM_Centre (TAG_USER+36) /* (BOOL) Center the text of this item */
98 #define PM_Center PM_Centre /* American version... */
99 #define PM_TextPen (TAG_USER+45) /* (ULONG) Pen number for text colour of this item */
100 #define PM_Shadowed (TAG_USER+48) /* (BOOL) Draw a shadow behind the text */
102 /* Other item attributes */
103 #define PM_TitleBar (TAG_USER+32) /* (BOOL) Horizontal separator bar */
104 #define PM_WideTitleBar (TAG_USER+33) /* (BOOL) Same as above, but full width */
105 #define PM_NoSelect (TAG_USER+25) /* (BOOL) Make the item unselectable (without visual indication) */
106 #define PM_Disabled (TAG_USER+38) /* (BOOL) Disable an item */
107 #define PM_Hidden (TAG_USER+63) /* (BOOL) This item is not to be drawn (nor used in the layout process) */
110 #define PM_ImageSelected (TAG_USER+39) /* (struct Image *) Image when selected, title will be rendered on top it */
111 #define PM_ImageUnselected (TAG_USER+40) /* (struct Image *) Image when unselected */
112 #define PM_IconSelected (TAG_USER+41) /* (struct Image *) Icon when selected */
113 #define PM_IconUnselected (TAG_USER+42) /* (struct Image *) Icon when unselected */
116 #define PM_Checkit (TAG_USER+27) /* (BOOL) Leave space for a checkmark */
117 #define PM_Checked (TAG_USER+28) /* (BOOL) Make this item is checked */
118 #define PM_AutoStore (TAG_USER+44) /* (BOOL *) Pointer to BOOL reflecting the current state of the item */
119 #define PM_Exclude (TAG_USER+37) /* (PM_IDLst *) Items to unselect or select when this gets selected */
120 #define PM_ExcludeShared (TAG_USER+101) /* (BOOL) Used if the list is shared between two or more items */
121 #define PM_Toggle (TAG_USER+100) /* (BOOL) Enable/disable toggling of check/mx items. Default: TRUE */
123 /* Dynamic construction/destruction */
124 #define PM_SubConstruct (TAG_USER+61) /* (struct Hook *) Constructor hook for submenus. Called before menu is opened. */
125 #define PM_SubDestruct (TAG_USER+62) /* (struct Hook *) Destructor hook for submenus. Called after menu has closed. */
127 /* Special/misc. stuff */
128 #define PM_UserDataString (TAG_USER+46) /* (STRPTR) Allocates memory and copies the string to UserData. */
129 #define PM_Flags (TAG_USER+24) /* (UlONG) For internal use */
130 #define PM_ColourBox (TAG_USER+60) /* (UlONG) Filled rectangle (for palettes etc.) */
131 #define PM_ColorBox PM_ColourBox /* For Americans... */
133 // Tags passed to MakeMenu
136 #define PM_Item (TAG_USER+50) /* (PopupMenu *) Item pointer from MakeItem */
137 #define PM_Dummy (TAG_USER+51) /* (void) Ignored. */
140 // Tags passed to MakeIDList
143 #define PM_ExcludeID (TAG_USER+55) /* (ULONG) ID number of menu to deselect when this gets selected */
144 #define PM_IncludeID (TAG_USER+56) /* (ULONG) ID number of menu to select when this gets selected */
145 #define PM_ReflectID (TAG_USER+57) /* (ULONG) ID number of menu that should reflect the state of this one */
146 #define PM_InverseID (TAG_USER+58) /* (ULONG) ID number of menu to inverse reflect the state of this one */
149 // Tags for PM_InsertMenuItemA()
152 #define PM_Insert_Before (TAG_USER+200) /* (BOOL) Insert before the item pointed to by the following argument (N/A) */
153 #define PM_Insert_BeforeID (TAG_USER+201) /* (ULONG) Insert before the first item with ID equal to the argument */
154 #define PM_Insert_After (TAG_USER+202) /* (PopupMenu *) Insert after the item pointed to by the following argument */
155 #define PM_Insert_AfterID (TAG_USER+203) /* (ULONG) Insert after the first item with ID equal to the argument */
156 #define PM_Insert_Last (TAG_USER+205) /* (BOOL) Insert after the last item */
157 #define PM_Insert_First (TAG_USER+209) /* (BOOL) Insert after the first item (which is usually invisible) */
158 #define PM_InsertSub_First (TAG_USER+206) /* (PopupMenu *) Insert before the first item in the submenu */
159 #define PM_InsertSub_Last (TAG_USER+207) /* (PopupMenu *) Insert at the and of a submenu */
160 #define PM_InsertSub_Sorted (TAG_USER+208) /* (PopupMenu *) (N/A) */
161 #define PM_Insert_Item (TAG_USER+210) /* (PopupMenu *) Item to insert, may be repeated for several items */
167 #define PML_None 0 /* Normal item */
168 #define PML_Horizontal 1 /* Horizontal group */
169 #define PML_Vertical 2 /* Vertical group */
170 #define PML_Table 3 /* Table group */
171 #define PML_Default 255 /* Don't use */
177 #define PMMenu(t) PM_MakeMenu(\
178 PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
179 PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
180 PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
181 #define PMMenuID(t) PM_MakeMenu(\
182 PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
183 PM_Item, PM_MakeItem(PM_TitleID, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
184 PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
185 #define PMSubMenu(t) PM_Sub, PM_MakeMenu(PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
186 PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
187 #define PMSimpleSub PM_Sub, PM_MakeMenu(PM_Dummy, 0
188 #define PMItem(t) PM_Item, PM_MakeItem(PM_Title, t
189 #define PMItemID(t) PM_Item, PM_MakeItem(PM_TitleID, t
190 #define PMInfo(t) PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE
191 #define PMColBox(c) PM_Item, PM_MakeItem(PM_ColourBox, c
192 #define PMBar PM_Item, PM_MakeItem(PM_TitleBar, TRUE
193 #define PMMenuTitle(t) PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
194 PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
195 #define PMHoriz PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Horizontal
196 #define PMVert PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Vertical
197 #define PMMembers PM_Members, PM_MakeMenu(PM_Dummy, 0
199 #define PMExcl PM_Exclude, PM_MakeIDList(
200 #define ExID(id) PM_ExcludeID, id
201 #define InID(id) PM_IncludeID, id
202 #define RefID(id) PM_ReflectID, id
203 #define InvID(id) PM_InverseID, id
205 #define PMCheckItem(t,id) PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE
207 #define PMMXItem(t,id) PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE, PM_Toggle, FALSE
209 #define PMEnd TAG_DONE)
212 #define End TAG_DONE)
217 /* For compatibility with old sources - DO NOT USE */
218 #define PMTitleBar PMBar
219 #define PMNarrowBar PMBar
220 #define PMNarrowTitleBar PMBar
228 struct PopupMenuBase
{
229 struct Library pmb_Library
;
232 struct Library
*pmb_ExecBase
; /* These library */
233 struct Library
*pmb_UtilityBase
; /* pointers are */
234 struct Library
*pmb_IntuitionBase
; /* valid as long */
235 struct Library
*pmb_GfxBase
; /* as pm lib */
236 struct Library
*pmb_DOSBase
; /* is open. */
237 BOOL pmb_NewPrefs
; /* Reload prefs. */
238 struct Library
*pmb_CxBase
; /* commodities. */
239 struct Library
*pmb_LayersBase
; /* layers.library */
240 struct Library
*pmb_CyberGfxBase
; /* cybergfx.lib */
245 #define POPUPMENU_VERSION 10L
246 #define POPUPMENU_NAME "popupmenu.library"
247 #define OPEN_PM_LIB (PopupMenuBase=(struct PopupMenuBase *)\
248 OpenLibrary(POPUPMENU_NAME, POPUPMENU_VERSION))
249 #define CLOSE_PM_LIB if(PopupMenuBase) CloseLibrary((struct Library *)PopupMenuBase);
252 // PopupMenu structure
255 // This structure may change in future versions.
256 // Do not read or write fields directly, use PM_Set/GetPopupMenuAttrs()
260 struct PopupMenu
*Next
; /* Next item in menu */
262 struct PopupMenu
*Sub
; /* Sub menu pointer */
263 struct PopupMenu
*Group
; /* Group members */
267 STRPTR Title
; /* Title */
268 ULONG TitleID
; /* Locale string ID */
269 Object
*Boopsi
; /* Boopsi object */
272 ULONG Flags
; /* Flags */
273 ULONG ID
; /* Item ID */
274 APTR UserData
; /* UserData */
276 WORD Left
; /* Left pos of this item */
277 WORD Top
; /* Top pos of this item */
278 UWORD Width
; /* Width of this item */
279 UWORD Height
; /* Height of this item */
281 /* Very private and undocumented stuff follows. */
282 /* Mess with it at your own risk. */
284 UWORD ExtFlags
; /* Extended flags */
286 UBYTE Layout
; /* Layout mode */
287 UBYTE CBox
; /* ColourBox pen */
289 struct PM_IDLst
*Exclude
; /* Exclude/Included/Reflected items */
290 BOOL
*AutoSetPtr
;/* Ptr to BOOL containing current state */
293 struct Image
*Images
[2]; /* Images/Icons (0 - unselected, 1 - sel) */
297 UBYTE CommKey
; /* Command Key */
298 UBYTE Weight
; /* Weight */
299 struct Hook
*SubConstruct
; /* SubMenu Constructor hook */
300 struct Hook
*SubDestruct
; /* SubMenu Destructor hook */
301 UBYTE TextPen
; /* Pen number for item's text */
307 typedef struct PopupMenu PopupMenu
;
309 /* Public flags for the PopupMenu->Header.Flags field */
311 #define PM_CHECKIT 0x40000000
312 #define PM_CHECKED 0x80000000