diff dstep/appkit/NSFontManager.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 f8a3b67adfcb
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/appkit/NSFontManager.d	Sun Jan 03 22:06:11 2010 +0100
@@ -0,0 +1,393 @@
+/**
+ * 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.NSFontManager;
+
+import dstep.appkit.NSFont;
+import dstep.appkit.NSFontDescriptor;
+import dstep.appkit.NSFontPanel;
+import dstep.appkit.NSMenu;
+import dstep.applicationservices.coregraphics.CGBase;
+import dstep.foundation.NSArray;
+import dstep.foundation.NSDictionary;
+import dstep.foundation.NSGeometry;
+import dstep.foundation.NSObjCRuntime;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSString;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc;
+
+typedef NSUInteger NSFontTraitMask;
+typedef NSUInteger NSFontAction;
+
+enum
+{
+	NSItalicFontMask = 0x00000001,
+	NSBoldFontMask = 0x00000002,
+	NSUnboldFontMask = 0x00000004,
+	NSNonStandardCharacterSetFontMask = 0x00000008,
+	NSNarrowFontMask = 0x00000010,
+	NSExpandedFontMask = 0x00000020,
+	NSCondensedFontMask = 0x00000040,
+	NSSmallCapsFontMask = 0x00000080,
+	NSPosterFontMask = 0x00000100,
+	NSCompressedFontMask = 0x00000200,
+	NSFixedPitchFontMask = 0x00000400,
+	NSUnitalicFontMask = 0x01000000
+}
+
+enum
+{
+	NSFontCollectionApplicationOnlyMask = 1 << 0
+}
+
+enum
+{
+	NSNoFontChangeAction = 0,
+	NSViaPanelFontAction = 1,
+	NSAddTraitFontAction = 2,
+	NSSizeUpFontAction = 3,
+	NSSizeDownFontAction = 4,
+	NSHeavierFontAction = 5,
+	NSLighterFontAction = 6,
+	NSRemoveTraitFontAction = 7
+}
+
+const TNSFontManagerMenuActionMethods = `
+
+	bool fontNamed (NSString fName, uint someTraits)
+	{
+		return invokeObjcSelf!(bool, "fontNamed:hasTraits:", NSString, uint)(fName, someTraits);
+	}
+
+	NSArray availableFontNamesWithTraits (uint someTraits)
+	{
+		return invokeObjcSelf!(NSArray, "availableFontNamesWithTraits:", uint)(someTraits);
+	}
+
+	void addFontTrait (Object sender)
+	{
+		return invokeObjcSelf!(void, "addFontTrait:", Object)(sender);
+	}
+
+	void removeFontTrait (Object sender)
+	{
+		return invokeObjcSelf!(void, "removeFontTrait:", Object)(sender);
+	}
+
+	void modifyFontViaPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "modifyFontViaPanel:", Object)(sender);
+	}
+
+	void modifyFont (Object sender)
+	{
+		return invokeObjcSelf!(void, "modifyFont:", Object)(sender);
+	}
+
+	void orderFrontFontPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "orderFrontFontPanel:", Object)(sender);
+	}
+
+	void orderFrontStylesPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "orderFrontStylesPanel:", Object)(sender);
+	}
+
+	//mixin ObjcBindMethod!(fontNamed, "fontNamed:hasTraits:");
+	//mixin ObjcBindMethod!(availableFontNamesWithTraits, "availableFontNamesWithTraits:");
+	//mixin ObjcBindMethod!(addFontTrait, "addFontTrait:");
+	//mixin ObjcBindMethod!(removeFontTrait, "removeFontTrait:");
+	//mixin ObjcBindMethod!(modifyFontViaPanel, "modifyFontViaPanel:");
+	//mixin ObjcBindMethod!(modifyFont, "modifyFont:");
+	//mixin ObjcBindMethod!(orderFrontFontPanel, "orderFrontFontPanel:");
+	//mixin ObjcBindMethod!(orderFrontStylesPanel, "orderFrontStylesPanel:");
+
+`;
+
+const TNSFontManagerResponderMethod = `
+
+	void changeFont (Object sender)
+	{
+		return invokeObjcSelf!(void, "changeFont:", Object)(sender);
+	}
+
+	//mixin ObjcBindMethod!(changeFont, "changeFont:");
+
+`;
+
+const TNSFontManagerDelegate = `
+
+	bool fontManager (Object sender, NSString fontName)
+	{
+		return invokeObjcSelf!(bool, "fontManager:willIncludeFont:", Object, NSString)(sender, fontName);
+	}
+
+	//mixin ObjcBindMethod!(fontManager, "fontManager:willIncludeFont:");
+
+`;
+
+class NSFontManager : NSObject
+{
+	mixin (ObjcWrap);
+
+	static void setFontPanelFactory (Class factoryId)
+	{
+		return invokeObjcSelfClass!(void, "setFontPanelFactory:", Class)(factoryId);
+	}
+
+	static void setFontManagerFactory (Class factoryId)
+	{
+		return invokeObjcSelfClass!(void, "setFontManagerFactory:", Class)(factoryId);
+	}
+
+	static NSFontManager sharedFontManager ()
+	{
+		return invokeObjcSelfClass!(NSFontManager, "sharedFontManager");
+	}
+
+	bool isMultiple ()
+	{
+		return invokeObjcSelf!(bool, "isMultiple");
+	}
+
+	NSFont selectedFont ()
+	{
+		return invokeObjcSelf!(NSFont, "selectedFont");
+	}
+
+	void setSelectedFont (NSFont fontObj, bool flag)
+	{
+		return invokeObjcSelf!(void, "setSelectedFont:isMultiple:", NSFont, bool)(fontObj, flag);
+	}
+
+	void setFontMenu (NSMenu newMenu)
+	{
+		return invokeObjcSelf!(void, "setFontMenu:", NSMenu)(newMenu);
+	}
+
+	NSMenu fontMenu (bool create)
+	{
+		return invokeObjcSelf!(NSMenu, "fontMenu:", bool)(create);
+	}
+
+	NSFontPanel fontPanel (bool create)
+	{
+		return invokeObjcSelf!(NSFontPanel, "fontPanel:", bool)(create);
+	}
+
+	NSFont fontWithFamily (NSString family, uint traits, NSInteger weight, CGFloat size)
+	{
+		return invokeObjcSelf!(NSFont, "fontWithFamily:traits:weight:size:", NSString, uint, NSInteger, CGFloat)(family, traits, weight, size);
+	}
+
+	uint traitsOfFont (NSFont fontObj)
+	{
+		return invokeObjcSelf!(uint, "traitsOfFont:", NSFont)(fontObj);
+	}
+
+	NSInteger weightOfFont (NSFont fontObj)
+	{
+		return invokeObjcSelf!(NSInteger, "weightOfFont:", NSFont)(fontObj);
+	}
+
+	NSArray availableFonts ()
+	{
+		return invokeObjcSelf!(NSArray, "availableFonts");
+	}
+
+	NSArray availableFontFamilies ()
+	{
+		return invokeObjcSelf!(NSArray, "availableFontFamilies");
+	}
+
+	NSArray availableMembersOfFontFamily (NSString fam)
+	{
+		return invokeObjcSelf!(NSArray, "availableMembersOfFontFamily:", NSString)(fam);
+	}
+
+	NSFont convertFont (NSFont fontObj)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:", NSFont)(fontObj);
+	}
+
+	NSFont convertFont (NSFont fontObj, CGFloat size)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:toSize:", NSFont, CGFloat)(fontObj, size);
+	}
+
+	NSFont convertFont (NSFont fontObj, NSString typeface)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:toFace:", NSFont, NSString)(fontObj, typeface);
+	}
+
+	NSFont convertFont (NSFont fontObj, NSString family)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:toFamily:", NSFont, NSString)(fontObj, family);
+	}
+
+	NSFont convertFont (NSFont fontObj, uint trait)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:toHaveTrait:", NSFont, uint)(fontObj, trait);
+	}
+
+	NSFont convertFont (NSFont fontObj, uint trait)
+	{
+		return invokeObjcSelf!(NSFont, "convertFont:toNotHaveTrait:", NSFont, uint)(fontObj, trait);
+	}
+
+	NSFont convertWeight (bool upFlag, NSFont fontObj)
+	{
+		return invokeObjcSelf!(NSFont, "convertWeight:ofFont:", bool, NSFont)(upFlag, fontObj);
+	}
+
+	bool isEnabled ()
+	{
+		return invokeObjcSelf!(bool, "isEnabled");
+	}
+
+	void setEnabled (bool flag)
+	{
+		return invokeObjcSelf!(void, "setEnabled:", bool)(flag);
+	}
+
+	SEL action ()
+	{
+		return invokeObjcSelf!(SEL, "action");
+	}
+
+	void setAction (SEL aSelector)
+	{
+		return invokeObjcSelf!(void, "setAction:", SEL)(aSelector);
+	}
+
+	bool sendAction ()
+	{
+		return invokeObjcSelf!(bool, "sendAction");
+	}
+
+	void setDelegate (Object anObject)
+	{
+		return invokeObjcSelf!(void, "setDelegate:", Object)(anObject);
+	}
+
+	Object delegate_ ()
+	{
+		return invokeObjcSelf!(Object, "delegate");
+	}
+
+	NSString localizedNameForFamily (NSString family, NSString faceKey)
+	{
+		return invokeObjcSelf!(NSString, "localizedNameForFamily:face:", NSString, NSString)(family, faceKey);
+	}
+
+	void setSelectedAttributes (NSDictionary attributes, bool flag)
+	{
+		return invokeObjcSelf!(void, "setSelectedAttributes:isMultiple:", NSDictionary, bool)(attributes, flag);
+	}
+
+	NSDictionary convertAttributes (NSDictionary attributes)
+	{
+		return invokeObjcSelf!(NSDictionary, "convertAttributes:", NSDictionary)(attributes);
+	}
+
+	NSArray availableFontNamesMatchingFontDescriptor (NSFontDescriptor descriptor)
+	{
+		return invokeObjcSelf!(NSArray, "availableFontNamesMatchingFontDescriptor:", NSFontDescriptor)(descriptor);
+	}
+
+	NSArray collectionNames ()
+	{
+		return invokeObjcSelf!(NSArray, "collectionNames");
+	}
+
+	NSArray fontDescriptorsInCollection (NSString collectionNames)
+	{
+		return invokeObjcSelf!(NSArray, "fontDescriptorsInCollection:", NSString)(collectionNames);
+	}
+
+	bool addCollection (NSString collectionName, NSInteger collectionOptions)
+	{
+		return invokeObjcSelf!(bool, "addCollection:options:", NSString, NSInteger)(collectionName, collectionOptions);
+	}
+
+	bool removeCollection (NSString collectionName)
+	{
+		return invokeObjcSelf!(bool, "removeCollection:", NSString)(collectionName);
+	}
+
+	void addFontDescriptors (NSArray descriptors, NSString collectionName)
+	{
+		return invokeObjcSelf!(void, "addFontDescriptors:toCollection:", NSArray, NSString)(descriptors, collectionName);
+	}
+
+	void removeFontDescriptor (NSFontDescriptor descriptor, NSString collection)
+	{
+		return invokeObjcSelf!(void, "removeFontDescriptor:fromCollection:", NSFontDescriptor, NSString)(descriptor, collection);
+	}
+
+	uint currentFontAction ()
+	{
+		return invokeObjcSelf!(uint, "currentFontAction");
+	}
+
+	uint convertFontTraits (uint traits)
+	{
+		return invokeObjcSelf!(uint, "convertFontTraits:", uint)(traits);
+	}
+
+	void setTarget (Object aTarget)
+	{
+		return invokeObjcSelf!(void, "setTarget:", Object)(aTarget);
+	}
+
+	Object target ()
+	{
+		return invokeObjcSelf!(Object, "target");
+	}
+	
+	// NSFontManagerMenuActionMethods
+	bool fontNamed (NSString fName, uint someTraits)
+	{
+		return invokeObjcSelf!(bool, "fontNamed:hasTraits:", NSString, uint)(fName, someTraits);
+	}
+
+	NSArray availableFontNamesWithTraits (uint someTraits)
+	{
+		return invokeObjcSelf!(NSArray, "availableFontNamesWithTraits:", uint)(someTraits);
+	}
+
+	void addFontTrait (Object sender)
+	{
+		return invokeObjcSelf!(void, "addFontTrait:", Object)(sender);
+	}
+
+	void removeFontTrait (Object sender)
+	{
+		return invokeObjcSelf!(void, "removeFontTrait:", Object)(sender);
+	}
+
+	void modifyFontViaPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "modifyFontViaPanel:", Object)(sender);
+	}
+
+	void modifyFont (Object sender)
+	{
+		return invokeObjcSelf!(void, "modifyFont:", Object)(sender);
+	}
+
+	void orderFrontFontPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "orderFrontFontPanel:", Object)(sender);
+	}
+
+	void orderFrontStylesPanel (Object sender)
+	{
+		return invokeObjcSelf!(void, "orderFrontStylesPanel:", Object)(sender);
+	}
+}
\ No newline at end of file