home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Menus.h < prev    next >
Encoding:
Text File  |  1994-11-11  |  11.9 KB  |  326 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Menus.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __MENUS__
  18. #define __MENUS__
  19.  
  20.  
  21. #ifndef __MEMORY__
  22. #include <Memory.h>
  23. #endif
  24. /*    #include <Types.h>                                            */
  25. /*        #include <ConditionalMacros.h>                            */
  26. /*    #include <MixedMode.h>                                        */
  27.  
  28. #ifndef __QUICKDRAW__
  29. #include <Quickdraw.h>
  30. #endif
  31. /*    #include <QuickdrawText.h>                                    */
  32.  
  33. #ifndef __EVENTS__
  34. #include <Events.h>
  35. #endif
  36. /*    #include <OSUtils.h>                                        */
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42. #if GENERATINGPOWERPC
  43. #pragma options align=mac68k
  44. #endif
  45.  
  46. #ifdef __CFM68K__
  47. #pragma lib_export on
  48. #endif
  49.  
  50.  
  51. enum {
  52.     noMark                        = 0,                            /*mark symbol for MarkItem*/
  53. /* menu defProc messages */
  54.     mDrawMsg                    = 0,
  55.     mChooseMsg                    = 1,
  56.     mSizeMsg                    = 2,
  57.     mDrawItemMsg                = 4,
  58.     mCalcItemMsg                = 5,
  59.     textMenuProc                = 0,
  60.     hMenuCmd                    = 27,                            /*itemCmd == 0x001B ==> hierarchical menu*/
  61.     hierMenu                    = -1,                            /*a hierarchical menu - for InsertMenu call*/
  62.     mPopUpMsg                    = 3,                            /*menu defProc messages - place yourself*/
  63.     mctAllItems                    = -98,                            /*search for all Items for the given ID*/
  64.     mctLastIDIndic                = -99                            /*last color table entry has this in ID field*/
  65. };
  66.  
  67. #ifndef STRICT_MENUS
  68. #define STRICT_MENUS 0
  69. #endif
  70. #if STRICT_MENUS
  71. typedef struct OpaqueMenuRef *MenuRef;
  72.  
  73. #else
  74. struct MenuInfo {
  75.     short                            menuID;
  76.     short                            menuWidth;
  77.     short                            menuHeight;
  78.     Handle                            menuProc;
  79.     long                            enableFlags;
  80.     Str255                            menuData;
  81. };
  82. typedef struct MenuInfo MenuInfo, *MenuPtr, **MenuHandle;
  83.  
  84. typedef MenuHandle MenuRef;
  85.  
  86. #endif
  87. typedef pascal void (*MenuDefProcPtr)(short message, MenuRef theMenu, Rect *menuRect, Point hitPt, short *whichItem);
  88. typedef pascal long (*MenuBarDefProcPtr)(short selector, short message, short parameter1, long parameter2);
  89. typedef pascal void (*MenuHookProcPtr)(void);
  90. typedef pascal short (*MBarHookProcPtr)(Rect *menuRect);
  91.  
  92. #if GENERATINGCFM
  93. typedef UniversalProcPtr MenuDefUPP;
  94. typedef UniversalProcPtr MenuBarDefUPP;
  95. typedef UniversalProcPtr MenuHookUPP;
  96. typedef UniversalProcPtr MBarHookUPP;
  97. #else
  98. typedef MenuDefProcPtr MenuDefUPP;
  99. typedef MenuBarDefProcPtr MenuBarDefUPP;
  100. typedef MenuHookProcPtr MenuHookUPP;
  101. typedef Register68kProcPtr MBarHookUPP;
  102. #endif
  103.  
  104. enum {
  105.     uppMenuDefProcInfo = kPascalStackBased
  106.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  107.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(MenuRef)))
  108.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  109.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Point)))
  110.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short*))),
  111.     uppMenuBarDefProcInfo = kPascalStackBased
  112.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  113.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  114.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  115.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  116.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  117.     uppMenuHookProcInfo = kPascalStackBased,
  118.     uppMBarHookProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseMBarHook )
  119. };
  120.  
  121. #if GENERATINGCFM
  122. #define NewMenuDefProc(userRoutine)        \
  123.         (MenuDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuDefProcInfo, GetCurrentArchitecture())
  124. #define NewMenuBarDefProc(userRoutine)        \
  125.         (MenuBarDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuBarDefProcInfo, GetCurrentArchitecture())
  126. #define NewMenuHookProc(userRoutine)        \
  127.         (MenuHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuHookProcInfo, GetCurrentArchitecture())
  128. #define NewMBarHookProc(userRoutine)        \
  129.         (MBarHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMBarHookProcInfo, GetCurrentArchitecture())
  130. #else
  131. #define NewMenuDefProc(userRoutine)        \
  132.         ((MenuDefUPP) (userRoutine))
  133. #define NewMenuBarDefProc(userRoutine)        \
  134.         ((MenuBarDefUPP) (userRoutine))
  135. #define NewMenuHookProc(userRoutine)        \
  136.         ((MenuHookUPP) (userRoutine))
  137. #define NewMBarHookProc(userRoutine)        \
  138.         ((MBarHookUPP) (userRoutine))
  139. #endif
  140.  
  141. #if GENERATINGCFM
  142. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem)        \
  143.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuDefProcInfo, (message), (theMenu), (menuRect), (hitPt), (whichItem))
  144. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2)        \
  145.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuBarDefProcInfo, (selector), (message), (parameter1), (parameter2))
  146. #define CallMenuHookProc(userRoutine)        \
  147.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuHookProcInfo)
  148. #define CallMBarHookProc(userRoutine, menuRect)        \
  149.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMBarHookProcInfo, (menuRect))
  150. #else
  151. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem)        \
  152.         (*(userRoutine))((message), (theMenu), (menuRect), (hitPt), (whichItem))
  153. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2)        \
  154.         (*(userRoutine))((selector), (message), (parameter1), (parameter2))
  155. #define CallMenuHookProc(userRoutine)        \
  156.         (*(userRoutine))()
  157. /* (*MBarHookProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  158. #endif
  159.  
  160. struct MCEntry {
  161.     short                            mctID;                        /*menu ID.  ID = 0 is the menu bar*/
  162.     short                            mctItem;                    /*menu Item. Item = 0 is a title*/
  163.     RGBColor                        mctRGB1;                    /*usage depends on ID and Item*/
  164.     RGBColor                        mctRGB2;                    /*usage depends on ID and Item*/
  165.     RGBColor                        mctRGB3;                    /*usage depends on ID and Item*/
  166.     RGBColor                        mctRGB4;                    /*usage depends on ID and Item*/
  167.     short                            mctReserved;                /*reserved for internal use*/
  168. };
  169. typedef struct MCEntry MCEntry;
  170.  
  171. typedef MCEntry *MCEntryPtr;
  172.  
  173. typedef MCEntry MCTable[1], *MCTablePtr, **MCTableHandle;
  174.  
  175. struct MenuCRsrc {
  176.     short                            numEntries;                    /*number of entries*/
  177.     MCTable                            mcEntryRecs;                /*ARRAY [1..numEntries] of MCEntry*/
  178. };
  179. typedef struct MenuCRsrc MenuCRsrc;
  180.  
  181. typedef MenuCRsrc *MenuCRsrcPtr, **MenuCRsrcHandle;
  182.  
  183. extern pascal short GetMBarHeight( void )
  184.     TWOWORDINLINE( 0x3EB8, 0x0BAA ); /* MOVE.W $0BAA,(SP) */
  185. extern pascal void InitMenus(void)
  186.  ONEWORDINLINE(0xA930);
  187. extern pascal MenuRef NewMenu(short menuID, ConstStr255Param menuTitle)
  188.  ONEWORDINLINE(0xA931);
  189. extern pascal MenuRef GetMenu(short resourceID)
  190.  ONEWORDINLINE(0xA9BF);
  191. extern pascal void DisposeMenu(MenuRef theMenu)
  192.  ONEWORDINLINE(0xA932);
  193. extern pascal void AppendMenu(MenuRef menu, ConstStr255Param data)
  194.  ONEWORDINLINE(0xA933);
  195. extern pascal void AppendResMenu(MenuRef theMenu, ResType theType)
  196.  ONEWORDINLINE(0xA94D);
  197. extern pascal void InsertResMenu(MenuRef theMenu, ResType theType, short afterItem)
  198.  ONEWORDINLINE(0xA951);
  199. extern pascal void InsertMenu(MenuRef theMenu, short beforeID)
  200.  ONEWORDINLINE(0xA935);
  201. extern pascal void DrawMenuBar(void)
  202.  ONEWORDINLINE(0xA937);
  203. extern pascal void InvalMenuBar(void)
  204.  ONEWORDINLINE(0xA81D);
  205. extern pascal void DeleteMenu(short menuID)
  206.  ONEWORDINLINE(0xA936);
  207. extern pascal void ClearMenuBar(void)
  208.  ONEWORDINLINE(0xA934);
  209. extern pascal Handle GetNewMBar(short menuBarID)
  210.  ONEWORDINLINE(0xA9C0);
  211. extern pascal Handle GetMenuBar(void)
  212.  ONEWORDINLINE(0xA93B);
  213. extern pascal void SetMenuBar(Handle menuList)
  214.  ONEWORDINLINE(0xA93C);
  215. extern pascal void InsertMenuItem(MenuRef theMenu, ConstStr255Param itemString, short afterItem)
  216.  ONEWORDINLINE(0xA826);
  217. extern pascal void DeleteMenuItem(MenuRef theMenu, short item)
  218.  ONEWORDINLINE(0xA952);
  219. extern pascal long MenuKey(short ch)
  220.  ONEWORDINLINE(0xA93E);
  221. extern pascal void HiliteMenu(short menuID)
  222.  ONEWORDINLINE(0xA938);
  223. extern pascal void SetMenuItemText(MenuRef theMenu, short item, ConstStr255Param itemString)
  224.  ONEWORDINLINE(0xA947);
  225. extern pascal void GetMenuItemText(MenuRef theMenu, short item, Str255 itemString)
  226.  ONEWORDINLINE(0xA946);
  227. extern pascal void DisableItem(MenuRef theMenu, short item)
  228.  ONEWORDINLINE(0xA93A);
  229. extern pascal void EnableItem(MenuRef theMenu, short item)
  230.  ONEWORDINLINE(0xA939);
  231. extern pascal void CheckItem(MenuRef theMenu, short item, Boolean checked)
  232.  ONEWORDINLINE(0xA945);
  233. extern pascal void SetItemMark(MenuRef theMenu, short item, short markChar)
  234.  ONEWORDINLINE(0xA944);
  235. extern pascal void GetItemMark(MenuRef theMenu, short item, short *markChar)
  236.  ONEWORDINLINE(0xA943);
  237. extern pascal void SetItemIcon(MenuRef theMenu, short item, short iconIndex)
  238.  ONEWORDINLINE(0xA940);
  239. extern pascal void GetItemIcon(MenuRef theMenu, short item, short *iconIndex)
  240.  ONEWORDINLINE(0xA93F);
  241. extern pascal void SetItemStyle(MenuRef theMenu, short item, short chStyle)
  242.  ONEWORDINLINE(0xA942);
  243. extern pascal void GetItemStyle(MenuRef theMenu, short item, unsigned char *chStyle);
  244. extern pascal void CalcMenuSize(MenuRef theMenu)
  245.  ONEWORDINLINE(0xA948);
  246. extern pascal short CountMItems(MenuRef theMenu)
  247.  ONEWORDINLINE(0xA950);
  248. extern pascal MenuRef GetMenuHandle(short menuID)
  249.  ONEWORDINLINE(0xA949);
  250. extern pascal void FlashMenuBar(short menuID)
  251.  ONEWORDINLINE(0xA94C);
  252. extern pascal void SetMenuFlash(short count)
  253.  ONEWORDINLINE(0xA94A);
  254. extern pascal long MenuSelect(Point startPt)
  255.  ONEWORDINLINE(0xA93D);
  256. extern pascal void InitProcMenu(short resID)
  257.  ONEWORDINLINE(0xA808);
  258. extern pascal void GetItemCmd(MenuRef theMenu, short item, short *cmdChar)
  259.  ONEWORDINLINE(0xA84E);
  260. extern pascal void SetItemCmd(MenuRef theMenu, short item, short cmdChar)
  261.  ONEWORDINLINE(0xA84F);
  262. extern pascal long PopUpMenuSelect(MenuRef menu, short top, short left, short popUpItem)
  263.  ONEWORDINLINE(0xA80B);
  264. extern pascal long MenuChoice(void)
  265.  ONEWORDINLINE(0xAA66);
  266. extern pascal void DeleteMCEntries(short menuID, short menuItem)
  267.  ONEWORDINLINE(0xAA60);
  268. extern pascal MCTableHandle GetMCInfo(void)
  269.  ONEWORDINLINE(0xAA61);
  270. extern pascal void SetMCInfo(MCTableHandle menuCTbl)
  271.  ONEWORDINLINE(0xAA62);
  272. extern pascal void DisposeMCInfo(MCTableHandle menuCTbl)
  273.  ONEWORDINLINE(0xAA63);
  274. extern pascal MCEntryPtr GetMCEntry(short menuID, short menuItem)
  275.  ONEWORDINLINE(0xAA64);
  276. extern pascal void SetMCEntries(short numEntries, MCTablePtr menuCEntries)
  277.  ONEWORDINLINE(0xAA65);
  278. extern pascal void InsertFontResMenu(MenuRef theMenu, short afterItem, short scriptFilter)
  279.  THREEWORDINLINE(0x303C, 0x0400, 0xA825);
  280. extern pascal void InsertIntlResMenu(MenuRef theMenu, ResType theType, short afterItem, short scriptFilter)
  281.  THREEWORDINLINE(0x303C, 0x0601, 0xA825);
  282. extern pascal Boolean SystemEdit(short editCmd)
  283.  ONEWORDINLINE(0xA9C2);
  284. extern pascal void SystemMenu(long menuResult)
  285.  ONEWORDINLINE(0xA9B5);
  286. #if CGLUESUPPORTED
  287. extern MenuRef newmenu(short menuID, const char *menuTitle);
  288. extern void appendmenu(MenuRef menu, const char *data);
  289. extern void insertmenuitem(MenuRef theMenu, const char *itemString, short afterItem);
  290. extern long menuselect(const Point *startPt);
  291. extern void setmenuitemtext(MenuRef menu, short item, const char *itemString);
  292. extern void getmenuitemtext(MenuRef menu, short item, char *itemString);
  293. #endif
  294. #if OLDROUTINENAMES
  295. #define AddResMenu(theMenu, theType) AppendResMenu(theMenu, theType)
  296. #define InsMenuItem(theMenu, itemString, afterItem)  \
  297.     InsertMenuItem(theMenu, itemString, afterItem)
  298. #define DelMenuItem(theMenu, item) DeleteMenuItem(theMenu, item)
  299. #define SetItem(theMenu, item, itemString) SetMenuItemText(theMenu, item, itemString)
  300. #define GetItem(theMenu, item, itemString) GetMenuItemText(theMenu, item, itemString)
  301. #define GetMHandle(menuID) GetMenuHandle(menuID)
  302. #define DelMCEntries(menuID, menuItem) DeleteMCEntries(menuID, menuItem)
  303. #define DispMCInfo(menuCTbl) DisposeMCInfo(menuCTbl)
  304. #if CGLUESUPPORTED
  305. #define addresmenu(menu, data) appendresmenu(menu, data)
  306. #define getitem(menu, item, itemString) getmenuitemtext(menu, item, itemString)
  307. #define setitem(menu, item, itemString) setmenuitemtext(menu, item, itemString)
  308. #define insmenuitem(theMenu, itemString, afterItem)  \
  309.     insertmenuitem(theMenu, itemString, afterItem)
  310. #endif
  311. #endif
  312.  
  313. #ifdef __CFM68K__
  314. #pragma lib_export off
  315. #endif
  316.  
  317. #if GENERATINGPOWERPC
  318. #pragma options align=reset
  319. #endif
  320.  
  321. #ifdef __cplusplus
  322. }
  323. #endif
  324.  
  325. #endif /* __MENUS__ */
  326.