comparison dstep/appkit/NSGraphics.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
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.NSGraphics;
8
9 import dstep.appkit.AppKitDefines;
10 import dstep.appkit.NSColor;
11 import dstep.appkit.NSView;
12 import dstep.applicationservices.coregraphics.CGBase;
13 import dstep.foundation.NSGeometry;
14 import dstep.foundation.NSObjCRuntime;
15 import dstep.foundation.NSString;
16 import dstep.objc.bridge.Bridge;
17 import dstep.objc.objc;
18
19 import bindings = dstep.appkit.NSGraphics_bindings;
20
21 alias NSUInteger NSCompositingOperation;
22 alias NSUInteger NSBackingStoreType;
23 alias NSInteger NSWindowOrderingMode;
24 alias NSUInteger NSFocusRingPlacement;
25 alias NSUInteger NSFocusRingType;
26 alias int NSWindowDepth;
27 alias NSUInteger NSAnimationEffect;
28
29 extern (C)
30 {
31 extern
32 {
33 const CGFloat NSWhite;
34 const CGFloat NSLightGray;
35 const CGFloat NSDarkGray;
36 const CGFloat NSBlack;
37 }
38 }
39
40 private
41 {
42 NSString NSCalibratedWhiteColorSpace_;
43 NSString NSCalibratedBlackColorSpace_;
44 NSString NSCalibratedRGBColorSpace_;
45 NSString NSDeviceWhiteColorSpace_;
46 NSString NSDeviceBlackColorSpace_;
47 NSString NSDeviceRGBColorSpace_;
48 NSString NSDeviceCMYKColorSpace_;
49 NSString NSNamedColorSpace_;
50 NSString NSPatternColorSpace_;
51 NSString NSCustomColorSpace_;
52 NSString NSDeviceResolution_;
53 NSString NSDeviceColorSpaceName_;
54 NSString NSDeviceBitsPerSample_;
55 NSString NSDeviceIsScreen_;
56 NSString NSDeviceIsPrinter_;
57 NSString NSDeviceSize_;
58 }
59
60 NSString NSCalibratedWhiteColorSpace ()
61 {
62 if (NSCalibratedWhiteColorSpace_)
63 return NSCalibratedWhiteColorSpace_;
64
65 return NSCalibratedWhiteColorSpace_ = new NSString(bindings.NSCalibratedWhiteColorSpace);
66 }
67
68 NSString NSCalibratedBlackColorSpace ()
69 {
70 if (NSCalibratedBlackColorSpace_)
71 return NSCalibratedBlackColorSpace_;
72
73 return NSCalibratedBlackColorSpace_ = new NSString(bindings.NSCalibratedBlackColorSpace);
74 }
75
76 NSString NSCalibratedRGBColorSpace ()
77 {
78 if (NSCalibratedRGBColorSpace_)
79 return NSCalibratedRGBColorSpace_;
80
81 return NSCalibratedRGBColorSpace_ = new NSString(bindings.NSCalibratedRGBColorSpace);
82 }
83
84 NSString NSDeviceWhiteColorSpace ()
85 {
86 if (NSDeviceWhiteColorSpace_)
87 return NSDeviceWhiteColorSpace_;
88
89 return NSDeviceWhiteColorSpace_ = new NSString(bindings.NSDeviceWhiteColorSpace);
90 }
91
92 NSString NSDeviceBlackColorSpace ()
93 {
94 if (NSDeviceBlackColorSpace_)
95 return NSDeviceBlackColorSpace_;
96
97 return NSDeviceBlackColorSpace_ = new NSString(bindings.NSDeviceBlackColorSpace);
98 }
99
100 NSString NSDeviceRGBColorSpace ()
101 {
102 if (NSDeviceRGBColorSpace_)
103 return NSDeviceRGBColorSpace_;
104
105 return NSDeviceRGBColorSpace_ = new NSString(bindings.NSDeviceRGBColorSpace);
106 }
107
108 NSString NSDeviceCMYKColorSpace ()
109 {
110 if (NSDeviceCMYKColorSpace_)
111 return NSDeviceCMYKColorSpace_;
112
113 return NSDeviceCMYKColorSpace_ = new NSString(bindings.NSDeviceCMYKColorSpace);
114 }
115
116 NSString NSNamedColorSpace ()
117 {
118 if (NSNamedColorSpace_)
119 return NSNamedColorSpace_;
120
121 return NSNamedColorSpace_ = new NSString(bindings.NSNamedColorSpace);
122 }
123
124 NSString NSPatternColorSpace ()
125 {
126 if (NSPatternColorSpace_)
127 return NSPatternColorSpace_;
128
129 return NSPatternColorSpace_ = new NSString(bindings.NSPatternColorSpace);
130 }
131
132 NSString NSCustomColorSpace ()
133 {
134 if (NSCustomColorSpace_)
135 return NSCustomColorSpace_;
136
137 return NSCustomColorSpace_ = new NSString(bindings.NSCustomColorSpace);
138 }
139
140 NSString NSDeviceResolution ()
141 {
142 if (NSDeviceResolution_)
143 return NSDeviceResolution_;
144
145 return NSDeviceResolution_ = new NSString(bindings.NSDeviceResolution);
146 }
147
148 NSString NSDeviceColorSpaceName ()
149 {
150 if (NSDeviceColorSpaceName_)
151 return NSDeviceColorSpaceName_;
152
153 return NSDeviceColorSpaceName_ = new NSString(bindings.NSDeviceColorSpaceName);
154 }
155
156 NSString NSDeviceBitsPerSample ()
157 {
158 if (NSDeviceBitsPerSample_)
159 return NSDeviceBitsPerSample_;
160
161 return NSDeviceBitsPerSample_ = new NSString(bindings.NSDeviceBitsPerSample);
162 }
163
164 NSString NSDeviceIsScreen ()
165 {
166 if (NSDeviceIsScreen_)
167 return NSDeviceIsScreen_;
168
169 return NSDeviceIsScreen_ = new NSString(bindings.NSDeviceIsScreen);
170 }
171
172 NSString NSDeviceIsPrinter ()
173 {
174 if (NSDeviceIsPrinter_)
175 return NSDeviceIsPrinter_;
176
177 return NSDeviceIsPrinter_ = new NSString(bindings.NSDeviceIsPrinter);
178 }
179
180 NSString NSDeviceSize ()
181 {
182 if (NSDeviceSize_)
183 return NSDeviceSize_;
184
185 return NSDeviceSize_ = new NSString(bindings.NSDeviceSize);
186 }
187
188 enum
189 {
190 NSCompositeClear = 0,
191 NSCompositeCopy = 1,
192 NSCompositeSourceOver = 2,
193 NSCompositeSourceIn = 3,
194 NSCompositeSourceOut = 4,
195 NSCompositeSourceAtop = 5,
196 NSCompositeDestinationOver = 6,
197 NSCompositeDestinationIn = 7,
198 NSCompositeDestinationOut = 8,
199 NSCompositeDestinationAtop = 9,
200 NSCompositeXOR = 10,
201 NSCompositePlusDarker = 11,
202 NSCompositeHighlight = 12,
203 NSCompositePlusLighter = 13
204 }
205
206 enum
207 {
208 NSBackingStoreRetained = 0,
209 NSBackingStoreNonretained = 1,
210 NSBackingStoreBuffered = 2
211 }
212
213 enum
214 {
215 NSWindowAbove = 1,
216 NSWindowBelow = -1,
217 NSWindowOut = 0
218 }
219
220 enum
221 {
222 NSFocusRingOnly = 0,
223 NSFocusRingBelow = 1,
224 NSFocusRingAbove = 2
225 }
226
227 enum
228 {
229 NSFocusRingTypeDefault = 0,
230 NSFocusRingTypeNone = 1,
231 NSFocusRingTypeExterior = 2
232 }
233
234 enum
235 {
236 NSAnimationEffectDisappearingItemDefault = 0,
237 NSAnimationEffectPoof = 10
238 }
239 /*
240 int NSBestDepth (NSString colorSpace, NSInteger bps, NSInteger bpp, bool planar, bool* exactMatch)
241 {
242 return Bridge.invokeObjcFunction!(int, bindings.NSBestDepth, NSString, NSInteger, NSInteger, bool, bool*)(colorSpace, bps, bpp, planar, exactMatch);
243 }
244
245 NSString NSColorSpaceFromDepth (int depth)
246 {
247 return Bridge.invokeObjcFunction!(NSString, bindings.NSColorSpaceFromDepth, int)(depth);
248 }
249
250 NSInteger NSNumberOfColorComponents (NSString colorSpaceName)
251 {
252 return Bridge.invokeObjcFunction!(NSInteger, bindings.NSNumberOfColorComponents, NSString)(colorSpaceName);
253 }
254
255 NSColor NSReadPixel (NSPoint passedPoint)
256 {
257 return Bridge.invokeObjcFunction!(NSColor, bindings.NSReadPixel, NSPoint)(passedPoint);
258 }
259
260 void NSDrawBitmap (NSRect rect, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, NSInteger bpp, NSInteger bpr, bool isPlanar, bool hasAlpha, NSString colorSpaceName, char*[5] data)
261 {
262 return Bridge.invokeObjcFunction!(void, bindings.NSDrawBitmap, NSRect, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, NSString, char*[5])(rect, width, height, bps, spp, bpp, bpr, isPlanar, hasAlpha, colorSpaceName, data);
263 }
264
265 void NSShowAnimationEffect (uint animationEffect, NSPoint centerLocation, NSSize size, Object animationDelegate, SEL didEndSelector, void* contextInfo)
266 {
267 return Bridge.invokeObjcFunction!(void, bindings.NSShowAnimationEffect, uint, NSPoint, NSSize, Object, SEL, void*)(animationEffect, centerLocation, size, animationDelegate, didEndSelector, contextInfo);
268 }
269 */
270 extern (C)
271 {
272 bool NSPlanarFromDepth (int depth);
273 NSInteger NSBitsPerSampleFromDepth (int depth);
274 NSInteger NSBitsPerPixelFromDepth (int depth);
275 NSWindowDepth* NSAvailableWindowDepths ();
276 void NSRectFill (NSRect aRect);
277 void NSRectFillList (NSRect* rects, NSInteger count);
278 void NSRectFillListWithGrays (NSRect* rects, CGFloat* grays, NSInteger num);
279 void NSRectFillListWithColors (NSRect* rects, NSColor** colors, NSInteger num);
280 void NSRectFillUsingOperation (NSRect aRect, uint op);
281 void NSRectFillListUsingOperation (NSRect* rects, NSInteger count, uint op);
282 void NSRectFillListWithColorsUsingOperation (NSRect* rects, NSColor** colors, NSInteger num, uint op);
283 void NSFrameRect (NSRect aRect);
284 void NSFrameRectWithWidth (NSRect aRect, CGFloat frameWidth);
285 void NSFrameRectWithWidthUsingOperation (NSRect aRect, CGFloat frameWidth, uint op);
286 void NSRectClip (NSRect aRect);
287 void NSRectClipList (NSRect* rects, NSInteger count);
288 NSRect NSDrawTiledRects (NSRect boundsRect, NSRect clipRect, NSRectEdge* sides, CGFloat* grays, NSInteger count);
289 void NSDrawGrayBezel (NSRect aRect, NSRect clipRect);
290 void NSDrawGroove (NSRect aRect, NSRect clipRect);
291 void NSDrawWhiteBezel (NSRect aRect, NSRect clipRect);
292 void NSDrawButton (NSRect aRect, NSRect clipRect);
293 void NSEraseRect (NSRect aRect);
294 void NSCopyBits (NSInteger srcGState, NSRect srcRect, NSPoint destPoint);
295 void NSHighlightRect (NSRect aRect);
296 void NSBeep ();
297 void NSCountWindows (NSInteger* count);
298 void NSWindowList (NSInteger size, NSInteger* list);
299 void NSCountWindowsForContext (NSInteger context, NSInteger* count);
300 void NSWindowListForContext (NSInteger context, NSInteger size, NSInteger* list);
301 NSInteger NSGetWindowServerMemory (NSInteger context, NSInteger* virtualMemory, NSInteger* windowBackingMemory, NSString** windowDumpString);
302 NSRect NSDrawColorTiledRects (NSRect boundsRect, NSRect clipRect, NSRectEdge* sides, NSColor** colors, NSInteger count);
303 void NSDrawDarkBezel (NSRect aRect, NSRect clipRect);
304 void NSDrawLightBezel (NSRect aRect, NSRect clipRect);
305 void NSDottedFrameRect (NSRect aRect);
306 void NSDrawWindowBackground (NSRect aRect);
307 void NSSetFocusRingStyle (uint placement);
308 void NSDisableScreenUpdates ();
309 void NSEnableScreenUpdates ();
310 }