root/dwt/internal/gdip/native.d

Revision 247:41a9fce66f7f, 117.0 kB (checked in by Frank Benoit <benoit@tionex.de>, 6 months ago)

changed line-endings to unix format

Line 
1 /******************************************************************************
2
3   module:
4
5   Based on D version created by John Chapman for the Juno Project
6     see: www.dsource.org/projects/juno
7
8   Changes and Additions for DWT:
9     John Reimer <terminal.node@gmail.com>
10
11 ******************************************************************************/
12
13 module dwt.internal.gdip.native;
14
15 import dwt.internal.win32.WINTYPES;
16 import tango.sys.SharedLib : SharedLib;
17 import tango.util.log.Trace;
18
19 extern(Windows):
20
21 /******************************************************************************
22
23
24 ******************************************************************************/
25
26 enum DebugEventLevel {
27   Fatal,
28   Warning
29 }
30
31 alias void  function(DebugEventLevel level, char* message) DebugEventProc;
32
33 alias int   function(out uint token)    NotificationHookProc;
34 alias void  function(uint token)        NotificationUnhookProc;
35
36
37 /******************************************************************************
38
39
40 ******************************************************************************/
41
42
43 struct GdiplusStartupInput {
44   uint GdiplusVersion;
45   DebugEventProc DebugEventCallback;
46   int SuppressBackgroundThread;
47   int SuppressExternalCodecs;
48 }
49
50 struct GdiplusStartupOutput {
51   NotificationHookProc NotificationHook;
52   NotificationUnhookProc NotificationUnhook;
53 }
54
55 struct GpBitmapData {
56   int Width;
57   int Height;
58   int Stride;
59   int PixelFormat;
60   void* Scan0;
61   int Reserved;
62 }
63
64 struct GpColorMatrix {
65   float[5][5] m;
66 }
67
68 struct GpPropertyItem {
69   int id;
70   int length;
71   short type;
72   void* value;
73 }
74
75 struct GpColorPalette {
76   int Flags;
77   int Count;
78   int[1] Entries;
79 }
80
81 public struct GpRectF {
82     public float X;
83     public float Y;
84     public float Width;
85     public float Height;
86 }
87
88 public struct GpRect {
89     public int X;
90     public int Y;
91     public int Width;
92     public int Height;
93 }
94 public struct GpPoint {
95     public int X;
96     public int Y;
97 }
98 public struct GpPointF {
99     public float X;
100     public float Y;
101 }
102
103 alias int function(void*) GpDrawImageAbort;
104 alias GpDrawImageAbort GpGetThumbnailImageAbort;
105
106 /******************************************************************************
107
108
109 ******************************************************************************/
110
111 enum Status {
112   OK,
113   GenericError,
114   InvalidParameter,
115   OutOfMemory,
116   ObjectBusy,
117   InsufficientBuffer,
118   NotImplemented,
119   Win32Error,
120   WrongState,
121   Aborted,
122   FileNotFound,
123   ValueOverflow,
124   AccessDenied,
125   UnknownImageFormat,
126   FontFamilyNotFound,
127   FontStyleNotFound,
128   NotTrueTypeFont,
129   UnsupportedGdiplusVersion,
130   GdiplusNotInitialized,
131   PropertyNotFound,
132   PropertyNotSupported
133 }
134
135 /**************************************************************************
136
137     Opaque types managed by Gdi+
138
139 **************************************************************************/
140 typedef GpImage  GpBitmap;
141
142 // alias   uint   ARGB;
143 typedef Handle GpFontFamily;
144 typedef Handle GpImage;
145 typedef Handle GpBrush;
146 typedef Handle GpFont;
147 typedef Handle GpFontCollection;
148 typedef Handle GpGraphics;
149 typedef Handle GpGraphicsPath;
150 typedef Handle GpImageAttributes;
151 typedef Handle GpHatchBrush;
152 typedef Handle GpLinearGradientBrush;
153 typedef Handle GpMatrix;
154 typedef Handle GpPen;
155 typedef Handle GpRegion;
156 typedef Handle GpSolidBrush;
157 typedef Handle GpStringFormat;
158 typedef Handle GpTextureBrush;
159 typedef Handle GpPath;
160
161 alias void* Handle;
162
163 alias int BrushType;
164 alias int CombineMode;
165 alias int FlushIntention;
166 alias int MatrixOrder;
167 alias int GraphicsUnit;
168 alias int QualityMode;
169 alias int SmoothingMode;
170 alias int InterpolationMode;
171 alias int CompositingMode;
172 alias int CompositingQuality;
173 alias int PixelOffsetMode;
174 alias int PixelFormat;
175 alias int RotateFlipType;
176 alias int CoordinateSpace;
177 alias int WarpMode;
178 alias int WrapMode;
179 alias int FillMode;
180 alias int LineJoin;
181 alias int LineCap;
182 alias int DashCap;
183 alias int DashStyle;
184 alias int PenAlignment;
185 alias int ColorMatrixFlag;
186 alias int ColorAdjustType;
187 alias int ColorChannelFlag;
188 alias int ImageLockMode;
189 alias int ImageCodecFlags;
190 alias int EncoderParameterValueType;
191 alias int GenericFontFamilies;
192 alias int FontStyle;
193 alias int HatchStyle;
194 alias int StringFormatFlags;
195 alias int StringAlignment;
196 alias int StringTrimming;
197 alias int TextRenderingHint;
198 alias int PenType;
199 alias int LinearGradientMode;
200 alias int KnownColor;
201 alias int Unit;
202
203 alias uint GraphicsState;
204
205 /******************************************************************************
206
207     Flat GDI+ Exports (C Interface)
208
209 ******************************************************************************/
210
211 extern (Windows):
212
213 version( STATIC_GDIPLUS ){
214 Status GdiplusStartup( uint* token, GdiplusStartupInput* input, GdiplusStartupOutput* output);
215 void   GdiplusShutdown(uint token);
216 Status GdipCreateFromHDC(Handle hdc, out Handle graphics);
217 Status GdipCreateFromHDC2(Handle hdc, Handle hDevice, out Handle graphics);
218 Status GdipCreateFromHWND(Handle hwnd, out Handle graphics);
219 Status GdipGetImageGraphicsContext(Handle image, out Handle graphics);
220 Status GdipDeleteGraphics(Handle graphics);
221 Status GdipGetDC(Handle graphics, out Handle hdc);
222 Status GdipReleaseDC(Handle graphics, Handle hdc);
223 Status GdipSetClipGraphics(Handle graphics, Handle srcgraphics, CombineMode combineMode);
224 Status GdipSetClipRectI(Handle graphics, int x, int y, int width, int height, CombineMode combineMode);
225 Status GdipSetClipRect(Handle graphics, float x, float y, float width, float height, CombineMode combineMode);
226 Status GdipSetClipPath(Handle graphics, Handle path, CombineMode combineMode);
227 Status GdipSetClipRegion(Handle graphics, Handle region, CombineMode combineMode);
228 Status GdipSetClipHrgn(Handle graphics, HRGN hRgn, CombineMode combineMode);
229
230 Status GdipGetClip(Handle graphics, out Handle region);
231 Status GdipResetClip(Handle graphics);
232 Status GdipSaveGraphics(Handle graphics, out uint state);
233 Status GdipRestoreGraphics(Handle graphics, int state);
234 Status GdipFlush(Handle graphics, FlushIntention intention);
235 Status GdipScaleWorldTransform(Handle graphics, float sx, float sy, MatrixOrder order);
236 Status GdipRotateWorldTransform(Handle graphics, float angle, MatrixOrder order);
237 Status GdipTranslateWorldTransform(Handle graphics, float dx, float dy, MatrixOrder order);
238 Status GdipMultiplyWorldTransform(Handle graphics, Handle matrix, MatrixOrder order);
239 Status GdipResetWorldTransform(Handle graphics);
240 Status GdipBeginContainer(Handle graphics, ref GpRectF dstrect, ref GpRectF srcrect, GraphicsUnit unit, out int state);
241 Status GdipBeginContainerI(Handle graphics, ref GpRect dstrect, ref GpRect srcrect, GraphicsUnit unit, out int state);
242 Status GdipBeginContainer2(Handle graphics, out int state);
243 Status GdipEndContainer(Handle graphics, int state);
244 Status GdipGetDpiX(Handle graphics, out float dpi);
245 Status GdipGetDpiY(Handle graphics, out float dpi);
246 Status GdipGetPageUnit(Handle graphics, out GraphicsUnit unit);
247 Status GdipSetPageUnit(Handle graphics, GraphicsUnit unit);
248 Status GdipGetPageScale(Handle graphics, out float scale);
249 Status GdipSetPageScale(Handle graphics, float scale);
250 Status GdipGetWorldTransform(Handle graphics, Handle matrix); // out not necessary?
251 Status GdipSetWorldTransform(Handle graphics, Handle matrix);
252 Status GdipGetCompositingMode(Handle graphics, out CompositingMode compositingMode);
253 Status GdipSetCompositingMode(Handle graphics, CompositingMode compositingMode);
254 Status GdipGetCompositingQuality(Handle graphics, out CompositingQuality compositingQuality);
255 Status GdipSetCompositingQuality(Handle graphics, CompositingQuality compositingQuality);
256 Status GdipGetInterpolationMode(Handle graphics, out InterpolationMode interpolationMode);
257 Status GdipSetInterpolationMode(Handle graphics, InterpolationMode interpolationMode);
258 Status GdipGetSmoothingMode(Handle graphics, out SmoothingMode smoothingMode);
259 Status GdipSetSmoothingMode(Handle graphics, SmoothingMode smoothingMode);
260 Status GdipGetPixelOffsetMode(Handle graphics, out PixelOffsetMode pixelOffsetMode);
261 Status GdipSetPixelOffsetMode(Handle graphics, PixelOffsetMode pixelOffsetMode);
262 Status GdipGetTextContrast(Handle graphics, out uint textContrast);
263 Status GdipSetTextContrast(Handle graphics, uint textContrast);
264 Status GdipGraphicsClear(Handle graphics, int color);
265 Status GdipDrawLine(Handle graphics, Handle pen, float x1, float y1, float x2, float y2);
266 Status GdipDrawLines(Handle graphics, Handle pen, GpPointF* points, int count);
267 Status GdipDrawLineI(Handle graphics, Handle pen, int x1, int y1, int x2, int y2);
268 Status GdipDrawLinesI(Handle graphics, Handle pen, GpPoint* points, int count);
269 Status GdipDrawArc(Handle graphics, Handle pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
270 Status GdipDrawArcI(Handle graphics, Handle pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
271 Status GdipDrawBezier(Handle graphics, Handle pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
272 Status GdipDrawBeziers(Handle graphics, Handle pen, GpPointF* points, int count);
273 Status GdipDrawBezierI(Handle graphics, Handle pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
274 Status GdipDrawBeziersI(Handle graphics, Handle pen, GpPoint* points, int count);
275 Status GdipDrawRectangle(Handle graphics, Handle pen, float x, float y, float width, float height);
276 Status GdipDrawRectangles(Handle graphics, Handle pen, GpRectF* rects, int count);
277 Status GdipDrawRectangleI(Handle graphics, Handle pen, int x, int y, int width, int height);
278 Status GdipDrawRectanglesI(Handle graphics, Handle pen, GpRect* rects, int count);
279 Status GdipDrawEllipse(Handle graphics, Handle pen, float x, float y, float width, float height);
280 Status GdipDrawEllipseI(Handle graphics, Handle pen, int x, int y, int width, int height);
281 Status GdipDrawPie(Handle graphics, Handle pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
282 Status GdipDrawPieI(Handle graphics, Handle pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
283 Status GdipDrawPolygon(Handle graphics, Handle pen, GpPointF* points, int count);
284 Status GdipDrawPolygonI(Handle graphics, Handle pen, GpPoint* points, int count);
285 Status GdipDrawCurve(Handle graphics, Handle pen, GpPointF* points, int count);
286 Status GdipDrawCurve2(Handle graphics, Handle pen, GpPointF* points, int count, float tension);
287 Status GdipDrawCurve3(Handle graphics, Handle pen, GpPointF* points, int count, int offset, int numberOfSegments, float tension);
288 Status GdipDrawCurveI(Handle graphics, Handle pen, GpPoint* points, int count);
289 Status GdipDrawCurve2I(Handle graphics, Handle pen, GpPoint* points, int count, float tension);
290 Status GdipDrawCurve3I(Handle graphics, Handle pen, GpPoint* points, int count, int offset, int numberOfSegments, float tension);
291 Status GdipDrawClosedCurve(Handle graphics, Handle pen, GpPointF* points, int count);
292 Status GdipDrawClosedCurve2(Handle graphics, Handle pen, GpPointF* points, int count, float tension);
293 Status GdipDrawClosedCurveI(Handle graphics, Handle pen, GpPoint* points, int count);
294 Status GdipDrawClosedCurve2I(Handle graphics, Handle pen, GpPoint* points, int count, float tension);
295 Status GdipFillRectangleI(Handle graphics, Handle brush, int x, int y, int width, int height);
296 Status GdipFillRectangle(Handle graphics, Handle brush, float x, float y, float width, float height);
297 Status GdipFillRectanglesI(Handle graphics, Handle brush, GpRect* rects, int count);
298 Status GdipFillRectangles(Handle graphics, Handle brush, GpRectF* rects, int count);
299 Status GdipFillPolygon(Handle graphics, Handle brush, GpPointF* rects, int count, FillMode fillMode);
300 Status GdipFillPolygonI(Handle graphics, Handle brush, GpPoint* rects, int count, FillMode fillMode);
301 Status GdipFillEllipse(Handle graphics, Handle brush, float x, float y, float width, float height);
302 Status GdipFillEllipseI(Handle graphics, Handle brush, int x, int y, int width, int height);
303 Status GdipFillPie(Handle graphics, Handle brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
304 Status GdipFillPieI(Handle graphics, Handle brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
305 Status GdipFillPath(Handle graphics, Handle brush, Handle path);
306 Status GdipFillClosedCurve(Handle graphics, Handle brush, GpPointF* points, int count);
307 Status GdipFillClosedCurveI(Handle graphics, Handle brush, GpPoint* points, int count);
308 Status GdipFillClosedCurve2(Handle graphics, Handle brush, GpPointF* points, int count, FillMode fillMode, float tension);
309 Status GdipFillClosedCurve2I(Handle graphics, Handle brush, GpPoint* points, int count, FillMode fillMode, float tension);
310 Status GdipFillRegion(Handle graphics, Handle brush, Handle region);
311 Status GdipDrawString(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, Handle brush);
312 Status GdipMeasureString(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, ref GpRectF boundingBox, int* codepointsFitted, int* linesFitted);
313 Status GdipGetStringFormatMeasurableCharacterRangeCount(Handle format, out int count);
314 Status GdipCloneStringFormat(Handle format, out Handle newFormat);
315
316 Status GdipMeasureCharacterRanges(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, int regionCount, Handle* regions);
317 Status GdipDrawImage(Handle graphics, Handle image, float x, float y);
318 Status GdipDrawImageI(Handle graphics, Handle image, int x, int y);
319 Status GdipDrawImageRect(Handle graphics, Handle image, float x, float y, float width, float height);
320 Status GdipDrawImageRectI(Handle graphics, Handle image, int x, int y, int width, int height);
321 Status GdipDrawImagePointRect(Handle graphics, Handle image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
322 Status GdipDrawImagePointRectI(Handle graphics, Handle image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit);
323 Status GdipDrawImageRectRect(Handle graphics, Handle image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData);
324 Status GdipDrawImageRectRectI(Handle graphics, Handle image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData);
325 Status GdipDrawImagePoints(Handle graphics, Handle image, GpPointF* dstpoints, int count);
326 Status GdipDrawImagePointsI(Handle graphics, Handle image, GpPoint* dstpoints, int count);
327 Status GdipDrawImagePointsRect(Handle graphics, Handle image, GpPointF* dstpoints, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData);
328 Status GdipDrawImagePointsRectI(Handle graphics, Handle image, GpPoint* dstpoints, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData);
329 Status GdipIsVisiblePoint(Handle graphics, float x, float y, out int result);
330 Status GdipIsVisiblePointI(Handle graphics, int x, int y, out int result);
331 Status GdipIsVisibleRect(Handle graphics, float x, float y, float width, float height, out int result);
332 Status GdipIsVisibleRectI(Handle graphics, int x, int y, int width, int height, out int result);
333 Status GdipGetTextRenderingHint(Handle graphics, out TextRenderingHint mode);
334 Status GdipSetTextRenderingHint(Handle graphics, TextRenderingHint mode);
335 Status GdipGetClipBounds(Handle graphics, out GpRectF rect);
336 Status GdipGetClipBoundsI(Handle graphics, out GpRect rect);
337 Status GdipGetVisibleClipBounds(Handle graphics, out GpRectF rect);
338 Status GdipGetVisibleClipBoundsI(Handle graphics, out GpRect rect);
339 Status GdipIsClipEmpty(Handle graphics, out int result);
340 Status GdipIsVisibleClipEmpty(Handle graphics, out int result);
341 Status GdipGetRenderingOrigin(Handle graphics, out int x, out int y);
342 Status GdipSetRenderingOrigin(Handle graphics, int x, int y);
343 Status GdipGetNearestColor(Handle graphics, ref int argb);
344 Status GdipComment(Handle graphics, uint sizeData, ubyte* data);
345 Status GdipTransformPoints(Handle graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, GpPointF* points, int count);
346 Status GdipTransformPointsI(Handle graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, GpPoint* points, int count);
347
348 Status GdipCreateMatrix(out Handle matrix);
349 Status GdipCreateMatrix2(float m11, float m12, float m21, float m22, float dx, float dy, out Handle matrix);
350 Status GdipCreateMatrix3(ref GpRectF rect, GpPointF* dstplg, out Handle matrix);
351 Status GdipCreateMatrix3I(ref GpRect rect, GpPoint* dstplg, out Handle matrix);
352 Status GdipDeleteMatrix(Handle matrix);
353 Status GdipCloneMatrix(Handle matrix, out Handle cloneMatrix);
354 Status GdipGetMatrixElements(Handle matrix, float* matrixOut);
355 Status GdipSetMatrixElements(Handle matrix, float m11, float m12, float m21, float m22, float xy, float dy);
356 Status GdipInvertMatrix(Handle matrix);
357 Status GdipMultiplyMatrix(Handle matrix, Handle matrix2, MatrixOrder order);
358 Status GdipScaleMatrix(Handle matrix, float scaleX, float scaleY, MatrixOrder order);
359 Status GdipShearMatrix(Handle matrix, float shearX, float shearY, MatrixOrder order);
360 Status GdipRotateMatrix(Handle matrix, float angle, MatrixOrder order);
361 Status GdipTranslateMatrix(Handle matrix, float offsetX, float offsetY, MatrixOrder order);
362 Status GdipIsMatrixIdentity(Handle matrix, out int result);
363 Status GdipIsMatrixInvertible(Handle matrix, out int result);
364 Status GdipTransformMatrixPoints(Handle matrix, GpPointF *pts, int count);
365
366 Status GdipGetBrushType(Handle brush, out BrushType type );
367 Status GdipCloneBrush(Handle brush, out Handle cloneBrush);
368 Status GdipDeleteBrush(Handle brush);
369
370 Status GdipCreateSolidFill(int color, out Handle brush);
371 Status GdipGetSolidFillColor(Handle brush, out int color);
372 Status GdipSetSolidFillColor(Handle brush, int color);
373
374 Status GdipCreateTexture(Handle image, WrapMode wrapMode, out Handle texture);
375 Status GdipCreateTexture2(Handle image, WrapMode wrapMode, float x, float y, float width, float height, out Handle texture);
376 Status GdipCreateTexture2I(Handle image, WrapMode wrapMode, int x, int y, int width, int height, out Handle texture);
377 Status GdipGetTextureImage(Handle brush, out Handle image);
378 Status GdipGetTextureTransform(Handle brush, out Handle matrix);
379 Status GdipSetTextureTransform(Handle brush, Handle matrix);
380 Status GdipGetTextureWrapMode(Handle brush, out WrapMode wrapmode);
381 Status GdipSetTextureWrapMode(Handle brush, WrapMode wrapmode);
382
383 Status GdipCreateHatchBrush(HatchStyle hatchstyle, int forecol, int backcol, out Handle brush);
384 Status GdipGetHatchStyle(Handle brush, out HatchStyle hatchstyle);
385 Status GdipGetHatchForegroundColor(Handle brush, out int forecol);
386 Status GdipGetHatchBackgroundColor(Handle brush, out int backcol);
387
388 Status GdipCreateLineBrushI(ref GpPoint point1, ref GpPoint point2, int color1, int color2, WrapMode wrapMode, out Handle lineGradient);
389 Status GdipCreateLineBrush(ref GpPointF point1, ref GpPointF point2, int color1, int color2, WrapMode wrapMode, out Handle lineGradient);
390 Status GdipCreateLineBrushFromRectI(ref GpRect rect, int color1, int color2, LinearGradientMode mode, WrapMode wrapMode, out Handle lineGradient);
391 Status GdipCreateLineBrushFromRect(ref GpRectF rect, int color1, int color2, LinearGradientMode mode, WrapMode wrapMode, out Handle lineGradient);
392 Status GdipCreateLineBrushFromRectWithAngleI(ref GpRect rect, int color1, int color2, float angle, int isAngleScalable, WrapMode wrapMode, out Handle lineGradient);
393 Status GdipCreateLineBrushFromRectWithAngle(ref GpRectF rect, int color1, int color2, float angle, int isAngleScalable, WrapMode wrapMode, out Handle lineGradient);
394 Status GdipGetLineBlendCount(Handle brush, out int count);
395 Status GdipGetLineBlend(Handle brush, float* blend, float* positions, int count);
396 Status GdipSetLineBlend(Handle brush, float* blend, float* positions, int count);
397 Status GdipGetLinePresetBlendCount(Handle brush, out int count);
398 Status GdipGetLinePresetBlend(Handle brush, uint* blend, float* positions, int count);
399 Status GdipSetLinePresetBlend(Handle brush, uint* blend, float* positions, int count);
400 Status GdipGetLineWrapMode(Handle brush, out WrapMode wrapmode);