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