Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSFontManager.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSFontManager; | |
15 | |
16 import dwt.internal.cocoa.CGFloat; | |
17 import dwt.internal.cocoa.id; | |
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; | |
26 import dwt.internal.cocoa.NSString; | |
27 import dwt.internal.cocoa.OS; | |
28 import objc = dwt.internal.objc.runtime; | |
29 | |
30 alias uint NSFontTraitMask; | |
31 | |
32 enum NSFontAction | |
33 { | |
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 } | |
43 | |
44 public class NSFontManager : NSObject | |
45 { | |
46 | |
47 public this () | |
48 { | |
49 super(); | |
50 } | |
51 | |
52 public this (objc.id id) | |
53 { | |
54 super(id); | |
55 } | |
56 | |
57 public objc.SEL action () | |
58 { | |
59 return OS.objc_msgSend(this.id, OS.sel_action); | |
60 } | |
61 | |
62 public bool addCollection (NSString collectionName, NSInteger collectionOptions) | |
63 { | |
64 return OS.objc_msgSend(this.id, OS.sel_addCollection_1options_1, collectionName !is null ? collectionName.id : null, collectionOptions) !is null; | |
65 } | |
66 | |
67 public void addFontDescriptors (NSArray descriptors, NSString collectionName) | |
68 { | |
69 OS.objc_msgSend(this.id, OS.sel_addFontDescriptors_1toCollection_1, descriptors !is null ? descriptors.id : null, | |
70 collectionName !is null ? collectionName.id : null); | |
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 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 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, GCFloat 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 (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 (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 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 OS.objc_msgSend(this.id, OS.sel_weightOfFont_1, fontObj !is null ? fontObj.id : null); | |
339 } | |
340 | |
341 } |