comparison dwt/internal/cocoa/NSImageRep.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.NSImageRep; 14 module dwt.internal.cocoa.NSImageRep;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.NSArray; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSData;
19 import dwt.internal.cocoa.NSInteger;
20 import dwt.internal.cocoa.NSObject; 18 import dwt.internal.cocoa.NSObject;
21 import dwt.internal.cocoa.NSPasteboard;
22 import dwt.internal.cocoa.NSPoint;
23 import dwt.internal.cocoa.NSRect;
24 import dwt.internal.cocoa.NSSize;
25 import dwt.internal.cocoa.NSString;
26 import dwt.internal.cocoa.NSURL;
27 import dwt.internal.cocoa.OS; 19 import dwt.internal.cocoa.OS;
20 import dwt.internal.objc.cocoa.Cocoa;
28 import objc = dwt.internal.objc.runtime; 21 import objc = dwt.internal.objc.runtime;
29 22
30 public class NSImageRep : NSObject 23 public class NSImageRep : NSObject {
31 {
32 24
33 public this () 25 public this() {
34 { 26 super();
35 super(); 27 }
36 }
37 28
38 public this (objc.id id) 29 public this(objc.id id) {
39 { 30 super(id);
40 super(id); 31 }
41 }
42 32
43 public NSInteger bitsPerSample () 33 public this(cocoa.id id) {
44 { 34 super(id);
45 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_bitsPerSample); 35 }
46 }
47 36
48 public static bool canInitWithData (NSData data) 37 public NSInteger bitsPerSample() {
49 { 38 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_bitsPerSample);
50 return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithData_1, data !is null ? data.id_ : null) !is null; 39 }
51 }
52 40
53 public static bool canInitWithPasteboard (NSPasteboard pasteboard) 41 public bool hasAlpha() {
54 { 42 return OS.objc_msgSend_bool(this.id, OS.sel_hasAlpha);
55 return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null) !is null; 43 }
56 }
57 44
58 public NSString colorSpaceName () 45 public NSInteger pixelsHigh() {
59 { 46 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_pixelsHigh);
60 objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorSpaceName); 47 }
61 return result !is null ? new NSString(result) : null;
62 }
63 48
64 public bool draw () 49 public NSInteger pixelsWide() {
65 { 50 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_pixelsWide);
66 return OS.objc_msgSend(this.id_, OS.sel_draw) !is null; 51 }
67 }
68
69 public bool drawAtPoint (NSPoint point)
70 {
71 return OS.objc_msgSend(this.id_, OS.sel_drawAtPoint_1, point) !is null;
72 }
73
74 public bool drawInRect (NSRect rect)
75 {
76 return OS.objc_msgSend(this.id_, OS.sel_drawInRect_1, rect) !is null;
77 }
78
79 public bool hasAlpha ()
80 {
81 return OS.objc_msgSend(this.id_, OS.sel_hasAlpha) !is null;
82 }
83
84 public static NSArray imageFileTypes ()
85 {
86 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageFileTypes);
87 return result !is null ? new NSArray(result) : null;
88 }
89
90 public static NSArray imagePasteboardTypes ()
91 {
92 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imagePasteboardTypes);
93 return result !is null ? new NSArray(result) : null;
94 }
95
96 public static objc.Class imageRepClassForData (NSData data)
97 {
98 return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForData_1, data !is null ? data.id_ : null);
99 }
100
101 public static objc.Class imageRepClassForFileType (NSString type)
102 {
103 return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForFileType_1, type !is null ? type.id_ : null);
104 }
105
106 public static objc.Class imageRepClassForPasteboardType (NSString type)
107 {
108 return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForPasteboardType_1, type !is null ? type.id_ : null);
109 }
110
111 public static objc.Class imageRepClassForType (NSString type)
112 {
113 return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForType_1, type !is null ? type.id_ : null);
114 }
115
116 public static id imageRepWithContentsOfFile (NSString filename)
117 {
118 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfFile_1, filename !is null ? filename.id_ : null);
119 return result !is null ? new id(result) : null;
120 }
121
122 public static id imageRepWithContentsOfURL (NSURL url)
123 {
124 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfURL_1, url !is null ? url.id_ : null);
125 return result !is null ? new id(result) : null;
126 }
127
128 public static id imageRepWithPasteboard (NSPasteboard pasteboard)
129 {
130 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null);
131 return result !is null ? new id(result) : null;
132 }
133
134 public static NSArray imageRepsWithContentsOfFile (NSString filename)
135 {
136 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfFile_1, filename !is null ? filename.id_ : null);
137 return result !is null ? new NSArray(result) : null;
138 }
139
140 public static NSArray imageRepsWithContentsOfURL (NSURL url)
141 {
142 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfURL_1, url !is null ? url.id_ : null);
143 return result !is null ? new NSArray(result) : null;
144 }
145
146 public static NSArray imageRepsWithPasteboard (NSPasteboard pasteboard)
147 {
148 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null);
149 return result !is null ? new NSArray(result) : null;
150 }
151
152 public static NSArray imageTypes ()
153 {
154 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageTypes);
155 return result !is null ? new NSArray(result) : null;
156 }
157
158 public static NSArray imageUnfilteredFileTypes ()
159 {
160 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredFileTypes);
161 return result !is null ? new NSArray(result) : null;
162 }
163
164 public static NSArray imageUnfilteredPasteboardTypes ()
165 {
166 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredPasteboardTypes);
167 return result !is null ? new NSArray(result) : null;
168 }
169
170 public static NSArray imageUnfilteredTypes ()
171 {
172 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredTypes);
173 return result !is null ? new NSArray(result) : null;
174 }
175
176 public bool isOpaque ()
177 {
178 return OS.objc_msgSend(this.id_, OS.sel_isOpaque) !is null;
179 }
180
181 public NSInteger pixelsHigh ()
182 {
183 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_pixelsHigh);
184 }
185
186 public NSInteger pixelsWide ()
187 {
188 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_pixelsWide);
189 }
190
191 public static void registerImageRepClass (objc.Class imageRepClass)
192 {
193 OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registerImageRepClass_1, imageRepClass);
194 }
195
196 public static NSArray registeredImageRepClasses ()
197 {
198 objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registeredImageRepClasses);
199 return result !is null ? new NSArray(result) : null;
200 }
201
202 public void setAlpha (bool flag)
203 {
204 OS.objc_msgSend(this.id_, OS.sel_setAlpha_1, flag);
205 }
206
207 public void setBitsPerSample (NSInteger anInt)
208 {
209 OS.objc_msgSend(this.id_, OS.sel_setBitsPerSample_1, anInt);
210 }
211
212 public void setColorSpaceName (NSString string)
213 {
214 OS.objc_msgSend(this.id_, OS.sel_setColorSpaceName_1, string !is null ? string.id_ : null);
215 }
216
217 public void setOpaque (bool flag)
218 {
219 OS.objc_msgSend(this.id_, OS.sel_setOpaque_1, flag);
220 }
221
222 public void setPixelsHigh (NSInteger anInt)
223 {
224 OS.objc_msgSend(this.id_, OS.sel_setPixelsHigh_1, anInt);
225 }
226
227 public void setPixelsWide (NSInteger anInt)
228 {
229 OS.objc_msgSend(this.id_, OS.sel_setPixelsWide_1, anInt);
230 }
231
232 public void setSize (NSSize aSize)
233 {
234 OS.objc_msgSend(this.id_, OS.sel_setSize_1, aSize);
235 }
236
237 public NSSize size ()
238 {
239 NSSize result;
240 OS.objc_msgSend_stret(&result, this.id_, OS.sel_size);
241 return result;
242 }
243
244 public static void unregisterImageRepClass (objc.Class imageRepClass)
245 {
246 OS.objc_msgSend(OS.class_NSImageRep, OS.sel_unregisterImageRepClass_1, imageRepClass);
247 }
248 52
249 } 53 }