comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/gdip/Gdip.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children 2847134a5fc0
comparison
equal deleted inserted replaced
-1:000000000000 0:6dd524f61e62
1 /*******************************************************************************
2 * Copyright (c) 2000, 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 * Port to the D programming language:
11 * John Reimer <terminal.node@gmail.com>
12 * Frank Benoit <benoit@tionex.de>
13 *******************************************************************************/
14
15 module org.eclipse.swt.internal.gdip.Gdip;
16
17 import org.eclipse.swt.internal.gdip.native;
18
19 import org.eclipse.swt.internal.Library;
20 import org.eclipse.swt.internal.Platform;
21 import org.eclipse.swt.internal.win32.WINTYPES;
22 import org.eclipse.swt.internal.win32.WINAPI;
23 import org.eclipse.swt.internal.win32.OS;
24 version(TANGOSVN){
25 import tango.sys.win32.UserGdi;
26 }
27
28 alias org.eclipse.swt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput;
29 alias org.eclipse.swt.internal.gdip.native.GdiplusStartupOutput GdiplusStartupOutput;
30
31 /******************************************************************************
32
33 Gdip Class: provides access to the Gdi+ interface
34
35 /*****************************************************************************/
36
37 public class Gdip : Platform
38 {
39 static this(){
40 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
41 loadLib_Gdip();
42 }
43 }
44 /**************************************************************************
45
46 **************************************************************************/
47
48 private:
49
50 static FontFamily GenericSansSerifFontFamily = null;
51 static FontFamily GenericSerifFontFamily = null;
52 static FontFamily GenericMonospaceFontFamily = null;
53
54 /**************************************************************************
55
56 **************************************************************************/
57
58 struct FontFamily_T
59 {
60 Handle nativeFamily;
61 Status lastResult;
62 }
63
64 struct StringFormat_T
65 {
66
67 StringFormat format;
68 Status lastError;
69 }
70
71 static ubyte GenericTypographicStringFormatBuffer[StringFormat_T.sizeof] = 0;
72 static ubyte GenericDefaultStringFormatBuffer [StringFormat_T.sizeof] = 0;
73 static ubyte GenericSansSerifFontFamilyBuffer [FontFamily_T.sizeof] = 0;
74 static ubyte GenericSerifFontFamilyBuffer [FontFamily_T.sizeof] = 0;
75 static ubyte GenericMonospaceFontFamilyBuffer [FontFamily_T.sizeof] = 0;
76
77 /**************************************************************************
78
79 **************************************************************************/
80
81 public:
82
83 alias GpPoint Point;
84 alias GpPointF PointF;
85 alias GpRect Rect;
86 alias GpRectF RectF;
87 alias GpBitmapData BitmapData;
88 alias GpColorPalette ColorPalette;
89 alias GpDrawImageAbort DrawImageAbort;
90 alias GpColorMatrix ColorMatrix;
91
92 alias GpFontFamily FontFamily;
93 alias GpImage Image;
94 alias GpBrush Brush;
95 alias GpFont Font;
96 alias GpFontCollection FontCollection;
97 alias GpGraphics Graphics;
98 alias GpGraphicsPath GraphicsPath;
99 alias GpImageAttributes ImageAttributes;
100 alias GpHatchBrush HatchBrush;
101 alias GpLinearGradientBrush LinearGradientBrush;
102 alias GpMatrix Matrix;
103 alias GpPen Pen;
104 alias GpRegion Region;
105 alias GpSolidBrush SolidBrush;
106 alias GpStringFormat StringFormat;
107 alias GpTextureBrush TextureBrush;
108 alias GpPath Path;
109
110 alias Image Bitmap;
111
112 alias uint ARGB;
113
114 alias org.eclipse.swt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput;
115 alias org.eclipse.swt.internal.gdip.native.GdiplusStartupOutput GdiplusStartupOutput;
116
117 /**************************************************************************
118
119 Gdi+ Constants
120
121 **************************************************************************/
122
123 enum {
124 BrushTypeSolidColor = 0,
125 BrushTypeHatchFill = 1,
126 BrushTypeTextureFill = 2,
127 BrushTypePathGradient = 3,
128 BrushTypeLinearGradient = 4,
129 // ColorAdjustTypeBitmap = 1,
130 ColorMatrixFlagsDefault = 0,
131 CombineModeReplace = 0,
132 CombineModeIntersect = 1,
133 CombineModeUnion = 2,
134 CombineModeXor = 3,
135 CombineModeExclude = 4,
136 CombineModeComplement = 5,
137 FillModeAlternate = 0,
138 FillModeWinding = 1,
139 DashCapFlat = 0,
140 DashCapRound = 2,
141 DashCapTriangle = 3,
142 DashStyleSolid = 0,
143 DashStyleDash = 1,
144 DashStyleDot = 2,
145 DashStyleDashDot = 3,
146 DashStyleDashDotDot = 4,
147 DashStyleCustom = 5,
148 FontStyleRegular = 0,
149 FontStyleBold = 1,
150 FontStyleItalic = 2,
151 FontStyleBoldItalic = 3,
152 FontStyleUnderline = 4,
153 FontStyleStrikeout = 8,
154 PaletteFlagsHasAlpha = 0x0001,
155 FlushIntentionFlush = 0,
156 FlushIntentionSync = 1,
157 HotkeyPrefixNone = 0,
158 HotkeyPrefixShow = 1,
159 HotkeyPrefixHide = 2,
160 LineJoinMiter = 0,
161 LineJoinBevel = 1,
162 LineJoinRound = 2,
163 LineCapFlat = 0,
164 LineCapSquare = 1,
165 LineCapRound = 2,
166 MatrixOrderPrepend = 0,
167 MatrixOrderAppend = 1,
168 QualityModeDefault = 0,
169 QualityModeLow = 1,
170 QualityModeHigh = 2,
171 InterpolationModeInvalid = -1,
172 InterpolationModeDefault = QualityModeDefault,
173 InterpolationModeLowQuality = QualityModeLow,
174 InterpolationModeHighQuality = QualityModeHigh,
175 InterpolationModeBilinear = QualityModeHigh + 1,
176 InterpolationModeBicubic = QualityModeHigh + 2,
177 InterpolationModeNearestNeighbor = QualityModeHigh + 3,
178 InterpolationModeHighQualityBilinear = QualityModeHigh + 4,
179 InterpolationModeHighQualityBicubic = QualityModeHigh + 5,
180 PathPointTypeStart = 0,
181 PathPointTypeLine = 1,
182 PathPointTypeBezier = 3,
183 PathPointTypePathTypeMask = 0x7,
184 PathPointTypePathDashMode = 0x10,
185 PathPointTypePathMarker = 0x20,
186 PathPointTypeCloseSubpath = 0x80,
187 PathPointTypeBezier3 = 3,
188 PixelFormatIndexed = 0x00010000,
189 PixelFormatGDI = 0x00020000,
190 PixelFormatAlpha = 0x00040000,
191 PixelFormatPAlpha = 0x00080000,
192 PixelFormatExtended = 0x00100000,
193 PixelFormatCanonical = 0x00200000,
194 PixelFormat1bppIndexed = (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI),
195 PixelFormat4bppIndexed = (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI),
196 PixelFormat8bppIndexed = (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI),
197 PixelFormat16bppGrayScale = (4 | (16 << 8) | PixelFormatExtended),
198 PixelFormat16bppRGB555 = (5 | (16 << 8) | PixelFormatGDI),
199 PixelFormat16bppRGB565 = (6 | (16 << 8) | PixelFormatGDI),
200 PixelFormat16bppARGB1555 = (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI),
201 PixelFormat24bppRGB = (8 | (24 << 8) | PixelFormatGDI),
202 PixelFormat32bppRGB = (9 | (32 << 8) | PixelFormatGDI),
203 PixelFormat32bppARGB = (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical),
204 PixelFormat32bppPARGB = (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI),
205 PixelFormat48bppRGB = (12 | (48 << 8) | PixelFormatExtended),
206 PixelFormat64bppARGB = (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended),
207 PixelFormat64bppPARGB = (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended),
208 PixelFormatMax = 15,
209 PixelOffsetModeNone = QualityModeHigh + 1,
210 PixelOffsetModeHalf = QualityModeHigh + 2,
211 SmoothingModeInvalid = -1,
212 SmoothingModeDefault = QualityModeDefault,
213 SmoothingModeHighSpeed = QualityModeLow,
214 SmoothingModeHighQuality = QualityModeHigh,
215 SmoothingModeNone = 3,
216 SmoothingModeAntiAlias8x4 = 4,
217 SmoothingModeAntiAlias = SmoothingModeAntiAlias8x4,
218 SmoothingModeAntiAlias8x8 = 5,
219 StringFormatFlagsDirectionRightToLeft = 0x00000001,
220 StringFormatFlagsDirectionVertical = 0x00000002,
221 StringFormatFlagsNoFitBlackBox = 0x00000004,
222 StringFormatFlagsDisplayFormatControl = 0x00000020,
223 StringFormatFlagsNoFontFallback = 0x00000400,
224 StringFormatFlagsMeasureTrailingSpaces = 0x00000800,
225 StringFormatFlagsNoWrap = 0x00001000,
226 StringFormatFlagsLineLimit = 0x00002000,
227 StringFormatFlagsNoClip = 0x00004000,
228 TextRenderingHintSystemDefault = 0,
229 TextRenderingHintSingleBitPerPixelGridFit = 1,
230 TextRenderingHintSingleBitPerPixel = 2,
231 TextRenderingHintAntiAliasGridFit = 3,
232 TextRenderingHintAntiAlias = 4,
233 TextRenderingHintClearTypeGridFit = 5,
234 // UnitPixel = 2,
235 WrapModeTile = 0,
236 WrapModeTileFlipX = 1,
237 WrapModeTileFlipY = 2,
238 WrapModeTileFlipXY = 3,
239 WrapModeClamp = 4
240 }
241
242 enum
243 {
244 PenTypeSolidColor = BrushTypeSolidColor,
245 PenTypeHatchFill = BrushTypeHatchFill,
246 PenTypeTextureFill = BrushTypeTextureFill,
247 PenTypePathGradient = BrushTypePathGradient,
248 PenTypeLinearGradient = BrushTypeLinearGradient,
249 PenTypeUnknown = -1
250 }
251
252 enum
253 {
254 UnitWorld, // 0 -- World coordinate (non-physical unit)
255 UnitDisplay, // 1 -- Variable -- for PageTransform only
256 UnitPixel, // 2 -- Each unit is one device pixel.
257 UnitPoint, // 3 -- Each unit is a printer's point, or 1/72 inch.
258 UnitInch, // 4 -- Each unit is 1 inch.
259 UnitDocument, // 5 -- Each unit is 1/300 inch.
260 UnitMillimeter // 6 -- Each unit is 1 millimeter.
261 }
262
263 enum
264 {
265 AliceBlue = 0xFFF0F8FF,
266 AntiqueWhite = 0xFFFAEBD7,
267 Aqua = 0xFF00FFFF,
268 Aquamarine = 0xFF7FFFD4,
269 Azure = 0xFFF0FFFF,
270 Beige = 0xFFF5F5DC,
271 Bisque = 0xFFFFE4C4,
272 Black = 0xFF000000,
273 BlanchedAlmond = 0xFFFFEBCD,
274 Blue = 0xFF0000FF,
275 BlueViolet = 0xFF8A2BE2,
276 Brown = 0xFFA52A2A,
277 BurlyWood = 0xFFDEB887,
278 CadetBlue = 0xFF5F9EA0,
279 Chartreuse = 0xFF7FFF00,
280 Chocolate = 0xFFD2691E,
281 Coral = 0xFFFF7F50,
282 CornflowerBlue = 0xFF6495ED,
283 Cornsilk = 0xFFFFF8DC,
284 Crimson = 0xFFDC143C,
285 Cyan = 0xFF00FFFF,
286 DarkBlue = 0xFF00008B,
287 DarkCyan = 0xFF008B8B,
288 DarkGoldenrod = 0xFFB8860B,
289 DarkGray = 0xFFA9A9A9,
290 DarkGreen = 0xFF006400,
291 DarkKhaki = 0xFFBDB76B,
292 DarkMagenta = 0xFF8B008B,
293 DarkOliveGreen = 0xFF556B2F,
294 DarkOrange = 0xFFFF8C00,
295 DarkOrchid = 0xFF9932CC,
296 DarkRed = 0xFF8B0000,
297 DarkSalmon = 0xFFE9967A,
298 DarkSeaGreen = 0xFF8FBC8B,
299 DarkSlateBlue = 0xFF483D8B,
300 DarkSlateGray = 0xFF2F4F4F,
301 DarkTurquoise = 0xFF00CED1,
302 DarkViolet = 0xFF9400D3,
303 DeepPink = 0xFFFF1493,
304 DeepSkyBlue = 0xFF00BFFF,
305 DimGray = 0xFF696969,
306 DodgerBlue = 0xFF1E90FF,
307 Firebrick = 0xFFB22222,
308 FloralWhite = 0xFFFFFAF0,
309 ForestGreen = 0xFF228B22,
310 Fuchsia = 0xFFFF00FF,
311 Gainsboro = 0xFFDCDCDC,
312 GhostWhite = 0xFFF8F8FF,
313 Gold = 0xFFFFD700,
314 Goldenrod = 0xFFDAA520,
315 Gray = 0xFF808080,
316 Green = 0xFF008000,
317 GreenYellow = 0xFFADFF2F,
318 Honeydew = 0xFFF0FFF0,
319 HotPink = 0xFFFF69B4,
320 IndianRed = 0xFFCD5C5C,
321 Indigo = 0xFF4B0082,
322 Ivory = 0xFFFFFFF0,
323 Khaki = 0xFFF0E68C,
324 Lavender = 0xFFE6E6FA,
325 LavenderBlush = 0xFFFFF0F5,
326 LawnGreen = 0xFF7CFC00,
327 LemonChiffon = 0xFFFFFACD,
328 LightBlue = 0xFFADD8E6,
329 LightCoral = 0xFFF08080,
330 LightCyan = 0xFFE0FFFF,
331 LightGoldenrodYellow = 0xFFFAFAD2,
332 LightGray = 0xFFD3D3D3,
333 LightGreen = 0xFF90EE90,
334 LightPink = 0xFFFFB6C1,
335 LightSalmon = 0xFFFFA07A,
336 LightSeaGreen = 0xFF20B2AA,
337 LightSkyBlue = 0xFF87CEFA,
338 LightSlateGray = 0xFF778899,
339 LightSteelBlue = 0xFFB0C4DE,
340 LightYellow = 0xFFFFFFE0,
341 Lime = 0xFF00FF00,
342 LimeGreen = 0xFF32CD32,
343 Linen = 0xFFFAF0E6,
344 Magenta = 0xFFFF00FF,
345 Maroon = 0xFF800000,
346 MediumAquamarine = 0xFF66CDAA,
347 MediumBlue = 0xFF0000CD,
348 MediumOrchid = 0xFFBA55D3,
349 MediumPurple = 0xFF9370DB,
350 MediumSeaGreen = 0xFF3CB371,
351 MediumSlateBlue = 0xFF7B68EE,
352 MediumSpringGreen = 0xFF00FA9A,
353 MediumTurquoise = 0xFF48D1CC,
354 MediumVioletRed = 0xFFC71585,
355 MidnightBlue = 0xFF191970,
356 MintCream = 0xFFF5FFFA,
357 MistyRose = 0xFFFFE4E1,
358 Moccasin = 0xFFFFE4B5,
359 NavajoWhite = 0xFFFFDEAD,
360 Navy = 0xFF000080,
361 OldLace = 0xFFFDF5E6,
362 Olive = 0xFF808000,
363 OliveDrab = 0xFF6B8E23,
364 Orange = 0xFFFFA500,
365 OrangeRed = 0xFFFF4500,
366 Orchid = 0xFFDA70D6,
367 PaleGoldenrod = 0xFFEEE8AA,
368 PaleGreen = 0xFF98FB98,
369 PaleTurquoise = 0xFFAFEEEE,
370 PaleVioletRed = 0xFFDB7093,
371 PapayaWhip = 0xFFFFEFD5,
372 PeachPuff = 0xFFFFDAB9,
373 Peru = 0xFFCD853F,
374 Pink = 0xFFFFC0CB,
375 Plum = 0xFFDDA0DD,
376 PowderBlue = 0xFFB0E0E6,
377 Purple = 0xFF800080,
378 Red = 0xFFFF0000,
379 RosyBrown = 0xFFBC8F8F,
380 RoyalBlue = 0xFF4169E1,
381 SaddleBrown = 0xFF8B4513,
382 Salmon = 0xFFFA8072,
383 SandyBrown = 0xFFF4A460,
384 SeaGreen = 0xFF2E8B57,
385 SeaShell = 0xFFFFF5EE,
386 Sienna = 0xFFA0522D,
387 Silver = 0xFFC0C0C0,
388 SkyBlue = 0xFF87CEEB,
389 SlateBlue = 0xFF6A5ACD,
390 SlateGray = 0xFF708090,
391 Snow = 0xFFFFFAFA,
392 SpringGreen = 0xFF00FF7F,
393 SteelBlue = 0xFF4682B4,
394 Tan = 0xFFD2B48C,
395 Teal = 0xFF008080,
396 Thistle = 0xFFD8BFD8,
397 Tomato = 0xFFFF6347,
398 Transparent = 0x00FFFFFF,
399 Turquoise = 0xFF40E0D0,
400 Violet = 0xFFEE82EE,
401 Wheat = 0xFFF5DEB3,
402 White = 0xFFFFFFFF,
403 WhiteSmoke = 0xFFF5F5F5,
404 Yellow = 0xFFFFFF00,
405 YellowGreen = 0xFF9ACD32
406 }
407
408 // Shift count and bit mask for A, R, G, B components
409
410 enum
411 {
412 AlphaShift = 24,
413 RedShift = 16,
414 GreenShift = 8,
415 BlueShift = 0
416 }
417
418 enum
419 {
420 AlphaMask = 0xff000000,
421 RedMask = 0x00ff0000,
422 GreenMask = 0x0000ff00,
423 BlueMask = 0x000000ff
424 }
425
426 enum
427 {
428 ColorAdjustTypeDefault,
429 ColorAdjustTypeBitmap,
430 ColorAdjustTypeBrush,
431 ColorAdjustTypePen,
432 ColorAdjustTypeText,
433 ColorAdjustTypeCount,
434 ColorAdjustTypeAny // Reserved
435 }
436
437 static ARGB MakeARGB( ubyte a,
438 ubyte r,
439 ubyte g,
440 ubyte b )
441 {
442 return ((cast(ARGB) (b) << Gdip.BlueShift) |
443 (cast(ARGB) (g) << Gdip.GreenShift) |
444 (cast(ARGB) (r) << Gdip.RedShift) |
445 (cast(ARGB) (a) << Gdip.AlphaShift));
446 }
447
448 /**************************************************************************
449
450 Error Status control
451
452 **************************************************************************/
453
454 private static Status SetStatus( Status status )
455 {
456 if (status != Status.OK)
457 return ( lastResult = status );
458 else
459 return status;
460 }
461
462 private static Status lastResult;
463
464 /**************************************************************************
465
466 GDI+ Bitmap Wrap Interface
467
468 **************************************************************************/
469
470 public:
471
472 static void BitmapData_delete (BitmapData* bitmapdata)
473 {
474 delete bitmapdata;
475 }
476
477 /**************************************************************************
478
479 **************************************************************************/
480
481 static BitmapData* BitmapData_new()
482 {
483 return new BitmapData;
484 }
485
486 /**************************************************************************
487
488 **************************************************************************/
489
490 static int Bitmap_GetHBITMAP( Bitmap bitmap, ARGB colorBackground,
491 out HBITMAP hbmReturn )
492 {
493 return SetStatus( GdipCreateHBITMAPFromBitmap( bitmap, hbmReturn,
494 colorBackground ) );
495 }
496
497 /**************************************************************************
498
499 **************************************************************************/
500
501 static int Bitmap_GetHICON( Bitmap bitmap, out HICON hIconReturn)
502 {
503 return SetStatus( GdipCreateHICONFromBitmap( bitmap, hIconReturn ) );
504 }
505
506 /**************************************************************************
507
508 **************************************************************************/
509
510 static int Bitmap_LockBits( Bitmap bitmap, Rect* rect,
511 uint flags, PixelFormat pixelFormat,
512 BitmapData* lockedBitmapData )
513 {
514 return SetStatus( GdipBitmapLockBits( bitmap, rect, flags,
515 pixelFormat, lockedBitmapData ) );
516 }
517
518 /**************************************************************************
519
520 **************************************************************************/
521
522 static int Bitmap_UnlockBits( Bitmap bitmap, BitmapData* lockedBitmapData )
523 {
524 return SetStatus( GdipBitmapUnlockBits( bitmap, lockedBitmapData ) );
525 }
526
527 /**************************************************************************
528
529 **************************************************************************/
530
531 static void Bitmap_delete( Bitmap bitmap )
532 {
533 GdipDisposeImage( bitmap );
534 }
535
536 /**************************************************************************
537
538 **************************************************************************/
539
540 static Bitmap Bitmap_new( HICON hicon )
541 {
542 Bitmap bitmap;
543 Gdip.lastResult = GdipCreateBitmapFromHICON( hicon, bitmap );
544 return bitmap;
545 }
546
547 /**************************************************************************
548
549 **************************************************************************/
550
551 static Bitmap Bitmap_new( HBITMAP hbm, HPALETTE hpal )
552 {
553 Bitmap bitmap;
554 Gdip.lastResult = GdipCreateBitmapFromHBITMAP( hbm, hpal, bitmap );
555 return bitmap;
556 }
557
558 /**************************************************************************
559
560 **************************************************************************/
561
562 static Bitmap Bitmap_new( int width, int height, int stride,
563 PixelFormat format, ubyte* scan0 )
564 {
565 Bitmap bitmap;
566 Gdip.lastResult = GdipCreateBitmapFromScan0( width, height, stride,
567 format, scan0,
568 bitmap );
569 return bitmap;
570 }
571
572 /**************************************************************************
573
574 **************************************************************************/
575
576 static Bitmap Bitmap_new( wchar* filename, bool useIcm )
577 {
578 Bitmap bitmap;
579 if (useIcm) {
580 Gdip.lastResult = GdipCreateBitmapFromFileICM( filename, bitmap );
581 } else {
582 Gdip.lastResult = GdipCreateBitmapFromFile( filename, bitmap );
583 }
584 return bitmap;
585 }
586
587
588 /**************************************************************************
589
590 Gdi+ Image Wrap Interface
591
592 **************************************************************************/
593
594 static Status Image_GetLastStatus( Image image )
595 {
596 Status lastStatus = Gdip.lastResult;
597 Gdip.lastResult = Status.OK;
598 return lastStatus;
599 }
600
601 /**************************************************************************
602
603 **************************************************************************/
604
605 static PixelFormat Image_GetPixelFormat( Image image )
606 {
607 PixelFormat format;
608 SetStatus( GdipGetImagePixelFormat( image, format ) );
609 return format;
610 }
611
612 /**************************************************************************
613
614 **************************************************************************/
615
616 static uint Image_GetWidth( Image image )
617 {
618 uint width = 0;
619 SetStatus( GdipGetImageWidth( image, width ) );
620 return width;
621 }
622
623 /**************************************************************************
624
625 **************************************************************************/
626
627 static uint Image_GetHeight( Image image )
628 {
629 uint height = 0;
630 SetStatus( GdipGetImageHeight( image, height ) );
631 return height;
632 }
633
634 /**************************************************************************
635
636 **************************************************************************/
637
638 static Status Image_GetPalette( Image image, ColorPalette* palette, int size )
639 {
640 return SetStatus( GdipGetImagePalette( image, palette, size ) );
641 }
642
643 /**************************************************************************
644
645 **************************************************************************/
646
647 static int Image_GetPaletteSize( Image image )
648 {
649 int size = 0;
650 SetStatus( GdipGetImagePaletteSize( image, size ) );
651 return size;
652 }
653
654 /**************************************************************************
655
656 Gdi+ ImageAttributes Wrap Interface
657
658 **************************************************************************/
659
660 static ImageAttributes ImageAttributes_new()
661 {
662 ImageAttributes ImageAttr = null;
663 Gdip.lastResult = GdipCreateImageAttributes( ImageAttr );
664 return ImageAttr;
665 }
666
667 /**************************************************************************
668
669 **************************************************************************/
670
671 static void ImageAttributes_delete( ImageAttributes attrib )
672 {
673 GdipDisposeImageAttributes( attrib );
674 }
675
676 /**************************************************************************
677
678 **************************************************************************/
679
680 static Status ImageAttributes_SetWrapMode( ImageAttributes attrib,
681 WrapMode wrap,
682 ARGB color = Gdip.Black,
683 bool clamp = false )
684 {
685 return SetStatus(GdipSetImageAttributesWrapMode(
686 attrib, wrap, color, clamp));
687 }
688
689
690 /**************************************************************************
691
692 **************************************************************************/
693
694 static Status ImageAttributes_SetColorMatrix( ImageAttributes attrib,
695 ref ColorMatrix matrix,
696 ColorMatrixFlag mode = Gdip.ColorMatrixFlagsDefault,
697 ColorAdjustType type = Gdip.ColorAdjustTypeDefault )
698 {
699 return SetStatus( GdipSetImageAttributesColorMatrix(
700 attrib,
701 type,
702 true,
703 &matrix,
704 null,
705 mode));
706 }
707
708
709 /**************************************************************************
710
711 Gdi+ Brush Wrap Interface
712
713 **************************************************************************/
714
715 static Brush Brush_Clone( Brush brush )
716 {
717 Brush cloneBrush;
718 SetStatus( GdipCloneBrush( brush, cloneBrush ) );
719 return cloneBrush;
720 }
721
722 /**************************************************************************
723
724 **************************************************************************/
725
726 static BrushType Brush_GetType( Brush brush )
727 {
728 BrushType brushType = -1;
729 SetStatus( GdipGetBrushType( brush, brushType ) );
730 return brushType;
731 }
732
733 /**************************************************************************
734
735 Gdi+ HatchedBrush Wrap Interface
736
737 **************************************************************************/
738
739 static void HatchBrush_delete( HatchBrush brush )
740 {
741 GdipDeleteBrush(brush);
742 }
743
744 /**************************************************************************
745
746 **************************************************************************/
747
748 static HatchBrush HatchBrush_new( HatchStyle hatchStyle,
749 ARGB foreColor, ARGB backColor )
750 {
751 HatchBrush brush = null;
752
753 Gdip.lastResult = GdipCreateHatchBrush( hatchStyle,
754 foreColor,
755 backColor,
756 brush );
757 return brush;
758 }
759
760 /**************************************************************************
761
762 Gdi+ LinearGradientBrush Wrap Interface
763
764 **************************************************************************/
765
766 static LinearGradientBrush LinearGradientBrush_new( ref PointF point1, ref PointF point2,
767 ARGB color1, ARGB color2 )
768 {
769 LinearGradientBrush brush = null;
770
771 lastResult = GdipCreateLineBrush(point1, point2,
772 color1, color2,
773 WrapModeTile, brush);
774 return brush;
775
776 }
777
778 /**************************************************************************
779
780 **************************************************************************/
781
782 static void LinearGradientBrush_delete( LinearGradientBrush brush )
783 {
784 GdipDeleteBrush(brush);
785 }
786
787 /**************************************************************************
788
789 **************************************************************************/
790
791 static Status LinearGradientBrush_SetInterpolationColors( LinearGradientBrush brush,
792 ARGB* presetColors, float* blendPositions, int count )
793 {
794 if ((count <= 0) || presetColors is null)
795 return SetStatus(Status.InvalidParameter);
796
797 return SetStatus(GdipSetLinePresetBlend(brush, presetColors,
798 blendPositions,
799 count ) );
800 }
801
802 /**************************************************************************
803
804 **************************************************************************/
805
806 static Status LinearGradientBrush_SetWrapMode( LinearGradientBrush brush, WrapMode wrapMode )
807 {
808 return SetStatus(GdipSetLineWrapMode( brush, wrapMode));
809 }
810
811 /**************************************************************************
812
813 **************************************************************************/
814
815 static Status LinearGradientBrush_ResetTransform(LinearGradientBrush brush )
816 {
817 return SetStatus(GdipResetLineTransform(brush));
818 }
819
820 /**************************************************************************
821
822 **************************************************************************/
823
824 static int LinearGradientBrush_ScaleTransform( LinearGradientBrush brush,
825 float sx, float sy,
826 MatrixOrder order = MatrixOrderPrepend )
827 {
828 return SetStatus(GdipScaleLineTransform(brush, sx, sy, order));
829 }
830
831 /**************************************************************************
832
833 **************************************************************************/
834
835 static int LinearGradientBrush_TranslateTransform( LinearGradientBrush brush,
836 float dx, float dy,
837 MatrixOrder order = MatrixOrderPrepend )
838 {
839 return SetStatus(GdipTranslateLineTransform(brush, dx, dy, order));
840 }
841
842
843 /**************************************************************************
844
845 GDI+ TextureBrush Wrap Interface
846
847 **************************************************************************/
848
849 static TextureBrush TextureBrush_new( Image image, WrapMode wrapMode,
850 float dstX, float dstY,
851 float dstWidth, float dstHeight )
852 {
853 TextureBrush brush = null;
854
855 Gdip.lastResult = GdipCreateTexture2( image,
856 wrapMode,
857 dstX, dstY,
858 dstWidth, dstHeight,
859 brush );
860 return brush;
861
862 }
863
864 /**************************************************************************
865
866 **************************************************************************/
867
868 static void TextureBrush_delete( TextureBrush brush )
869 {
870 GdipDeleteBrush( brush );
871 }
872
873 /**************************************************************************
874
875 **************************************************************************/
876
877 static Status TextureBrush_SetTransform( TextureBrush brush, Matrix matrix )
878 {
879 return SetStatus(GdipSetTextureTransform(brush, matrix));
880 }
881
882 /**************************************************************************
883
884 **************************************************************************/
885
886 static Status TextureBrush_ResetTransform( TextureBrush brush )
887 {
888 return SetStatus(GdipResetTextureTransform(brush));
889 }
890
891 /**************************************************************************
892
893 **************************************************************************/
894
895 static Status TextureBrush_ScaleTransform( TextureBrush brush,
896 float sx, float sy,
897 MatrixOrder order = MatrixOrderPrepend )
898 {
899 return SetStatus(GdipScaleTextureTransform(brush, sx, sy, order));
900 }
901
902 /**************************************************************************
903
904 **************************************************************************/
905
906 static Status TextureBrush_TranslateTransform( TextureBrush brush,
907 float dx, float dy,
908 MatrixOrder order = MatrixOrderPrepend )
909 {
910 return SetStatus(GdipTranslateTextureTransform(brush, dx, dy, order));
911 }
912
913
914 /**************************************************************************
915
916 GDI+ Pen Wrap Interface
917
918 **************************************************************************/
919
920 static SolidBrush SolidBrush_new( ARGB color )
921 {
922 SolidBrush brush = null;
923
924 Gdip.lastResult = GdipCreateSolidFill( color, brush );
925
926 return brush;
927 }
928
929 /**************************************************************************
930
931 **************************************************************************/
932
933 static void SolidBrush_delete( SolidBrush brush )
934 {
935 GdipDeleteBrush(brush);
936 }
937
938 /**************************************************************************
939
940 GDI+ Pen Wrap Interface
941
942 **************************************************************************/
943
944 static Pen Pen_new( Brush brush, float width )
945 {
946 Unit unit = UnitWorld;
947 Pen pen = null;
948 Gdip.lastResult = GdipCreatePen2(brush, width, unit, pen);
949 return pen;
950 }
951
952 /**************************************************************************
953
954 **************************************************************************/
955
956 static void Pen_delete( Pen pen )
957 {
958 GdipDeletePen(pen);
959 }
960
961 /**************************************************************************
962
963 **************************************************************************/
964
965 static PenType Pen_GetPenType( Pen pen )
966 {
967 PenType type;
968 SetStatus(GdipGetPenFillType( pen, type ));
969 return type;
970 }
971
972 /**************************************************************************
973
974 **************************************************************************/
975
976 static Brush Pen_GetBrush( Pen pen )
977 {
978 Brush brush;
979 SetStatus(GdipGetPenBrushFill(pen, brush));
980 return brush;
981 }
982
983 /**************************************************************************
984
985 **************************************************************************/
986
987 static Status Pen_SetBrush( Pen pen, Brush brush )
988 {
989 return SetStatus(GdipSetPenBrushFill(pen, brush));
990 }
991
992 /**************************************************************************
993
994 **************************************************************************/
995
996 static Status Pen_SetDashOffset( Pen pen, float dashOffset )
997 {
998 return SetStatus(GdipSetPenDashOffset(pen, dashOffset));
999 }
1000
1001 /**************************************************************************
1002
1003 **************************************************************************/
1004
1005 static Status Pen_SetDashPattern( Pen pen, float* dashArray, int count )
1006 {
1007 return SetStatus(GdipSetPenDashArray(pen, dashArray, count));
1008 }
1009
1010 /**************************************************************************
1011
1012 **************************************************************************/
1013
1014 static Status Pen_SetDashStyle( Pen pen, DashStyle dashStyle )
1015 {
1016 return SetStatus(GdipSetPenDashStyle(pen, dashStyle));
1017 }
1018
1019 /**************************************************************************
1020
1021 **************************************************************************/
1022
1023 static Status Pen_SetLineCap( Pen pen, LineCap startCap, LineCap endCap, DashCap dashCap )
1024 {
1025 return SetStatus(GdipSetPenLineCap197819(pen, startCap, endCap, dashCap));
1026 }
1027
1028 /**************************************************************************
1029
1030 **************************************************************************/
1031
1032 static Status Pen_SetLineJoin( Pen pen, LineJoin lineJoin )
1033 {
1034 return SetStatus(GdipSetPenLineJoin(pen, lineJoin));
1035 }
1036
1037 /**************************************************************************
1038
1039 **************************************************************************/
1040
1041 static Status Pen_SetMiterLimit( Pen pen, float miterLimit )
1042 {
1043 return SetStatus(GdipSetPenMiterLimit(pen, miterLimit));
1044 }
1045
1046 /**************************************************************************
1047
1048 **************************************************************************/
1049
1050 static Status Pen_SetWidth( Pen pen, float width )
1051 {
1052 return SetStatus(GdipSetPenWidth(pen, width));
1053 }
1054
1055
1056 /**************************************************************************
1057
1058 GDI+ Color Wrap Interface
1059
1060 **************************************************************************/
1061
1062 // The following two color functions appear to serve little use
1063 // and should probably be replaced with an actual ARGB type assignment
1064 // wherever they are used.
1065
1066 // I'm guessing they are being used in case of future adoption of the
1067 // gdi+ Color class functionality in Swt.
1068
1069 static void Color_delete( ARGB color )
1070 {
1071 // no op
1072 }
1073
1074 /**************************************************************************
1075
1076 **************************************************************************/
1077
1078 static ARGB Color_new( ARGB color )
1079 {
1080 return color;
1081 }
1082
1083 /**************************************************************************
1084
1085 GDI+ FontFamily Wrap Interface
1086
1087 **************************************************************************/
1088
1089 static int FontFamily_GetFamilyName( FontFamily family, wchar* name, int language )
1090 {
1091 return SetStatus( GdipGetFamilyName( family, name, language ) );
1092 }
1093
1094 /**************************************************************************
1095
1096 **************************************************************************/
1097
1098 // CAUTION: Next two methods need to be tested - JJR
1099
1100 static void FontFamily_delete( FontFamily family )
1101 {
1102 if (family !is null)
1103 GdipDeleteFontFamily( family );
1104 }
1105
1106 /**************************************************************************
1107
1108 FontFamily_new() returns a null because flat Gdi+ FontFamily is
1109 internally assigned a null until it is associated with a font
1110 (see gdi+ C++ wrapper for details).
1111
1112 **************************************************************************/
1113
1114 static FontFamily FontFamily_new()
1115 {
1116 return null;
1117 }
1118
1119 /**************************************************************************
1120
1121 GDI+ Font Wrap Interface
1122
1123 **************************************************************************/
1124
1125
1126 static int Font_GetFamily( Font font, ref FontFamily family )
1127 {
1128 return SetStatus( GdipGetFamily( font, family ) );
1129 }
1130
1131 /**************************************************************************
1132
1133 **************************************************************************/
1134
1135 static float Font_GetSize( Font font )
1136 {
1137 float size;
1138 SetStatus( GdipGetFontSize( font, size ) );
1139 return size;
1140 }
1141
1142 /**************************************************************************
1143
1144 **************************************************************************/
1145
1146 static int Font_GetStyle( Font font )
1147 {
1148 int style;
1149 SetStatus( GdipGetFontStyle( font, style ) );
1150 return style;
1151 }
1152
1153 /**************************************************************************
1154
1155 **************************************************************************/
1156
1157 static bool Font_IsAvailable( Font font )
1158 {
1159 return (font !is null);
1160 }
1161
1162 /**************************************************************************
1163
1164 **************************************************************************/
1165
1166 static void Font_delete( Font font )
1167 {
1168 GdipDeleteFont( font );
1169 }
1170
1171 /**************************************************************************
1172
1173 **************************************************************************/
1174
1175 static Font Font_new( HDC hdc, HFONT hfont )
1176 {
1177 Font font = null;
1178
1179 if (hfont is null) {
1180 Gdip.lastResult = GdipCreateFontFromDC( hdc, font );
1181 } else {
1182 LOGFONTA logfont;
1183 if (GetObjectA( hfont, LOGFONTA.sizeof, &logfont ))
1184 Gdip.lastResult = GdipCreateFontFromLogfontA(hdc, logfont, font);
1185 else
1186 Gdip.lastResult = GdipCreateFontFromDC(hdc, font);
1187 }
1188
1189 return font;
1190 }
1191
1192
1193 /**************************************************************************
1194
1195 **************************************************************************/
1196
1197 static Font Font_new( wchar* familyName, float emSize, int style, uint unit,
1198 FontCollection fontCollection )
1199 {
1200 Font nativeFont = null;
1201 FontFamily nativeFamily = null;
1202
1203 Gdip.lastResult = GdipCreateFontFamilyFromName( familyName, fontCollection, nativeFamily );
1204
1205 if (Gdip.lastResult != Status.OK)
1206 {
1207 if (GenericSansSerifFontFamily != null)
1208 {
1209 nativeFamily = GenericSansSerifFontFamily;
1210 }
1211 //TODO: access buffer via "ptr" property?
1212 GenericSansSerifFontFamily = cast(FontFamily) GenericSansSerifFontFamilyBuffer;
1213 Gdip.lastResult = GdipGetGenericFontFamilySansSerif( GenericSansSerifFontFamily );
1214
1215 nativeFamily = GenericSansSerifFontFamily;
1216
1217 if (Gdip.lastResult != Status.OK)
1218 return null;
1219 }
1220
1221 Gdip.lastResult = GdipCreateFont( nativeFamily, emSize, style, unit, nativeFont );
1222
1223 if (Gdip.lastResult != Status.OK)
1224 {
1225 if (GenericSansSerifFontFamily != null)
1226 {
1227 nativeFamily = GenericSansSerifFontFamily;
1228 }
1229
1230 GenericSansSerifFontFamily = cast(FontFamily) GenericSansSerifFontFamilyBuffer;
1231 Gdip.lastResult = GdipGetGenericFontFamilySansSerif( GenericSansSerifFontFamily );
1232
1233 nativeFamily = GenericSansSerifFontFamily;
1234
1235 if (Gdip.lastResult != Status.OK)
1236 return null;
1237
1238 Gdip.lastResult = GdipCreateFont( nativeFamily, emSize, style,
1239 unit, nativeFont );
1240 }
1241
1242 return nativeFont;
1243 }
1244
1245 /**************************************************************************
1246
1247 GDI+ Startup and Shutdown Wrap Interface
1248
1249 **************************************************************************/
1250
1251 alias .GdiplusShutdown GdiplusShutdown;
1252
1253 /**************************************************************************
1254
1255 **************************************************************************/
1256
1257 alias .GdiplusStartup GdiplusStartup;
1258
1259
1260 /**************************************************************************
1261
1262 GDI+ Graphics Path Wrap Interface
1263
1264 **************************************************************************/
1265
1266 static Path GraphicsPath_new( FillMode fillMode = FillModeAlternate )
1267 {
1268 Path path = null;
1269 lastResult = GdipCreatePath(fillMode, path);
1270 return path;
1271 }
1272
1273 /**************************************************************************
1274
1275 **************************************************************************/
1276
1277 static Path GraphicsPath_new( Point* points, ubyte* types, int count,
1278 FillMode fillMode = FillModeAlternate )
1279 {
1280 Path path = null;
1281 lastResult = GdipCreatePath2I(points, types, count, fillMode, path);
1282 return path;
1283 }
1284
1285 /**************************************************************************
1286
1287 **************************************************************************/
1288
1289 static void GraphicsPath_delete( Path path )
1290 {
1291 GdipDeletePath(path);
1292 }
1293 static Path GraphicsPath_Clone( Handle path ){
1294 Path clonepath = null;
1295 SetStatus( GdipClonePath(path, clonepath));
1296 return clonepath;
1297 }
1298
1299
1300 static Status GraphicsPath_AddArcF( Path path, float x, float y,
1301 float width, float height,
1302 float startAngle, float sweepAngle )
1303 {
1304 return SetStatus( GdipAddPathArc( path, x, y, width,
1305 height, startAngle, sweepAngle) );
1306 }
1307
1308 /**************************************************************************
1309
1310 **************************************************************************/
1311
1312 static Status GraphicsPath_AddArc( Path path, int x, int y,
1313 int width, int height,
1314 float startAngle, float sweepAngle )
1315 {
1316 return SetStatus(GdipAddPathArcI( path,
1317 x,
1318 y,
1319 width,
1320 height,
1321 startAngle,
1322 sweepAngle));
1323 }
1324
1325 /**************************************************************************
1326
1327 **************************************************************************/
1328
1329 static Status GraphicsPath_AddBezier( Path path, float x1, float y1,
1330 float x2, float y2,
1331 float x3, float y3,
1332 float x4, float y4 )
1333 {
1334 return SetStatus( GdipAddPathBezier( path, x1, y1, x2, y2,
1335 x3, y3, x4, y4 ) );
1336 }
1337
1338 /**************************************************************************
1339
1340 **************************************************************************/
1341
1342 static Status GraphicsPath_AddLine( Path path, float x1, float y1,
1343 float x2, float y2 )
1344 {
1345 return SetStatus( GdipAddPathLine( path, x1, y1, x2, y2 ) );
1346 }
1347
1348
1349 /**************************************************************************
1350
1351 **************************************************************************/
1352
1353 static Status GraphicsPath_AddPath( Path path, Path addingPath, bool connect )
1354 {
1355 return SetStatus( GdipAddPathPath( path, addingPath, connect ) );
1356 }
1357
1358 /**************************************************************************
1359
1360 **************************************************************************/
1361
1362 static Status GraphicsPath_AddRectangle( Path path, RectF rect )
1363 {
1364 return SetStatus( GdipAddPathRectangle( path,
1365 rect.X,
1366 rect.Y,
1367 rect.Width,
1368 rect.Height ) );
1369 }
1370
1371
1372 /**************************************************************************
1373
1374 **************************************************************************/
1375
1376 static Status GraphicsPath_AddString( Path path, wchar* string,
1377 int length, FontFamily family,
1378 int style, float emSize,
1379 ref PointF origin, StringFormat format )
1380 {
1381 RectF rect = { origin.X, origin.Y, 0.0f, 0.0f };
1382
1383 return SetStatus( GdipAddPathString( path, string, length, family,
1384 style, emSize, rect, format ) );
1385 }
1386
1387
1388 /**************************************************************************
1389
1390 **************************************************************************/
1391
1392 static Status GraphicsPath_CloseFigure( Path path )
1393 {
1394 return SetStatus( GdipClosePathFigure(path) );
1395 }
1396
1397
1398 /**************************************************************************
1399
1400 **************************************************************************/
1401
1402 static Status GraphicsPath_Flatten( Path path, Matrix matrix, float flatness )
1403 {
1404 return SetStatus( GdipFlattenPath( path, matrix, flatness ) );
1405 }
1406
1407
1408 /**************************************************************************
1409
1410 **************************************************************************/
1411
1412 static Status GraphicsPath_GetBounds( Path path, ref RectF bounds,
1413 Matrix matrix, Pen pen )
1414 {
1415
1416 return SetStatus( GdipGetPathWorldBounds( path, bounds,
1417 matrix, pen ) );
1418 }
1419
1420 /**************************************************************************
1421
1422 **************************************************************************/
1423
1424 static Status GraphicsPath_GetLastPoint( Path path, out PointF lastPoint )
1425 {
1426 return SetStatus( GdipGetPathLastPoint( path, lastPoint) );
1427 }
1428
1429 /**************************************************************************
1430
1431 **************************************************************************/
1432
1433 static Status GraphicsPath_GetPathTypes( Path path, byte* types, int count )
1434 {
1435 return SetStatus( GdipGetPathTypes( path, types, count) );
1436 }
1437
1438 /**************************************************************************
1439
1440 **************************************************************************/
1441
1442 static Status GraphicsPath_GetPathPoints( Path path, PointF* points, int count)
1443 {
1444 return SetStatus(GdipGetPathPoints(path, points, count));
1445 }
1446
1447
1448 /**************************************************************************
1449
1450 **************************************************************************/
1451
1452 static int GraphicsPath_GetPointCount( Path path )
1453 {
1454 int count = 0;
1455
1456 SetStatus(GdipGetPointCount(path, count));
1457
1458 return count;
1459 }
1460
1461 /**************************************************************************
1462
1463 **************************************************************************/
1464
1465 static bool GraphicsPath_IsOutlineVisible( Path path,
1466 float x, float y, Pen pen, Graphics g = null )
1467 {
1468 int booln = false;
1469 SetStatus( GdipIsOutlineVisiblePathPoint( path, x, y,
1470 pen, g,
1471 booln ) );
1472 return (booln == true);
1473 }
1474
1475 /**************************************************************************
1476
1477 **************************************************************************/
1478
1479 static bool GraphicsPath_IsVisible( Path path, float x, float y, Graphics graphics )
1480 {
1481 int booln = false;
1482
1483 SetStatus(GdipIsVisiblePathPoint(path, x, y, graphics, booln));
1484
1485 return (booln == true);
1486 }
1487
1488 /**************************************************************************
1489
1490 **************************************************************************/
1491
1492 static int GraphicsPath_SetFillMode( Path path, FillMode fillmode )
1493 {
1494 return SetStatus( GdipSetPathFillMode(path, fillmode) );
1495 }
1496
1497 /**************************************************************************
1498
1499 **************************************************************************/
1500
1501 static int GraphicsPath_StartFigure( Path path )
1502 {
1503 return SetStatus(GdipStartPathFigure(path));
1504 }
1505
1506 /**************************************************************************
1507
1508 **************************************************************************/
1509
1510 static int GraphicsPath_Transform( Path path, Matrix matrix )
1511 {
1512 if(matrix)
1513 return SetStatus( GdipTransformPath(path, matrix));
1514 else
1515 return Status.OK;
1516
1517 }
1518
1519
1520 /**************************************************************************
1521
1522 GDI+ Graphics Wrap Interface
1523
1524 **************************************************************************/
1525
1526 static Graphics Graphics_new( HDC hdc )
1527 {
1528
1529 Graphics graphics = null;
1530
1531 Gdip.lastResult = GdipCreateFromHDC(hdc, graphics);
1532
1533 return graphics;
1534 }
1535
1536 /**************************************************************************
1537
1538 **************************************************************************/
1539
1540 static void Graphics_delete( Graphics graphics)
1541 {
1542 GdipDeleteGraphics(graphics);
1543 }
1544
1545 /**************************************************************************
1546
1547 **************************************************************************/
1548
1549 static Status Graphics_DrawArc( Graphics graphics, Pen pen,
1550 int x, int y, int width, int height,
1551 float startAngle, float sweepAngle )
1552 {
1553 return SetStatus(GdipDrawArcI(graphics, pen,
1554 x, y, width, height,
1555 startAngle, sweepAngle));
1556 }
1557
1558 /**************************************************************************
1559
1560 **************************************************************************/
1561
1562 static Status Graphics_DrawEllipse(Graphics graphics, Pen pen,
1563 int x, int y,
1564 int width, int height)
1565 {
1566 return SetStatus(GdipDrawEllipseI(graphics, pen,
1567 x, y, width, height));
1568 }
1569
1570 /**************************************************************************
1571
1572 **************************************************************************/
1573
1574 static Status Graphics_DrawImage(Graphics graphics, Image image, int x, int y)
1575 {
1576 return SetStatus(GdipDrawImageI(graphics,image, x, y));
1577 }
1578
1579 /**************************************************************************
1580
1581 **************************************************************************/
1582
1583 static Status Graphics_DrawImage( Graphics graphics, Image image, ref Rect destRect,
1584 int srcx, int srcy, int srcwidth, int srcheight,
1585 Unit srcUnit, ImageAttributes imageAttributes = null,
1586 DrawImageAbort callback = null, void* callbackData = null )
1587 {
1588 return SetStatus(GdipDrawImageRectRectI(graphics, image,
1589 destRect.X, destRect.Y,
1590 destRect.Width, destRect.Height,
1591 srcx, srcy,
1592 srcwidth, srcheight,
1593 srcUnit, imageAttributes,
1594 callback, callbackData));
1595 }
1596
1597 /**************************************************************************
1598
1599 **************************************************************************/
1600
1601 static Status Graphics_DrawLine( Graphics graphics, Pen pen,
1602 int x1, int y1, int x2, int y2 )
1603 {
1604 return SetStatus(GdipDrawLineI(graphics, pen, x1, y1, x2, y2));
1605 }
1606
1607 /**************************************************************************
1608
1609 **************************************************************************/
1610
1611 static Status Graphics_DrawLines( Graphics graphics, Pen pen, Point* points, uint count )
1612 {
1613 return SetStatus(GdipDrawLinesI(graphics, pen, points, count));
1614 }
1615
1616 /**************************************************************************
1617
1618 **************************************************************************/
1619
1620 static Status Graphics_DrawPath( Graphics graphics, Pen pen, Path path )
1621 {
1622 return SetStatus(GdipDrawPath(graphics, pen, path));
1623 }
1624
1625 /**************************************************************************
1626
1627 **************************************************************************/
1628
1629 static Status Graphics_DrawPolygon(Graphics graphics, Pen pen, Point* points, uint count )
1630 {
1631 return SetStatus(GdipDrawPolygonI(graphics, pen, points, count));
1632
1633 }
1634
1635 /**************************************************************************
1636
1637 **************************************************************************/
1638
1639 static Status Graphics_DrawRectangle( Graphics graphics, Pen pen, int x, int y,
1640 int width, int height )
1641 {
1642 return SetStatus(GdipDrawRectangleI(graphics, pen, x, y, width, height));
1643 }
1644
1645 /**************************************************************************
1646
1647 **************************************************************************/
1648
1649 static Status Graphics_DrawString( Graphics graphics, wchar* string, int length,
1650 Font font, ref PointF origin, Brush brush )
1651 {
1652 RectF rect = {origin.X, origin.Y, 0.0f, 0.0f};
1653
1654 return SetStatus(GdipDrawString(graphics,string,length, font, rect, null, brush));
1655 }
1656
1657 /**************************************************************************
1658
1659 **************************************************************************/
1660
1661 static Status Graphics_DrawString( Graphics graphics, wchar* string, int length,
1662 Font font, ref PointF origin,
1663 StringFormat format, Brush brush )
1664 {
1665 RectF rect = { origin.X, origin.Y, 0.0f, 0.0f };
1666
1667 return SetStatus(GdipDrawString(graphics, string, length, font, rect, format, brush));
1668 }
1669
1670 /**************************************************************************
1671
1672 **************************************************************************/
1673
1674 static Status Graphics_FillEllipse( Graphics graphics, Brush brush,
1675 int x, int y,
1676 int width, int height )
1677 {
1678 return SetStatus(GdipFillEllipseI(graphics, brush, x,y, width, height));
1679 }
1680
1681 /**************************************************************************
1682
1683 **************************************************************************/
1684
1685 static Status Graphics_FillPath( Graphics graphics, Brush brush, Path path )
1686 {
1687 return SetStatus(GdipFillPath(graphics,brush,path));
1688 }
1689
1690 /**************************************************************************
1691
1692 **************************************************************************/
1693
1694 static void Graphics_Flush( Graphics graphics, FlushIntention intention = FlushIntentionFlush )
1695 {
1696 GdipFlush(graphics, intention);
1697 }
1698
1699 /**************************************************************************
1700
1701 **************************************************************************/
1702
1703 static Status Graphics_FillPie( Graphics graphics, Brush brush,
1704 int x, int y,
1705 int width, int height,
1706 float startAngle, float sweepAngle )
1707 {
1708 return SetStatus(GdipFillPieI(graphics, brush,
1709 x, y, width, height,
1710 startAngle, sweepAngle));
1711 }
1712
1713 /**************************************************************************
1714
1715 **************************************************************************/
1716
1717 static Status Graphics_FillPolygon( Graphics graphics, Brush brush,
1718 Point* points, int count, FillMode fillMode )
1719 {
1720 return SetStatus(GdipFillPolygonI(graphics, brush, points, count, fillMode));
1721 }
1722
1723 /**************************************************************************
1724
1725 **************************************************************************/
1726
1727 static Status Graphics_FillRectangle( Graphics graphics, Brush brush,
1728 int x, int y,
1729 int width, int height )
1730 {
1731 return SetStatus(GdipFillRectangleI(graphics, brush,
1732 x, y,
1733 width, height));
1734 }
1735
1736 /**************************************************************************
1737
1738 **************************************************************************/
1739
1740 static Status Graphics_GetClipBounds( Graphics graphics, out RectF rect )
1741 {
1742 return SetStatus(GdipGetClipBounds(graphics, rect));
1743 }
1744
1745 /**************************************************************************
1746
1747 **************************************************************************/
1748
1749 static Status Graphics_GetClipBounds( Graphics graphics, out Rect rect )
1750 {
1751 return SetStatus(GdipGetClipBoundsI(graphics, rect));
1752 }
1753
1754 /**************************************************************************
1755
1756 **************************************************************************/
1757
1758 static Status Graphics_GetClip( Graphics graphics, Region region )
1759 {
1760 return SetStatus(GdipGetClip(graphics, region));
1761 }
1762
1763 /**************************************************************************
1764
1765 **************************************************************************/
1766
1767 static HDC Graphics_GetHDC(Graphics graphics)
1768 {
1769 HDC hdc = null;
1770
1771 SetStatus(GdipGetDC(graphics, hdc));
1772
1773 return hdc;
1774 }
1775
1776 /**************************************************************************
1777
1778 **************************************************************************/
1779
1780 static void Graphics_ReleaseHDC(Graphics graphics, HDC hdc)
1781 {
1782 SetStatus(GdipReleaseDC(graphics, hdc));
1783 }
1784
1785 /**************************************************************************
1786
1787 **************************************************************************/
1788
1789 static InterpolationMode Graphics_GetInterpolationMode( Graphics graphics )
1790 {
1791 InterpolationMode mode = InterpolationModeInvalid;
1792
1793 SetStatus(GdipGetInterpolationMode(graphics, mode));
1794
1795 return mode;
1796 }
1797
1798 /**************************************************************************
1799
1800 **************************************************************************/
1801
1802 static SmoothingMode Graphics_GetSmoothingMode( Graphics graphics )
1803 {
1804 SmoothingMode smoothingMode = SmoothingModeInvalid;
1805
1806 SetStatus(GdipGetSmoothingMode(graphics, smoothingMode));
1807
1808 return smoothingMode;
1809 }
1810
1811 /**************************************************************************
1812
1813 **************************************************************************/
1814
1815 static TextRenderingHint Graphics_GetTextRenderingHint( Graphics graphics )
1816 {
1817 TextRenderingHint hint;
1818
1819 SetStatus(GdipGetTextRenderingHint(graphics, hint));
1820
1821 return hint;
1822 }
1823
1824 /**************************************************************************
1825
1826 **************************************************************************/
1827
1828 static Status Graphics_GetTransform( Graphics graphics, Matrix matrix )
1829 {
1830 return SetStatus(GdipGetWorldTransform(graphics, matrix));
1831 }
1832
1833 /**************************************************************************
1834
1835 **************************************************************************/
1836
1837 static Status Graphics_GetVisibleClipBounds( Graphics graphics, out Rect rect )
1838 {
1839
1840 return SetStatus(GdipGetVisibleClipBoundsI(graphics, rect));
1841 }
1842
1843 /**************************************************************************
1844
1845 **************************************************************************/
1846
1847 static Status Graphics_MeasureString( Graphics graphics, wchar* string, int length,
1848 Font font, ref PointF origin,
1849 ref RectF boundingBox )
1850 {
1851 RectF rect = {origin.X, origin.Y, 0.0f, 0.0f};
1852
1853 return SetStatus(GdipMeasureString(
1854 graphics,
1855 string,
1856 length,
1857 font,
1858 rect,
1859 null,
1860 boundingBox,
1861 null,
1862 null
1863 ));
1864 }
1865
1866 /**************************************************************************
1867
1868 **************************************************************************/
1869
1870 static Status Graphics_MeasureString( Graphics graphics, wchar* string, int length,
1871 Font font, ref PointF origin,
1872 StringFormat format, ref RectF boundingBox )
1873 {
1874 RectF rect = {origin.X, origin.Y, 0.0f, 0.0f};
1875
1876 return SetStatus(GdipMeasureString(
1877 graphics,
1878 string,
1879 length,
1880 font,
1881 rect,
1882 format,
1883 boundingBox,
1884 null,
1885 null
1886 ));
1887 }
1888
1889 /**************************************************************************
1890
1891 **************************************************************************/
1892
1893 static Status Graphics_ResetClip( Graphics graphics )
1894 {
1895 return SetStatus(GdipResetClip(graphics));
1896 }
1897
1898 /**************************************************************************
1899
1900 **************************************************************************/
1901
1902 static Status Graphics_Restore( Graphics graphics, GraphicsState gstate )
1903 {
1904 return SetStatus(GdipRestoreGraphics(graphics, gstate));
1905 }
1906
1907 /**************************************************************************
1908
1909 **************************************************************************/
1910
1911 static GraphicsState Graphics_Save( Graphics graphics )
1912 {
1913 GraphicsState gstate;
1914
1915 SetStatus(GdipSaveGraphics(graphics, gstate));
1916
1917 return gstate;
1918 }
1919
1920 /**************************************************************************
1921
1922 **************************************************************************/
1923
1924 static Status Graphics_ScaleTransform( Graphics graphics, float sx, float sy,
1925 MatrixOrder order = MatrixOrderPrepend )
1926 {
1927 return SetStatus(GdipScaleWorldTransform(graphics, sx, sy, order));
1928 }
1929
1930 /**************************************************************************
1931
1932 **************************************************************************/
1933
1934 static Status Graphics_SetClip( Graphics graphics, HRGN hrgn,
1935 CombineMode combineMode = CombineModeReplace )
1936 {
1937 return SetStatus(GdipSetClipHrgn(graphics, hrgn, combineMode));
1938 }
1939
1940 /**************************************************************************
1941
1942 **************************************************************************/
1943
1944 static Status Graphics_SetClipPath( Graphics graphics, Path path,
1945 CombineMode combineMode = CombineModeReplace )
1946 {
1947 return SetStatus(GdipSetClipPath(graphics, path, combineMode));
1948 }
1949
1950 /**************************************************************************
1951
1952 **************************************************************************/
1953
1954 static Status Graphics_SetClip( Graphics graphics, ref Rect rect,
1955 CombineMode combineMode = CombineModeReplace )
1956 {
1957 return SetStatus( GdipSetClipRectI( graphics,
1958 rect.X, rect.Y,
1959 rect.Width, rect.Height,
1960 combineMode));
1961 }
1962
1963 //static Status Graphics_SetClipPath(Graphics graphics, GraphicsPath path ){
1964 // return SetStatus( SetClipPath( graphics, path ));
1965 //}
1966 /**************************************************************************
1967
1968 **************************************************************************/
1969
1970 static Status Graphics_SetCompositingQuality( Graphics graphics,
1971 CompositingQuality compositingQuality )
1972 {
1973 return SetStatus(GdipSetCompositingQuality(graphics, compositingQuality));
1974 }
1975
1976 /**************************************************************************
1977
1978 **************************************************************************/
1979
1980 static Status Graphics_SetPageUnit( Graphics graphics, Unit unit )
1981 {
1982 return SetStatus(GdipSetPageUnit(graphics, unit));
1983 }
1984
1985 /**************************************************************************
1986
1987 **************************************************************************/
1988
1989 static Status Graphics_SetPixelOffsetMode( Graphics graphics,
1990 PixelOffsetMode pixelOffsetMode )
1991 {
1992 return SetStatus(GdipSetPixelOffsetMode(graphics, pixelOffsetMode));
1993 }
1994
1995 /**************************************************************************
1996
1997 **************************************************************************/
1998
1999 static Status Graphics_SetSmoothingMode( Graphics graphics,
2000 SmoothingMode smoothingMode )
2001 {
2002 return SetStatus(GdipSetSmoothingMode(graphics, smoothingMode));
2003 }
2004
2005 /**************************************************************************
2006
2007 **************************************************************************/
2008
2009 static Status Graphics_SetTransform( Graphics graphics, Matrix matrix )
2010 {
2011 return SetStatus(GdipSetWorldTransform(graphics, matrix));
2012 }
2013
2014 /**************************************************************************
2015
2016 **************************************************************************/
2017
2018 static Status Graphics_SetInterpolationMode( Graphics graphics,
2019 InterpolationMode mode )
2020 {
2021 return SetStatus(GdipSetInterpolationMode(graphics, mode));
2022 }
2023
2024 /**************************************************************************
2025
2026 **************************************************************************/
2027
2028 static Status Graphics_SetTextRenderingHint( Graphics graphics, TextRenderingHint mode )
2029 {
2030 return SetStatus(GdipSetTextRenderingHint(graphics, mode));
2031 }
2032
2033 /**************************************************************************
2034
2035 **************************************************************************/
2036
2037 static Status Graphics_TranslateTransform( Graphics graphics, float dx, float dy,
2038 MatrixOrder order = MatrixOrderPrepend )
2039 {
2040 return SetStatus(GdipTranslateWorldTransform(graphics, dx, dy, order));
2041 }
2042
2043 /**************************************************************************
2044
2045 Gdi+ Region Wrap Interface
2046
2047 **************************************************************************/
2048
2049 static Region Region_new( HRGN hRgn )
2050 {
2051 Region region = null;
2052
2053 Gdip.lastResult = GdipCreateRegionHrgn( hRgn, region);
2054
2055 return region;
2056 }
2057
2058 /**************************************************************************
2059
2060 **************************************************************************/
2061
2062 static Region Region_new()
2063 {
2064 Region region = null;
2065
2066 Gdip.lastResult = GdipCreateRegion(region);
2067
2068 return region;
2069 }
2070
2071 /**************************************************************************
2072
2073 **************************************************************************/
2074
2075 static void Region_delete( Region region )
2076 {
2077 GdipDeleteRegion(region);
2078 }
2079
2080 /**************************************************************************
2081
2082 **************************************************************************/
2083
2084 static HRGN Region_GetHRGN( Region region, Graphics graphics )
2085 {
2086 HRGN hrgn;
2087
2088 SetStatus(GdipGetRegionHRgn(region, graphics, hrgn));
2089
2090 return hrgn;
2091 }
2092
2093 /**************************************************************************
2094
2095 **************************************************************************/
2096
2097 static int Region_IsInfinite( Region region, Graphics graphics )
2098 {
2099 int booln = false;
2100
2101 SetStatus(GdipIsInfiniteRegion(region, graphics, booln));
2102
2103 return booln;
2104 }
2105
2106 /**************************************************************************
2107
2108 Gdi+ Matrix Wrap Interface
2109
2110 **************************************************************************/
2111
2112 static Matrix Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy)
2113 {
2114 Matrix matrix = null;
2115
2116 Gdip.lastResult = GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, matrix);
2117
2118 return matrix;
2119 }
2120
2121 /**************************************************************************
2122
2123 **************************************************************************/
2124
2125 static void Matrix_delete( Matrix matrix )
2126 {
2127 GdipDeleteMatrix( matrix );
2128 }
2129
2130 /**************************************************************************
2131
2132 **************************************************************************/
2133
2134 static Status Matrix_GetElements( Matrix matrix, float* m )
2135 {
2136 return SetStatus( GdipGetMatrixElements( matrix, m ) );
2137 }
2138
2139 /**************************************************************************
2140
2141 **************************************************************************/
2142
2143 static Status Matrix_Invert( Matrix matrix )
2144 {
2145 return SetStatus( GdipInvertMatrix( matrix ) );
2146 }
2147
2148 /**************************************************************************
2149
2150 **************************************************************************/
2151
2152 static int Matrix_IsIdentity( Matrix matrix )
2153 {
2154 int result = false;
2155
2156 SetStatus(GdipIsMatrixIdentity( matrix, result ) );
2157
2158 return result;
2159 }
2160
2161 /**************************************************************************
2162
2163 **************************************************************************/
2164
2165 static Status Matrix_Multiply( Matrix nativeMatrix, Matrix matrix,
2166 MatrixOrder order = MatrixOrderPrepend )
2167 {
2168 return SetStatus( GdipMultiplyMatrix( nativeMatrix, matrix, order) );
2169 }
2170
2171 /**************************************************************************
2172
2173 **************************************************************************/
2174
2175 static int Matrix_Rotate( Matrix matrix, float angle, MatrixOrder order = MatrixOrderPrepend )
2176 {
2177 return SetStatus( GdipRotateMatrix( matrix, angle, order ) );
2178 }
2179
2180 /**************************************************************************
2181
2182 **************************************************************************/
2183
2184 static Status Matrix_Scale( Matrix matrix, float scaleX , float scaleY,
2185 MatrixOrder order = MatrixOrderPrepend )
2186 {
2187 return SetStatus( GdipScaleMatrix(matrix, scaleX, scaleY, order) );
2188 }
2189 static Status Matrix_Shear( Matrix matrix, float shearX, float shearY, MatrixOrder order ){
2190 return SetStatus( GdipShearMatrix(matrix, shearX, shearY, order));
2191 }
2192
2193 /**************************************************************************
2194
2195 **************************************************************************/
2196
2197 static Status Matrix_SetElements( Matrix matrix, float m11, float m12,
2198 float m21, float m22,
2199 float dx, float dy )
2200 {
2201 return SetStatus( GdipSetMatrixElements( matrix, m11, m12, m21, m22, dx, dy ) );
2202 }
2203
2204 /**************************************************************************
2205
2206 **************************************************************************/
2207
2208 static Status Matrix_TransformPoints( Matrix matrix, PointF* pts, int count = 1 )
2209 {
2210 return SetStatus( GdipTransformMatrixPoints( matrix, pts, count ) );
2211 }
2212
2213 /**************************************************************************
2214
2215 **************************************************************************/
2216
2217 static Status Matrix_Translate( Matrix matrix, float offsetX, float offsetY,
2218 MatrixOrder order = MatrixOrderPrepend )
2219 {
2220 return SetStatus( GdipTranslateMatrix( matrix, offsetX, offsetY, order ) );
2221 }
2222
2223
2224 /**************************************************************************
2225
2226 Gdi+ StringFromat Wrap Interface
2227
2228 **************************************************************************/
2229
2230 static void StringFormat_delete( StringFormat format )
2231 {
2232 GdipDeleteStringFormat( format );
2233 }
2234
2235 /**************************************************************************
2236
2237 **************************************************************************/
2238
2239 static StringFormat StringFormat_Clone( StringFormat format )
2240 {
2241 StringFormat clonedStringFormat = null;
2242
2243 Gdip.lastResult = GdipCloneStringFormat( format, clonedStringFormat );
2244
2245 if (Gdip.lastResult == Status.OK)
2246 return clonedStringFormat;
2247 else
2248 return null;
2249 }
2250
2251 /**************************************************************************
2252
2253 **************************************************************************/
2254
2255 static StringFormat StringFormat_GenericDefault()
2256 {
2257 // TODO: do we need to access buffer through "ptr" property?
2258 StringFormat genericDefaultStringFormat =
2259 cast(StringFormat) GenericDefaultStringFormatBuffer;
2260
2261 Gdip.lastResult = GdipStringFormatGetGenericDefault( genericDefaultStringFormat );
2262
2263 return genericDefaultStringFormat;
2264 }
2265
2266 /**************************************************************************
2267
2268 **************************************************************************/
2269
2270 static StringFormat StringFormat_GenericTypographic()
2271 {
2272 // TODO: do we need to access buffer through "ptr" property?
2273 StringFormat genericTypographicStringFormat =
2274 cast(StringFormat) GenericTypographicStringFormatBuffer;
2275
2276 Gdip.lastResult = GdipStringFormatGetGenericTypographic(
2277 genericTypographicStringFormat );
2278
2279 return genericTypographicStringFormat;
2280 }
2281
2282 /**************************************************************************
2283
2284 **************************************************************************/
2285
2286 // TODO: StringFormat class in Gdi+ maintains it's own lastError status
2287 // Right now all lastError and lastResult status for org.eclipse.swt's gdip objects
2288 // are combined in one Gdip SetStatus method and lastResult member.
2289 // Consider if there is a need to maintain per object lastResult
2290 // monitoring. For now, this /should/ work as is.
2291
2292 static int StringFormat_GetFormatFlags(StringFormat format)
2293 {
2294 int flags;
2295 SetStatus( GdipGetStringFormatFlags(format, flags));
2296 return flags;
2297 }
2298
2299 /**************************************************************************
2300
2301 **************************************************************************/
2302
2303 static int StringFormat_SetHotkeyPrefix( StringFormat format, int hotkeyPrefix )
2304 {
2305 return SetStatus(GdipSetStringFormatHotkeyPrefix(format, hotkeyPrefix));
2306 }
2307
2308 /**************************************************************************
2309
2310 **************************************************************************/
2311
2312 static int StringFormat_SetFormatFlags( StringFormat format, int flags )
2313 {
2314 return SetStatus(GdipSetStringFormatFlags(format, flags));
2315 }
2316
2317 /**************************************************************************
2318
2319 **************************************************************************/
2320
2321 static int StringFormat_SetTabStops( StringFormat format, float firstTabOffset,
2322 int count, float* tabStops)
2323 {
2324 return SetStatus( GdipSetStringFormatTabStops( format, firstTabOffset,
2325 count, tabStops ) );
2326 }
2327
2328 /**************************************************************************
2329
2330 **************************************************************************/
2331 }