diff dwt/internal/cocoa/NSFont.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 62202ce0039f
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSFont.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSFont.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,474 +1,89 @@
 /*******************************************************************************
- * 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.NSFont;
 
-import dwt.internal.cocoa.CGFloat;
-import dwt.internal.cocoa.id;
-import dwt.internal.cocoa.NSAffineTransform;
-import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSCharacterSet;
-import dwt.internal.cocoa.NSCell : NSControlSize;
-import dwt.internal.cocoa.NSDictionary;
-import dwt.internal.cocoa.NSFontDescriptor;
-import dwt.internal.cocoa.NSGraphicsContext;
-import dwt.internal.cocoa.NSInteger;
+import dwt.dwthelper.utils;
+import dwt.internal.c.Carbon;
+import cocoa = dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCell;
 import dwt.internal.cocoa.NSObject;
-import dwt.internal.cocoa.NSPoint;
-import dwt.internal.cocoa.NSRect;
-import dwt.internal.cocoa.NSSize;
 import dwt.internal.cocoa.NSString;
 import dwt.internal.cocoa.OS;
-//import dwt.internal.objc.foundation.NSGeometry;
 import objc = dwt.internal.objc.runtime;
 
 alias uint NSGlyph;
 
-enum NSMultibyteGlyphPacking
-{
-    NSNativeShortGlyphPacking = 5
+public class NSFont : NSObject {
+
+public this() {
+    super();
+}
+
+public this(objc.id id) {
+    super(id);
+}
+
+public this(cocoa.id id) {
+    super(id);
 }
 
-enum NSGlyphRelation
-{
-    NSGlyphBelow = 1,
-    NSGlyphAbove = 2
+public CGFloat ascender() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_ascender);
+}
+
+public CGFloat descender() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_descender);
 }
 
-enum NSFontRenderingMode
-{
-    NSFontDefaultRenderingMode = 0,
-    NSFontAntialiasedRenderingMode = 1,
-    NSFontIntegerAdvancementsRenderingMode = 2,
-    NSFontAntialiasedIntegerAdvancementsRenderingMode = 3
+public NSString familyName() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_familyName);
+    return result !is null ? new NSString(result) : null;
+}
+
+public NSString fontName() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_fontName);
+    return result !is null ? new NSString(result) : null;
 }
 
-public class NSFont : NSObject
-{
-
-    public this ()
-    {
-        super();
-    }
-
-    public this (objc.id id)
-    {
-        super(id);
-    }
-
-    public NSSize advancementForGlyph (NSGlyph ag)
-    {
-        NSSize result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_advancementForGlyph_1, ag);
-        return result;
-    }
-
-    public NSDictionary afmDictionary ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_afmDictionary);
-        return result !is null ? new NSDictionary(result) : null;
-    }
-
-    public CGFloat ascender ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_ascender);
-    }
-
-    public static NSFont boldSystemFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_boldSystemFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSRect boundingRectForFont ()
-    {
-        NSRect result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_boundingRectForFont);
-        return result;
-    }
-
-    public NSRect boundingRectForGlyph (NSGlyph aGlyph)
-    {
-        NSRect result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_boundingRectForGlyph_1, aGlyph);
-        return result;
-    }
-
-    public CGFloat capHeight ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_capHeight);
-    }
-
-    public static NSFont controlContentFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_controlContentFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSCharacterSet coveredCharacterSet ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_coveredCharacterSet);
-        return result !is null ? new NSCharacterSet(result) : null;
-    }
-
-    public CGFloat defaultLineHeightForFont ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_defaultLineHeightForFont);
-    }
-
-    public CGFloat descender ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_descender);
-    }
-
-    public NSString displayName ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_displayName);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSString encodingScheme ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_encodingScheme);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSString familyName ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_familyName);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSFontDescriptor fontDescriptor ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontDescriptor);
-        return result !is null ? new NSFontDescriptor(result) : null;
-    }
+public static NSFont fontWithName(NSString fontName, float /*double*/ fontSize) {
+    objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithName_size_, fontName !is null ? fontName.id : null, fontSize);
+    return result !is null ? new NSFont(result) : null;
+}
 
-    public NSString fontName ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontName);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public static NSFont static_fontWithDescriptor_size_ (NSFontDescriptor fontDescriptor, CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithDescriptor_1size_1, fontDescriptor !is null ? fontDescriptor.id_ : null,
-                fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont static_fontWithDescriptor_textTransform_ (NSFontDescriptor fontDescriptor, NSAffineTransform textTransform)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithDescriptor_1textTransform_1,
-                fontDescriptor !is null ? fontDescriptor.id_ : null, textTransform !is null ? textTransform.id_ : null);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont static_fontWithName_matrix_ (NSString fontName, CGFloat fontMatrix)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithName_1matrix_1, fontName !is null ? fontName.id_ : null, fontMatrix);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont static_fontWithName_size_ (NSString fontName, CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithName_1size_1, fontName !is null ? fontName.id_ : null, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public void getAdvancements_forGlyphs_count_ (NSSizeArray advancements, /*const*/NSGlyph* glyphs, NSUInteger glyphCount)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_getAdvancements_1forGlyphs_1count_1, advancements, glyphs, glyphCount);
-    }
-
-    public void getAdvancements_forPackedGlyphs_length_ (NSSizeArray advancements, /*const*/void* packedGlyphs, NSUInteger length)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_getAdvancements_1forPackedGlyphs_1length_1, advancements, packedGlyphs, length);
-    }
-
-    public void getBoundingRects (NSRectArray bounds, /*const*/NSGlyph* glyphs, NSUInteger glyphCount)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_getBoundingRects_1forGlyphs_1count_1, bounds, glyphs, glyphCount);
-    }
-
-    public bool glyphIsEncoded (NSGlyph aGlyph)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_glyphIsEncoded_1, aGlyph) !is null;
-    }
+public CGFloat leading() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_leading);
+}
 
-    public NSMultibyteGlyphPacking glyphPacking ()
-    {
-        return cast(NSMultibyteGlyphPacking) OS.objc_msgSend(this.id_, OS.sel_glyphPacking);
-    }
-
-    public NSGlyph glyphWithName (NSString aName)
-    {
-        return cast(NSGlyph) OS.objc_msgSend(this.id_, OS.sel_glyphWithName_1, aName !is null ? aName.id_ : null);
-    }
-
-    public bool isBaseFont ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isBaseFont) !is null;
-    }
-
-    public bool isFixedPitch ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isFixedPitch) !is null;
-    }
-
-    public CGFloat italicAngle ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_italicAngle);
-    }
-
-    public static NSFont labelFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_labelFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static CGFloat labelFontSize ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_labelFontSize);
-    }
-
-    public CGFloat leading ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_leading);
-    }
-
-    public /*const*/CGFloat* matrix ()
-    {
-        return cast(/*const*/CGFloat*) OS.objc_msgSend(this.id_, OS.sel_matrix);
-    }
-
-    public NSSize maximumAdvancement ()
-    {
-        NSSize result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_maximumAdvancement);
-        return result;
-    }
+public CGFloat pointSize() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_pointSize);
+}
 
-    public static NSFont menuBarFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_menuBarFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont menuFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_menuFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont messageFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_messageFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public NSStringEncoding mostCompatibleStringEncoding ()
-    {
-        return cast(NSStringEncoding) OS.objc_msgSend(this.id_, OS.sel_mostCompatibleStringEncoding);
-    }
-
-    public NSUInteger numberOfGlyphs ()
-    {
-        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfGlyphs);
-    }
-
-    public static NSFont paletteFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_paletteFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public CGFloat pointSize ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_pointSize);
-    }
-
-    public NSPoint positionOfGlyph_forCharacter_struckOverRect_ (NSGlyph aGlyph, short aChar, NSRect aRect)
-    {
-        NSPoint result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_positionOfGlyph_1forCharacter_1struckOverRect_1, aGlyph, aChar, aRect);
-        return result;
-    }
-
-    public NSPoint positionOfGlyph_precededByGlyph_isNominal_ (NSGlyph curGlyph, NSGlyph prevGlyph, bool* nominal)
-    {
-        NSPoint result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_positionOfGlyph_1precededByGlyph_1isNominal_1, curGlyph, prevGlyph, nominal);
-        return result;
-    }
-
-    public NSPoint positionOfGlyph_struckOverGlyph_metricsExist_ (NSGlyph curGlyph, NSGlyph prevGlyph, bool* exist)
-    {
-        NSPoint result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_positionOfGlyph_1struckOverGlyph_1metricsExist_1, curGlyph, prevGlyph, exist);
-        return result;
-    }
-
-    public NSPoint positionOfGlyph_struckOverRect_metricsExist_ (NSGlyph aGlyph, NSRect aRect, bool* exist)
-    {
-        NSPoint result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_positionOfGlyph_1struckOverRect_1metricsExist_1, aGlyph, aRect, exist);
-        return result;
-    }
-
-    public NSPoint positionOfGlyph_withRelation_toBaseGlyph_totalAdvancement_metricsExist_ (NSGlyph thisGlyph, NSGlyphRelation rel,
-            NSGlyph baseGlyph, NSSizePointer adv, bool* exist)
-    {
-        NSPoint result;
-        OS.objc_msgSend_stret(&result, this.id_, OS.sel_positionOfGlyph_1withRelation_1toBaseGlyph_1totalAdvancement_1metricsExist_1, thisGlyph, rel,
-                baseGlyph, adv, exist);
-        return result;
-    }
-
-    public NSInteger positionsForCompositeSequence (NSGlyph* someGlyphs, NSInteger numGlyphs, NSPointArray points)
-    {
-        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_positionsForCompositeSequence_1numberOfGlyphs_1pointArray_1, someGlyphs, numGlyphs, points);
-    }
-
-    public static NSArray preferredFontNames ()
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_preferredFontNames);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSFont printerFont ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_printerFont);
-        return result is this.id_ ? this : (result !is null ? new NSFont(result) : null);
-    }
-
-    public NSFontRenderingMode renderingMode ()
-    {
-        return cast(NSFontRenderingMode) OS.objc_msgSend(this.id_, OS.sel_renderingMode);
-    }
-
-    public NSFont screenFont ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_screenFont);
-        return result is this.id_ ? this : (result !is null ? new NSFont(result) : null);
-    }
+public static CGFloat smallSystemFontSize() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_smallSystemFontSize);
+}
 
-    public NSFont screenFontWithRenderingMode (NSFontRenderingMode renderingMode)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_screenFontWithRenderingMode_1, renderingMode);
-        return result is this.id_ ? this : (result !is null ? new NSFont(result) : null);
-    }
-
-    public void set ()
-    {
-        OS.objc_msgSend(this.id_, OS.sel_set);
-    }
-
-    public void setInContext (NSGraphicsContext graphicsContext)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_setInContext_1, graphicsContext !is null ? graphicsContext.id_ : null);
-    }
-
-    public static void setPreferredFontNames (NSArray fontNameArray)
-    {
-        OS.objc_msgSend(OS.class_NSFont, OS.sel_setPreferredFontNames_1, fontNameArray !is null ? fontNameArray.id_ : null);
-    }
-
-    public static void setUserFixedPitchFont (NSFont aFont)
-    {
-        OS.objc_msgSend(OS.class_NSFont, OS.sel_setUserFixedPitchFont_1, aFont !is null ? aFont.id_ : null);
-    }
-
-    public static void setUserFont (NSFont aFont)
-    {
-        OS.objc_msgSend(OS.class_NSFont, OS.sel_setUserFont_1, aFont !is null ? aFont.id_ : null);
-    }
-
-    public static CGFloat smallSystemFontSize ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_smallSystemFontSize);
-    }
-
-    public static NSFont systemFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_systemFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static CGFloat systemFontSize ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSize);
-    }
-
-    public static CGFloat systemFontSizeForControlSize (NSControlSize controlSize)
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSizeForControlSize_1, controlSize);
-    }
+public static NSFont systemFontOfSize(CGFloat fontSize) {
+    objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_systemFontOfSize_, fontSize);
+    return result !is null ? new NSFont(result) : null;
+}
 
-    public NSAffineTransform textTransform ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_textTransform);
-        return result !is null ? new NSAffineTransform(result) : null;
-    }
-
-    public static NSFont titleBarFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_titleBarFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont toolTipsFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_toolTipsFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public CGFloat underlinePosition ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_underlinePosition);
-    }
+public static CGFloat systemFontSize() {
+    return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSize);
+}
 
-    public CGFloat underlineThickness ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_underlineThickness);
-    }
-
-    public static void useFont (NSString fontName)
-    {
-        OS.objc_msgSend(OS.class_NSFont, OS.sel_useFont_1, fontName !is null ? fontName.id_ : null);
-    }
-
-    public static NSFont userFixedPitchFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_userFixedPitchFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public static NSFont userFontOfSize (CGFloat fontSize)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_userFontOfSize_1, fontSize);
-        return result !is null ? new NSFont(result) : null;
-    }
-
-    public CGFloat widthOfString (NSString string)
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_widthOfString_1, string !is null ? string.id_ : null);
-    }
-
-    public CGFloat xHeight ()
-    {
-        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_xHeight);
-    }
+public static CGFloat systemFontSizeForControlSize(NSControlSize controlSize) {
+    return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSizeForControlSize_, controlSize);
+}
 
 }