Mercurial > projects > dstep
diff dstep/appkit/NSDrawer.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/appkit/NSDrawer.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,286 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Sep 24, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.appkit.NSDrawer; + +import dstep.appkit.AppKitDefines; +import dstep.appkit.NSResponder; +import dstep.appkit.NSView; +import dstep.appkit.NSWindow; +import dstep.applicationservices.coregraphics.CGBase; +import dstep.corefoundation.CFDate; +import dstep.corefoundation.CFRunLoop; +import dstep.foundation.NSArray; +import dstep.foundation.NSGeometry; +import dstep.foundation.NSLock; +import dstep.foundation.NSNotification; +import dstep.foundation.NSObjCRuntime; +import dstep.foundation.NSObject; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +import bindings = dstep.appkit.NSDrawer_bindings; + +alias NSUInteger NSDrawerState; + +private +{ + NSString NSDrawerWillOpenNotification_; + NSString NSDrawerDidOpenNotification_; + NSString NSDrawerWillCloseNotification_; + NSString NSDrawerDidCloseNotification_; +} + +NSString NSDrawerWillOpenNotification () +{ + if (NSDrawerWillOpenNotification_) + return NSDrawerWillOpenNotification_; + + return NSDrawerWillOpenNotification_ = new NSString(bindings.NSDrawerWillOpenNotification); +} + +NSString NSDrawerDidOpenNotification () +{ + if (NSDrawerDidOpenNotification_) + return NSDrawerDidOpenNotification_; + + return NSDrawerDidOpenNotification_ = new NSString(bindings.NSDrawerDidOpenNotification); +} + +NSString NSDrawerWillCloseNotification () +{ + if (NSDrawerWillCloseNotification_) + return NSDrawerWillCloseNotification_; + + return NSDrawerWillCloseNotification_ = new NSString(bindings.NSDrawerWillCloseNotification); +} + +NSString NSDrawerDidCloseNotification () +{ + if (NSDrawerDidCloseNotification_) + return NSDrawerDidCloseNotification_; + + return NSDrawerDidCloseNotification_ = new NSString(bindings.NSDrawerDidCloseNotification); +} + +enum +{ + NSDrawerClosedState = 0, + NSDrawerOpeningState = 1, + NSDrawerOpenState = 2, + NSDrawerClosingState = 3 +} + +class NSDrawer : NSResponder +{ + mixin (ObjcWrap); + + NSDrawer initWithContentSize (NSSize contentSize, int edge) + { + id result = invokeObjcSelf!(id, "initWithContentSize:preferredEdge:", NSSize, int)(contentSize, edge); + return result is this.objcObject ? this : (result !is null ? new NSDrawer(result) : null); + } + + this (NSSize contentSize, int edge) + { + super(NSDrawer.alloc.initWithContentSize(contentSize, edge).objcObject); + } + + void setParentWindow (NSWindow parent) + { + return invokeObjcSelf!(void, "setParentWindow:", NSWindow)(parent); + } + + NSWindow parentWindow () + { + return invokeObjcSelf!(NSWindow, "parentWindow"); + } + + void setContentView (NSView aView) + { + return invokeObjcSelf!(void, "setContentView:", NSView)(aView); + } + + NSView contentView () + { + return invokeObjcSelf!(NSView, "contentView"); + } + + void setPreferredEdge (int edge) + { + return invokeObjcSelf!(void, "setPreferredEdge:", int)(edge); + } + + int preferredEdge () + { + return invokeObjcSelf!(int, "preferredEdge"); + } + + void setDelegate (Object anObject) + { + return invokeObjcSelf!(void, "setDelegate:", Object)(anObject); + } + + Object delegate_ () + { + return invokeObjcSelf!(Object, "delegate"); + } + + void open () + { + return invokeObjcSelf!(void, "open"); + } + + void openOnEdge (int edge) + { + return invokeObjcSelf!(void, "openOnEdge:", int)(edge); + } + + void close () + { + return invokeObjcSelf!(void, "close"); + } + + void open (Object sender) + { + return invokeObjcSelf!(void, "open:", Object)(sender); + } + + void close (Object sender) + { + return invokeObjcSelf!(void, "close:", Object)(sender); + } + + void toggle (Object sender) + { + return invokeObjcSelf!(void, "toggle:", Object)(sender); + } + + NSInteger state () + { + return invokeObjcSelf!(NSInteger, "state"); + } + + int edge () + { + return invokeObjcSelf!(int, "edge"); + } + + void setContentSize (NSSize size) + { + return invokeObjcSelf!(void, "setContentSize:", NSSize)(size); + } + + NSSize contentSize () + { + return invokeObjcSelf!(NSSize, "contentSize"); + } + + void setMinContentSize (NSSize size) + { + return invokeObjcSelf!(void, "setMinContentSize:", NSSize)(size); + } + + NSSize minContentSize () + { + return invokeObjcSelf!(NSSize, "minContentSize"); + } + + void setMaxContentSize (NSSize size) + { + return invokeObjcSelf!(void, "setMaxContentSize:", NSSize)(size); + } + + NSSize maxContentSize () + { + return invokeObjcSelf!(NSSize, "maxContentSize"); + } + + void setLeadingOffset (CGFloat offset) + { + return invokeObjcSelf!(void, "setLeadingOffset:", CGFloat)(offset); + } + + CGFloat leadingOffset () + { + return invokeObjcSelf!(CGFloat, "leadingOffset"); + } + + void setTrailingOffset (CGFloat offset) + { + return invokeObjcSelf!(void, "setTrailingOffset:", CGFloat)(offset); + } + + CGFloat trailingOffset () + { + return invokeObjcSelf!(CGFloat, "trailingOffset"); + } +} + +const TDrawers = ` + + NSArray drawers () + { + return invokeObjcSelf!(NSArray, "drawers"); + } + + //mixin ObjcBindMethod!(drawers, "drawers"); + +`; + +const TNSDrawerDelegate = ` + + bool drawerShouldOpen (NSDrawer sender) + { + return invokeObjcSelf!(bool, "drawerShouldOpen:", NSDrawer)(sender); + } + + bool drawerShouldClose (NSDrawer sender) + { + return invokeObjcSelf!(bool, "drawerShouldClose:", NSDrawer)(sender); + } + + NSSize drawerWillResizeContents (NSDrawer sender, NSSize contentSize) + { + return invokeObjcSelf!(NSSize, "drawerWillResizeContents:toSize:", NSDrawer, NSSize)(sender, contentSize); + } + + //mixin ObjcBindMethod!(drawerShouldOpen, "drawerShouldOpen:"); + //mixin ObjcBindMethod!(drawerShouldClose, "drawerShouldClose:"); + //mixin ObjcBindMethod!(drawerWillResizeContents, "drawerWillResizeContents:toSize:"); + +`; + +const TNSDrawerNotifications = ` + + void drawerWillOpen (NSNotification notification) + { + return invokeObjcSelf!(void, "drawerWillOpen:", NSNotification)(notification); + } + + void drawerDidOpen (NSNotification notification) + { + return invokeObjcSelf!(void, "drawerDidOpen:", NSNotification)(notification); + } + + void drawerWillClose (NSNotification notification) + { + return invokeObjcSelf!(void, "drawerWillClose:", NSNotification)(notification); + } + + void drawerDidClose (NSNotification notification) + { + return invokeObjcSelf!(void, "drawerDidClose:", NSNotification)(notification); + } + + //mixin ObjcBindMethod!(drawerWillOpen, "drawerWillOpen:"); + //mixin ObjcBindMethod!(drawerDidOpen, "drawerDidOpen:"); + //mixin ObjcBindMethod!(drawerWillClose, "drawerWillClose:"); + //mixin ObjcBindMethod!(drawerDidClose, "drawerDidClose:"); + +`; +