comparison 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
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.NSFontManager;
8
9 import dstep.appkit.NSFont;
10 import dstep.appkit.NSFontDescriptor;
11 import dstep.appkit.NSFontPanel;
12 import dstep.appkit.NSMenu;
13 import dstep.applicationservices.coregraphics.CGBase;
14 import dstep.foundation.NSArray;
15 import dstep.foundation.NSDictionary;
16 import dstep.foundation.NSGeometry;
17 import dstep.foundation.NSObjCRuntime;
18 import dstep.foundation.NSObject;
19 import dstep.foundation.NSString;
20 import dstep.objc.bridge.Bridge;
21 import dstep.objc.objc;
22
23 typedef NSUInteger NSFontTraitMask;
24 typedef NSUInteger NSFontAction;
25
26 enum
27 {
28 NSItalicFontMask = 0x00000001,
29 NSBoldFontMask = 0x00000002,
30 NSUnboldFontMask = 0x00000004,
31 NSNonStandardCharacterSetFontMask = 0x00000008,
32 NSNarrowFontMask = 0x00000010,
33 NSExpandedFontMask = 0x00000020,
34 NSCondensedFontMask = 0x00000040,
35 NSSmallCapsFontMask = 0x00000080,
36 NSPosterFontMask = 0x00000100,
37 NSCompressedFontMask = 0x00000200,
38 NSFixedPitchFontMask = 0x00000400,
39 NSUnitalicFontMask = 0x01000000
40 }
41
42 enum
43 {
44 NSFontCollectionApplicationOnlyMask = 1 << 0
45 }
46
47 enum
48 {
49 NSNoFontChangeAction = 0,
50 NSViaPanelFontAction = 1,
51 NSAddTraitFontAction = 2,
52 NSSizeUpFontAction = 3,
53 NSSizeDownFontAction = 4,
54 NSHeavierFontAction = 5,
55 NSLighterFontAction = 6,
56 NSRemoveTraitFontAction = 7
57 }
58
59 const TNSFontManagerMenuActionMethods = `
60
61 bool fontNamed (NSString fName, uint someTraits)
62 {
63 return invokeObjcSelf!(bool, "fontNamed:hasTraits:", NSString, uint)(fName, someTraits);
64 }
65
66 NSArray availableFontNamesWithTraits (uint someTraits)
67 {
68 return invokeObjcSelf!(NSArray, "availableFontNamesWithTraits:", uint)(someTraits);
69 }
70
71 void addFontTrait (Object sender)
72 {
73 return invokeObjcSelf!(void, "addFontTrait:", Object)(sender);
74 }
75
76 void removeFontTrait (Object sender)
77 {
78 return invokeObjcSelf!(void, "removeFontTrait:", Object)(sender);
79 }
80
81 void modifyFontViaPanel (Object sender)
82 {
83 return invokeObjcSelf!(void, "modifyFontViaPanel:", Object)(sender);
84 }
85
86 void modifyFont (Object sender)
87 {
88 return invokeObjcSelf!(void, "modifyFont:", Object)(sender);
89 }
90
91 void orderFrontFontPanel (Object sender)
92 {
93 return invokeObjcSelf!(void, "orderFrontFontPanel:", Object)(sender);
94 }
95
96 void orderFrontStylesPanel (Object sender)
97 {
98 return invokeObjcSelf!(void, "orderFrontStylesPanel:", Object)(sender);
99 }
100
101 //mixin ObjcBindMethod!(fontNamed, "fontNamed:hasTraits:");
102 //mixin ObjcBindMethod!(availableFontNamesWithTraits, "availableFontNamesWithTraits:");
103 //mixin ObjcBindMethod!(addFontTrait, "addFontTrait:");
104 //mixin ObjcBindMethod!(removeFontTrait, "removeFontTrait:");
105 //mixin ObjcBindMethod!(modifyFontViaPanel, "modifyFontViaPanel:");
106 //mixin ObjcBindMethod!(modifyFont, "modifyFont:");
107 //mixin ObjcBindMethod!(orderFrontFontPanel, "orderFrontFontPanel:");
108 //mixin ObjcBindMethod!(orderFrontStylesPanel, "orderFrontStylesPanel:");
109
110 `;
111
112 const TNSFontManagerResponderMethod = `
113
114 void changeFont (Object sender)
115 {
116 return invokeObjcSelf!(void, "changeFont:", Object)(sender);
117 }
118
119 //mixin ObjcBindMethod!(changeFont, "changeFont:");
120
121 `;
122
123 const TNSFontManagerDelegate = `
124
125 bool fontManager (Object sender, NSString fontName)
126 {
127 return invokeObjcSelf!(bool, "fontManager:willIncludeFont:", Object, NSString)(sender, fontName);
128 }
129
130 //mixin ObjcBindMethod!(fontManager, "fontManager:willIncludeFont:");
131
132 `;
133
134 class NSFontManager : NSObject
135 {
136 mixin (ObjcWrap);
137
138 static void setFontPanelFactory (Class factoryId)
139 {
140 return invokeObjcSelfClass!(void, "setFontPanelFactory:", Class)(factoryId);
141 }
142
143 static void setFontManagerFactory (Class factoryId)
144 {
145 return invokeObjcSelfClass!(void, "setFontManagerFactory:", Class)(factoryId);
146 }
147
148 static NSFontManager sharedFontManager ()
149 {
150 return invokeObjcSelfClass!(NSFontManager, "sharedFontManager");
151 }
152
153 bool isMultiple ()
154 {
155 return invokeObjcSelf!(bool, "isMultiple");
156 }
157
158 NSFont selectedFont ()
159 {
160 return invokeObjcSelf!(NSFont, "selectedFont");
161 }
162
163 void setSelectedFont (NSFont fontObj, bool flag)
164 {
165 return invokeObjcSelf!(void, "setSelectedFont:isMultiple:", NSFont, bool)(fontObj, flag);
166 }
167
168 void setFontMenu (NSMenu newMenu)
169 {
170 return invokeObjcSelf!(void, "setFontMenu:", NSMenu)(newMenu);
171 }
172
173 NSMenu fontMenu (bool create)
174 {
175 return invokeObjcSelf!(NSMenu, "fontMenu:", bool)(create);
176 }
177
178 NSFontPanel fontPanel (bool create)
179 {
180 return invokeObjcSelf!(NSFontPanel, "fontPanel:", bool)(create);
181 }
182
183 NSFont fontWithFamily (NSString family, uint traits, NSInteger weight, CGFloat size)
184 {
185 return invokeObjcSelf!(NSFont, "fontWithFamily:traits:weight:size:", NSString, uint, NSInteger, CGFloat)(family, traits, weight, size);
186 }
187
188 uint traitsOfFont (NSFont fontObj)
189 {
190 return invokeObjcSelf!(uint, "traitsOfFont:", NSFont)(fontObj);
191 }
192
193 NSInteger weightOfFont (NSFont fontObj)
194 {
195 return invokeObjcSelf!(NSInteger, "weightOfFont:", NSFont)(fontObj);
196 }
197
198 NSArray availableFonts ()
199 {
200 return invokeObjcSelf!(NSArray, "availableFonts");
201 }
202
203 NSArray availableFontFamilies ()
204 {
205 return invokeObjcSelf!(NSArray, "availableFontFamilies");
206 }
207
208 NSArray availableMembersOfFontFamily (NSString fam)
209 {
210 return invokeObjcSelf!(NSArray, "availableMembersOfFontFamily:", NSString)(fam);
211 }
212
213 NSFont convertFont (NSFont fontObj)
214 {
215 return invokeObjcSelf!(NSFont, "convertFont:", NSFont)(fontObj);
216 }
217
218 NSFont convertFont (NSFont fontObj, CGFloat size)
219 {
220 return invokeObjcSelf!(NSFont, "convertFont:toSize:", NSFont, CGFloat)(fontObj, size);
221 }
222
223 NSFont convertFont (NSFont fontObj, NSString typeface)
224 {
225 return invokeObjcSelf!(NSFont, "convertFont:toFace:", NSFont, NSString)(fontObj, typeface);
226 }
227
228 NSFont convertFont (NSFont fontObj, NSString family)
229 {
230 return invokeObjcSelf!(NSFont, "convertFont:toFamily:", NSFont, NSString)(fontObj, family);
231 }
232
233 NSFont convertFont (NSFont fontObj, uint trait)
234 {
235 return invokeObjcSelf!(NSFont, "convertFont:toHaveTrait:", NSFont, uint)(fontObj, trait);
236 }
237
238 NSFont convertFont (NSFont fontObj, uint trait)
239 {
240 return invokeObjcSelf!(NSFont, "convertFont:toNotHaveTrait:", NSFont, uint)(fontObj, trait);
241 }
242
243 NSFont convertWeight (bool upFlag, NSFont fontObj)
244 {
245 return invokeObjcSelf!(NSFont, "convertWeight:ofFont:", bool, NSFont)(upFlag, fontObj);
246 }
247
248 bool isEnabled ()
249 {
250 return invokeObjcSelf!(bool, "isEnabled");
251 }
252
253 void setEnabled (bool flag)
254 {
255 return invokeObjcSelf!(void, "setEnabled:", bool)(flag);
256 }
257
258 SEL action ()
259 {
260 return invokeObjcSelf!(SEL, "action");
261 }
262
263 void setAction (SEL aSelector)
264 {
265 return invokeObjcSelf!(void, "setAction:", SEL)(aSelector);
266 }
267
268 bool sendAction ()
269 {
270 return invokeObjcSelf!(bool, "sendAction");
271 }
272
273 void setDelegate (Object anObject)
274 {
275 return invokeObjcSelf!(void, "setDelegate:", Object)(anObject);
276 }
277
278 Object delegate_ ()
279 {
280 return invokeObjcSelf!(Object, "delegate");
281 }
282
283 NSString localizedNameForFamily (NSString family, NSString faceKey)
284 {
285 return invokeObjcSelf!(NSString, "localizedNameForFamily:face:", NSString, NSString)(family, faceKey);
286 }
287
288 void setSelectedAttributes (NSDictionary attributes, bool flag)
289 {
290 return invokeObjcSelf!(void, "setSelectedAttributes:isMultiple:", NSDictionary, bool)(attributes, flag);
291 }
292
293 NSDictionary convertAttributes (NSDictionary attributes)
294 {
295 return invokeObjcSelf!(NSDictionary, "convertAttributes:", NSDictionary)(attributes);
296 }
297
298 NSArray availableFontNamesMatchingFontDescriptor (NSFontDescriptor descriptor)
299 {
300 return invokeObjcSelf!(NSArray, "availableFontNamesMatchingFontDescriptor:", NSFontDescriptor)(descriptor);
301 }
302
303 NSArray collectionNames ()
304 {
305 return invokeObjcSelf!(NSArray, "collectionNames");
306 }
307
308 NSArray fontDescriptorsInCollection (NSString collectionNames)
309 {
310 return invokeObjcSelf!(NSArray, "fontDescriptorsInCollection:", NSString)(collectionNames);
311 }
312
313 bool addCollection (NSString collectionName, NSInteger collectionOptions)
314 {
315 return invokeObjcSelf!(bool, "addCollection:options:", NSString, NSInteger)(collectionName, collectionOptions);
316 }
317
318 bool removeCollection (NSString collectionName)
319 {
320 return invokeObjcSelf!(bool, "removeCollection:", NSString)(collectionName);
321 }
322
323 void addFontDescriptors (NSArray descriptors, NSString collectionName)
324 {
325 return invokeObjcSelf!(void, "addFontDescriptors:toCollection:", NSArray, NSString)(descriptors, collectionName);
326 }
327
328 void removeFontDescriptor (NSFontDescriptor descriptor, NSString collection)
329 {
330 return invokeObjcSelf!(void, "removeFontDescriptor:fromCollection:", NSFontDescriptor, NSString)(descriptor, collection);
331 }
332
333 uint currentFontAction ()
334 {
335 return invokeObjcSelf!(uint, "currentFontAction");
336 }
337
338 uint convertFontTraits (uint traits)
339 {
340 return invokeObjcSelf!(uint, "convertFontTraits:", uint)(traits);
341 }
342
343 void setTarget (Object aTarget)
344 {
345 return invokeObjcSelf!(void, "setTarget:", Object)(aTarget);
346 }
347
348 Object target ()
349 {
350 return invokeObjcSelf!(Object, "target");
351 }
352
353 // NSFontManagerMenuActionMethods
354 bool fontNamed (NSString fName, uint someTraits)
355 {
356 return invokeObjcSelf!(bool, "fontNamed:hasTraits:", NSString, uint)(fName, someTraits);
357 }
358
359 NSArray availableFontNamesWithTraits (uint someTraits)
360 {
361 return invokeObjcSelf!(NSArray, "availableFontNamesWithTraits:", uint)(someTraits);
362 }
363
364 void addFontTrait (Object sender)
365 {
366 return invokeObjcSelf!(void, "addFontTrait:", Object)(sender);
367 }
368
369 void removeFontTrait (Object sender)
370 {
371 return invokeObjcSelf!(void, "removeFontTrait:", Object)(sender);
372 }
373
374 void modifyFontViaPanel (Object sender)
375 {
376 return invokeObjcSelf!(void, "modifyFontViaPanel:", Object)(sender);
377 }
378
379 void modifyFont (Object sender)
380 {
381 return invokeObjcSelf!(void, "modifyFont:", Object)(sender);
382 }
383
384 void orderFrontFontPanel (Object sender)
385 {
386 return invokeObjcSelf!(void, "orderFrontFontPanel:", Object)(sender);
387 }
388
389 void orderFrontStylesPanel (Object sender)
390 {
391 return invokeObjcSelf!(void, "orderFrontStylesPanel:", Object)(sender);
392 }
393 }