Mercurial > projects > dstep
view dstep/appkit/NSFont.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 source
/** * 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.NSFont; import dstep.appkit.AppKitDefines; import dstep.appkit.NSAffineTransform; import dstep.appkit.NSCell; import dstep.appkit.NSFontDescriptor; import dstep.appkit.NSGraphicsContext; import dstep.applicationservices.coregraphics.CGBase; import dstep.foundation.NSCharacterSet; import dstep.foundation.NSCoder; import dstep.foundation.NSGeometry; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.appkit.NSFont_bindings; alias uint NSGlyph; typedef NSUInteger NSMultibyteGlyphPacking; typedef NSUInteger NSFontRenderingMode; extern (C) { extern { const CGFloat* NSFontIdentityMatrix; } } private { NSString NSAntialiasThresholdChangedNotification_; NSString NSFontSetChangedNotification_; } NSString NSAntialiasThresholdChangedNotification () { if (NSAntialiasThresholdChangedNotification_) return NSAntialiasThresholdChangedNotification_; return NSAntialiasThresholdChangedNotification_ = new NSString(bindings.NSAntialiasThresholdChangedNotification); } NSString NSFontSetChangedNotification () { if (NSFontSetChangedNotification_) return NSFontSetChangedNotification_; return NSFontSetChangedNotification_ = new NSString(bindings.NSFontSetChangedNotification); } enum { NSControlGlyph = 0x00FFFFFF, NSNullGlyph = 0x0 } enum { NSNativeShortGlyphPacking = 5 } enum { NSFontDefaultRenderingMode = 0, NSFontAntialiasedRenderingMode = 1, NSFontIntegerAdvancementsRenderingMode = 2, NSFontAntialiasedIntegerAdvancementsRenderingMode = 3 } class NSFont : NSObject, INSCopying, INSCoding { mixin (ObjcWrap); this (NSCoder aDecoder) { super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } typeof(this) initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); } typeof(this) copyWithZone (NSZone* zone) { return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); } static NSFont fontWithName (NSString fontName, CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "fontWithName:size:", NSString, CGFloat)(fontName, fontSize); } static NSFont fontWithName (NSString fontName, CGFloat* fontMatrix) { return invokeObjcSelfClass!(NSFont, "fontWithName:matrix:", NSString, CGFloat*)(fontName, fontMatrix); } static NSFont fontWithDescriptor (NSFontDescriptor fontDescriptor, CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "fontWithDescriptor:size:", NSFontDescriptor, CGFloat)(fontDescriptor, fontSize); } static NSFont fontWithDescriptor (NSFontDescriptor fontDescriptor, NSAffineTransform textTransform) { return invokeObjcSelfClass!(NSFont, "fontWithDescriptor:textTransform:", NSFontDescriptor, NSAffineTransform)(fontDescriptor, textTransform); } static NSFont userFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "userFontOfSize:", CGFloat)(fontSize); } static NSFont userFixedPitchFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "userFixedPitchFontOfSize:", CGFloat)(fontSize); } static void setUserFont (NSFont aFont) { return invokeObjcSelfClass!(void, "setUserFont:", NSFont)(aFont); } static void setUserFixedPitchFont (NSFont aFont) { return invokeObjcSelfClass!(void, "setUserFixedPitchFont:", NSFont)(aFont); } static NSFont systemFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "systemFontOfSize:", CGFloat)(fontSize); } static NSFont boldSystemFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "boldSystemFontOfSize:", CGFloat)(fontSize); } static NSFont labelFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "labelFontOfSize:", CGFloat)(fontSize); } static NSFont titleBarFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "titleBarFontOfSize:", CGFloat)(fontSize); } static NSFont menuFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "menuFontOfSize:", CGFloat)(fontSize); } static NSFont menuBarFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "menuBarFontOfSize:", CGFloat)(fontSize); } static NSFont messageFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "messageFontOfSize:", CGFloat)(fontSize); } static NSFont paletteFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "paletteFontOfSize:", CGFloat)(fontSize); } static NSFont toolTipsFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "toolTipsFontOfSize:", CGFloat)(fontSize); } static NSFont controlContentFontOfSize (CGFloat fontSize) { return invokeObjcSelfClass!(NSFont, "controlContentFontOfSize:", CGFloat)(fontSize); } static CGFloat systemFontSize () { return invokeObjcSelfClass!(CGFloat, "systemFontSize"); } static CGFloat smallSystemFontSize () { return invokeObjcSelfClass!(CGFloat, "smallSystemFontSize"); } static CGFloat labelFontSize () { return invokeObjcSelfClass!(CGFloat, "labelFontSize"); } static CGFloat systemFontSizeForControlSize (uint controlSize) { return invokeObjcSelfClass!(CGFloat, "systemFontSizeForControlSize:", uint)(controlSize); } NSString fontName () { return invokeObjcSelf!(NSString, "fontName"); } CGFloat pointSize () { return invokeObjcSelf!(CGFloat, "pointSize"); } CGFloat* matrix () { return invokeObjcSelf!(CGFloat*, "matrix"); } NSString familyName () { return invokeObjcSelf!(NSString, "familyName"); } NSString displayName () { return invokeObjcSelf!(NSString, "displayName"); } NSFontDescriptor fontDescriptor () { return invokeObjcSelf!(NSFontDescriptor, "fontDescriptor"); } NSAffineTransform textTransform () { return invokeObjcSelf!(NSAffineTransform, "textTransform"); } NSUInteger numberOfGlyphs () { return invokeObjcSelf!(NSUInteger, "numberOfGlyphs"); } uint mostCompatibleStringEncoding () { return invokeObjcSelf!(uint, "mostCompatibleStringEncoding"); } uint glyphWithName (NSString aName) { return invokeObjcSelf!(uint, "glyphWithName:", NSString)(aName); } NSCharacterSet coveredCharacterSet () { return invokeObjcSelf!(NSCharacterSet, "coveredCharacterSet"); } NSRect boundingRectForFont () { return invokeObjcSelf!(NSRect, "boundingRectForFont"); } NSSize maximumAdvancement () { return invokeObjcSelf!(NSSize, "maximumAdvancement"); } CGFloat ascender () { return invokeObjcSelf!(CGFloat, "ascender"); } CGFloat descender () { return invokeObjcSelf!(CGFloat, "descender"); } CGFloat leading () { return invokeObjcSelf!(CGFloat, "leading"); } CGFloat underlinePosition () { return invokeObjcSelf!(CGFloat, "underlinePosition"); } CGFloat underlineThickness () { return invokeObjcSelf!(CGFloat, "underlineThickness"); } CGFloat italicAngle () { return invokeObjcSelf!(CGFloat, "italicAngle"); } CGFloat capHeight () { return invokeObjcSelf!(CGFloat, "capHeight"); } CGFloat xHeight () { return invokeObjcSelf!(CGFloat, "xHeight"); } bool isFixedPitch () { return invokeObjcSelf!(bool, "isFixedPitch"); } NSRect boundingRectForGlyph (uint aGlyph) { return invokeObjcSelf!(NSRect, "boundingRectForGlyph:", uint)(aGlyph); } NSSize advancementForGlyph (uint ag) { return invokeObjcSelf!(NSSize, "advancementForGlyph:", uint)(ag); } void getBoundingRects (NSRectArray bounds, NSGlyph* glyphs, NSUInteger glyphCount) { return invokeObjcSelf!(void, "getBoundingRects:forGlyphs:count:", NSRectArray, NSGlyph*, NSUInteger)(bounds, glyphs, glyphCount); } void getAdvancements (NSSizeArray advancements, NSGlyph* glyphs, NSUInteger glyphCount) { return invokeObjcSelf!(void, "getAdvancements:forGlyphs:count:", NSSizeArray, NSGlyph*, NSUInteger)(advancements, glyphs, glyphCount); } void getAdvancements (NSSizeArray advancements, void* packedGlyphs, NSUInteger length) { return invokeObjcSelf!(void, "getAdvancements:forPackedGlyphs:length:", NSSizeArray, void*, NSUInteger)(advancements, packedGlyphs, length); } void set () { return invokeObjcSelf!(void, "set"); } void setInContext (NSGraphicsContext graphicsContext) { return invokeObjcSelf!(void, "setInContext:", NSGraphicsContext)(graphicsContext); } NSFont printerFont () { id result = invokeObjcSelf!(id, "printerFont"); return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null); } NSFont screenFont () { id result = invokeObjcSelf!(id, "screenFont"); return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null); } NSFont screenFontWithRenderingMode (uint renderingMode) { id result = invokeObjcSelf!(id, "screenFontWithRenderingMode:", uint)(renderingMode); return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null); } uint renderingMode () { return invokeObjcSelf!(uint, "renderingMode"); } } extern (C) { NSInteger NSConvertGlyphsToPackedGlyphs (NSGlyph* glBuf, NSInteger count, uint packing, char* packedGlyphs); }