comparison dwt/internal/cocoa/NSImage.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.NSImage;
15
16 import dwt.internal.cocoa.CGFloat;
17 import dwt.internal.cocoa.IconRef;
18 import dwt.internal.cocoa.id;
19 import dwt.internal.cocoa.NSArray;
20 import dwt.internal.cocoa.NSBitmapImageRep : NSTIFFCompression;
21 import dwt.internal.cocoa.NSColor;
22 import dwt.internal.cocoa.NSData;
23 import dwt.internal.cocoa.NSDictionary;
24 import dwt.internal.cocoa.NSImageRep;
25 import dwt.internal.cocoa.NSObject;
26 import dwt.internal.cocoa.NSPasteboard;
27 import dwt.internal.cocoa.NSPoint;
28 import dwt.internal.cocoa.NSRect;
29 import dwt.internal.cocoa.NSSize;
30 import dwt.internal.cocoa.NSString;
31 import dwt.internal.cocoa.NSURL;
32 import dwt.internal.cocoa.OS;
33 import objc = dwt.internal.objc.runtime;
34
35 enum NSCompositingOperation
36 {
37 NSCompositeClear = 0,
38 NSCompositeCopy = 1,
39 NSCompositeSourceOver = 2,
40 NSCompositeSourceIn = 3,
41 NSCompositeSourceOut = 4,
42 NSCompositeSourceAtop = 5,
43 NSCompositeDestinationOver = 6,
44 NSCompositeDestinationIn = 7,
45 NSCompositeDestinationOut = 8,
46 NSCompositeDestinationAtop = 9,
47 NSCompositeXOR = 10,
48 NSCompositePlusDarker = 11,
49 NSCompositeHighlight = 12,
50 NSCompositePlusLighter = 13
51 }
52
53 enum NSImageCacheMode
54 {
55 NSImageCacheDefault,
56 NSImageCacheAlways,
57 NSImageCacheBySize,
58 NSImageCacheNever
59 }
60
61 public class NSImage : NSObject
62 {
63
64 public this ()
65 {
66 super();
67 }
68
69 public this (objc.id id)
70 {
71 super(id);
72 }
73
74 public NSData TIFFRepresentation ()
75 {
76 objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation);
77 return result !is null ? new NSData(result) : null;
78 }
79
80 public NSData TIFFRepresentationUsingCompression (NSTIFFCompression comp, float aFloat)
81 {
82 objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, aFloat);
83 return result !is null ? new NSData(result) : null;
84 }
85
86 public void addRepresentation (NSImageRep imageRep)
87 {
88 OS.objc_msgSend(this.id, OS.sel_addRepresentation_1, imageRep !is null ? imageRep.id : null);
89 }
90
91 public void addRepresentations (NSArray imageReps)
92 {
93 OS.objc_msgSend(this.id, OS.sel_addRepresentations_1, imageReps !is null ? imageReps.id : null);
94 }
95
96 public NSRect alignmentRect ()
97 {
98 NSRect result;
99 OS.objc_msgSend_stret(result, this.id, OS.sel_alignmentRect);
100 return result;
101 }
102
103 public NSColor backgroundColor ()
104 {
105 objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
106 return result !is null ? new NSColor(result) : null;
107 }
108
109 public NSImageRep bestRepresentationForDevice (NSDictionary deviceDescription)
110 {
111 objc.id result = OS.objc_msgSend(this.id, OS.sel_bestRepresentationForDevice_1, deviceDescription !is null ? deviceDescription.id : null);
112 return result !is null ? new NSImageRep(result) : null;
113 }
114
115 public bool cacheDepthMatchesImageDepth ()
116 {
117 return OS.objc_msgSend(this.id, OS.sel_cacheDepthMatchesImageDepth) !is null;
118 }
119
120 public NSImageCacheMode cacheMode ()
121 {
122 return OS.objc_msgSend(this.id, OS.sel_cacheMode);
123 }
124
125 public static bool canInitWithPasteboard (NSPasteboard pasteboard)
126 {
127 return OS.objc_msgSend(OS.class_NSImage, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id : null) !is null;
128 }
129
130 public void cancelIncrementalLoad ()
131 {
132 OS.objc_msgSend(this.id, OS.sel_cancelIncrementalLoad);
133 }
134
135 public void compositeToPoint_fromRect_operation_ (NSPoint point, NSRect rect, NSCompositingOperation op)
136 {
137 OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1fromRect_1operation_1, point, rect, op);
138 }
139
140 public void compositeToPoint_fromRect_operation_fraction_ (NSPoint point, NSRect rect, NSCompositingOperation op, CGFloat delta)
141 {
142 OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1fromRect_1operation_1fraction_1, point, rect, op, delta);
143 }
144
145 public void compositeToPoint_operation_ (NSPoint point, NSCompositingOperation op)
146 {
147 OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1operation_1, point, op);
148 }
149
150 public void compositeToPoint_operation_fraction_ (NSPoint point, NSCompositingOperation op, CGFloat delta)
151 {
152 OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1operation_1fraction_1, point, op, delta);
153 }
154
155 public id delegatee ()
156 {
157 objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
158 return result !is null ? new id(result) : null;
159 }
160
161 public void dissolveToPoint_fraction_ (NSPoint point, CGFloat aFloat)
162 {
163 OS.objc_msgSend(this.id, OS.sel_dissolveToPoint_1fraction_1, point, aFloat);
164 }
165
166 public void dissolveToPoint_fromRect_fraction_ (NSPoint point, NSRect rect, CGFloat aFloat)
167 {
168 OS.objc_msgSend(this.id, OS.sel_dissolveToPoint_1fromRect_1fraction_1, point, rect, aFloat);
169 }
170
171 public void drawAtPoint (NSPoint point, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
172 {
173 OS.objc_msgSend(this.id, OS.sel_drawAtPoint_1fromRect_1operation_1fraction_1, point, fromRect, op, delta);
174 }
175
176 public void drawInRect (NSRect rect, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
177 {
178 OS.objc_msgSend(this.id, OS.sel_drawInRect_1fromRect_1operation_1fraction_1, rect, fromRect, op, delta);
179 }
180
181 public bool drawRepresentation (NSImageRep imageRep, NSRect rect)
182 {
183 return OS.objc_msgSend(this.id, OS.sel_drawRepresentation_1inRect_1, imageRep !is null ? imageRep.id : null, rect) !is null;
184 }
185
186 public static NSArray imageFileTypes ()
187 {
188 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageFileTypes);
189 return result !is null ? new NSArray(result) : null;
190 }
191
192 public static id imageNamed (NSString name)
193 {
194 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageNamed_1, name !is null ? name.id : null);
195 return result !is null ? new id(result) : null;
196 }
197
198 public static NSArray imagePasteboardTypes ()
199 {
200 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imagePasteboardTypes);
201 return result !is null ? new NSArray(result) : null;
202 }
203
204 public static NSArray imageTypes ()
205 {
206 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageTypes);
207 return result !is null ? new NSArray(result) : null;
208 }
209
210 public static NSArray imageUnfilteredFileTypes ()
211 {
212 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredFileTypes);
213 return result !is null ? new NSArray(result) : null;
214 }
215
216 public static NSArray imageUnfilteredPasteboardTypes ()
217 {
218 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredPasteboardTypes);
219 return result !is null ? new NSArray(result) : null;
220 }
221
222 public static NSArray imageUnfilteredTypes ()
223 {
224 objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredTypes);
225 return result !is null ? new NSArray(result) : null;
226 }
227
228 public NSImage initByReferencingFile (NSString fileName)
229 {
230 objc.id result = OS.objc_msgSend(this.id, OS.sel_initByReferencingFile_1, fileName !is null ? fileName.id : null);
231 return result !is null ? this : null;
232 }
233
234 public NSImage initByReferencingURL (NSURL url)
235 {
236 objc.id result = OS.objc_msgSend(this.id, OS.sel_initByReferencingURL_1, url !is null ? url.id : null);
237 return result !is null ? this : null;
238 }
239
240 public NSImage initWithContentsOfFile (NSString fileName)
241 {
242 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, fileName !is null ? fileName.id : null);
243 return result !is null ? this : null;
244 }
245
246 public NSImage initWithContentsOfURL (NSURL url)
247 {
248 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
249 return result !is null ? this : null;
250 }
251
252 public NSImage initWithData (NSData data)
253 {
254 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
255 return result !is null ? this : null;
256 }
257
258 public NSImage initWithIconRef (IconRef iconRef)
259 {
260 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIconRef_1, iconRef);
261 return result !is null ? this : null;
262 }
263
264 public NSImage initWithPasteboard (NSPasteboard pasteboard)
265 {
266 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
267 return result !is null ? this : null;
268 }
269
270 public NSImage initWithSize (NSSize aSize)
271 {
272 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSize_1, aSize);
273 return result !is null ? this : null;
274 }
275
276 public bool isCachedSeparately ()
277 {
278 return OS.objc_msgSend(this.id, OS.sel_isCachedSeparately) !is null;
279 }
280
281 public bool isDataRetained ()
282 {
283 return OS.objc_msgSend(this.id, OS.sel_isDataRetained) !is null;
284 }
285
286 public bool isFlipped ()
287 {
288 return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
289 }
290
291 public bool isTemplate ()
292 {
293 return OS.objc_msgSend(this.id, OS.sel_isTemplate) !is null;
294 }
295
296 public bool isValid ()
297 {
298 return OS.objc_msgSend(this.id, OS.sel_isValid) !is null;
299 }
300
301 public void lockFocus ()
302 {
303 OS.objc_msgSend(this.id, OS.sel_lockFocus);
304 }
305
306 public void lockFocusOnRepresentation (NSImageRep imageRepresentation)
307 {
308 OS.objc_msgSend(this.id, OS.sel_lockFocusOnRepresentation_1, imageRepresentation !is null ? imageRepresentation.id : null);
309 }
310
311 public bool matchesOnMultipleResolution ()
312 {
313 return OS.objc_msgSend(this.id, OS.sel_matchesOnMultipleResolution) !is null;
314 }
315
316 public NSString name ()
317 {
318 objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
319 return result !is null ? new NSString(result) : null;
320 }
321
322 public bool prefersColorMatch ()
323 {
324 return OS.objc_msgSend(this.id, OS.sel_prefersColorMatch) !is null;
325 }
326
327 public void recache ()
328 {
329 OS.objc_msgSend(this.id, OS.sel_recache);
330 }
331
332 public void removeRepresentation (NSImageRep imageRep)
333 {
334 OS.objc_msgSend(this.id, OS.sel_removeRepresentation_1, imageRep !is null ? imageRep.id : null);
335 }
336
337 public NSArray representations ()
338 {
339 objc.id result = OS.objc_msgSend(this.id, OS.sel_representations);
340 return result !is null ? new NSArray(result) : null;
341 }
342
343 public bool scalesWhenResized ()
344 {
345 return OS.objc_msgSend(this.id, OS.sel_scalesWhenResized) !is null;
346 }
347
348 public void setAlignmentRect (NSRect rect)
349 {
350 OS.objc_msgSend(this.id, OS.sel_setAlignmentRect_1, rect);
351 }
352
353 public void setBackgroundColor (NSColor aColor)
354 {
355 OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, aColor !is null ? aColor.id : null);
356 }
357
358 public void setCacheDepthMatchesImageDepth (bool flag)
359 {
360 OS.objc_msgSend(this.id, OS.sel_setCacheDepthMatchesImageDepth_1, flag);
361 }
362
363 public void setCacheMode (NSImageCacheMode mode)
364 {
365 OS.objc_msgSend(this.id, OS.sel_setCacheMode_1, mode);
366 }
367
368 public void setCachedSeparately (bool flag)
369 {
370 OS.objc_msgSend(this.id, OS.sel_setCachedSeparately_1, flag);
371 }
372
373 public void setDataRetained (bool flag)
374 {
375 OS.objc_msgSend(this.id, OS.sel_setDataRetained_1, flag);
376 }
377
378 public void setDelegate (id anObject)
379 {
380 OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
381 }
382
383 public void setFlipped (bool flag)
384 {
385 OS.objc_msgSend(this.id, OS.sel_setFlipped_1, flag);
386 }
387
388 public void setMatchesOnMultipleResolution (bool flag)
389 {
390 OS.objc_msgSend(this.id, OS.sel_setMatchesOnMultipleResolution_1, flag);
391 }
392
393 public bool setName (NSString string)
394 {
395 return OS.objc_msgSend(this.id, OS.sel_setName_1, string !is null ? string.id : null) !is null;
396 }
397
398 public void setPrefersColorMatch (bool flag)
399 {
400 OS.objc_msgSend(this.id, OS.sel_setPrefersColorMatch_1, flag);
401 }
402
403 public void setScalesWhenResized (bool flag)
404 {
405 OS.objc_msgSend(this.id, OS.sel_setScalesWhenResized_1, flag);
406 }
407
408 public void setSize (NSSize aSize)
409 {
410 OS.objc_msgSend(this.id, OS.sel_setSize_1, aSize);
411 }
412
413 public void setTemplate (bool isTemplate)
414 {
415 OS.objc_msgSend(this.id, OS.sel_setTemplate_1, isTemplate);
416 }
417
418 public void setUsesEPSOnResolutionMismatch (bool flag)
419 {
420 OS.objc_msgSend(this.id, OS.sel_setUsesEPSOnResolutionMismatch_1, flag);
421 }
422
423 public NSSize size ()
424 {
425 NSSize result;
426 OS.objc_msgSend_struct(result, this.id, OS.sel_size);
427 return result;
428 }
429
430 public void unlockFocus ()
431 {
432 OS.objc_msgSend(this.id, OS.sel_unlockFocus);
433 }
434
435 public bool usesEPSOnResolutionMismatch ()
436 {
437 return OS.objc_msgSend(this.id, OS.sel_usesEPSOnResolutionMismatch) !is null;
438 }
439
440 }