Mercurial > projects > dwt-mac
comparison 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 |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSFontManager; | 14 module dwt.internal.cocoa.NSFontManager; |
15 | 15 |
16 import dwt.internal.cocoa.CGFloat; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.id; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSArray; | 18 import dwt.internal.cocoa.NSArray; |
19 import dwt.internal.cocoa.NSDictionary; | |
20 import dwt.internal.cocoa.NSFont; | |
21 import dwt.internal.cocoa.NSFontDescriptor; | |
22 import dwt.internal.cocoa.NSFontPanel; | |
23 import dwt.internal.cocoa.NSInteger; | |
24 import dwt.internal.cocoa.NSMenu; | |
25 import dwt.internal.cocoa.NSObject; | 19 import dwt.internal.cocoa.NSObject; |
26 import dwt.internal.cocoa.NSString; | 20 import dwt.internal.cocoa.NSString; |
27 import dwt.internal.cocoa.OS; | 21 import dwt.internal.cocoa.OS; |
28 import objc = dwt.internal.objc.runtime; | 22 import objc = dwt.internal.objc.runtime; |
29 | 23 |
30 alias uint NSFontTraitMask; | 24 public class NSFontManager : NSObject { |
31 | 25 |
32 enum NSFontAction | 26 public this() { |
33 { | 27 super(); |
34 NSNoFontChangeAction = 0, | |
35 NSViaPanelFontAction = 1, | |
36 NSAddTraitFontAction = 2, | |
37 NSSizeUpFontAction = 3, | |
38 NSSizeDownFontAction = 4, | |
39 NSHeavierFontAction = 5, | |
40 NSLighterFontAction = 6, | |
41 NSRemoveTraitFontAction = 7 | |
42 } | 28 } |
43 | 29 |
44 public class NSFontManager : NSObject | 30 public this(objc.id id) { |
45 { | 31 super(id); |
32 } | |
46 | 33 |
47 public this () | 34 public this(cocoa.id id) { |
48 { | 35 super(id); |
49 super(); | 36 } |
50 } | |
51 | 37 |
52 public this (objc.id id) | 38 public NSArray availableFontFamilies() { |
53 { | 39 objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFontFamilies); |
54 super(id); | 40 return result !is null ? new NSArray(result) : null; |
55 } | 41 } |
56 | 42 |
57 public objc.SEL action () | 43 public NSArray availableFonts() { |
58 { | 44 objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFonts); |
59 return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action); | 45 return result !is null ? new NSArray(result) : null; |
60 } | 46 } |
61 | 47 |
62 public bool addCollection (NSString collectionName, NSInteger collectionOptions) | 48 public NSArray availableMembersOfFontFamily(NSString fam) { |
63 { | 49 objc.id result = OS.objc_msgSend(this.id, OS.sel_availableMembersOfFontFamily_, fam !is null ? fam.id : null); |
64 return OS.objc_msgSend(this.id_, OS.sel_addCollection_1options_1, collectionName !is null ? collectionName.id_ : null, collectionOptions) !is null; | 50 return result !is null ? new NSArray(result) : null; |
65 } | 51 } |
66 | 52 |
67 public void addFontDescriptors (NSArray descriptors, NSString collectionName) | 53 public static NSFontManager sharedFontManager() { |
68 { | 54 objc.id result = OS.objc_msgSend(OS.class_NSFontManager, OS.sel_sharedFontManager); |
69 OS.objc_msgSend(this.id_, OS.sel_addFontDescriptors_1toCollection_1, descriptors !is null ? descriptors.id_ : null, | 55 return result !is null ? new NSFontManager(result) : null; |
70 collectionName !is null ? collectionName.id_ : null); | 56 } |
71 } | |
72 | |
73 public void addFontTrait (id sender) | |
74 { | |
75 OS.objc_msgSend(this.id_, OS.sel_addFontTrait_1, sender !is null ? sender.id_ : null); | |
76 } | |
77 | |
78 public NSArray availableFontFamilies () | |
79 { | |
80 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontFamilies); | |
81 return result !is null ? new NSArray(result) : null; | |
82 } | |
83 | |
84 public NSArray availableFontNamesMatchingFontDescriptor (NSFontDescriptor descriptor) | |
85 { | |
86 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontNamesMatchingFontDescriptor_1, descriptor !is null ? descriptor.id_ : null); | |
87 return result !is null ? new NSArray(result) : null; | |
88 } | |
89 | |
90 public NSArray availableFontNamesWithTraits (NSFontTraitMask someTraits) | |
91 { | |
92 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFontNamesWithTraits_1, someTraits); | |
93 return result !is null ? new NSArray(result) : null; | |
94 } | |
95 | |
96 public NSArray availableFonts () | |
97 { | |
98 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableFonts); | |
99 return result !is null ? new NSArray(result) : null; | |
100 } | |
101 | |
102 public NSArray availableMembersOfFontFamily (NSString fam) | |
103 { | |
104 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableMembersOfFontFamily_1, fam !is null ? fam.id_ : null); | |
105 return result !is null ? new NSArray(result) : null; | |
106 } | |
107 | |
108 public NSArray collectionNames () | |
109 { | |
110 objc.id result = OS.objc_msgSend(this.id_, OS.sel_collectionNames); | |
111 return result !is null ? new NSArray(result) : null; | |
112 } | |
113 | |
114 public NSDictionary convertAttributes (NSDictionary attributes) | |
115 { | |
116 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertAttributes_1, attributes !is null ? attributes.id_ : null); | |
117 return result !is null ? new NSDictionary(result) : null; | |
118 } | |
119 | |
120 public NSFont convertFont_ (NSFont fontObj) | |
121 { | |
122 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1, fontObj !is null ? fontObj.id_ : null); | |
123 return result !is null ? new NSFont(result) : null; | |
124 } | |
125 | |
126 public NSFont convertFont_toFace_ (NSFont fontObj, NSString typeface) | |
127 { | |
128 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toFace_1, fontObj !is null ? fontObj.id_ : null, | |
129 typeface !is null ? typeface.id_ : null); | |
130 return result !is null ? new NSFont(result) : null; | |
131 } | |
132 | |
133 public NSFont convertFont_toFamily_ (NSFont fontObj, NSString family) | |
134 { | |
135 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toFamily_1, fontObj !is null ? fontObj.id_ : null, | |
136 family !is null ? family.id_ : null); | |
137 return result !is null ? new NSFont(result) : null; | |
138 } | |
139 | |
140 public NSFont convertFont_toHaveTrait_ (NSFont fontObj, NSFontTraitMask trait) | |
141 { | |
142 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toHaveTrait_1, fontObj !is null ? fontObj.id_ : null, trait); | |
143 return result !is null ? new NSFont(result) : null; | |
144 } | |
145 | |
146 public NSFont convertFont_toNotHaveTrait_ (NSFont fontObj, NSFontTraitMask trait) | |
147 { | |
148 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toNotHaveTrait_1, fontObj !is null ? fontObj.id_ : null, trait); | |
149 return result !is null ? new NSFont(result) : null; | |
150 } | |
151 | |
152 public NSFont convertFont_toSize_ (NSFont fontObj, CGFloat size) | |
153 { | |
154 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertFont_1toSize_1, fontObj !is null ? fontObj.id_ : null, size); | |
155 return result !is null ? new NSFont(result) : null; | |
156 } | |
157 | |
158 public NSFontTraitMask convertFontTraits (NSFontTraitMask traits) | |
159 { | |
160 return cast(NSFontTraitMask) OS.objc_msgSend(this.id_, OS.sel_convertFontTraits_1, traits); | |
161 } | |
162 | |
163 public NSFont convertWeight (bool upFlag, NSFont fontObj) | |
164 { | |
165 objc.id result = OS.objc_msgSend(this.id_, OS.sel_convertWeight_1ofFont_1, upFlag, fontObj !is null ? fontObj.id_ : null); | |
166 return result !is null ? new NSFont(result) : null; | |
167 } | |
168 | |
169 public NSFontAction currentFontAction () | |
170 { | |
171 return cast(NSFontAction) OS.objc_msgSend(this.id_, OS.sel_currentFontAction); | |
172 } | |
173 | |
174 public id delegatee () | |
175 { | |
176 objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate); | |
177 return result !is null ? new id(result) : null; | |
178 } | |
179 | |
180 public NSArray fontDescriptorsInCollection (NSString collectionNames) | |
181 { | |
182 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontDescriptorsInCollection_1, collectionNames !is null ? collectionNames.id_ : null); | |
183 return result !is null ? new NSArray(result) : null; | |
184 } | |
185 | |
186 public NSMenu fontMenu (bool create) | |
187 { | |
188 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontMenu_1, create); | |
189 return result !is null ? new NSMenu(result) : null; | |
190 } | |
191 | |
192 public bool fontNamed (NSString fName, NSFontTraitMask someTraits) | |
193 { | |
194 return OS.objc_msgSend(this.id_, OS.sel_fontNamed_1hasTraits_1, fName !is null ? fName.id_ : null, someTraits) !is null; | |
195 } | |
196 | |
197 public NSFontPanel fontPanel (bool create) | |
198 { | |
199 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontPanel_1, create); | |
200 return result !is null ? new NSFontPanel(result) : null; | |
201 } | |
202 | |
203 public NSFont fontWithFamily (NSString family, NSFontTraitMask traits, NSInteger weight, CGFloat size) | |
204 { | |
205 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fontWithFamily_1traits_1weight_1size_1, family !is null ? family.id_ : null, traits, weight, | |
206 size); | |
207 return result !is null ? new NSFont(result) : null; | |
208 } | |
209 | |
210 public bool isEnabled () | |
211 { | |
212 return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null; | |
213 } | |
214 | |
215 public bool isMultiple () | |
216 { | |
217 return OS.objc_msgSend(this.id_, OS.sel_isMultiple) !is null; | |
218 } | |
219 | |
220 public NSString localizedNameForFamily (NSString family, NSString faceKey) | |
221 { | |
222 objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedNameForFamily_1face_1, family !is null ? family.id_ : null, | |
223 faceKey !is null ? faceKey.id_ : null); | |
224 return result !is null ? new NSString(result) : null; | |
225 } | |
226 | |
227 public void modifyFont (id sender) | |
228 { | |
229 OS.objc_msgSend(this.id_, OS.sel_modifyFont_1, sender !is null ? sender.id_ : null); | |
230 } | |
231 | |
232 public void modifyFontViaPanel (id sender) | |
233 { | |
234 OS.objc_msgSend(this.id_, OS.sel_modifyFontViaPanel_1, sender !is null ? sender.id_ : null); | |
235 } | |
236 | |
237 public void orderFrontFontPanel (id sender) | |
238 { | |
239 OS.objc_msgSend(this.id_, OS.sel_orderFrontFontPanel_1, sender !is null ? sender.id_ : null); | |
240 } | |
241 | |
242 public void orderFrontStylesPanel (id sender) | |
243 { | |
244 OS.objc_msgSend(this.id_, OS.sel_orderFrontStylesPanel_1, sender !is null ? sender.id_ : null); | |
245 } | |
246 | |
247 public bool removeCollection (NSString collectionName) | |
248 { | |
249 return OS.objc_msgSend(this.id_, OS.sel_removeCollection_1, collectionName !is null ? collectionName.id_ : null) !is null; | |
250 } | |
251 | |
252 public void removeFontDescriptor (NSFontDescriptor descriptor, NSString collection) | |
253 { | |
254 OS.objc_msgSend(this.id_, OS.sel_removeFontDescriptor_1fromCollection_1, descriptor !is null ? descriptor.id_ : null, | |
255 collection !is null ? collection.id_ : null); | |
256 } | |
257 | |
258 public void removeFontTrait (id sender) | |
259 { | |
260 OS.objc_msgSend(this.id_, OS.sel_removeFontTrait_1, sender !is null ? sender.id_ : null); | |
261 } | |
262 | |
263 public NSFont selectedFont () | |
264 { | |
265 objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedFont); | |
266 return result !is null ? new NSFont(result) : null; | |
267 } | |
268 | |
269 public bool sendAction () | |
270 { | |
271 return OS.objc_msgSend(this.id_, OS.sel_sendAction) !is null; | |
272 } | |
273 | |
274 public void setAction (objc.SEL aSelector) | |
275 { | |
276 OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector); | |
277 } | |
278 | |
279 public void setDelegate (id anObject) | |
280 { | |
281 OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null); | |
282 } | |
283 | |
284 public void setEnabled (bool flag) | |
285 { | |
286 OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag); | |
287 } | |
288 | |
289 public static void setFontManagerFactory (objc.Class factoryId) | |
290 { | |
291 OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontManagerFactory_1, factoryId); | |
292 } | |
293 | |
294 public void setFontMenu (NSMenu newMenu) | |
295 { | |
296 OS.objc_msgSend(this.id_, OS.sel_setFontMenu_1, newMenu !is null ? newMenu.id_ : null); | |
297 } | |
298 | |
299 public static void setFontPanelFactory (objc.Class factoryId) | |
300 { | |
301 OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontPanelFactory_1, factoryId); | |
302 } | |
303 | |
304 public void setSelectedAttributes (NSDictionary attributes, bool flag) | |
305 { | |
306 OS.objc_msgSend(this.id_, OS.sel_setSelectedAttributes_1isMultiple_1, attributes !is null ? attributes.id_ : null, flag); | |
307 } | |
308 | |
309 public void setSelectedFont (NSFont fontObj, bool flag) | |
310 { | |
311 OS.objc_msgSend(this.id_, OS.sel_setSelectedFont_1isMultiple_1, fontObj !is null ? fontObj.id_ : null, flag); | |
312 } | |
313 | |
314 public void setTarget (id aTarget) | |
315 { | |
316 OS.objc_msgSend(this.id_, OS.sel_setTarget_1, aTarget !is null ? aTarget.id_ : null); | |
317 } | |
318 | |
319 public static NSFontManager sharedFontManager () | |
320 { | |
321 objc.id result = OS.objc_msgSend(OS.class_NSFontManager, OS.sel_sharedFontManager); | |
322 return result !is null ? new NSFontManager(result) : null; | |
323 } | |
324 | |
325 public id target () | |
326 { | |
327 objc.id result = OS.objc_msgSend(this.id_, OS.sel_target); | |
328 return result !is null ? new id(result) : null; | |
329 } | |
330 | |
331 public NSFontTraitMask traitsOfFont (NSFont fontObj) | |
332 { | |
333 return cast(NSFontTraitMask) OS.objc_msgSend(this.id_, OS.sel_traitsOfFont_1, fontObj !is null ? fontObj.id_ : null); | |
334 } | |
335 | |
336 public NSInteger weightOfFont (NSFont fontObj) | |
337 { | |
338 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_weightOfFont_1, fontObj !is null ? fontObj.id_ : null); | |
339 } | |
340 | 57 |
341 } | 58 } |