comparison 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
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Sep 24, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.appkit.NSFont;
8
9 import dstep.appkit.AppKitDefines;
10 import dstep.appkit.NSAffineTransform;
11 import dstep.appkit.NSCell;
12 import dstep.appkit.NSFontDescriptor;
13 import dstep.appkit.NSGraphicsContext;
14 import dstep.applicationservices.coregraphics.CGBase;
15 import dstep.foundation.NSCharacterSet;
16 import dstep.foundation.NSCoder;
17 import dstep.foundation.NSGeometry;
18 import dstep.foundation.NSObjCRuntime;
19 import dstep.foundation.NSObject;
20 import dstep.foundation.NSString;
21 import dstep.foundation.NSZone;
22 import dstep.objc.bridge.Bridge;
23 import dstep.objc.objc;
24
25 import bindings = dstep.appkit.NSFont_bindings;
26
27 alias uint NSGlyph;
28 typedef NSUInteger NSMultibyteGlyphPacking;
29 typedef NSUInteger NSFontRenderingMode;
30
31 extern (C)
32 {
33 extern
34 {
35 const CGFloat* NSFontIdentityMatrix;
36 }
37 }
38
39 private
40 {
41 NSString NSAntialiasThresholdChangedNotification_;
42 NSString NSFontSetChangedNotification_;
43 }
44
45 NSString NSAntialiasThresholdChangedNotification ()
46 {
47 if (NSAntialiasThresholdChangedNotification_)
48 return NSAntialiasThresholdChangedNotification_;
49
50 return NSAntialiasThresholdChangedNotification_ = new NSString(bindings.NSAntialiasThresholdChangedNotification);
51 }
52
53 NSString NSFontSetChangedNotification ()
54 {
55 if (NSFontSetChangedNotification_)
56 return NSFontSetChangedNotification_;
57
58 return NSFontSetChangedNotification_ = new NSString(bindings.NSFontSetChangedNotification);
59 }
60
61 enum
62 {
63 NSControlGlyph = 0x00FFFFFF,
64 NSNullGlyph = 0x0
65 }
66
67 enum
68 {
69 NSNativeShortGlyphPacking = 5
70 }
71
72 enum
73 {
74 NSFontDefaultRenderingMode = 0,
75 NSFontAntialiasedRenderingMode = 1,
76 NSFontIntegerAdvancementsRenderingMode = 2,
77 NSFontAntialiasedIntegerAdvancementsRenderingMode = 3
78 }
79
80 class NSFont : NSObject, INSCopying, INSCoding
81 {
82 mixin (ObjcWrap);
83
84 this (NSCoder aDecoder)
85 {
86 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
87 }
88
89 void encodeWithCoder (NSCoder aCoder)
90 {
91 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
92 }
93
94 typeof(this) initWithCoder (NSCoder aDecoder)
95 {
96 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
97 }
98
99 typeof(this) copyWithZone (NSZone* zone)
100 {
101 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
102 }
103
104 static NSFont fontWithName (NSString fontName, CGFloat fontSize)
105 {
106 return invokeObjcSelfClass!(NSFont, "fontWithName:size:", NSString, CGFloat)(fontName, fontSize);
107 }
108
109 static NSFont fontWithName (NSString fontName, CGFloat* fontMatrix)
110 {
111 return invokeObjcSelfClass!(NSFont, "fontWithName:matrix:", NSString, CGFloat*)(fontName, fontMatrix);
112 }
113
114 static NSFont fontWithDescriptor (NSFontDescriptor fontDescriptor, CGFloat fontSize)
115 {
116 return invokeObjcSelfClass!(NSFont, "fontWithDescriptor:size:", NSFontDescriptor, CGFloat)(fontDescriptor, fontSize);
117 }
118
119 static NSFont fontWithDescriptor (NSFontDescriptor fontDescriptor, NSAffineTransform textTransform)
120 {
121 return invokeObjcSelfClass!(NSFont, "fontWithDescriptor:textTransform:", NSFontDescriptor, NSAffineTransform)(fontDescriptor, textTransform);
122 }
123
124 static NSFont userFontOfSize (CGFloat fontSize)
125 {
126 return invokeObjcSelfClass!(NSFont, "userFontOfSize:", CGFloat)(fontSize);
127 }
128
129 static NSFont userFixedPitchFontOfSize (CGFloat fontSize)
130 {
131 return invokeObjcSelfClass!(NSFont, "userFixedPitchFontOfSize:", CGFloat)(fontSize);
132 }
133
134 static void setUserFont (NSFont aFont)
135 {
136 return invokeObjcSelfClass!(void, "setUserFont:", NSFont)(aFont);
137 }
138
139 static void setUserFixedPitchFont (NSFont aFont)
140 {
141 return invokeObjcSelfClass!(void, "setUserFixedPitchFont:", NSFont)(aFont);
142 }
143
144 static NSFont systemFontOfSize (CGFloat fontSize)
145 {
146 return invokeObjcSelfClass!(NSFont, "systemFontOfSize:", CGFloat)(fontSize);
147 }
148
149 static NSFont boldSystemFontOfSize (CGFloat fontSize)
150 {
151 return invokeObjcSelfClass!(NSFont, "boldSystemFontOfSize:", CGFloat)(fontSize);
152 }
153
154 static NSFont labelFontOfSize (CGFloat fontSize)
155 {
156 return invokeObjcSelfClass!(NSFont, "labelFontOfSize:", CGFloat)(fontSize);
157 }
158
159 static NSFont titleBarFontOfSize (CGFloat fontSize)
160 {
161 return invokeObjcSelfClass!(NSFont, "titleBarFontOfSize:", CGFloat)(fontSize);
162 }
163
164 static NSFont menuFontOfSize (CGFloat fontSize)
165 {
166 return invokeObjcSelfClass!(NSFont, "menuFontOfSize:", CGFloat)(fontSize);
167 }
168
169 static NSFont menuBarFontOfSize (CGFloat fontSize)
170 {
171 return invokeObjcSelfClass!(NSFont, "menuBarFontOfSize:", CGFloat)(fontSize);
172 }
173
174 static NSFont messageFontOfSize (CGFloat fontSize)
175 {
176 return invokeObjcSelfClass!(NSFont, "messageFontOfSize:", CGFloat)(fontSize);
177 }
178
179 static NSFont paletteFontOfSize (CGFloat fontSize)
180 {
181 return invokeObjcSelfClass!(NSFont, "paletteFontOfSize:", CGFloat)(fontSize);
182 }
183
184 static NSFont toolTipsFontOfSize (CGFloat fontSize)
185 {
186 return invokeObjcSelfClass!(NSFont, "toolTipsFontOfSize:", CGFloat)(fontSize);
187 }
188
189 static NSFont controlContentFontOfSize (CGFloat fontSize)
190 {
191 return invokeObjcSelfClass!(NSFont, "controlContentFontOfSize:", CGFloat)(fontSize);
192 }
193
194 static CGFloat systemFontSize ()
195 {
196 return invokeObjcSelfClass!(CGFloat, "systemFontSize");
197 }
198
199 static CGFloat smallSystemFontSize ()
200 {
201 return invokeObjcSelfClass!(CGFloat, "smallSystemFontSize");
202 }
203
204 static CGFloat labelFontSize ()
205 {
206 return invokeObjcSelfClass!(CGFloat, "labelFontSize");
207 }
208
209 static CGFloat systemFontSizeForControlSize (uint controlSize)
210 {
211 return invokeObjcSelfClass!(CGFloat, "systemFontSizeForControlSize:", uint)(controlSize);
212 }
213
214 NSString fontName ()
215 {
216 return invokeObjcSelf!(NSString, "fontName");
217 }
218
219 CGFloat pointSize ()
220 {
221 return invokeObjcSelf!(CGFloat, "pointSize");
222 }
223
224 CGFloat* matrix ()
225 {
226 return invokeObjcSelf!(CGFloat*, "matrix");
227 }
228
229 NSString familyName ()
230 {
231 return invokeObjcSelf!(NSString, "familyName");
232 }
233
234 NSString displayName ()
235 {
236 return invokeObjcSelf!(NSString, "displayName");
237 }
238
239 NSFontDescriptor fontDescriptor ()
240 {
241 return invokeObjcSelf!(NSFontDescriptor, "fontDescriptor");
242 }
243
244 NSAffineTransform textTransform ()
245 {
246 return invokeObjcSelf!(NSAffineTransform, "textTransform");
247 }
248
249 NSUInteger numberOfGlyphs ()
250 {
251 return invokeObjcSelf!(NSUInteger, "numberOfGlyphs");
252 }
253
254 uint mostCompatibleStringEncoding ()
255 {
256 return invokeObjcSelf!(uint, "mostCompatibleStringEncoding");
257 }
258
259 uint glyphWithName (NSString aName)
260 {
261 return invokeObjcSelf!(uint, "glyphWithName:", NSString)(aName);
262 }
263
264 NSCharacterSet coveredCharacterSet ()
265 {
266 return invokeObjcSelf!(NSCharacterSet, "coveredCharacterSet");
267 }
268
269 NSRect boundingRectForFont ()
270 {
271 return invokeObjcSelf!(NSRect, "boundingRectForFont");
272 }
273
274 NSSize maximumAdvancement ()
275 {
276 return invokeObjcSelf!(NSSize, "maximumAdvancement");
277 }
278
279 CGFloat ascender ()
280 {
281 return invokeObjcSelf!(CGFloat, "ascender");
282 }
283
284 CGFloat descender ()
285 {
286 return invokeObjcSelf!(CGFloat, "descender");
287 }
288
289 CGFloat leading ()
290 {
291 return invokeObjcSelf!(CGFloat, "leading");
292 }
293
294 CGFloat underlinePosition ()
295 {
296 return invokeObjcSelf!(CGFloat, "underlinePosition");
297 }
298
299 CGFloat underlineThickness ()
300 {
301 return invokeObjcSelf!(CGFloat, "underlineThickness");
302 }
303
304 CGFloat italicAngle ()
305 {
306 return invokeObjcSelf!(CGFloat, "italicAngle");
307 }
308
309 CGFloat capHeight ()
310 {
311 return invokeObjcSelf!(CGFloat, "capHeight");
312 }
313
314 CGFloat xHeight ()
315 {
316 return invokeObjcSelf!(CGFloat, "xHeight");
317 }
318
319 bool isFixedPitch ()
320 {
321 return invokeObjcSelf!(bool, "isFixedPitch");
322 }
323
324 NSRect boundingRectForGlyph (uint aGlyph)
325 {
326 return invokeObjcSelf!(NSRect, "boundingRectForGlyph:", uint)(aGlyph);
327 }
328
329 NSSize advancementForGlyph (uint ag)
330 {
331 return invokeObjcSelf!(NSSize, "advancementForGlyph:", uint)(ag);
332 }
333
334 void getBoundingRects (NSRectArray bounds, NSGlyph* glyphs, NSUInteger glyphCount)
335 {
336 return invokeObjcSelf!(void, "getBoundingRects:forGlyphs:count:", NSRectArray, NSGlyph*, NSUInteger)(bounds, glyphs, glyphCount);
337 }
338
339 void getAdvancements (NSSizeArray advancements, NSGlyph* glyphs, NSUInteger glyphCount)
340 {
341 return invokeObjcSelf!(void, "getAdvancements:forGlyphs:count:", NSSizeArray, NSGlyph*, NSUInteger)(advancements, glyphs, glyphCount);
342 }
343
344 void getAdvancements (NSSizeArray advancements, void* packedGlyphs, NSUInteger length)
345 {
346 return invokeObjcSelf!(void, "getAdvancements:forPackedGlyphs:length:", NSSizeArray, void*, NSUInteger)(advancements, packedGlyphs, length);
347 }
348
349 void set ()
350 {
351 return invokeObjcSelf!(void, "set");
352 }
353
354 void setInContext (NSGraphicsContext graphicsContext)
355 {
356 return invokeObjcSelf!(void, "setInContext:", NSGraphicsContext)(graphicsContext);
357 }
358
359 NSFont printerFont ()
360 {
361 id result = invokeObjcSelf!(id, "printerFont");
362 return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null);
363 }
364
365 NSFont screenFont ()
366 {
367 id result = invokeObjcSelf!(id, "screenFont");
368 return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null);
369 }
370
371 NSFont screenFontWithRenderingMode (uint renderingMode)
372 {
373 id result = invokeObjcSelf!(id, "screenFontWithRenderingMode:", uint)(renderingMode);
374 return result is this.objcObject ? this : (result !is null ? new NSFont(result) : null);
375 }
376
377 uint renderingMode ()
378 {
379 return invokeObjcSelf!(uint, "renderingMode");
380 }
381
382 }
383
384 extern (C)
385 {
386 NSInteger NSConvertGlyphsToPackedGlyphs (NSGlyph* glBuf, NSInteger count, uint packing, char* packedGlyphs);
387 }