Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSMenu.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSMenu.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,350 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSMenu; + +import dwt.internal.cocoa.CGFloat; +import dwt.internal.cocoa.id; +import dwt.internal.cocoa.NSArray; +import dwt.internal.cocoa.NSEvent; +import dwt.internal.cocoa.NSFont; +import dwt.internal.cocoa.NSInteger; +import dwt.internal.cocoa.NSMenuItem; +import dwt.internal.cocoa.NSObject; +import dwt.internal.cocoa.NSPoint; +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.NSView; +import dwt.internal.cocoa.NSZone; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +public class NSMenu : NSObject +{ + + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public void addItem (NSMenuItem newItem) + { + OS.objc_msgSend(this.id, OS.sel_addItem_1, newItem !is null ? newItem.id : null); + } + + public NSMenuItem addItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_addItemWithTitle_1action_1keyEquivalent_1, aString !is null ? aString.id : null, aSelector, + charCode !is null ? charCode.id : null); + return result !is null ? new NSMenuItem(result) : null; + } + + public NSMenu attachedMenu () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenu); + return result is this.id ? this : (result !is null ? new NSMenu(result) : null); + } + + public bool autoenablesItems () + { + return OS.objc_msgSend(this.id, OS.sel_autoenablesItems) !is null; + } + + public void cancelTracking () + { + OS.objc_msgSend(this.id, OS.sel_cancelTracking); + } + + public id contextMenuRepresentation () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_contextMenuRepresentation); + return result !is null ? new id(result) : null; + } + + public id delegatee () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate); + return result !is null ? new id(result) : null; + } + + public void helpRequested (NSEvent eventPtr) + { + OS.objc_msgSend(this.id, OS.sel_helpRequested_1, eventPtr !is null ? eventPtr.id : null); + } + + public NSMenuItem highlightedItem () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightedItem); + return result !is null ? new NSMenuItem(result) : null; + } + + public NSInteger indexOfItem (NSMenuItem index) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItem_1, index !is null ? index.id : null); + } + + public NSInteger indexOfItemWithRepresentedObject (id object) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithRepresentedObject_1, object !is null ? object.id : null); + } + + public NSInteger indexOfItemWithSubmenu (NSMenu submenu) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithSubmenu_1, submenu !is null ? submenu.id : null); + } + + public NSInteger indexOfItemWithTag (NSInteger aTag) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTag_1, aTag); + } + + public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id : null, actionSelector); + } + + public NSInteger indexOfItemWithTitle (NSString aTitle) + { + return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTitle_1, aTitle !is null ? aTitle.id : null); + } + + public NSMenu initWithTitle (NSString aTitle) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTitle_1, aTitle !is null ? aTitle.id : null); + return result !is null ? this : null; + } + + public void insertItem (NSMenuItem newItem, NSInteger index) + { + OS.objc_msgSend(this.id, OS.sel_insertItem_1atIndex_1, newItem !is null ? newItem.id : null, index); + } + + public NSMenuItem insertItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode, NSInteger index) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_insertItemWithTitle_1action_1keyEquivalent_1atIndex_1, aString !is null ? aString.id : null, + aSelector, charCode !is null ? charCode.id : null, index); + return result !is null ? new NSMenuItem(result) : null; + } + + public bool isAttached () + { + return OS.objc_msgSend(this.id, OS.sel_isAttached) !is null; + } + + public bool isTornOff () + { + return OS.objc_msgSend(this.id, OS.sel_isTornOff) !is null; + } + + public NSArray itemArray () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_itemArray); + return result !is null ? new NSArray(result) : null; + } + + public NSMenuItem itemAtIndex (NSInteger index) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_1, index); + return result !is null ? new NSMenuItem(result) : null; + } + + public void itemChanged (NSMenuItem item) + { + OS.objc_msgSend(this.id, OS.sel_itemChanged_1, item !is null ? item.id : null); + } + + public NSMenuItem itemWithTag (NSInteger tag) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTag_1, tag); + return result !is null ? new NSMenuItem(result) : null; + } + + public NSMenuItem itemWithTitle (NSString aTitle) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTitle_1, aTitle !is null ? aTitle.id : null); + return result !is null ? new NSMenuItem(result) : null; + } + + public NSPoint locationForSubmenu (NSMenu aSubmenu) + { + NSPoint result; + OS.objc_msgSend_stret(result, this.id, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id : null); + return result; + } + + public CGFloat menuBarHeight () + { + return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_menuBarHeight); + } + + public static bool menuBarVisible () + { + return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuBarVisible) !is null; + } + + public bool menuChangedMessagesEnabled () + { + return OS.objc_msgSend(this.id, OS.sel_menuChangedMessagesEnabled) !is null; + } + + public id menuRepresentation () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_menuRepresentation); + return result !is null ? new id(result) : null; + } + + public static NSZone* menuZone () + { + return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuZone); + } + + public NSInteger numberOfItems () + { + return OS.objc_msgSend(this.id, OS.sel_numberOfItems); + } + + public void performActionForItemAtIndex (NSInteger index) + { + OS.objc_msgSend(this.id, OS.sel_performActionForItemAtIndex_1, index); + } + + public bool performKeyEquivalent (NSEvent theEvent) + { + return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null; + } + + public static void static_popUpContextMenu_withEvent_forView_ (NSMenu menu, NSEvent event, NSView view) + { + OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1, menu !is null ? menu.id : null, + event !is null ? event.id : null, view !is null ? view.id : null); + } + + public static void static_popUpContextMenu_withEvent_forView_withFont_ (NSMenu menu, NSEvent event, NSView view, NSFont font) + { + OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1withFont_1, menu !is null ? menu.id : null, + event !is null ? event.id : null, view !is null ? view.id : null, font !is null ? font.id : null); + } + + public void removeItem (NSMenuItem item) + { + OS.objc_msgSend(this.id, OS.sel_removeItem_1, item !is null ? item.id : null); + } + + public void removeItemAtIndex (NSInteger index) + { + OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index); + } + + public void setAutoenablesItems (bool flag) + { + OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_1, flag); + } + + public void setContextMenuRepresentation (id menuRep) + { + OS.objc_msgSend(this.id, OS.sel_setContextMenuRepresentation_1, menuRep !is null ? menuRep.id : null); + } + + public void setDelegate (id anObject) + { + OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null); + } + + public static void setMenuBarVisible (bool visible) + { + OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuBarVisible_1, visible); + } + + public void setMenuChangedMessagesEnabled (bool flag) + { + OS.objc_msgSend(this.id, OS.sel_setMenuChangedMessagesEnabled_1, flag); + } + + public void setMenuRepresentation (id menuRep) + { + OS.objc_msgSend(this.id, OS.sel_setMenuRepresentation_1, menuRep !is null ? menuRep.id : null); + } + + public static void setMenuZone (NSZone* aZone) + { + OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuZone_1, aZone); + } + + public void setShowsStateColumn (bool showsState) + { + OS.objc_msgSend(this.id, OS.sel_setShowsStateColumn_1, showsState); + } + + public void setSubmenu (NSMenu aMenu, NSMenuItem anItem) + { + OS.objc_msgSend(this.id, OS.sel_setSubmenu_1forItem_1, aMenu !is null ? aMenu.id : null, anItem !is null ? anItem.id : null); + } + + public void setSupermenu (NSMenu supermenu) + { + OS.objc_msgSend(this.id, OS.sel_setSupermenu_1, supermenu !is null ? supermenu.id : null); + } + + public void setTearOffMenuRepresentation (id menuRep) + { + OS.objc_msgSend(this.id, OS.sel_setTearOffMenuRepresentation_1, menuRep !is null ? menuRep.id : null); + } + + public void setTitle (NSString aString) + { + OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null); + } + + public bool showsStateColumn () + { + return OS.objc_msgSend(this.id, OS.sel_showsStateColumn) !is null; + } + + public void sizeToFit () + { + OS.objc_msgSend(this.id, OS.sel_sizeToFit); + } + + public void submenuAction (id sender) + { + OS.objc_msgSend(this.id, OS.sel_submenuAction_1, sender !is null ? sender.id : null); + } + + public NSMenu supermenu () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_supermenu); + return result is this.id ? this : (result !is null ? new NSMenu(result) : null); + } + + public id tearOffMenuRepresentation () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_tearOffMenuRepresentation); + return result !is null ? new id(result) : null; + } + + public NSString title () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_title); + return result !is null ? new NSString(result) : null; + } + + public void update () + { + OS.objc_msgSend(this.id, OS.sel_update); + } + +}