1{ Parsed from AppKit.framework NSMenu.h }
2
3
4{$ifdef TYPES}
5type
6  NSMenuPtr = ^NSMenu;
7  NSMenuDelegateProtocolPtr = ^NSMenuDelegateProtocol;
8{$endif}
9
10{$ifdef CLASSES}
11
12type
13  NSMenu = objcclass external (NSObject, NSCopyingProtocol, NSCodingProtocol)
14  private
15    _supermenu: NSMenu;
16    _title: NSString;
17    _itemArray: id;
18    _extra: id;
19    _mFlags: bitpacked record
20      case byte of
21        0: (_anonBitField__mFlags0: cuint);
22        1: (
23          noAutoenable: 0..1;
24          inMain: 0..1;
25          internalPerformAction: 0..1;
26          condenseSeparators: 0..1;
27          disabled: 0..1;
28          ownedByPopUp: 0..1;
29          delegateNeedsUpdate: 0..1;
30          delegateUpdateItem: 0..1;
31          delegateHasKeyEquiv: 0..1;
32          delegateHasAltKeyEquiv: 0..1;
33          excludeMarkColumn: 0..1;
34          isContextualMenu: 0..1;
35          cmPluginMode: 0..((1 shl 2)-1);
36          invertedCMPluginTypes: 0..((1 shl 2)-1);
37          allowsDifferentSelection: 0..1;
38          noTopPadding: 0..1;
39          noBottomPadding: 0..1;
40          hasNCStyle: 0..1;
41          RESERVED: 0..((1 shl 12)-1);
42        );
43      end;
44    _uiid: NSString;
45  public
46    function initWithTitle (aTitle: NSString): instancetype; message 'initWithTitle:';
47    procedure setTitle(newValue: NSString); message 'setTitle:';
48    function title: NSString; message 'title';
49    class procedure popUpContextMenu_withEvent_forView (menu: NSMenu; event: NSEvent; view: NSView); message 'popUpContextMenu:withEvent:forView:';
50    class procedure popUpContextMenu_withEvent_forView_withFont (menu: NSMenu; event: NSEvent; view: NSView; font: NSFont); message 'popUpContextMenu:withEvent:forView:withFont:';
51    function popUpMenuPositioningItem_atLocation_inView (item: NSMenuItem; location: NSPoint; view: NSView): ObjCBOOL; message 'popUpMenuPositioningItem:atLocation:inView:'; { available in 10_6 }
52    class procedure setMenuBarVisible (visible: ObjCBOOL); message 'setMenuBarVisible:';
53    class function menuBarVisible: ObjCBOOL; message 'menuBarVisible';
54    procedure setSupermenu(newValue: NSMenu); message 'setSupermenu:';
55    function supermenu: NSMenu; message 'supermenu';
56    procedure insertItem_atIndex (newItem: NSMenuItem; index: NSInteger); message 'insertItem:atIndex:';
57    procedure addItem (newItem: NSMenuItem); message 'addItem:';
58    function insertItemWithTitle_action_keyEquivalent_atIndex (aString: NSString; aSelector: SEL; charCode: NSString; index: NSInteger): NSMenuItem; message 'insertItemWithTitle:action:keyEquivalent:atIndex:';
59    function addItemWithTitle_action_keyEquivalent (aString: NSString; aSelector: SEL; charCode: NSString): NSMenuItem; message 'addItemWithTitle:action:keyEquivalent:';
60    procedure removeItemAtIndex (index: NSInteger); message 'removeItemAtIndex:';
61    procedure removeItem (item: NSMenuItem); message 'removeItem:';
62    procedure setSubmenu_forItem (aMenu: NSMenu; anItem: NSMenuItem); message 'setSubmenu:forItem:';
63    procedure removeAllItems; message 'removeAllItems'; { available in 10_6 }
64    function itemArray: NSArray; message 'itemArray';
65    function numberOfItems: NSInteger; message 'numberOfItems';
66    function itemAtIndex (index: NSInteger): NSMenuItem; message 'itemAtIndex:';
67    function indexOfItem (index: NSMenuItem): NSInteger; message 'indexOfItem:';
68    function indexOfItemWithTitle (aTitle: NSString): NSInteger; message 'indexOfItemWithTitle:';
69    function indexOfItemWithTag (aTag: NSInteger): NSInteger; message 'indexOfItemWithTag:';
70    function indexOfItemWithRepresentedObject (object_: id): NSInteger; message 'indexOfItemWithRepresentedObject:';
71    function indexOfItemWithSubmenu (submenu: NSMenu): NSInteger; message 'indexOfItemWithSubmenu:';
72    function indexOfItemWithTarget_andAction (target: id; actionSelector: SEL): NSInteger; message 'indexOfItemWithTarget:andAction:';
73    function itemWithTitle (aTitle: NSString): NSMenuItem; message 'itemWithTitle:';
74    function itemWithTag (tag: NSInteger): NSMenuItem; message 'itemWithTag:';
75    procedure setAutoenablesItems(newValue: ObjCBOOL); message 'setAutoenablesItems:';
76    function autoenablesItems: ObjCBOOL; message 'autoenablesItems';
77    procedure update; message 'update';
78    function performKeyEquivalent (theEvent: NSEvent): ObjCBOOL; message 'performKeyEquivalent:';
79    procedure itemChanged (item: NSMenuItem); message 'itemChanged:';
80    procedure performActionForItemAtIndex (index: NSInteger); message 'performActionForItemAtIndex:';
81    procedure setDelegate(newValue: NSMenuDelegateProtocol); message 'setDelegate:';
82    function delegate: NSMenuDelegateProtocol; message 'delegate';
83    function menuBarHeight: CGFloat; message 'menuBarHeight';
84    procedure cancelTracking; message 'cancelTracking'; { available in 10_5 }
85    procedure cancelTrackingWithoutAnimation; message 'cancelTrackingWithoutAnimation'; { available in 10_6 }
86    function highlightedItem: NSMenuItem; message 'highlightedItem';
87    procedure setMinimumWidth(newValue: CGFloat); message 'setMinimumWidth:';
88    function minimumWidth: CGFloat; message 'minimumWidth';
89    function size: NSSize; message 'size';
90    procedure setFont(newValue: NSFont); message 'setFont:';
91    function font: NSFont; message 'font';
92    procedure setAllowsContextMenuPlugIns(newValue: ObjCBOOL); message 'setAllowsContextMenuPlugIns:';
93    function allowsContextMenuPlugIns: ObjCBOOL; message 'allowsContextMenuPlugIns';
94    procedure setShowsStateColumn(newValue: ObjCBOOL); message 'setShowsStateColumn:';
95    function showsStateColumn: ObjCBOOL; message 'showsStateColumn';
96    class function menuZone: NSZonePtr; message 'menuZone';
97    procedure setMenuChangedMessagesEnabled(newValue: ObjCBOOL); message 'setMenuChangedMessagesEnabled:';
98    function menuChangedMessagesEnabled: ObjCBOOL; message 'menuChangedMessagesEnabled';
99    procedure helpRequested (eventPtr: NSEvent); message 'helpRequested:';
100    function isTornOff: ObjCBOOL; message 'isTornOff';
101
102    { Adopted protocols }
103    function copyWithZone (zone: NSZonePtr): id; message 'copyWithZone:';
104    procedure encodeWithCoder (aCoder: NSCoder); message 'encodeWithCoder:';
105    function initWithCoder (aDecoder: NSCoder): id; message 'initWithCoder:';
106  end;
107
108
109type
110  NSSubmenuAction = objccategory external (NSMenu)
111    procedure submenuAction (sender: id); message 'submenuAction:';
112  end;
113
114type
115  NSMenuValidation = objccategory external (NSObject)
116    function validateMenuItem (menuItem: NSMenuItem): ObjCBOOL; message 'validateMenuItem:';
117  end;
118{$endif}
119
120{$ifdef PROTOCOLS}
121
122type
123  NSMenuDelegateProtocol = objcprotocol external name 'NSMenuDelegate' (NSObjectProtocol)
124  optional
125    procedure menuNeedsUpdate (menu: NSMenu); message 'menuNeedsUpdate:';
126    function numberOfItemsInMenu (menu: NSMenu): NSInteger; message 'numberOfItemsInMenu:';
127    function menu_updateItem_atIndex_shouldCancel (menu: NSMenu; item: NSMenuItem; index: NSInteger; shouldCancel: ObjCBOOL): ObjCBOOL; message 'menu:updateItem:atIndex:shouldCancel:';
128    function menuHasKeyEquivalent_forEvent_target_action (menu: NSMenu; event: NSEvent; target: idPtr; action: SELPtr): ObjCBOOL; message 'menuHasKeyEquivalent:forEvent:target:action:';
129    procedure menuWillOpen (menu: NSMenu); message 'menuWillOpen:'; { available in 10_5 }
130    procedure menuDidClose (menu: NSMenu); message 'menuDidClose:'; { available in 10_5 }
131    procedure menu_willHighlightItem (menu: NSMenu; item: NSMenuItem); message 'menu:willHighlightItem:'; { available in 10_5 }
132    function confinementRectForMenu_onScreen (menu: NSMenu; screen: NSScreen): NSRect; message 'confinementRectForMenu:onScreen:'; { available in 10_6 }
133  end;
134{$endif}
135
136{$ifdef TYPES}
137type
138  NSMenuProperties = NSUInteger;
139  NSMenuPropertiesPtr = ^NSMenuProperties;
140
141const
142  NSMenuPropertyItemTitle = 1 shl 0;
143  NSMenuPropertyItemAttributedTitle = 1 shl 1;
144  NSMenuPropertyItemKeyEquivalent = 1 shl 2;
145  NSMenuPropertyItemImage = 1 shl 3;
146  NSMenuPropertyItemEnabled = 1 shl 4;
147  NSMenuPropertyItemAccessibilityDescription = 1 shl 5;
148{$endif}
149
150{$ifdef CLASSES}
151
152type
153  NSMenuPropertiesToUpdate = objccategory external (NSMenu)
154    function propertiesToUpdate: NSMenuProperties; message 'propertiesToUpdate';
155  end;
156{$endif}
157
158{$ifdef EXTERNAL_SYMBOLS}
159var
160  NSMenuWillSendActionNotification: NSString; cvar; external;
161  NSMenuDidSendActionNotification: NSString; cvar; external;
162  NSMenuDidAddItemNotification: NSString; cvar; external;
163  NSMenuDidRemoveItemNotification: NSString; cvar; external;
164  NSMenuDidChangeItemNotification: NSString; cvar; external;
165  NSMenuDidBeginTrackingNotification: NSString; cvar; external;
166  NSMenuDidEndTrackingNotification: NSString; cvar; external;
167{$endif}
168
169{$ifdef CLASSES}
170
171type
172  NSMenu_NSDeprecated = objccategory external name 'NSDeprecated' (NSMenu)
173    procedure setMenuRepresentation (menuRep: id); message 'setMenuRepresentation:'; deprecated 'in 10_0, 10_2';
174    function menuRepresentation: id; message 'menuRepresentation'; deprecated 'in 10_0, 10_2';
175    procedure setContextMenuRepresentation (menuRep: id); message 'setContextMenuRepresentation:'; deprecated 'in 10_0, 10_2';
176    function contextMenuRepresentation: id; message 'contextMenuRepresentation'; deprecated 'in 10_0, 10_2';
177    procedure setTearOffMenuRepresentation (menuRep: id); message 'setTearOffMenuRepresentation:'; deprecated 'in 10_0, 10_2';
178    function tearOffMenuRepresentation: id; message 'tearOffMenuRepresentation'; deprecated 'in 10_0, 10_2';
179    class procedure setMenuZone (aZone: NSZonePtr); message 'setMenuZone:'; deprecated 'in 10_0, 10_2';
180    function attachedMenu: NSMenu; message 'attachedMenu'; deprecated 'in 10_0, 10_2';
181    function isAttached: ObjCBOOL; message 'isAttached'; deprecated 'in 10_0, 10_2';
182    procedure sizeToFit; message 'sizeToFit'; deprecated 'in 10_0, 10_2';
183    function locationForSubmenu (aSubmenu: NSMenu): NSPoint; message 'locationForSubmenu:'; deprecated 'in 10_0, 10_2';
184  end;
185{$endif}
186
187