comparison dwt/internal/cocoa/NSGraphicsContext.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.NSGraphicsContext;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSBitmapImageRep;
18 import dwt.internal.cocoa.NSDictionary;
19 import dwt.internal.cocoa.NSImage : NSCompositingOperation;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSObject;
22 import dwt.internal.cocoa.NSPoint;
23 import dwt.internal.cocoa.NSWindow;
24 import dwt.internal.cocoa.OS;
25 import objc = dwt.internal.objc.runtime;
26
27 alias NSInteger NSColorRenderingIntent;
28
29 enum
30 {
31 NSColorRenderingIntentDefault,
32 NSColorRenderingIntentAbsoluteColorimetric,
33 NSColorRenderingIntentRelativeColorimetric,
34 NSColorRenderingIntentPerceptual,
35 NSColorRenderingIntentSaturation
36 }
37
38 enum NSImageInterpolation
39 {
40 NSImageInterpolationDefault,
41 NSImageInterpolationNone,
42 NSImageInterpolationLow,
43 NSImageInterpolationHigh
44 }
45
46 public class NSGraphicsContext : NSObject
47 {
48
49 public this ()
50 {
51 super();
52 }
53
54 public this (objc.id id)
55 {
56 super(id);
57 }
58
59 //public CIContext CIContext() {
60 // objc.id result = OS.objc_msgSend(this.id, OS.sel_CIContext);
61 // return result !is null ? new CIContext(result) : null;
62 //}
63
64 public NSDictionary attributes ()
65 {
66 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
67 return result !is null ? new NSDictionary(result) : null;
68 }
69
70 public NSColorRenderingIntent colorRenderingIntent ()
71 {
72 return OS.objc_msgSend(this.id, OS.sel_colorRenderingIntent);
73 }
74
75 public NSCompositingOperation compositingOperation ()
76 {
77 return OS.objc_msgSend(this.id, OS.sel_compositingOperation);
78 }
79
80 public static NSGraphicsContext currentContext ()
81 {
82 objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContext);
83 return result !is null ? new NSGraphicsContext(result) : null;
84 }
85
86 public static bool currentContextDrawingToScreen ()
87 {
88 return OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContextDrawingToScreen) !is null;
89 }
90
91 public void flushGraphics ()
92 {
93 OS.objc_msgSend(this.id, OS.sel_flushGraphics);
94 }
95
96 public id focusStack ()
97 {
98 objc.id result = OS.objc_msgSend(this.id, OS.sel_focusStack);
99 return result !is null ? new id(result) : null;
100 }
101
102 public static NSGraphicsContext graphicsContextWithAttributes (NSDictionary attributes)
103 {
104 objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithAttributes_1,
105 attributes !is null ? attributes.id : null);
106 return result !is null ? new NSGraphicsContext(result) : null;
107 }
108
109 public static NSGraphicsContext graphicsContextWithBitmapImageRep (NSBitmapImageRep bitmapRep)
110 {
111 objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithBitmapImageRep_1,
112 bitmapRep !is null ? bitmapRep.id : null);
113 return result !is null ? new NSGraphicsContext(result) : null;
114 }
115
116 public static NSGraphicsContext graphicsContextWithGraphicsPort (void* graphicsPort, bool initialFlippedState)
117 {
118 objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithGraphicsPort_1flipped_1, graphicsPort,
119 initialFlippedState);
120 return result !is null ? new NSGraphicsContext(result) : null;
121 }
122
123 public static NSGraphicsContext graphicsContextWithWindow (NSWindow window)
124 {
125 objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithWindow_1, window !is null ? window.id : null);
126 return result !is null ? new NSGraphicsContext(result) : null;
127 }
128
129 public void* graphicsPort ()
130 {
131 return OS.objc_msgSend(this.id, OS.sel_graphicsPort);
132 }
133
134 public NSImageInterpolation imageInterpolation ()
135 {
136 return OS.objc_msgSend(this.id, OS.sel_imageInterpolation);
137 }
138
139 public bool isDrawingToScreen ()
140 {
141 return OS.objc_msgSend(this.id, OS.sel_isDrawingToScreen) !is null;
142 }
143
144 public bool isFlipped ()
145 {
146 return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
147 }
148
149 public NSPoint patternPhase ()
150 {
151 NSPoint result;
152 OS.objc_msgSend_stret(result, this.id, OS.sel_patternPhase);
153 return result;
154 }
155
156 public void restoreGraphicsState ()
157 {
158 OS.objc_msgSend(this.id, OS.sel_restoreGraphicsState);
159 }
160
161 public static void static_restoreGraphicsState ()
162 {
163 OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_restoreGraphicsState);
164 }
165
166 public void saveGraphicsState ()
167 {
168 OS.objc_msgSend(this.id, OS.sel_saveGraphicsState);
169 }
170
171 public static void static_saveGraphicsState ()
172 {
173 OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_saveGraphicsState);
174 }
175
176 public void setColorRenderingIntent (NSColorRenderingIntent renderingIntent)
177 {
178 OS.objc_msgSend(this.id, OS.sel_setColorRenderingIntent_1, renderingIntent);
179 }
180
181 public void setCompositingOperation (NSCompositingOperation operation)
182 {
183 OS.objc_msgSend(this.id, OS.sel_setCompositingOperation_1, operation);
184 }
185
186 public static void setCurrentContext (NSGraphicsContext context)
187 {
188 OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setCurrentContext_1, context !is null ? context.id : null);
189 }
190
191 public void setFocusStack (id stack)
192 {
193 OS.objc_msgSend(this.id, OS.sel_setFocusStack_1, stack !is null ? stack.id : null);
194 }
195
196 public static void setGraphicsState (NSInteger gState)
197 {
198 OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setGraphicsState_1, gState);
199 }
200
201 public void setImageInterpolation (NSImageInterpolation interpolation)
202 {
203 OS.objc_msgSend(this.id, OS.sel_setImageInterpolation_1, interpolation);
204 }
205
206 public void setPatternPhase (NSPoint phase)
207 {
208 OS.objc_msgSend(this.id, OS.sel_setPatternPhase_1, phase);
209 }
210
211 public void setShouldAntialias (bool antialias)
212 {
213 OS.objc_msgSend(this.id, OS.sel_setShouldAntialias_1, antialias);
214 }
215
216 public bool shouldAntialias ()
217 {
218 return OS.objc_msgSend(this.id, OS.sel_shouldAntialias) !is null;
219 }
220
221 }