Menus.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:58k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Menus.h
  3.  
  4.      Contains:   Menu Manager Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 9.0
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MENUS__
  18. #define __MENUS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __EVENTS__
  23. #include "Events.h"
  24. #endif
  25. #ifndef __QUICKDRAW__
  26. #include "Quickdraw.h"
  27. #endif
  28. #ifndef __FONTS__
  29. #include "Fonts.h"
  30. #endif
  31. #ifndef __TEXTCOMMON__
  32. #include "TextCommon.h"
  33. #endif
  34. #ifndef __PROCESSES__
  35. #include "Processes.h"
  36. #endif
  37. #ifndef __APPLEEVENTS__
  38. #include "AppleEvents.h"
  39. #endif
  40. #ifndef __COLLECTIONS__
  41. #include "Collections.h"
  42. #endif
  43. #ifndef __MACERRORS__
  44. #include "MacErrors.h"
  45. #endif
  46. #if PRAGMA_ONCE
  47. #pragma once
  48. #endif
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #if PRAGMA_IMPORT
  53. #pragma import on
  54. #endif
  55. #if PRAGMA_STRUCT_ALIGN
  56.     #pragma options align=mac68k
  57. #elif PRAGMA_STRUCT_PACKPUSH
  58.     #pragma pack(push, 2)
  59. #elif PRAGMA_STRUCT_PACK
  60.     #pragma pack(2)
  61. #endif
  62. /*--------------------------------------------------------------------------------------*/
  63. /*  o Menu Constants                                                                    */
  64. /*--------------------------------------------------------------------------------------*/
  65. enum {
  66.     noMark                      = 0                             /*mark symbol for MarkItem*/
  67. };
  68. enum {
  69.                                                                 /* menu defProc messages */
  70.     kMenuDrawMsg                = 0,
  71.     kMenuSizeMsg                = 2,
  72.     kMenuPopUpMsg               = 3,
  73.     kMenuCalcItemMsg            = 5,
  74.     kMenuThemeSavvyMsg          = 7,                            /* is your MDEF theme-savvy?  If so, return hex 7473 in the whichItem parameter*/
  75.     mDrawMsg                    = 0,
  76.     mSizeMsg                    = 2,
  77.     mPopUpMsg                   = 3,                            /* position the popup menu rect appropriately */
  78.     mCalcItemMsg                = 5
  79. };
  80. #if CALL_NOT_IN_CARBON
  81. /*
  82.    Carbon MDEFs must replace mChooseMsg with the new messages kMenuFindItemMsg and kMenuHiliteItemMsg. 
  83.    mDrawItemMsg was used by the popup menu control before 8.5, but is no longer used. 
  84. */
  85. enum {
  86.     mChooseMsg                  = 1,
  87.     mDrawItemMsg                = 4,
  88.     kMenuChooseMsg              = 1,
  89.     kMenuDrawItemMsg            = 4
  90. };
  91. #endif  /* CALL_NOT_IN_CARBON */
  92. enum {
  93.     kThemeSavvyMenuResponse     = 0x7473
  94. };
  95. /* these MDEF messages are only supported in Carbon*/
  96. enum {
  97.     kMenuInitMsg                = 8,
  98.     kMenuDisposeMsg             = 9,
  99.     kMenuFindItemMsg            = 10,
  100.     kMenuHiliteItemMsg          = 11
  101. };
  102. enum {
  103.     textMenuProc                = 0,
  104.     hMenuCmd                    = 27,                           /*itemCmd == 0x001B ==> hierarchical menu*/
  105.     hierMenu                    = -1,                           /*a hierarchical menu - for InsertMenu call*/
  106.     kInsertHierarchicalMenu     = -1,                           /*a better name for hierMenu */
  107.     mctAllItems                 = -98,                          /*search for all Items for the given ID*/
  108.     mctLastIDIndic              = -99                           /*last color table entry has this in ID field*/
  109. };
  110. /* Constants for use with MacOS 8.0 (Appearance 1.0) and later*/
  111. enum {
  112.     kMenuStdMenuProc            = 63,
  113.     kMenuStdMenuBarProc         = 63
  114. };
  115. enum {
  116.     kMenuNoModifiers            = 0,                            /* Mask for no modifiers*/
  117.     kMenuShiftModifier          = (1 << 0),                     /* Mask for shift key modifier*/
  118.     kMenuOptionModifier         = (1 << 1),                     /* Mask for option key modifier*/
  119.     kMenuControlModifier        = (1 << 2),                     /* Mask for control key modifier*/
  120.     kMenuNoCommandModifier      = (1 << 3)                      /* Mask for no command key modifier*/
  121. };
  122. enum {
  123.     kMenuNoIcon                 = 0,                            /* No icon*/
  124.     kMenuIconType               = 1,                            /* Type for ICON*/
  125.     kMenuShrinkIconType         = 2,                            /* Type for ICON plotted 16 x 16*/
  126.     kMenuSmallIconType          = 3,                            /* Type for SICN*/
  127.     kMenuColorIconType          = 4,                            /* Type for cicn*/
  128.     kMenuIconSuiteType          = 5,                            /* Type for Icon Suite*/
  129.     kMenuIconRefType            = 6                             /* Type for Icon Ref*/
  130. };
  131. enum {
  132.     kMenuAttrExcludesMarkColumn = (1 << 0),                     /* No space is allocated for the mark character */
  133.     kMenuAttrAutoDisable        = (1 << 2)                      /* Menu title is automatically disabled when all items are disabled */
  134. };
  135. typedef OptionBits                      MenuAttributes;
  136. enum {
  137.     kMenuItemAttrSubmenuParentChoosable = (1 << 2)              /* Parent item of a submenu is still selectable by the user */
  138. };
  139. typedef OptionBits                      MenuItemAttributes;
  140. typedef UInt32 MenuTrackingMode;
  141. enum {
  142.     kMenuTrackingModeMouse      = 1,                            /* Menus are being tracked using the mouse*/
  143.     kMenuTrackingModeKeyboard   = 2                             /* Menus are being tracked using the keyboard*/
  144. };
  145. /*--------------------------------------------------------------------------------------*/
  146. /*  o Menu Types                                                                        */
  147. /*--------------------------------------------------------------------------------------*/
  148. typedef SInt16                          MenuID;
  149. typedef UInt16                          MenuItemIndex;
  150. typedef UInt32                          MenuCommand;
  151. #if !OPAQUE_TOOLBOX_STRUCTS
  152. struct MenuInfo {
  153.     MenuID                          menuID;
  154.     short                           menuWidth;
  155.     short                           menuHeight;
  156.     Handle                          menuProc;
  157.     long                            enableFlags;
  158.     Str255                          menuData;
  159. };
  160. typedef struct MenuInfo                 MenuInfo;
  161. typedef MenuInfo *                      MenuPtr;
  162. typedef MenuPtr *                       MenuHandle;
  163. #else
  164. typedef struct OpaqueMenuHandle*        MenuHandle;
  165. #endif  /* !OPAQUE_TOOLBOX_STRUCTS */
  166. /* MenuRef and MenuHandle are equivalent. Use either. We don't care.*/
  167. typedef MenuHandle                      MenuRef;
  168. struct MCEntry {
  169.     MenuID                          mctID;                      /*menu ID.  ID = 0 is the menu bar*/
  170.     short                           mctItem;                    /*menu Item. Item = 0 is a title*/
  171.     RGBColor                        mctRGB1;                    /*usage depends on ID and Item*/
  172.     RGBColor                        mctRGB2;                    /*usage depends on ID and Item*/
  173.     RGBColor                        mctRGB3;                    /*usage depends on ID and Item*/
  174.     RGBColor                        mctRGB4;                    /*usage depends on ID and Item*/
  175.     short                           mctReserved;                /*reserved for internal use*/
  176. };
  177. typedef struct MCEntry                  MCEntry;
  178. typedef MCEntry *                       MCEntryPtr;
  179. typedef MCEntry                         MCTable[1];
  180. typedef MCEntry *                       MCTablePtr;
  181. typedef MCTablePtr *                    MCTableHandle;
  182. struct MenuCRsrc {
  183.     short                           numEntries;                 /*number of entries*/
  184.     MCTable                         mcEntryRecs;                /*ARRAY [1..numEntries] of MCEntry*/
  185. };
  186. typedef struct MenuCRsrc                MenuCRsrc;
  187. typedef MenuCRsrc *                     MenuCRsrcPtr;
  188. typedef MenuCRsrcPtr *                  MenuCRsrcHandle;
  189. #if TARGET_OS_WIN32
  190. /* QuickTime 3.0 */
  191. struct MenuAccessKeyRec {
  192.     short                           count;
  193.     long                            flags;
  194.     unsigned char                   keys[1];
  195. };
  196. typedef struct MenuAccessKeyRec         MenuAccessKeyRec;
  197. typedef MenuAccessKeyRec *              MenuAccessKeyPtr;
  198. typedef MenuAccessKeyPtr *              MenuAccessKeyHandle;
  199. #if CALL_NOT_IN_CARBON
  200. EXTERN_API_C( void )
  201. SetMenuItemHotKey               (MenuRef                menu,
  202.                                  short                  itemID,
  203.                                  char                   hotKey,
  204.                                  long                   flags);
  205. #endif  /* CALL_NOT_IN_CARBON */
  206. #endif  /* TARGET_OS_WIN32 */
  207. struct MenuTrackingData {
  208.     MenuRef                         menu;
  209.     MenuItemIndex                   itemSelected;
  210.     MenuItemIndex                   itemUnderMouse;
  211.     Rect                            itemRect;
  212.     SInt32                          virtualMenuTop;
  213.     SInt32                          virtualMenuBottom;
  214. };
  215. typedef struct MenuTrackingData         MenuTrackingData;
  216. typedef MenuTrackingData *              MenuTrackingDataPtr;
  217. struct HiliteMenuItemData {
  218.     MenuItemIndex                   previousItem;
  219.     MenuItemIndex                   newItem;
  220. };
  221. typedef struct HiliteMenuItemData       HiliteMenuItemData;
  222. typedef HiliteMenuItemData *            HiliteMenuItemDataPtr;
  223. /*--------------------------------------------------------------------------------------*/
  224. /*  o Menu ProcPtrs                                                                     */
  225. /*                                                                                      */
  226. /*  All of these procs are considered deprecated.  Developers interested in portability */
  227. /*  to Carbon should avoid them entirely, if at all possible.                           */
  228. /*--------------------------------------------------------------------------------------*/
  229. typedef CALLBACK_API( void , MenuDefProcPtr )(short message, MenuRef theMenu, Rect *menuRect, Point hitPt, short *whichItem);
  230. typedef STACK_UPP_TYPE(MenuDefProcPtr)                          MenuDefUPP;
  231. #if OPAQUE_UPP_TYPES
  232.     EXTERN_API(MenuDefUPP)
  233.     NewMenuDefUPP                  (MenuDefProcPtr          userRoutine);
  234.     EXTERN_API(void)
  235.     DisposeMenuDefUPP              (MenuDefUPP              userUPP);
  236.     EXTERN_API(void)
  237.     InvokeMenuDefUPP               (short                   message,
  238.                                     MenuRef                 theMenu,
  239.                                     Rect *                  menuRect,
  240.                                     Point                   hitPt,
  241.                                     short *                 whichItem,
  242.                                     MenuDefUPP              userUPP);
  243. #else
  244.     enum { uppMenuDefProcInfo = 0x0000FF80 };                       /* pascal no_return_value Func(2_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  245.     #define NewMenuDefUPP(userRoutine)                              (MenuDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuDefProcInfo, GetCurrentArchitecture())
  246.     #define DisposeMenuDefUPP(userUPP)                              DisposeRoutineDescriptor(userUPP)
  247.     #define InvokeMenuDefUPP(message, theMenu, menuRect, hitPt, whichItem, userUPP)  CALL_FIVE_PARAMETER_UPP((userUPP), uppMenuDefProcInfo, (message), (theMenu), (menuRect), (hitPt), (whichItem))
  248. #endif
  249. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  250. #define NewMenuDefProc(userRoutine)                             NewMenuDefUPP(userRoutine)
  251. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem) InvokeMenuDefUPP(message, theMenu, menuRect, hitPt, whichItem, userRoutine)
  252. typedef CALLBACK_API( long , MenuBarDefProcPtr )(short selector, short message, short parameter1, long parameter2);
  253. typedef CALLBACK_API( void , MenuHookProcPtr )(void );
  254. typedef CALLBACK_API( short , MBarHookProcPtr )(Rect *menuRect);
  255. typedef STACK_UPP_TYPE(MenuBarDefProcPtr)                       MenuBarDefUPP;
  256. typedef STACK_UPP_TYPE(MenuHookProcPtr)                         MenuHookUPP;
  257. typedef STACK_UPP_TYPE(MBarHookProcPtr)                         MBarHookUPP;
  258. #if OPAQUE_UPP_TYPES
  259. #if CALL_NOT_IN_CARBON
  260.     EXTERN_API(MenuBarDefUPP)
  261.     NewMenuBarDefUPP               (MenuBarDefProcPtr       userRoutine);
  262.     EXTERN_API(MenuHookUPP)
  263.     NewMenuHookUPP                 (MenuHookProcPtr         userRoutine);
  264.     EXTERN_API(MBarHookUPP)
  265.     NewMBarHookUPP                 (MBarHookProcPtr         userRoutine);
  266.     EXTERN_API(void)
  267.     DisposeMenuBarDefUPP           (MenuBarDefUPP           userUPP);
  268.     EXTERN_API(void)
  269.     DisposeMenuHookUPP             (MenuHookUPP             userUPP);
  270.     EXTERN_API(void)
  271.     DisposeMBarHookUPP             (MBarHookUPP             userUPP);
  272.     EXTERN_API(long)
  273.     InvokeMenuBarDefUPP            (short                   selector,
  274.                                     short                   message,
  275.                                     short                   parameter1,
  276.                                     long                    parameter2,
  277.                                     MenuBarDefUPP           userUPP);
  278.     EXTERN_API(void)
  279.     InvokeMenuHookUPP              (MenuHookUPP             userUPP);
  280.     EXTERN_API(short)
  281.     InvokeMBarHookUPP              (Rect *                  menuRect,
  282.                                     MBarHookUPP             userUPP);
  283. #endif  /* CALL_NOT_IN_CARBON */
  284. #else
  285.     enum { uppMenuBarDefProcInfo = 0x00003AB0 };                    /* pascal 4_bytes Func(2_bytes, 2_bytes, 2_bytes, 4_bytes) */
  286.     enum { uppMenuHookProcInfo = 0x00000000 };                      /* pascal no_return_value Func() */
  287.     enum { uppMBarHookProcInfo = 0x000000CF };                      /* SPECIAL_CASE_PROCINFO(12) */
  288.     #define NewMenuBarDefUPP(userRoutine)                           (MenuBarDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuBarDefProcInfo, GetCurrentArchitecture())
  289.     #define NewMenuHookUPP(userRoutine)                             (MenuHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuHookProcInfo, GetCurrentArchitecture())
  290.     #define NewMBarHookUPP(userRoutine)                             (MBarHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMBarHookProcInfo, GetCurrentArchitecture())
  291.     #define DisposeMenuBarDefUPP(userUPP)                           DisposeRoutineDescriptor(userUPP)
  292.     #define DisposeMenuHookUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  293.     #define DisposeMBarHookUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  294.     #define InvokeMenuBarDefUPP(selector, message, parameter1, parameter2, userUPP)  (long)CALL_FOUR_PARAMETER_UPP((userUPP), uppMenuBarDefProcInfo, (selector), (message), (parameter1), (parameter2))
  295.     #define InvokeMenuHookUPP(userUPP)                              CALL_ZERO_PARAMETER_UPP((userUPP), uppMenuHookProcInfo)
  296.     #define InvokeMBarHookUPP(menuRect, userUPP)                    (short)CALL_ONE_PARAMETER_UPP((userUPP), uppMBarHookProcInfo, (menuRect))
  297. #endif
  298. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  299. #define NewMenuBarDefProc(userRoutine)                          NewMenuBarDefUPP(userRoutine)
  300. #define NewMenuHookProc(userRoutine)                            NewMenuHookUPP(userRoutine)
  301. #define NewMBarHookProc(userRoutine)                            NewMBarHookUPP(userRoutine)
  302. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2) InvokeMenuBarDefUPP(selector, message, parameter1, parameter2, userRoutine)
  303. #define CallMenuHookProc(userRoutine)                           InvokeMenuHookUPP(userRoutine)
  304. #define CallMBarHookProc(userRoutine, menuRect)                 InvokeMBarHookUPP(menuRect, userRoutine)
  305. enum {
  306.     kMenuDefProcPtr             = 0                             /* raw proc-ptr access based on old MDEF */
  307. };
  308. typedef UInt32                          MenuDefType;
  309. struct MenuDefSpec {
  310.     MenuDefType                     defType;
  311.     union {
  312.         MenuDefUPP                      defProc;
  313.     }                                 u;
  314. };
  315. typedef struct MenuDefSpec              MenuDefSpec;
  316. typedef MenuDefSpec *                   MenuDefSpecPtr;
  317. /*--------------------------------------------------------------------------------------*/
  318. /*  o Menu Manager Initialization                                                       */
  319. /*--------------------------------------------------------------------------------------*/
  320. #if CALL_NOT_IN_CARBON
  321. EXTERN_API( void )
  322. InitProcMenu                    (short                  resID)                              ONEWORDINLINE(0xA808);
  323. EXTERN_API( void )
  324. InitMenus                       (void)                                                      ONEWORDINLINE(0xA930);
  325. /*--------------------------------------------------------------------------------------*/
  326. /*  o Menu Manipulation                                                                 */
  327. /*--------------------------------------------------------------------------------------*/
  328. #endif  /* CALL_NOT_IN_CARBON */
  329. EXTERN_API( MenuRef )
  330. NewMenu                         (MenuID                 menuID,
  331.                                  ConstStr255Param       menuTitle)                          ONEWORDINLINE(0xA931);
  332. #if TARGET_OS_MAC
  333.     #define MacGetMenu GetMenu
  334. #endif
  335. EXTERN_API( MenuRef )
  336. MacGetMenu                      (short                  resourceID)                         ONEWORDINLINE(0xA9BF);
  337. EXTERN_API( void )
  338. DisposeMenu                     (MenuRef                theMenu)                            ONEWORDINLINE(0xA932);
  339. EXTERN_API( void )
  340. CalcMenuSize                    (MenuRef                theMenu)                            ONEWORDINLINE(0xA948);
  341. EXTERN_API( short )
  342. CountMenuItems                  (MenuRef                theMenu)                            ONEWORDINLINE(0xA950);
  343. /* CountMItems() has been renamed to CountMenuItems() in Carbon */
  344. #if CALL_NOT_IN_CARBON
  345. EXTERN_API( short )
  346. CountMItems                     (MenuRef                theMenu)                            ONEWORDINLINE(0xA950);
  347. #if CALL_NOT_IN_CARBON
  348. #define CountMenuItems( menu )  CountMItems( menu )
  349. #endif /* CALL_NOT_IN_CARBON */
  350. /* Routines available in Mac OS 8.5 and later */
  351. #endif  /* CALL_NOT_IN_CARBON */
  352. EXTERN_API( OSStatus )
  353. GetMenuFont                     (MenuRef                menu,
  354.                                  SInt16 *               outFontID,
  355.                                  UInt16 *               outFontSize);
  356. EXTERN_API( OSStatus )
  357. SetMenuFont                     (MenuRef                menu,
  358.                                  SInt16                 inFontID,
  359.                                  UInt16                 inFontSize);
  360. EXTERN_API( Boolean )
  361. GetMenuExcludesMarkColumn       (MenuRef                menu);
  362. EXTERN_API( OSStatus )
  363. SetMenuExcludesMarkColumn       (MenuRef                menu,
  364.                                  Boolean                excludesMark);
  365. /* Routines available in Carbon only*/
  366. EXTERN_API( OSStatus )
  367. RegisterMenuDefinition          (SInt16                 inResID,
  368.                                  MenuDefSpecPtr         inDefSpec);
  369. EXTERN_API( OSStatus )
  370. CreateNewMenu                   (MenuID                 menuID,
  371.                                  MenuAttributes         menuAttributes,
  372.                                  MenuRef *              outMenuRef);
  373. EXTERN_API( OSStatus )
  374. CreateCustomMenu                (const MenuDefSpec *    defSpec,
  375.                                  MenuID                 menuID,
  376.                                  MenuAttributes         menuAttributes,
  377.                                  MenuRef *              outMenuRef);
  378. /*--------------------------------------------------------------------------------------*/
  379. /*  o Menu Item Insertion                                                               */
  380. /*--------------------------------------------------------------------------------------*/
  381. #if TARGET_OS_MAC
  382.     #define MacAppendMenu AppendMenu
  383. #endif
  384. EXTERN_API( void )
  385. MacAppendMenu                   (MenuRef                menu,
  386.                                  ConstStr255Param       data)                               ONEWORDINLINE(0xA933);
  387. EXTERN_API( void )
  388. InsertResMenu                   (MenuRef                theMenu,
  389.                                  ResType                theType,
  390.                                  short                  afterItem)                          ONEWORDINLINE(0xA951);
  391. EXTERN_API( void )
  392. AppendResMenu                   (MenuRef                theMenu,
  393.                                  ResType                theType)                            ONEWORDINLINE(0xA94D);
  394. #if TARGET_OS_MAC
  395.     #define MacInsertMenuItem InsertMenuItem
  396. #endif
  397. EXTERN_API( void )
  398. MacInsertMenuItem               (MenuRef                theMenu,
  399.                                  ConstStr255Param       itemString,
  400.                                  short                  afterItem)                          ONEWORDINLINE(0xA826);
  401. EXTERN_API( void )
  402. DeleteMenuItem                  (MenuRef                theMenu,
  403.                                  short                  item)                               ONEWORDINLINE(0xA952);
  404. EXTERN_API( void )
  405. InsertFontResMenu               (MenuRef                theMenu,
  406.                                  short                  afterItem,
  407.                                  short                  scriptFilter)                       THREEWORDINLINE(0x303C, 0x0400, 0xA825);
  408. EXTERN_API( void )
  409. InsertIntlResMenu               (MenuRef                theMenu,
  410.                                  ResType                theType,
  411.                                  short                  afterItem,
  412.                                  short                  scriptFilter)                       THREEWORDINLINE(0x303C, 0x0601, 0xA825);
  413. /* Routines available in Mac OS 8.5 and later*/
  414. EXTERN_API( OSStatus )
  415. AppendMenuItemText              (MenuRef                menu,
  416.                                  ConstStr255Param       inString);
  417. EXTERN_API( OSStatus )
  418. InsertMenuItemText              (MenuRef                menu,
  419.                                  ConstStr255Param       inString,
  420.                                  MenuItemIndex          afterItem);
  421. /* Routines available in Carbon and later*/
  422. /*--------------------------------------------------------------------------------------*/
  423. /*  o Menu Events                                                                       */
  424. /*--------------------------------------------------------------------------------------*/
  425. EXTERN_API( long )
  426. MenuKey                         (CharParameter          ch)                                 ONEWORDINLINE(0xA93E);
  427. EXTERN_API( long )
  428. MenuSelect                      (Point                  startPt)                            ONEWORDINLINE(0xA93D);
  429. EXTERN_API( long )
  430. PopUpMenuSelect                 (MenuRef                menu,
  431.                                  short                  top,
  432.                                  short                  left,
  433.                                  short                  popUpItem)                          ONEWORDINLINE(0xA80B);
  434. EXTERN_API( long )
  435. MenuChoice                      (void)                                                      ONEWORDINLINE(0xAA66);
  436. /* Routines available in Mac OS 8.0 (Appearance 1.0) and later*/
  437. EXTERN_API( UInt32 )
  438. MenuEvent                       (const EventRecord *    inEvent)                            THREEWORDINLINE(0x303C, 0x020C, 0xA825);
  439. /*--------------------------------------------------------------------------------------*/
  440. /*  o Menu Bar                                                                          */
  441. /*--------------------------------------------------------------------------------------*/
  442. EXTERN_API( short )
  443. GetMBarHeight                   (void)                                                      TWOWORDINLINE(0x3EB8, 0x0BAA);
  444. #if TARGET_OS_MAC
  445.     #define MacDrawMenuBar DrawMenuBar
  446. #endif
  447. EXTERN_API( void )
  448. MacDrawMenuBar                  (void)                                                      ONEWORDINLINE(0xA937);
  449. EXTERN_API( void )
  450. InvalMenuBar                    (void)                                                      ONEWORDINLINE(0xA81D);
  451. EXTERN_API( void )
  452. HiliteMenu                      (MenuID                 menuID)                             ONEWORDINLINE(0xA938);
  453. EXTERN_API( Handle )
  454. GetNewMBar                      (short                  menuBarID)                          ONEWORDINLINE(0xA9C0);
  455. EXTERN_API( Handle )
  456. GetMenuBar                      (void)                                                      ONEWORDINLINE(0xA93B);
  457. EXTERN_API( void )
  458. SetMenuBar                      (Handle                 menuList)                           ONEWORDINLINE(0xA93C);
  459. EXTERN_API( MenuRef )
  460. GetMenuHandle                   (MenuID                 menuID)                             ONEWORDINLINE(0xA949);
  461. #if TARGET_OS_MAC
  462.     #define MacInsertMenu InsertMenu
  463. #endif
  464. EXTERN_API( void )
  465. MacInsertMenu                   (MenuRef                theMenu,
  466.                                  MenuID                 beforeID)                           ONEWORDINLINE(0xA935);
  467. #if TARGET_OS_MAC
  468.     #define MacDeleteMenu DeleteMenu
  469. #endif
  470. EXTERN_API( void )
  471. MacDeleteMenu                   (MenuID                 menuID)                             ONEWORDINLINE(0xA936);
  472. EXTERN_API( void )
  473. ClearMenuBar                    (void)                                                      ONEWORDINLINE(0xA934);
  474. EXTERN_API( void )
  475. SetMenuFlashCount               (short                  count)                              ONEWORDINLINE(0xA94A);
  476. /* SetMenuFlash() has been renamed to SetMenuFlashCount() in Carbon */
  477. #if CALL_NOT_IN_CARBON
  478. EXTERN_API( void )
  479. SetMenuFlash                    (short                  count)                              ONEWORDINLINE(0xA94A);
  480. #if CALL_NOT_IN_CARBON
  481. #define SetMenuFlashCount( count )  SetMenuFlash( count )
  482. #endif /* CALL_NOT_IN_CARBON */
  483. #endif  /* CALL_NOT_IN_CARBON */
  484. EXTERN_API( void )
  485. FlashMenuBar                    (MenuID                 menuID)                             ONEWORDINLINE(0xA94C);
  486. /* These are obsolete because Carbon does not support desk accessories.*/
  487. #if CALL_NOT_IN_CARBON
  488. EXTERN_API( Boolean )
  489. SystemEdit                      (short                  editCmd)                            ONEWORDINLINE(0xA9C2);
  490. EXTERN_API( void )
  491. SystemMenu                      (long                   menuResult)                         ONEWORDINLINE(0xA9B5);
  492. /* Routines available in Mac OS 8.5 and later*/
  493. #endif  /* CALL_NOT_IN_CARBON */
  494. EXTERN_API( Boolean )
  495. IsMenuBarVisible                (void);
  496. EXTERN_API( void )
  497. ShowMenuBar                     (void);
  498. EXTERN_API( void )
  499. HideMenuBar                     (void);
  500. /*--------------------------------------------------------------------------------------*/
  501. /*  o Menu Item Accessors                                                               */
  502. /*--------------------------------------------------------------------------------------*/
  503. #if TARGET_OS_MAC
  504.     #define MacCheckMenuItem CheckMenuItem
  505. #endif
  506. EXTERN_API( void )
  507. MacCheckMenuItem                (MenuRef                theMenu,
  508.                                  short                  item,
  509.                                  Boolean                checked)                            ONEWORDINLINE(0xA945);
  510. /* CheckItem() has been renamed to CheckMenuItem() in Carbon */
  511. #if CALL_NOT_IN_CARBON
  512. EXTERN_API( void )
  513. CheckItem                       (MenuRef                theMenu,
  514.                                  short                  item,
  515.                                  Boolean                checked)                            ONEWORDINLINE(0xA945);
  516. #if TARGET_OS_MAC && CALL_NOT_IN_CARBON
  517. #define CheckMenuItem( menu, item, checked ) CheckItem( menu, item, checked )
  518. #endif
  519. #endif  /* CALL_NOT_IN_CARBON */
  520. EXTERN_API( void )
  521. SetMenuItemText                 (MenuRef                theMenu,
  522.                                  short                  item,
  523.                                  ConstStr255Param       itemString)                         ONEWORDINLINE(0xA947);
  524. EXTERN_API( void )
  525. GetMenuItemText                 (MenuRef                theMenu,
  526.                                  short                  item,
  527.                                  Str255                 itemString)                         ONEWORDINLINE(0xA946);
  528. EXTERN_API( void )
  529. SetItemMark                     (MenuRef                theMenu,
  530.                                  short                  item,
  531.                                  CharParameter          markChar)                           ONEWORDINLINE(0xA944);
  532. EXTERN_API( void )
  533. GetItemMark                     (MenuRef                theMenu,
  534.                                  short                  item,
  535.                                  CharParameter *        markChar)                           ONEWORDINLINE(0xA943);
  536. EXTERN_API( void )
  537. SetItemCmd                      (MenuRef                theMenu,
  538.                                  short                  item,
  539.                                  CharParameter          cmdChar)                            ONEWORDINLINE(0xA84F);
  540. EXTERN_API( void )
  541. GetItemCmd                      (MenuRef                theMenu,
  542.                                  short                  item,
  543.                                  CharParameter *        cmdChar)                            ONEWORDINLINE(0xA84E);
  544. EXTERN_API( void )
  545. SetItemIcon                     (MenuRef                theMenu,
  546.                                  short                  item,
  547.                                  short                  iconIndex)                          ONEWORDINLINE(0xA940);
  548. /* icon is returned in high byte of 16-bit iconIndex */
  549. EXTERN_API( void )
  550. GetItemIcon                     (MenuRef                theMenu,
  551.                                  short                  item,
  552.                                  short *                iconIndex)                          ONEWORDINLINE(0xA93F);
  553. EXTERN_API( void )
  554. SetItemStyle                    (MenuRef                theMenu,
  555.                                  short                  item,
  556.                                  StyleParameter         chStyle)                            ONEWORDINLINE(0xA942);
  557. EXTERN_API( void )
  558. GetItemStyle                    (MenuRef                theMenu,
  559.                                  short                  item,
  560.                                  Style *                chStyle);
  561. /* These APIs are not supported in Carbon. Please use EnableMenuItem and */
  562. /* DisableMenuItem (available back through Mac OS 8.5) instead.          */
  563. #if CALL_NOT_IN_CARBON
  564. EXTERN_API( void )
  565. DisableItem                     (MenuRef                theMenu,
  566.                                  short                  item)                               ONEWORDINLINE(0xA93A);
  567. EXTERN_API( void )
  568. EnableItem                      (MenuRef                theMenu,
  569.                                  short                  item)                               ONEWORDINLINE(0xA939);
  570. /* Routines available in Mac OS 8.0 (Appearance 1.0) and later*/
  571. #endif  /* CALL_NOT_IN_CARBON */
  572. EXTERN_API( OSErr )
  573. SetMenuItemCommandID            (MenuRef                inMenu,
  574.                                  SInt16                 inItem,
  575.                                  MenuCommand            inCommandID)                        THREEWORDINLINE(0x303C, 0x0502, 0xA825);
  576. EXTERN_API( OSErr )
  577. GetMenuItemCommandID            (MenuRef                inMenu,
  578.                                  SInt16                 inItem,
  579.                                  MenuCommand *          outCommandID)                       THREEWORDINLINE(0x303C, 0x0503, 0xA825);
  580. EXTERN_API( OSErr )
  581. SetMenuItemModifiers            (MenuRef                inMenu,
  582.                                  SInt16                 inItem,
  583.                                  UInt8                  inModifiers)                        THREEWORDINLINE(0x303C, 0x0404, 0xA825);
  584. EXTERN_API( OSErr )
  585. GetMenuItemModifiers            (MenuRef                inMenu,
  586.                                  SInt16                 inItem,
  587.                                  UInt8 *                outModifiers)                       THREEWORDINLINE(0x303C, 0x0505, 0xA825);
  588. EXTERN_API( OSErr )
  589. SetMenuItemIconHandle           (MenuRef                inMenu,
  590.                                  SInt16                 inItem,
  591.                                  UInt8                  inIconType,
  592.                                  Handle                 inIconHandle)                       THREEWORDINLINE(0x303C, 0x0606, 0xA825);
  593. EXTERN_API( OSErr )
  594. GetMenuItemIconHandle           (MenuRef                inMenu,
  595.                                  SInt16                 inItem,
  596.                                  UInt8 *                outIconType,
  597.                                  Handle *               outIconHandle)                      THREEWORDINLINE(0x303C, 0x0707, 0xA825);
  598. EXTERN_API( OSErr )
  599. SetMenuItemTextEncoding         (MenuRef                inMenu,
  600.                                  SInt16                 inItem,
  601.                                  TextEncoding           inScriptID)                         THREEWORDINLINE(0x303C, 0x0408, 0xA825);
  602. EXTERN_API( OSErr )
  603. GetMenuItemTextEncoding         (MenuRef                inMenu,
  604.                                  SInt16                 inItem,
  605.                                  TextEncoding *         outScriptID)                        THREEWORDINLINE(0x303C, 0x0509, 0xA825);
  606. EXTERN_API( OSErr )
  607. SetMenuItemHierarchicalID       (MenuRef                inMenu,
  608.                                  SInt16                 inItem,
  609.                                  MenuID                 inHierID)                           THREEWORDINLINE(0x303C, 0x040D, 0xA825);
  610. EXTERN_API( OSErr )
  611. GetMenuItemHierarchicalID       (MenuRef                inMenu,
  612.                                  SInt16                 inItem,
  613.                                  MenuID *               outHierID)                          THREEWORDINLINE(0x303C, 0x050E, 0xA825);
  614. EXTERN_API( OSErr )
  615. SetMenuItemFontID               (MenuRef                inMenu,
  616.                                  SInt16                 inItem,
  617.                                  SInt16                 inFontID)                           THREEWORDINLINE(0x303C, 0x040F, 0xA825);
  618. EXTERN_API( OSErr )
  619. GetMenuItemFontID               (MenuRef                inMenu,
  620.                                  SInt16                 inItem,
  621.                                  SInt16 *               outFontID)                          THREEWORDINLINE(0x303C, 0x0510, 0xA825);
  622. EXTERN_API( OSErr )
  623. SetMenuItemRefCon               (MenuRef                inMenu,
  624.                                  SInt16                 inItem,
  625.                                  UInt32                 inRefCon)                           THREEWORDINLINE(0x303C, 0x050A, 0xA825);
  626. EXTERN_API( OSErr )
  627. GetMenuItemRefCon               (MenuRef                inMenu,
  628.                                  SInt16                 inItem,
  629.                                  UInt32 *               outRefCon)                          THREEWORDINLINE(0x303C, 0x050B, 0xA825);
  630. /* Please use the menu item property APIs in Carbon.*/
  631. #if CALL_NOT_IN_CARBON
  632. EXTERN_API( OSErr )
  633. SetMenuItemRefCon2              (MenuRef                inMenu,
  634.                                  SInt16                 inItem,
  635.                                  UInt32                 inRefCon2)                          THREEWORDINLINE(0x303C, 0x0511, 0xA825);
  636. EXTERN_API( OSErr )
  637. GetMenuItemRefCon2              (MenuRef                inMenu,
  638.                                  SInt16                 inItem,
  639.                                  UInt32 *               outRefCon2)                         THREEWORDINLINE(0x303C, 0x0512, 0xA825);
  640. #endif  /* CALL_NOT_IN_CARBON */
  641. EXTERN_API( OSErr )
  642. SetMenuItemKeyGlyph             (MenuRef                inMenu,
  643.                                  SInt16                 inItem,
  644.                                  SInt16                 inGlyph)                            THREEWORDINLINE(0x303C, 0x0513, 0xA825);
  645. EXTERN_API( OSErr )
  646. GetMenuItemKeyGlyph             (MenuRef                inMenu,
  647.                                  SInt16                 inItem,
  648.                                  SInt16 *               outGlyph)                           THREEWORDINLINE(0x303C, 0x0514, 0xA825);
  649. /* Routines available in Mac OS 8.5 and later (supporting enabling/disabling of > 31 items)*/
  650. #if TARGET_OS_MAC
  651.     #define MacEnableMenuItem EnableMenuItem
  652. #endif
  653. EXTERN_API( void )
  654. MacEnableMenuItem               (MenuRef                theMenu,
  655.                                  MenuItemIndex          item);
  656. EXTERN_API( void )
  657. DisableMenuItem                 (MenuRef                theMenu,
  658.                                  MenuItemIndex          item);
  659. EXTERN_API( Boolean )
  660. IsMenuItemEnabled               (MenuRef                menu,
  661.                                  MenuItemIndex          item);
  662. EXTERN_API( void )
  663. EnableMenuItemIcon              (MenuRef                theMenu,
  664.                                  MenuItemIndex          item)                               THREEWORDINLINE(0x303C, 0x0019, 0xA825);
  665. EXTERN_API( void )
  666. DisableMenuItemIcon             (MenuRef                theMenu,
  667.                                  MenuItemIndex          item)                               THREEWORDINLINE(0x303C, 0x0020, 0xA825);
  668. EXTERN_API( Boolean )
  669. IsMenuItemIconEnabled           (MenuRef                menu,
  670.                                  MenuItemIndex          item)                               THREEWORDINLINE(0x303C, 0x0018, 0xA825);
  671. /*--------------------------------------------------------------------------------------*/
  672. /*  o Menu Item Color Tables                                                            */
  673. /*                                                                                      */
  674. /*  Menu color manipulation is considered deprecated with the advent of the Appearance  */
  675. /*  Manager.  Avoid using these routines if possible                                    */
  676. /*--------------------------------------------------------------------------------------*/
  677. EXTERN_API( void )
  678. DeleteMCEntries                 (MenuID                 menuID,
  679.                                  short                  menuItem)                           ONEWORDINLINE(0xAA60);
  680. EXTERN_API( MCTableHandle )
  681. GetMCInfo                       (void)                                                      ONEWORDINLINE(0xAA61);
  682. EXTERN_API( void )
  683. SetMCInfo                       (MCTableHandle          menuCTbl)                           ONEWORDINLINE(0xAA62);
  684. EXTERN_API( void )
  685. DisposeMCInfo                   (MCTableHandle          menuCTbl)                           ONEWORDINLINE(0xAA63);
  686. EXTERN_API( MCEntryPtr )
  687. GetMCEntry                      (MenuID                 menuID,
  688.                                  short                  menuItem)                           ONEWORDINLINE(0xAA64);
  689. EXTERN_API( void )
  690. SetMCEntries                    (short                  numEntries,
  691.                                  MCTablePtr             menuCEntries)                       ONEWORDINLINE(0xAA65);
  692. /*--------------------------------------------------------------------------------------*/
  693. /* o Properties  (Mac OS 8.5 and later)                                                 */
  694. /*                                                                                      */
  695. /* With the following property APIs, you can attach any piece of data you'd like to a   */
  696. /* menu or menu item. Passing zero for the item number parameter indicates you'd like   */
  697. /* to attach the data to the menu itself, and not to any specific menu item.            */
  698. /*--------------------------------------------------------------------------------------*/
  699. enum {
  700.     kMenuPropertyPersistent     = 0x00000001                    /* whether this property gets saved when flattening the menu*/
  701. };
  702. EXTERN_API( OSStatus )
  703. GetMenuItemProperty             (MenuRef                menu,
  704.                                  MenuItemIndex          item,
  705.                                  OSType                 propertyCreator,
  706.                                  OSType                 propertyTag,
  707.                                  UInt32                 bufferSize,
  708.                                  UInt32 *               actualSize,
  709.                                  void *                 propertyBuffer);
  710. EXTERN_API( OSStatus )
  711. GetMenuItemPropertySize         (MenuRef                menu,
  712.                                  MenuItemIndex          item,
  713.                                  OSType                 propertyCreator,
  714.                                  OSType                 propertyTag,
  715.                                  UInt32 *               size);
  716. EXTERN_API( OSStatus )
  717. SetMenuItemProperty             (MenuRef                menu,
  718.                                  MenuItemIndex          item,
  719.                                  OSType                 propertyCreator,
  720.                                  OSType                 propertyTag,
  721.                                  UInt32                 propertySize,
  722.                                  const void *           propertyData);
  723. EXTERN_API( OSStatus )
  724. RemoveMenuItemProperty          (MenuRef                menu,
  725.                                  MenuItemIndex          item,
  726.                                  OSType                 propertyCreator,
  727.                                  OSType                 propertyTag);
  728. EXTERN_API( OSStatus )
  729. GetMenuItemPropertyAttributes   (MenuRef                menu,
  730.                                  MenuItemIndex          item,
  731.                                  OSType                 propertyCreator,
  732.                                  OSType                 propertyTag,
  733.                                  UInt32 *               attributes);
  734. EXTERN_API( OSStatus )
  735. ChangeMenuItemPropertyAttributes (MenuRef               menu,
  736.                                  MenuItemIndex          item,
  737.                                  OSType                 propertyCreator,
  738.                                  OSType                 propertyTag,
  739.                                  UInt32                 attributesToSet,
  740.                                  UInt32                 attributesToClear);
  741. /*--------------------------------------------------------------------------------------*/
  742. /*  o Attributes (Carbon and later)                                                     */
  743. /*                                                                                      */
  744. /*  Each menu and menu item has attribute flags.                                        */
  745. /*--------------------------------------------------------------------------------------*/
  746. EXTERN_API( OSStatus )
  747. GetMenuAttributes               (MenuRef                menu,
  748.                                  MenuAttributes *       outAttributes);
  749. EXTERN_API( OSStatus )
  750. ChangeMenuAttributes            (MenuRef                menu,
  751.                                  MenuAttributes         setTheseAttributes,
  752.                                  MenuAttributes         clearTheseAttributes);
  753. EXTERN_API( OSStatus )
  754. GetMenuItemAttributes           (MenuRef                menu,
  755.                                  MenuItemIndex          item,
  756.                                  MenuItemAttributes *   outAttributes);
  757. EXTERN_API( OSStatus )
  758. ChangeMenuItemAttributes        (MenuRef                menu,
  759.                                  MenuItemIndex          item,
  760.                                  MenuItemAttributes     setTheseAttributes,
  761.                                  MenuItemAttributes     clearTheseAttributes);
  762. /*--------------------------------------------------------------------------------------*/
  763. /*  o Mass menu item enabling and disabling (Carbon and later)                          */
  764. /*                                                                                      */
  765. /*  Useful when rewriting code that whacks the enableFlags field directly.              */
  766. /*--------------------------------------------------------------------------------------*/
  767. EXTERN_API( void )
  768. DisableAllMenuItems             (MenuRef                theMenu);
  769. EXTERN_API( void )
  770. EnableAllMenuItems              (MenuRef                theMenu);
  771. EXTERN_API( Boolean )
  772. MenuHasEnabledItems             (MenuRef                theMenu);
  773. /*--------------------------------------------------------------------------------------*/
  774. /*  o Menu tracking status (Carbon and later)                                           */
  775. /*                                                                                      */
  776. /*  Get info about the selected menu item during menu tracking. Replaces direct access  */
  777. /*  to low-mem globals that used to hold this info.                                     */
  778. /*--------------------------------------------------------------------------------------*/
  779. EXTERN_API( OSStatus )
  780. GetMenuTrackingData             (MenuRef                theMenu,
  781.                                  MenuTrackingData *     outData);
  782. /*--------------------------------------------------------------------------------------*/
  783. /*  o.Universal command ID access (Carbon and later)                                    */
  784. /*                                                                                      */
  785. /*  These APIs allow you to operate on menu items strictly by command ID, with no       */
  786. /*  knowledge of a menu item's index.                                                   */
  787. /*--------------------------------------------------------------------------------------*/
  788. EXTERN_API( ItemCount )
  789. CountMenuItemsWithCommandID     (MenuRef                menu,
  790.                                  MenuCommand            commandID);
  791. EXTERN_API( OSStatus )
  792. GetIndMenuItemWithCommandID     (MenuRef                menu,
  793.                                  MenuCommand            commandID,
  794.                                  UInt32                 itemIndex,
  795.                                  MenuRef *              outMenu,
  796.                                  MenuItemIndex *        outIndex);
  797. EXTERN_API( void )
  798. EnableMenuCommand               (MenuRef                theMenu,
  799.                                  MenuCommand            commandID);
  800. EXTERN_API( void )
  801. DisableMenuCommand              (MenuRef                theMenu,
  802.                                  MenuCommand            commandID);
  803. EXTERN_API( Boolean )
  804. IsMenuCommandEnabled            (MenuRef                menu,
  805.                                  MenuCommand            commandID);
  806. EXTERN_API( OSStatus )
  807. GetMenuCommandProperty          (MenuRef                menu,
  808.                                  MenuCommand            commandID,
  809.                                  OSType                 propertyCreator,
  810.                                  OSType                 propertyTag,
  811.                                  ByteCount              bufferSize,
  812.                                  ByteCount *            actualSize,
  813.                                  void *                 propertyBuffer);
  814. EXTERN_API( OSStatus )
  815. GetMenuCommandPropertySize      (MenuRef                menu,
  816.                                  MenuCommand            commandID,
  817.                                  OSType                 propertyCreator,
  818.                                  OSType                 propertyTag,
  819.                                  ByteCount *            size);
  820. EXTERN_API( OSStatus )
  821. SetMenuCommandProperty          (MenuRef                menu,
  822.                                  MenuCommand            commandID,
  823.                                  OSType                 propertyCreator,
  824.                                  OSType                 propertyTag,
  825.                                  ByteCount              propertySize,
  826.                                  const void *           propertyData);
  827. EXTERN_API( OSStatus )
  828. RemoveMenuCommandProperty       (MenuRef                menu,
  829.                                  MenuCommand            commandID,
  830.                                  OSType                 propertyCreator,
  831.                                  OSType                 propertyTag);
  832. /*--------------------------------------------------------------------------------------*/
  833. /*  o.Standard font menu (Carbon and later)                                             */
  834. /*                                                                                      */
  835. /*  These APIs allow you to create and use the standard font menu.                      */
  836. /*--------------------------------------------------------------------------------------*/
  837. enum {
  838.     kHierarchicalFontMenuOption = 0x00000001
  839. };
  840. EXTERN_API( OSStatus )
  841. CreateStandardFontMenu          (MenuRef                menu,
  842.                                  MenuItemIndex          afterItem,
  843.                                  MenuID                 firstHierMenuID,
  844.                                  OptionBits             options,
  845.                                  ItemCount *            outHierMenuCount);
  846. EXTERN_API( OSStatus )
  847. UpdateStandardFontMenu          (MenuRef                menu,
  848.                                  ItemCount *            outHierMenuCount);
  849. EXTERN_API( OSStatus )
  850. GetFontFamilyFromMenuSelection  (MenuRef                menu,
  851.                                  MenuItemIndex          item,
  852.                                  FMFontFamily *         outFontFamily,
  853.                                  FMFontStyle *          outStyle);
  854. /*--------------------------------------------------------------------------------------*/
  855. /*  o Contextual Menu routines and constants                                            */
  856. /*  available with Conxtextual Menu extension 1.0 and later                             */
  857. /*--------------------------------------------------------------------------------------*/
  858. /* Gestalt Selector for classic 68K apps only. */
  859. /* CFM apps should weak link and check the symbols. */
  860. enum {
  861.     gestaltContextualMenuAttr   = FOUR_CHAR_CODE('cmnu'),
  862.     gestaltContextualMenuUnusedBit = 0,
  863.     gestaltContextualMenuTrapAvailable = 1
  864. };
  865. /* Values indicating what kind of help the application supports */
  866. enum {
  867.     kCMHelpItemNoHelp           = 0,
  868.     kCMHelpItemAppleGuide       = 1,
  869.     kCMHelpItemOtherHelp        = 2
  870. };
  871. /* Values indicating what was chosen from the menu */
  872. enum {
  873.     kCMNothingSelected          = 0,
  874.     kCMMenuItemSelected         = 1,
  875.     kCMShowHelpSelected         = 3
  876. };
  877. EXTERN_API( OSStatus )
  878. InitContextualMenus             (void)                                                      TWOWORDINLINE(0x7001, 0xAA72);
  879. EXTERN_API( Boolean )
  880. IsShowContextualMenuClick       (const EventRecord *    inEvent)                            TWOWORDINLINE(0x7002, 0xAA72);
  881. EXTERN_API( OSStatus )
  882. ContextualMenuSelect            (MenuRef                inMenu,
  883.                                  Point                  inGlobalLocation,
  884.                                  Boolean                inReserved,
  885.                                  UInt32                 inHelpType,
  886.                                  ConstStr255Param       inHelpItemString,
  887.                                  const AEDesc *         inSelection,
  888.                                  UInt32 *               outUserSelectionType,
  889.                                  SInt16 *               outMenuID,
  890.                                  MenuItemIndex *        outMenuItem)                        TWOWORDINLINE(0x7003, 0xAA72);
  891. EXTERN_API( Boolean )
  892. ProcessIsContextualMenuClient   (ProcessSerialNumber *  inPSN)                              TWOWORDINLINE(0x7004, 0xAA72);
  893. /*--------------------------------------------------------------------------------------*/
  894. /*  o Contextual Menu Plugin Notes                                                      */
  895. /*                                                                                      */
  896. /*  For Mac OS X, we will support a new type of Contextual Menu Plugin: the CFM-based   */
  897. /*  plugin. Each plugin must be a separate file in the Contextual Menu Items subfolder  */
  898. /*  of the system folder. It must export two functions and has the option of exporting  */
  899. /*  a third; these three functions are virtually identical to the methods that must be  */
  900. /*  supported by a SOM-based plugin.                                                        */
  901. /*                                                                                      */
  902. /*  The required symbols must be named "ExamineContext" and "HandleSelection".          */
  903. /*  The optional symbol must be named "PostMenuCleanup".                                */
  904. /*                                                                                      */
  905. /*  The ExamineContext routine must have the following prototype:                       */
  906. /*      pascal OSStatus ExamineContext( const AEDesc* inContext,                        */
  907. /*                                      AEDescList* outCommandPairs );                  */
  908. /*                                                                                      */
  909. /*  The HandleSelection routine must have the following prototype:                      */
  910. /*      pascal OSStatus HandleSelection(    const AEDesc* inContext,                    */
  911. /*                                          SInt32 inCommandID );                       */
  912. /*                                                                                      */
  913. /*  The PostMenuCleanup routine must have the following prototype:                      */
  914. /*      pascal void PostMenuCleanup(     void );                                            */
  915. /*--------------------------------------------------------------------------------------*/
  916. #if CALL_NOT_IN_CARBON
  917. EXTERN_API_C( MenuRef )
  918. newmenu                         (MenuID                 menuID,
  919.                                  const char *           menuTitle);
  920. EXTERN_API_C( void )
  921. appendmenu                      (MenuRef                menu,
  922.                                  const char *           data);
  923. EXTERN_API_C( void )
  924. insertmenuitem                  (MenuRef                theMenu,
  925.                                  const char *           itemString,
  926.                                  short                  afterItem);
  927. EXTERN_API_C( long )
  928. menuselect                      (const Point *          startPt);
  929. EXTERN_API_C( void )
  930. setmenuitemtext                 (MenuRef                menu,
  931.                                  short                  item,
  932.                                  const char *           itemString);
  933. EXTERN_API_C( void )
  934. getmenuitemtext                 (MenuRef                menu,
  935.                                  short                  item,
  936.                                  char *                 itemString);
  937. #endif  /* CALL_NOT_IN_CARBON */
  938. #if OLDROUTINENAMES
  939. #define AddResMenu(theMenu, theType) AppendResMenu(theMenu, theType)
  940. #define InsMenuItem(theMenu, itemString, afterItem) InsertMenuItem(theMenu, itemString, afterItem)
  941. #define DelMenuItem( theMenu, item ) DeleteMenuItem( theMenu, item )
  942. #if TARGET_OS_MAC
  943. #define SetItem MacSetItem
  944. #define GetItem MacGetItem
  945. #endif
  946. #define MacSetItem(theMenu, item, itemString) SetMenuItemText(theMenu, item, itemString)
  947. #define MacGetItem(theMenu, item, itemString) GetMenuItemText(theMenu, item, itemString)
  948. #define GetMHandle(menuID) GetMenuHandle(menuID)
  949. #define DelMCEntries(menuID, menuItem) DeleteMCEntries(menuID, menuItem)
  950. #define DispMCInfo(menuCTbl) DisposeMCInfo(menuCTbl)
  951. #if CALL_NOT_IN_CARBON
  952. #define addresmenu(menu, data) appendresmenu(menu, data)
  953. #define getitem(menu, item, itemString) getmenuitemtext(menu, item, itemString)
  954. #define setitem(menu, item, itemString) setmenuitemtext(menu, item, itemString)
  955. #define insmenuitem(theMenu, itemString, afterItem) insertmenuitem(theMenu, itemString, afterItem)
  956. #endif
  957. #endif  /* OLDROUTINENAMES */
  958. #if ACCESSOR_CALLS_ARE_FUNCTIONS
  959. /* Getters */
  960. EXTERN_API( MenuID )
  961. GetMenuID                       (MenuRef                menu);
  962. EXTERN_API( SInt16 )
  963. GetMenuWidth                    (MenuRef                menu);
  964. EXTERN_API( SInt16 )
  965. GetMenuHeight                   (MenuRef                menu);
  966. EXTERN_API( StringPtr )
  967. GetMenuTitle                    (MenuRef                menu,
  968.                                  Str255                 title);
  969. EXTERN_API( OSStatus )
  970. GetMenuDefinition               (MenuRef                menu,
  971.                                  MenuDefSpecPtr         outDefSpec);
  972. /* Setters */
  973. EXTERN_API( void )
  974. SetMenuID                       (MenuRef                menu,
  975.                                  MenuID                 menuID);
  976. EXTERN_API( void )
  977. SetMenuWidth                    (MenuRef                menu,
  978.                                  SInt16                 width);
  979. EXTERN_API( void )
  980. SetMenuHeight                   (MenuRef                menu,
  981.                                  SInt16                 height);
  982. EXTERN_API( OSStatus )
  983. SetMenuTitle                    (MenuRef                menu,
  984.                                  ConstStr255Param       title);
  985. EXTERN_API( OSStatus )
  986. SetMenuDefinition               (MenuRef                menu,
  987.                                  const MenuDefSpec *    defSpec);
  988. #endif  /* ACCESSOR_CALLS_ARE_FUNCTIONS */
  989. #if TARGET_OS_WIN32
  990. #endif  /* TARGET_OS_WIN32 */
  991. #if PRAGMA_STRUCT_ALIGN
  992.     #pragma options align=reset
  993. #elif PRAGMA_STRUCT_PACKPUSH
  994.     #pragma pack(pop)
  995. #elif PRAGMA_STRUCT_PACK
  996.     #pragma pack()
  997. #endif
  998. #ifdef PRAGMA_IMPORT_OFF
  999. #pragma import off
  1000. #elif PRAGMA_IMPORT
  1001. #pragma import reset
  1002. #endif
  1003. #ifdef __cplusplus
  1004. }
  1005. #endif
  1006. #endif /* __MENUS__ */