home *** CD-ROM | disk | FTP | other *** search
/ back2roots/filegate / filegate.zip / filegate / ads / adsutils / PMDEV.LHA / PopupMenuDeveloper / C / include / libraries / pm.h
Encoding:
C/C++ Source or Header  |  2001-01-11  |  13.1 KB  |  308 lines

  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:
  11. //
  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.
  21. //
  22. */
  23.  
  24. #ifndef LIBRARIES_POPUPMENU_H
  25. #define LIBRARIES_POPUPMENU_H
  26.  
  27. #ifndef EXEC_TYPES_H
  28. #include <exec/types.h>
  29. #endif
  30.  
  31. #ifndef EXEC_LIBRARIES_H
  32. #include <exec/libraries.h>
  33. #endif
  34.  
  35. #ifndef UTILITY_TAGITEM_H
  36. #include <utility/tagitem.h>
  37. #endif
  38.  
  39. #ifndef INTUITION_CLASSUSR_H
  40. #include <intuition/classusr.h>
  41. #endif
  42.  
  43. /*
  44. // Tags passed to PM_OpenPopupMenuA and PM_FilterIMsgA
  45. */
  46.  
  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.  
  68. /*
  69. // Tags passed to MakeItem
  70. */
  71.  
  72. #define PM_Title        (TAG_USER+20)    /* (STRPTR) Item title                                */
  73. #define PM_UserData        (TAG_USER+21)    /* (void *) Anything, returned by OpenPopupMenu when this item is selected    */
  74. #define PM_ID            (TAG_USER+22)    /* (ULONG) ID number, if you want an easy way to access this item later        */
  75. #define PM_CommKey        (TAG_USER+47)    /* (char) Keyboard shortcut for this item.                    */
  76. #define PM_TitleID        (TAG_USER+49)    /* (ULONG) Locale string ID                             */
  77. #define PM_Object        (TAG_USER+43)    /* (Object *) BOOPSI object with the abillity to render this item        */
  78.  
  79. /* Submenu & Layout tags */
  80. /* PM_Sub & PM_Members are mutally exclusive */
  81. #define PM_Sub            (TAG_USER+23)    /* (PopupMenu *) Pointer to submenu list (from PM_MakeMenu)            */
  82. #define PM_Members        (TAG_USER+65)    /* (PopupMenu *) Members for this group (list created by PM_MakeMenu)        */
  83. #define PM_LayoutMode        (TAG_USER+64)    /* (ULONG) Layout method (PML_Horizontal / PML_Vertical)            */
  84.  
  85. /* Text attributes */
  86. #define PM_FillPen        (TAG_USER+26)    /* (BOOL) Make the item appear in FILLPEN                    */
  87. #define PM_Italic        (TAG_USER+29)    /* (BOOL) Italic text                                */
  88. #define PM_Bold            (TAG_USER+30)    /* (BOOL) Bold text                                */
  89. #define PM_Underlined        (TAG_USER+31)    /* (BOOL) Underlined text                            */
  90. #define PM_ShadowPen        (TAG_USER+34)    /* (BOOL) Draw text in SHADOWPEN                        */
  91. #define PM_ShinePen        (TAG_USER+35)    /* (BOOL) Draw text in SHINEPEN                            */
  92. #define PM_Centre        (TAG_USER+36)    /* (BOOL) Center the text of this item                        */
  93. #define PM_Center        PM_Centre    /* American version... */
  94. #define PM_TextPen        (TAG_USER+45)    /* (ULONG) Pen number for text colour of this item                */
  95. #define PM_Shadowed        (TAG_USER+48)    /* (BOOL) Draw a shadow behind the text                        */
  96.  
  97. /* Other item attributes */
  98. #define PM_TitleBar        (TAG_USER+32)    /* (BOOL) Horizontal separator bar                        */
  99. #define PM_WideTitleBar        (TAG_USER+33)    /* (BOOL) Same as above, but full width                        */
  100. #define PM_NoSelect        (TAG_USER+25)    /* (BOOL) Make the item unselectable (without visual indication)        */
  101. #define PM_Disabled        (TAG_USER+38)    /* (BOOL) Disable an item                            */
  102. #define PM_Hidden        (TAG_USER+63)    /* (BOOL) This item is not to be drawn (nor used in the layout process)        */
  103.  
  104. /* Images & Icons */
  105. #define PM_ImageSelected    (TAG_USER+39)    /* (struct Image *) Image when selected, title will be rendered on top it    */
  106. #define PM_ImageUnselected    (TAG_USER+40)    /* (struct Image *) Image when unselected                    */
  107. #define PM_IconSelected        (TAG_USER+41)    /* (struct Image *) Icon when selected                        */
  108. #define PM_IconUnselected    (TAG_USER+42)    /* (struct Image *) Icon when unselected                    */
  109.  
  110. /* Check/MX items */
  111. #define PM_Checkit        (TAG_USER+27)    /* (BOOL) Leave space for a checkmark                        */
  112. #define PM_Checked        (TAG_USER+28)    /* (BOOL) Make this item is checked                        */
  113. #define PM_AutoStore        (TAG_USER+44)    /* (BOOL *) Pointer to BOOL reflecting the current state of the item        */
  114. #define PM_Exclude        (TAG_USER+37)    /* (PM_IDLst *) Items to unselect or select when this gets selected        */
  115. #define PM_ExcludeShared    (TAG_USER+101)    /* (BOOL) Used if the list is shared between two or more items            */
  116. #define PM_Toggle        (TAG_USER+100)    /* (BOOL) Enable/disable toggling of check/mx items. Default: TRUE        */
  117.  
  118. /* Dynamic construction/destruction */
  119. #define PM_SubConstruct        (TAG_USER+61)    /* (struct Hook *) Constructor hook for submenus. Called before menu is opened.    */
  120. #define PM_SubDestruct        (TAG_USER+62)    /* (struct Hook *) Destructor hook for submenus. Called after menu has closed.    */
  121.  
  122. /* Special/misc. stuff */
  123. #define PM_UserDataString    (TAG_USER+46)    /* (STRPTR) Allocates memory and copies the string to UserData.            */
  124. #define PM_Flags        (TAG_USER+24)    /* (UlONG) For internal use                            */
  125. #define PM_ColourBox        (TAG_USER+60)    /* (UlONG) Filled rectangle (for palettes etc.)                    */
  126. #define PM_ColorBox        PM_ColourBox    /* For Americans... */
  127. /*
  128. // Tags passed to MakeMenu
  129. */
  130.  
  131. #define PM_Item            (TAG_USER+50)    /* (PopupMenu *) Item pointer from MakeItem                    */
  132. #define PM_Dummy        (TAG_USER+51)    /* (void) Ignored.                                */
  133.  
  134. /*
  135. // Tags passed to MakeIDList
  136. */
  137.  
  138. #define PM_ExcludeID        (TAG_USER+55)    /* (ULONG) ID number of menu to deselect when this gets selected        */
  139. #define PM_IncludeID        (TAG_USER+56)    /* (ULONG) ID number of menu to select when this gets selected            */
  140. #define PM_ReflectID        (TAG_USER+57)    /* (ULONG) ID number of menu that should reflect the state of this one        */
  141. #define PM_InverseID        (TAG_USER+58)    /* (ULONG) ID number of menu to inverse reflect the state of this one        */
  142.  
  143. /*
  144. // Tags for PM_InsertMenuItemA()
  145. */
  146.  
  147. #define PM_Insert_Before    (TAG_USER+200)    /* (BOOL) Insert before the item pointed to by the following argument    (N/A)    */
  148. #define PM_Insert_BeforeID    (TAG_USER+201)    /* (ULONG) Insert before the first item with ID equal to the argument        */
  149. #define PM_Insert_After        (TAG_USER+202)    /* (PopupMenu *) Insert after the item pointed to by the following argument    */
  150. #define PM_Insert_AfterID    (TAG_USER+203)    /* (ULONG) Insert after the first item with ID equal to the argument        */
  151. #define PM_Insert_Last        (TAG_USER+205)    /* (BOOL) Insert after the last item                        */
  152. #define PM_Insert_First        (TAG_USER+209)    /* (BOOL) Insert after the first item (which is usually invisible)        */
  153. #define PM_InsertSub_First    (TAG_USER+206)    /* (PopupMenu *) Insert before the first item in the submenu            */ 
  154. #define PM_InsertSub_Last    (TAG_USER+207)    /* (PopupMenu *) Insert at the and of a submenu                    */
  155. #define PM_InsertSub_Sorted    (TAG_USER+208)    /* (PopupMenu *)                             (N/A)    */
  156. #define PM_Insert_Item        (TAG_USER+210)    /* (PopupMenu *) Item to insert, may be repeated for several items        */
  157.  
  158. /*
  159. // Layout methods
  160. */
  161.  
  162. #define PML_None        0        /* Normal item        */
  163. #define PML_Horizontal        1        /* Horizontal group    */
  164. #define PML_Vertical        2        /* Vertical group    */
  165. #define PML_Table        3        /* Table group        */
  166. #define PML_Default        255        /* Don't use        */
  167.  
  168. /*
  169. // Macros
  170. */
  171.  
  172. #define PMMenu(t)    PM_MakeMenu(\
  173.             PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
  174.             PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  175.             PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  176. #define PMMenuID(t)    PM_MakeMenu(\
  177.             PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
  178.             PM_Item, PM_MakeItem(PM_TitleID, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  179.             PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  180. #define PMSubMenu(t)    PM_Sub, PM_MakeMenu(PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
  181.             PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  182. #define PMSimpleSub    PM_Sub, PM_MakeMenu(PM_Dummy, 0
  183. #define PMItem(t)    PM_Item, PM_MakeItem(PM_Title, t
  184. #define PMItemID(t)    PM_Item, PM_MakeItem(PM_TitleID, t
  185. #define PMInfo(t)    PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE
  186. #define PMColBox(c)    PM_Item, PM_MakeItem(PM_ColourBox, c
  187. #define PMBar        PM_Item, PM_MakeItem(PM_TitleBar, TRUE
  188. #define PMMenuTitle(t)    PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  189.             PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  190. #define PMHoriz        PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Horizontal
  191. #define PMVert        PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Vertical
  192. #define PMMembers    PM_Members, PM_MakeMenu(PM_Dummy, 0
  193.  
  194. #define PMExcl        PM_Exclude, PM_MakeIDList(
  195. #define ExID(id)    PM_ExcludeID, id
  196. #define InID(id)    PM_IncludeID, id
  197. #define RefID(id)    PM_ReflectID, id
  198. #define InvID(id)    PM_InverseID, id
  199.  
  200. #define PMCheckItem(t,id)    PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE
  201.  
  202. #define PMMXItem(t,id)    PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE, PM_Toggle, FALSE
  203.  
  204. #define PMEnd        TAG_DONE)
  205.  
  206. #ifndef End
  207. #define End        TAG_DONE)
  208. #endif
  209.  
  210. #define PMERR        (-5L)
  211.  
  212. /* For compatibility with old sources - DO NOT USE */
  213. #define PMTitleBar    PMBar
  214. #define PMNarrowBar    PMBar
  215. #define PMNarrowTitleBar PMBar
  216.  
  217. /*
  218. // Library base
  219. */
  220.  
  221. #ifndef PM_NOBASE
  222.  
  223. struct PopupMenuBase {
  224.     struct Library        pmb_Library;
  225.     ULONG            pmb_SegList;
  226.     ULONG            pmb_Flags;
  227.     struct Library        *pmb_ExecBase;        /* Theese library */
  228.     struct Library        *pmb_UtilityBase;    /* pointers are   */
  229.     struct Library        *pmb_IntuitionBase;    /* valid as long  */
  230.     struct Library        *pmb_GfxBase;        /* as pm lib      */
  231.     struct Library        *pmb_DOSBase;        /* is open.       */
  232.     BOOL            pmb_NewPrefs;        /* Reload prefs.  */
  233.     struct Library        *pmb_CxBase;        /* commodities.   */
  234.     struct Library        *pmb_LayersBase;    /* layers.library */
  235.     struct Library        *pmb_CyberGfxBase;    /* cybergfx.lib   */
  236. };
  237.  
  238. #endif
  239.  
  240. #define POPUPMENU_VERSION    10L
  241. #define POPUPMENU_NAME        "popupmenu.library"
  242. #define OPEN_PM_LIB            (PopupMenuBase=(struct PopupMenuBase *)\
  243.                             OpenLibrary(POPUPMENU_NAME, POPUPMENU_VERSION))
  244. #define CLOSE_PM_LIB        if(PopupMenuBase) CloseLibrary((struct Library *)PopupMenuBase);
  245.  
  246. /*
  247. // PopupMenu structure
  248. //
  249. // Note:
  250. // This structure may change in future versions.
  251. // Do not read or write fields directly, use PM_Set/GetPopupMenuAttrs()
  252. */
  253.  
  254. struct PopupMenu {
  255.     struct PopupMenu        *Next;        /* Next item in menu */
  256.     union {
  257.         struct PopupMenu    *Sub;        /* Sub menu pointer */
  258.         struct PopupMenu    *Group;        /* Group members */
  259.     };
  260.  
  261.     union {
  262.         STRPTR              Title;      /* Title */
  263.         ULONG               TitleID;    /* Locale string ID */
  264.         Object              *Boopsi;    /* Boopsi object */
  265.     };
  266.  
  267.     ULONG                   Flags;        /* Flags */
  268.     ULONG                   ID;         /* Item ID */
  269.     APTR                    UserData;   /* UserData */
  270.     
  271.     WORD                    Left;       /* Left pos of this item */
  272.     WORD                    Top;        /* Top pos of this item */
  273.     UWORD                   Width;      /* Width of this item */
  274.     UWORD                   Height;     /* Height of this item */
  275.  
  276.     /* Very private and undocumented stuff follows. */
  277.     /* Mess with it at your own risk. */
  278.  
  279.     UWORD                   ExtFlags;     /* Extended flags */
  280.  
  281.     UBYTE                   Layout;        /* Layout mode */
  282.     UBYTE                   CBox;       /* ColourBox pen */
  283.  
  284.     struct PM_IDLst         *Exclude;   /* Exclude/Included/Reflected items */
  285.     BOOL                    *AutoSetPtr;/* Ptr to BOOL containing current state */
  286.  
  287.     union {
  288.         struct Image           *Images[2]; /* Images/Icons (0 - unselected, 1 - sel) */
  289.         STRPTR                IconID;
  290.     };
  291.  
  292.     UBYTE                   CommKey;    /* Command Key */
  293.     UBYTE                      Weight;     /* Weight */
  294.     struct Hook             *SubConstruct;  /* SubMenu Constructor hook */
  295.     struct Hook             *SubDestruct;   /* SubMenu Destructor hook */
  296.     UBYTE                   TextPen;    /* Pen number for item's text */
  297.     UBYTE                   Pad;
  298. };
  299.  
  300. typedef struct PopupMenu PopupMenu;
  301.  
  302. /* Public flags for the PopupMenu->Header.Flags field */
  303.  
  304. #define PM_CHECKIT             0x40000000
  305. #define PM_CHECKED             0x80000000
  306.  
  307. #endif
  308.