diff dwt/internal/cocoa/NSFontManager.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSFontManager.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSFontManager.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,341 +1,58 @@
 /*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 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
+ *    IBM Corporation - initial API and implementation
  *     
  * Port to the D programming language:
- *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *    Jacob Carlborg <doob@me.com>
  *******************************************************************************/
 module dwt.internal.cocoa.NSFontManager;
 
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
 import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSFont;
-import dwt.internal.cocoa.NSFontDescriptor;
-import dwt.internal.cocoa.NSFontPanel;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSMenu;
 import dwt.internal.cocoa.NSObject;
 import dwt.internal.cocoa.NSString;
 import dwt.internal.cocoa.OS;
 import objc = dwt.internal.objc.runtime;
 
-alias uint NSFontTraitMask;
+public class NSFontManager : NSObject {
+
+public this() {
+    super();
+}
 
-enum NSFontAction
-{
-    NSNoFontChangeAction = 0,
-    NSViaPanelFontAction = 1,
-    NSAddTraitFontAction = 2,
-    NSSizeUpFontAction = 3,
-    NSSizeDownFontAction = 4,
-    NSHeavierFontAction = 5,
-    NSLighterFontAction = 6,
-    NSRemoveTraitFontAction = 7
+public this(objc.id id) {
+    super(id);
+}
+
+public this(cocoa.id id) {
+    super(id);
 }
 
-public class NSFontManager : NSObject
-{
-
-    public this ()
-    {
-        super();
-    }
-
-    public this (objc.id id)
-    {
-        super(id);
-    }
-
-    public objc.SEL action ()
-    {
-        return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action);
-    }
-
-    public bool addCollection (NSString collectionName, NSInteger collectionOptions)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_addCollection_1options_1, collectionName !is null ? collectionName.id_ : null, collectionOptions) !is null;
-    }
-
-    public void addFontDescriptors (NSArray descriptors, NSString collectionName)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_addFontDescriptors_1toCollection_1, descriptors !is null ? descriptors.id_ : null,
-                collectionName !is null ? collectionName.id_ : null);
-    }
-
-    public void addFontTrait (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_addFontTrait_1, sender !is null ? sender.id_ : null);
-    }
-
-    public NSArray availableFontFamilies ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontFamilies);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray availableFontNamesMatchingFontDescriptor (NSFontDescriptor descriptor)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontNamesMatchingFontDescriptor_1, descriptor !is null ? descriptor.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray availableFontNamesWithTraits (NSFontTraitMask someTraits)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontNamesWithTraits_1, someTraits);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray availableFonts ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFonts);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray availableMembersOfFontFamily (NSString fam)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableMembersOfFontFamily_1, fam !is null ? fam.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray collectionNames ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_collectionNames);
-        return result !is null ? new NSArray(result) : null;
-    }
+public NSArray availableFontFamilies() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFontFamilies);
+    return result !is null ? new NSArray(result) : null;
+}
 
-    public NSDictionary convertAttributes (NSDictionary attributes)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertAttributes_1, attributes !is null ? attributes.id_ : null);
-        return result !is null ? new NSDictionary(result) : null;
-    }
-
-    public NSFont convertFont_ (NSFont fontObj)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1, fontObj !is null ? fontObj.id_ : null);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFont convertFont_toFace_ (NSFont fontObj, NSString typeface)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toFace_1, fontObj !is null ? fontObj.id_ : null,
-                typeface !is null ? typeface.id_ : null);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFont convertFont_toFamily_ (NSFont fontObj, NSString family)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toFamily_1, fontObj !is null ? fontObj.id_ : null,
-                family !is null ? family.id_ : null);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFont convertFont_toHaveTrait_ (NSFont fontObj, NSFontTraitMask trait)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toHaveTrait_1, fontObj !is null ? fontObj.id_ : null, trait);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFont convertFont_toNotHaveTrait_ (NSFont fontObj, NSFontTraitMask trait)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toNotHaveTrait_1, fontObj !is null ? fontObj.id_ : null, trait);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFont convertFont_toSize_ (NSFont fontObj, CGFloat size)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toSize_1, fontObj !is null ? fontObj.id_ : null, size);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFontTraitMask convertFontTraits (NSFontTraitMask traits)
-    {
-        return cast(NSFontTraitMask) OS.objc_msgSend(this.id_, OS.sel_convertFontTraits_1, traits);
-    }
-
-    public NSFont convertWeight (bool upFlag, NSFont fontObj)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertWeight_1ofFont_1, upFlag, fontObj !is null ? fontObj.id_ : null);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSFontAction currentFontAction ()
-    {
-        return cast(NSFontAction) OS.objc_msgSend(this.id_, OS.sel_currentFontAction);
-    }
-
-    public id delegatee ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
-        return result !is null ? new id(result) : null;
-    }
-
-    public NSArray fontDescriptorsInCollection (NSString collectionNames)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontDescriptorsInCollection_1, collectionNames !is null ? collectionNames.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSMenu fontMenu (bool create)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontMenu_1, create);
-        return result !is null ? new NSMenu(result) : null;
-    }
+public NSArray availableFonts() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFonts);
+    return result !is null ? new NSArray(result) : null;
+}
 
-    public bool fontNamed (NSString fName, NSFontTraitMask someTraits)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fontNamed_1hasTraits_1, fName !is null ? fName.id_ : null, someTraits) !is null;
-    }
-
-    public NSFontPanel fontPanel (bool create)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontPanel_1, create);
-        return result !is null ? new NSFontPanel(result) : null;
-    }
-
-    public NSFont fontWithFamily (NSString family, NSFontTraitMask traits, NSInteger weight, CGFloat size)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontWithFamily_1traits_1weight_1size_1, family !is null ? family.id_ : null, traits, weight,
-                size);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public bool isEnabled ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null;
-    }
-
-    public bool isMultiple ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isMultiple) !is null;
-    }
-
-    public NSString localizedNameForFamily (NSString family, NSString faceKey)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedNameForFamily_1face_1, family !is null ? family.id_ : null,
-                faceKey !is null ? faceKey.id_ : null);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public void modifyFont (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_modifyFont_1, sender !is null ? sender.id_ : null);
-    }
-
-    public void modifyFontViaPanel (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_modifyFontViaPanel_1, sender !is null ? sender.id_ : null);
-    }
-
-    public void orderFrontFontPanel (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_orderFrontFontPanel_1, sender !is null ? sender.id_ : null);
-    }
-
-    public void orderFrontStylesPanel (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_orderFrontStylesPanel_1, sender !is null ? sender.id_ : null);
-    }
-
-    public bool removeCollection (NSString collectionName)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_removeCollection_1, collectionName !is null ? collectionName.id_ : null) !is null;
-    }
-
-    public void removeFontDescriptor (NSFontDescriptor descriptor, NSString collection)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_removeFontDescriptor_1fromCollection_1, descriptor !is null ? descriptor.id_ : null,
-                collection !is null ? collection.id_ : null);
-    }
-
-    public void removeFontTrait (id sender)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_removeFontTrait_1, sender !is null ? sender.id_ : null);
-    }
+public NSArray availableMembersOfFontFamily(NSString fam) {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_availableMembersOfFontFamily_, fam !is null ? fam.id : null);
+    return result !is null ? new NSArray(result) : null;
+}
 
-    public NSFont selectedFont ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedFont);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public bool sendAction ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_sendAction) !is null;
-    }
-
-    public void setAction (objc.SEL aSelector)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
-    }
-
-    public void setDelegate (id anObject)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
-    }
-
-    public void setEnabled (bool flag)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag);
-    }
-
-    public static void setFontManagerFactory (objc.Class factoryId)
-    {
-        OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontManagerFactory_1, factoryId);
-    }
-
-    public void setFontMenu (NSMenu newMenu)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setFontMenu_1, newMenu !is null ? newMenu.id_ : null);
-    }
-
-    public static void setFontPanelFactory (objc.Class factoryId)
-    {
-        OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontPanelFactory_1, factoryId);
-    }
-
-    public void setSelectedAttributes (NSDictionary attributes, bool flag)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setSelectedAttributes_1isMultiple_1, attributes !is null ? attributes.id_ : null, flag);
-    }
-
-    public void setSelectedFont (NSFont fontObj, bool flag)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setSelectedFont_1isMultiple_1, fontObj !is null ? fontObj.id_ : null, flag);
-    }
-
-    public void setTarget (id aTarget)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setTarget_1, aTarget !is null ? aTarget.id_ : null);
-    }
-
-    public static NSFontManager sharedFontManager ()
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFontManager, OS.sel_sharedFontManager);
-        return result !is null ? new NSFontManager(result) : null;
-    }
-
-    public id target ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_target);
-        return result !is null ? new id(result) : null;
-    }
-
-    public NSFontTraitMask traitsOfFont (NSFont fontObj)
-    {
-        return cast(NSFontTraitMask) OS.objc_msgSend(this.id_, OS.sel_traitsOfFont_1, fontObj !is null ? fontObj.id_ : null);
-    }
-
-    public NSInteger weightOfFont (NSFont fontObj)
-    {
-        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_weightOfFont_1, fontObj !is null ? fontObj.id_ : null);
-    }
+public static NSFontManager sharedFontManager() {
+    objc.id result = OS.objc_msgSend(OS.class_NSFontManager, OS.sel_sharedFontManager);
+    return result !is null ? new NSFontManager(result) : null;
+}
 
 }