source: trunk/ab5.0/ablib/src/Classes/System/Drawing/Graphics.ab@ 700

Last change on this file since 700 was 700, checked in by イグトランス (egtra), 15 years ago

GdiPlusEnums.abの列挙体を名前空間System.Drawing以下に配置

File size: 49.6 KB
Line 
1' Classes/System/Drawing/Graphics.ab
2
3Namespace System
4Namespace Drawing
5
6Class Brush
7Public
8 nativeBrush As *GpBrush
9End Class
10Class StringFormat
11Public
12 nativeFormat As *GpStringFormat
13End Class
14Class Image
15Public
16 nativeImage As *GpImage
17End Class
18Class ImageAttributes
19Public
20 nativeImage As *GpImageAttributes
21End Class
22Class Metafile
23Inherits Image
24End Class
25Class Region
26Public
27 nativeRegion As *GpRegion
28End Class
29Class GraphicsPath
30Public
31 nativePath As *GpPath
32End Class
33Class CachedBitmap
34Public
35 nativeCachedBitmap As *GpCachedBitmap
36End Class
37
38Delegate Function EnumerateMetafileProc(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
39
40Namespace Detail
41
42TypeDef NativeEnumerateMetafileProc = *Function(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
43
44Type EnumerateMetafileProcData
45 Proc As EnumerateMetafileProc
46 Data As VoidPtr
47End Type
48
49Function NativeEnumerateMetafileProcEntry(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
50 Dim procData = callbackData As *EnumerateMetafileProcData
51 Dim proc = procData->Proc
52 NativeEnumerateMetafileProcEntry = proc(recordType, flags, dataSize, data, procData->Data)
53End Function
54
55End Namespace
56
57Class Graphics
58Public
59 '=========================================================================
60 ' Properties
61 '=========================================================================
62 Const Function Clip() As Region
63 Clip = New Region
64 SetStatus(GdipGetClip(nativeGraphics, Clip.nativeRegion))
65 End Function
66
67 Sub Clip(region As Region)
68 Imports System.Drawing.Drawing2D
69 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, CombineMode.Replace))
70 End Sub
71
72 Const Function ClipBounds() As RectangleF
73 SetStatus(GdipGetClipBounds(nativeGraphics, ClipBounds))
74 End Function
75
76 Const Function ClipBoundsI() As Rectangle
77 SetStatus(GdipGetClipBoundsI(nativeGraphics, ClipBoundsI))
78 End Function
79/*
80 Const Function CompositingMode() As Drawing2D.CompositingMode
81 SetStatus(GdipGetCompositingMode(nativeGraphics, CompositingMode))
82 End Function
83
84 Sub CompositingMode(mode As Drawing2D.CompositingMode)
85 SetStatus(GdipSetCompositingMode(nativeGraphics, mode))
86 End Sub
87
88 Function CompositingQuality() As Drawing2D.CompositingQuality
89 SetStatus(GdipGetCompositingQuality(nativeGraphics, CompositingQuality))
90 End Function
91
92 Sub CompositingQuality(cq As Drawing2D.CompositingQuality)
93 Return SetStatus(GdipSetCompositingQuality(nativeGraphics, cq))
94 End Sub
95*/
96 Const Function DpiX() As Single
97 SetStatus(GdipGetDpiX(nativeGraphics, DpiX))
98 End Function
99
100 Const Function DpiY() As Single
101 SetStatus(GdipGetDpiY(nativeGraphics, DpiY))
102 End Function
103/*
104 Const Function InterpolationMode() As Drawing2D.InterpolationMode
105 SetStatus(GdipGetInterpolationMode(nativeGraphics, InterpolationMode))
106 End Function
107
108 Sub InterpolationMode(im As Drawing2D.InterpolationMode)
109 InterpolationMode = SetStatus(GdipSetInterpolationMode(nativeGraphics, im))
110 End Sub
111*/
112 Const Function IsClipEmpty() As Boolean
113 Dim b = FALSE As BOOL
114 SetStatus(GdipIsClipEmpty(nativeGraphics, b))
115 IsClipEmpty = b As Boolean
116 End Function
117
118 Const Function IsVisibleClipEmpty() As Boolean
119 Dim b = FALSE As BOOL
120 SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, b))
121 IsVisibleClipEmpty = b As Boolean
122 End Function
123
124 Sub PageScale(scale As Single)
125 SetStatus(GdipSetPageScale(nativeGraphics, scale))
126 End Sub
127
128 Const Function PageScale() As Single
129 SetStatus(GdipGetPageScale(nativeGraphics, PageScale))
130 End Function
131/*
132 Const Function PageUnit() As GraphicsUnit
133 SetStatus(GdipGetPageUnit(nativeGraphics, PageUnit))
134 End Function
135*/
136 Sub PageUnit(unit As GraphicsUnit)
137 SetStatus(GdipSetPageUnit(nativeGraphics, unit))
138 End Sub
139/*
140 Function PixelOffsetMode() As Drawing2D.PixelOffsetMode
141 PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Invalid
142 SetStatus(GdipGetPixelOffsetMode(nativeGraphics, PixelOffsetMode))
143 End Function
144*/
145 Sub PixelOffsetMode(mode As Drawing2D.PixelOffsetMode)
146 SetStatus(GdipSetPixelOffsetMode(nativeGraphics, mode))
147 End Sub
148
149 Function RenderingOrigin() As Point
150 With RenderingOrigin
151 .X = 0
152 .Y = 0
153 SetStatus(GdipGetRenderingOrigin(nativeGraphics, .X, .Y))
154 End With
155 End Function
156
157 Sub RenderingOrigin(pt As Point)
158 SetStatus(GdipSetRenderingOrigin(nativeGraphics, pt.X, pt.Y))
159 End Sub
160/*
161 Function SmoothingMode() As Drawing2D.SmoothingMode
162 SetStatus(GdipGetSmoothingMode(nativeGraphics, SmoothingMode))
163 End Function
164*/
165 Sub SmoothingMode(mode As Drawing2D.SmoothingMode)
166 SetStatus(GdipSetSmoothingMode(nativeGraphics, mode))
167 End Sub
168
169 Function TextContrast() As DWord
170 SetStatus(GdipGetTextContrast(nativeGraphics, TextContrast))
171 End Function
172
173 Sub TextContrast(contrast As DWord)
174 SetStatus(GdipSetTextContrast(nativeGraphics, contrast))
175 End Sub
176/*
177 Function TextRenderingHint() As Text.TextRenderingHint
178 SetStatus(GdipGetTextRenderingHint(nativeGraphics, ByVal VarPtr(TextRenderingHint)))
179 End Function
180*/
181 Sub TextRenderingHint(mode As TextRenderingHint)
182 SetStatus(GdipSetTextRenderingHint(nativeGraphics, mode))
183 End Sub
184
185 Function Transform() As Drawing2D.Matrix
186 Dim native As *GpMatrix
187 SetStatus(GdipGetWorldTransform(nativeGraphics, native))
188 Transform = New Drawing2D.Matrix(native)
189 End Function
190
191 Sub Transform(matrix As Drawing2D.Matrix)
192 SetStatus(GdipSetWorldTransform(nativeGraphics, matrix.nativeMatrix))
193 End Sub
194
195 Function VisibleClipBounds() As RectangleF
196 SetStatus(GdipGetVisibleClipBounds(nativeGraphics, VisibleClipBounds))
197 End Function
198
199 Function VisibleClipBoundsI() As Rectangle
200 SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, VisibleClipBoundsI))
201 End Function
202
203 '=========================================================================
204 ' Methods
205 '=========================================================================
206 Static Function FromHDC(hdc As HDC) As Graphics
207 Dim graphics = 0 As *GpGraphics
208 SetStatus(GdipCreateFromHDC(hdc, graphics))
209 Return New Graphics(graphics)
210 End Function
211
212 Static Function FromHDC(hdc As HDC, hdevice As HANDLE) As Graphics
213 Dim graphics = 0 As *GpGraphics
214 SetStatus(GdipCreateFromHDC2(hdc, hdevice, graphics))
215 Return New Graphics(graphics)
216 End Function
217
218 Static Function FromHwnd(hwnd As HWND) As Graphics
219 Dim graphics = 0 As *GpGraphics
220 SetStatus(GdipCreateFromHWND(hwnd, graphics))
221 Return New Graphics(graphics)
222 End Function
223
224 Static Function FromHwnd(hwnd As HWND, icm As Boolean) As Graphics
225 Dim graphics = 0 As *GpGraphics
226 If icm Then
227 SetStatus(GdipCreateFromHWNDICM(hwnd, graphics))
228 Else
229 SetStatus(GdipCreateFromHWND(hwnd, graphics))
230 End If
231 Return New Graphics(graphics)
232 End Function
233
234 Static Function FromImage(image As Image) As Graphics
235 If ActiveBasic.IsNothing(image) Then
236 Throw New ArgumentNullException("image")
237 End If
238 Dim graphics = 0 As *GpGraphics
239 SetStatus(GdipGetImageGraphicsContext(image.nativeImage, graphics))
240 Return New Graphics(graphics)
241 End Function
242
243 Sub Dispose()
244 GdipDeleteGraphics(nativeGraphics)
245 nativeGraphics = 0
246 End Sub
247
248 Sub ~Graphics()
249 Dispose()
250 End Sub
251
252 Sub Flush()
253 GdipFlush(nativeGraphics, System.Drawing.Drawing2D.FlushIntention.Flush)
254 End Sub
255
256 Sub Flush(intention As Drawing2D.FlushIntention)
257 GdipFlush(nativeGraphics, intention)
258 End Sub
259
260 Function GetHDC() As HDC
261 GetHDC = 0
262 SetStatus(GdipGetDC(nativeGraphics, GetHDC))
263 End Function
264
265 Sub ReleaseHDC(hdc As HDC)
266 SetStatus(GdipReleaseDC(nativeGraphics, hdc))
267 End Sub
268
269 Sub ResetTransform()
270 SetStatus(GdipResetWorldTransform(nativeGraphics))
271 End Sub
272
273 Sub MultiplyTransform(matrix As Drawing2D.Matrix)
274 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, System.Drawing.Drawing2D.MatrixOrder.Prepend))
275 End Sub
276
277 Sub MultiplyTransform(matrix As Drawing2D.Matrix, order As Drawing2D.MatrixOrder)
278 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, order))
279 End Sub
280
281 Sub TranslateTransform(dx As Single, dy As Single)
282 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
283 End Sub
284
285 Sub TranslateTransform(dx As Single, dy As Single, order As Drawing2D.MatrixOrder)
286 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order))
287 End Sub
288
289 Sub ScaleTransform(sx As Single, sy As Single)
290 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
291 End Sub
292
293 Sub ScaleTransform(sx As Single, sy As Single, order As Drawing2D.MatrixOrder)
294 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order))
295 End Sub
296
297 Sub RotateTransform(angle As Single)
298 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, System.Drawing.Drawing2D.MatrixOrder.Prepend))
299 End Sub
300
301 Sub RotateTransform(angle As Single, order As Drawing2D.MatrixOrder)
302 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order))
303 End Sub
304
305 Sub TransformPoints(destSpace As Drawing2D.CoordinateSpace, srcSpace As Drawing2D.CoordinateSpace, pts As *PointF, count As Long)
306 SetStatus(GdipTransformPoints(nativeGraphics, destSpace, srcSpace, pts, count))
307 End Sub
308
309 Sub TransformPoints(destSpace As Drawing2D.CoordinateSpace, srcSpace As Drawing2D.CoordinateSpace, pts As *Point, count As Long)
310 SetStatus(GdipTransformPointsI(nativeGraphics, destSpace, srcSpace, pts, count))
311 End Sub
312
313 Const Function GetNearestColor(color As Color) As Color
314 GetNearestColor = color
315 SetStatus(GdipGetNearestColor(nativeGraphics, GetNearestColor))
316 End Function
317
318 Sub DrawLine(pen As Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)
319 SetStatus(GdipDrawLine(nativeGraphics, pen.NativePen, x1, y1, x2, y2))
320 End Sub
321
322 Sub DrawLine(pen As Pen, ByRef pt1 As PointF, ByRef pt2 As PointF)
323 DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
324 End Sub
325
326 Sub DrawLines(pen As Pen, points As *PointF, count As Long)
327 SetStatus(GdipDrawLines(nativeGraphics, pen.NativePen, points, count))
328 End Sub
329
330 Sub DrawLine(pen As Pen, x1 As Long, y1 As Long, x2 As Long, y2 As Long)
331 SetStatus(GdipDrawLineI(nativeGraphics, pen.NativePen, x1, y1, x2, y2))
332 End Sub
333
334 Sub DrawLine(pen As Pen, ByRef pt1 As Point, ByRef pt2 As Point)
335 DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
336 End Sub
337
338 Sub DrawLines(pen As Pen, points As *Point, count As Long)
339 SetStatus(GdipDrawLinesI(nativeGraphics, pen.NativePen, points, count))
340 End Sub
341
342 Sub DrawArc(pen As Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
343 SetStatus(GdipDrawArc(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
344 End Sub
345
346 Sub DrawArc(pen As Pen, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
347 DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
348 End Sub
349
350 Sub DrawArc(pen As Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
351 SetStatus(GdipDrawArcI(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
352 End Sub
353
354 Sub DrawArc(pen As Pen, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
355 DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
356 End Sub
357
358 Sub DrawBezier(pen As Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single)
359 SetStatus(GdipDrawBezier(nativeGraphics, pen.NativePen, x1, y1,x2, y2, x3, y3, x4, y4))
360 End Sub
361
362 Sub DrawBezier(pen As Pen, ByRef pt1 As PointF, ByRef pt2 As PointF, ByRef pt3 As PointF, ByRef pt4 As PointF)
363 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
364 End Sub
365
366 Sub DrawBeziers(pen As Pen, points As *PointF, count As Long)
367 SetStatus(GdipDrawBeziers(nativeGraphics, pen.NativePen, points, count))
368 End Sub
369
370 Sub DrawBezier(pen As Pen, x1 As Long, y1 As Long, x2 As Long, y2 As Long, x3 As Long, y3 As Long, x4 As Long, y4 As Long)
371 SetStatus(GdipDrawBezierI(nativeGraphics, pen.NativePen, x1, y1, x2, y2, x3, y3, x4, y4))
372 End Sub
373
374 Sub DrawBezier(pen As Pen, ByRef pt1 As Point, ByRef pt2 As Point, ByRef pt3 As Point, ByRef pt4 As Point)
375 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
376 End Sub
377
378 Sub DrawBeziers(pen As Pen, points As *Point, count As Long)
379 SetStatus(GdipDrawBeziersI(nativeGraphics, pen.NativePen, points, count))
380 End Sub
381
382 Sub DrawRectangle(pen As Pen, ByRef rect As RectangleF)
383 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
384 End Sub
385
386 Sub DrawRectangle(pen As Pen, x As Single, y As Single, width As Single, height As Single)
387 SetStatus(GdipDrawRectangle(nativeGraphics, pen.NativePen, x, y, width, height))
388 End Sub
389
390 Sub DrawRectangles(pen As Pen, rects As *RectangleF, count As Long)
391 SetStatus(GdipDrawRectangles(nativeGraphics, pen.NativePen, rects, count))
392 End Sub
393
394 Sub DrawRectangle(pen As Pen, ByRef rect As Rectangle)
395 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
396 End Sub
397
398 Sub DrawRectangle(pen As Pen, x As Long, y As Long, width As Long, height As Long)
399 SetStatus(GdipDrawRectangleI(nativeGraphics, pen.NativePen, x, y, width, height))
400 End Sub
401
402 Sub DrawRectangles(pen As Pen, rects As *Rectangle, count As Long)
403 SetStatus(GdipDrawRectanglesI(nativeGraphics, pen.NativePen, rects, count))
404 End Sub
405
406 Sub DrawEllipse(pen As Pen, ByRef rect As RectangleF)
407 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
408 End Sub
409
410 Sub DrawEllipse(pen As Pen, x As Single, y As Single, width As Single, height As Single)
411 SetStatus(GdipDrawEllipse(nativeGraphics, pen.NativePen, x, y, width, height))
412 End Sub
413
414 Sub DrawEllipse(pen As Pen, ByRef rect As Rectangle)
415 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
416 End Sub
417
418 Sub DrawEllipse(pen As Pen, x As Long, y As Long, width As Long, height As Long)
419 SetStatus(GdipDrawEllipseI(nativeGraphics, pen.NativePen, x, y, width, height))
420 End Sub
421
422 Sub DrawPie(pen As Pen, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
423 DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
424 End Sub
425
426 Sub DrawPie(pen As Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
427 SetStatus(GdipDrawPie(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
428 End Sub
429
430 Sub DrawPie(pen As Pen, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
431 DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
432 End Sub
433
434 Sub DrawPie(pen As Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
435 SetStatus(GdipDrawPieI(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
436 End Sub
437
438 Sub DrawPolygon(pen As Pen, points As *PointF, count As Long)
439 SetStatus(GdipDrawPolygon(nativeGraphics, pen.NativePen, points, count))
440 End Sub
441
442 Sub DrawPolygon(pen As Pen, points As *Point, count As Long)
443 SetStatus(GdipDrawPolygonI(nativeGraphics, pen.NativePen, points, count))
444 End Sub
445
446 Sub DrawPath(pen As Pen, path As GraphicsPath)
447 If ActiveBasic.IsNothing(pen) Or ActiveBasic.IsNothing(path) Then
448 Throw New ArgumentNullException("pen or path or both")
449 End If
450 SetStatus(GdipDrawPath(nativeGraphics, pen.NativePen, path.nativePath))
451 End Sub
452
453 Sub DrawCurve(pen As Pen, points As *PointF, count As Long)
454 SetStatus(GdipDrawCurve(nativeGraphics, pen.NativePen, points, count))
455 End Sub
456
457 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, tension As Single)
458 SetStatus(GdipDrawCurve2(nativeGraphics, pen.NativePen, points,count, tension))
459 End Sub
460
461 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, offset As Long, numberOfSegments As Long)
462 SetStatus(GdipDrawCurve3(nativeGraphics, pen.NativePen, points, count, offset,numberOfSegments, 0.5))
463 End Sub
464
465 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, offset As Long, numberOfSegments As Long, tension As Single)
466 SetStatus(GdipDrawCurve3(nativeGraphics, pen.NativePen, points, count, offset,numberOfSegments, tension))
467 End Sub
468
469 Sub DrawCurve(pen As Pen, points As *Point, count As Long)
470 SetStatus(GdipDrawCurveI(nativeGraphics, pen.NativePen, points, count))
471 End Sub
472
473 Sub DrawCurve(pen As Pen, points As *Point, count As Long, tension As Single)
474 SetStatus(GdipDrawCurve2I(nativeGraphics, pen.NativePen, points, count, tension))
475 End Sub
476
477 Sub DrawCurve(pen As Pen, points As *Point, count As Long, offset As Long, numberOfSegments As Long)
478 SetStatus(GdipDrawCurve3I(nativeGraphics, pen.NativePen, points, count, offset, numberOfSegments, 0.5))
479 End Sub
480
481 Sub DrawCurve(pen As Pen, points As *Point, count As Long, offset As Long, numberOfSegments As Long, tension As Single)
482 SetStatus(GdipDrawCurve3I(nativeGraphics, pen.NativePen, points, count, offset, numberOfSegments, tension))
483 End Sub
484
485 Sub DrawClosedCurve(pen As Pen, points As *PointF, count As Long)
486 SetStatus(GdipDrawClosedCurve(nativeGraphics, pen.NativePen, points, count))
487 End Sub
488
489 Sub DrawClosedCurve(pen As Pen, points As *PointF, count As Long, tension As Single)
490 SetStatus(GdipDrawClosedCurve2(nativeGraphics, pen.NativePen, points, count, tension))
491 End Sub
492
493 Sub DrawClosedCurve(pen As Pen, points As *Point, count As Long)
494 SetStatus(GdipDrawClosedCurveI(nativeGraphics, pen.NativePen, points, count))
495 End Sub
496
497 Sub DrawClosedCurve(pen As Pen, points As *Point, count As Long, tension As Single)
498 SetStatus(GdipDrawClosedCurve2I(nativeGraphics, pen.NativePen, points, count, tension))
499 End Sub
500
501 Sub Clear(color As Color)
502 SetStatus(GdipGraphicsClear(nativeGraphics, color))
503 End Sub
504
505 Sub FillRectangle(brush As Brush, ByRef rect As RectangleF)
506 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
507 End Sub
508
509 Sub FillRectangle(brush As Brush, x As Single, y As Single, width As Single, height As Single)
510 SetStatus(GdipFillRectangle(nativeGraphics, brush.nativeBrush, x, y, width, height))
511 End Sub
512
513 Sub FillRectangles(brush As Brush, rects As *RectangleF, count As Long)
514 SetStatus(GdipFillRectangles(nativeGraphics,brush.nativeBrush,rects, count))
515 End Sub
516
517 Sub FillRectangle(brush As Brush, ByRef rect As Rectangle)
518 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
519 End Sub
520
521 Sub FillRectangle(brush As Brush, x As Long, y As Long, width As Long, height As Long)
522 SetStatus(GdipFillRectangleI(nativeGraphics, brush.nativeBrush, x, y, width, height))
523 End Sub
524
525 Sub FillRectangles(brush As Brush, rects As *Rectangle, count As Long)
526 SetStatus(GdipFillRectanglesI(nativeGraphics, brush.nativeBrush, rects, count))
527 End Sub
528
529' Sub FillPolygon(brush As Brush, points As *PointF, count As Long)
530' FillPolygon(brush, points, count, System.Drawing.Drawing2D.FillMode.Alternate)
531' End Sub
532
533 Sub FillPolygon(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode)
534 SetStatus(GdipFillPolygon(nativeGraphics, brush.nativeBrush, points, count, fillMode))
535 End Sub
536
537' Sub FillPolygon(brush As Brush, points As *Point, count As Long)
538' FillPolygon(brush, points, count, System.Drawing.Drawing2D.FillMode.Alternate)
539' End Sub
540
541 Sub FillPolygon(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode)
542 SetStatus(GdipFillPolygonI(nativeGraphics, brush.nativeBrush, points, count, fillMode))
543 End Sub
544
545 Sub FillEllipse(brush As Brush, ByRef rect As RectangleF)
546 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
547 End Sub
548
549 Sub FillEllipse(brush As Brush, x As Single, y As Single, width As Single, height As Single)
550 SetStatus(GdipFillEllipse(nativeGraphics, brush.nativeBrush, x, y, width, height))
551 End Sub
552
553 Sub FillEllipse(brush As Brush, ByRef rect As Rectangle)
554 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
555 End Sub
556
557 Sub FillEllipse(brush As Brush, x As Long, y As Long, width As Long, height As Long)
558 SetStatus(GdipFillEllipseI(nativeGraphics, brush.nativeBrush, x, y, width, height))
559 End Sub
560
561 Sub FillPie(brush As Brush, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
562 FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
563 End Sub
564
565 Sub FillPie(brush As Brush, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
566 SetStatus(GdipFillPie(nativeGraphics, brush.nativeBrush, x, y, width, height, startAngle, sweepAngle))
567 End Sub
568
569 Sub FillPie(brush As Brush, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
570 FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
571 End Sub
572
573 Sub FillPie(brush As Brush, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
574 SetStatus(GdipFillPieI(nativeGraphics, brush.nativeBrush, x, y, width, height, startAngle, sweepAngle))
575 End Sub
576
577 Sub FillPath(brush As Brush, path As GraphicsPath)
578 If ActiveBasic.IsNothing(brush) Or ActiveBasic.IsNothing(path) Then
579 Throw New ArgumentNullException("brush or path or both")
580 End If
581 SetStatus(GdipFillPath(nativeGraphics, brush.nativeBrush, path.nativePath))
582 End Sub
583
584 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long)
585 SetStatus(GdipFillClosedCurve(nativeGraphics, brush.nativeBrush, points, count))
586 End Sub
587
588 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode)
589 SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.nativeBrush, points, count, 0.5, fillMode))
590 End Sub
591
592 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode, tension As Single)
593 SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.nativeBrush, points, count, tension, fillMode))
594 End Sub
595
596 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long)
597 SetStatus(GdipFillClosedCurveI(nativeGraphics, brush.nativeBrush, points, count))
598 End Sub
599
600 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode)
601 SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.nativeBrush, points, count, 0.5, fillMode))
602 End Sub
603
604 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode, tension As Single)
605 SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.nativeBrush, points, count, tension, fillMode))
606 End Sub
607
608 Sub FillRegion(brush As Brush, region As Region)
609 SetStatus(GdipFillRegion(nativeGraphics, brush.nativeBrush, region.nativeRegion))
610 End Sub
611
612'DrawStringは次の組み合わせからなる。
613'(PCWSTR, Long) or String
614'PointF or (Single, Single) or Rectangle
615'StringFormatの有無
616 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, ByRef origin As PointF, stringFormat = Nothing As StringFormat)
617 DrawString(str, length, font, brush, origin.X, origin.Y, stringFormat)
618 End Sub
619
620 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, x As Single, y As Single, stringFormat = Nothing As StringFormat)
621 Dim rc As RectangleF
622 rc.X = x
623 rc.Y = y
624 rc.Width = 0
625 rc.Height = 0
626 DrawString(str, length, font, brush, rc, stringFormat)
627 End Sub
628
629 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, ByRef layoutRect As RectangleF, stringFormat = Nothing As StringFormat)
630 Dim nativeFont = getNativeFont(font)
631 Dim nativeFormat = getNativeStringFormat(stringFormat)
632 Dim nativeBrush = getNativeBrush(brush)
633 SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, nativeBrush))
634 End Sub
635
636 Sub DrawString(s As String, font As Font, brush As Brush, ByRef origin As PointF, stringFormat = Nothing As StringFormat)
637 DrawString(s, font, brush, origin.X, origin.Y, stringFormat)
638 End Sub
639
640 Sub DrawString(s As String, font As Font, brush As Brush, x As Single, y As Single, stringFormat = Nothing As StringFormat)
641 Dim rc As RectangleF
642 rc.X = x
643 rc.Y = y
644 rc.Width = 0
645 rc.Height = 0
646 DrawString(s, font, brush, rc, stringFormat)
647 End Sub
648
649 Sub DrawString(s As String, font As Font, brush As Brush, ByRef layoutRect As RectangleF, stringFormat = Nothing As StringFormat)
650 Dim wcs As PCWSTR
651 Dim len = GetStr(s, wcs) As Long
652 DrawString(wcs, len As Long, font, brush, layoutRect, stringFormat)
653 End Sub
654
655 Function MeasureString(s As String, font As Font) As SizeF
656 Dim pt As PointF
657 MeasureString = MeasureString(s, font, pt, Nothing)
658 End Function
659
660 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF) As SizeF
661 MeasureString = MeasureString(s, font, layoutRectSize, Nothing)
662 End Function
663
664 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat) As SizeF
665 Dim wcs As PCWSTR
666 Dim len = GetStr(s, wcs) As Long
667 MeasureString = MeasureString(wcs, len, font, layoutRectSize, stringFormat)
668 End Function
669
670 Function MeasureString(s As String, font As Font, ByRef origin As PointF, stringFormat As StringFormat) As SizeF
671 Dim wcs As PCWSTR
672 Dim len = GetStr(s, wcs) As Long
673 MeasureString = MeasureString(wcs, len, font, origin, stringFormat)
674 End Function
675
676 Function MeasureString(s As String, font As Font, width As Long, stringFormat As StringFormat) As SizeF
677 Dim wcs As PCWSTR
678 Dim len = GetStr(s, wcs) As Long
679 MeasureString = MeasureString(wcs, len, font, width, stringFormat)
680 End Function
681
682 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat, ByRef codepointsFitted As Long, ByRef linesFilled As Long) As SizeF
683 Dim wcs As PCWSTR
684 Dim len = GetStr(s, wcs) As Long
685 MeasureString = MeasureString(wcs, len, font, layoutRectSize, stringFormat, codepointsFitted, linesFilled)
686 End Function
687
688 Function MeasureString(str As PCWSTR, length As Long, font As Font) As SizeF
689 Dim pt As PointF
690 MeasureString = MeasureString(str, length, font, pt, Nothing)
691 End Function
692
693 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF) As SizeF
694 MeasureString = MeasureString(str, length, font, layoutRectSize, Nothing)
695 End Function
696
697 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat) As SizeF
698 MeasureString = measureStringPt(str, length, font, layoutRectSize, stringFormat, 0, 0)
699 End Function
700
701 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef origin As PointF, stringFormat As StringFormat) As SizeF
702 Dim layoutRect As RectangleF
703 With layoutRect
704 .X = origin.X
705 .Y = origin.Y
706 .Width = 0
707 .Height = 0
708 End With
709 MeasureString = measureString(str, length, font, layoutRect, stringFormat, 0, 0)
710 End Function
711
712 Function MeasureString(str As PCWSTR, length As Long, font As Font, width As Long, stringFormat As StringFormat) As SizeF
713 Dim layoutRect As RectangleF
714 With layoutRect
715 .X = 0
716 .Y = 0
717 .Width = width
718 .Height = 0
719 End With
720 MeasureString = measureString(str, length, font, layoutRect, stringFormat, 0, 0)
721 End Function
722
723 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat, ByRef codepointsFitted As Long, ByRef linesFilled As Long) As SizeF
724 MeasureString = measureStringPt(str, length, font, layoutRectSize, stringFormat, VarPtr(codepointsFitted), VarPtr(linesFilled))
725 End Function
726
727Private
728 Function measureStringPt(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat, codepointsFitted As *Long, linesFilled As *Long) As SizeF
729 Dim layoutRect As RectangleF
730 With layoutRect
731 .X = 0
732 .Y = 0
733 .Width = layoutRectSize.Width
734 .Height = layoutRectSize.Height
735 End With
736 measureStringPt = measureString(str, length, font, layoutRect, stringFormat, codepointsFitted, linesFilled)
737 End Function
738
739 Function measureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRect As RectangleF, stringFormat As StringFormat, codepointsFitted As *Long, linesFilled As *Long) As SizeF
740 Dim nativeFont = getNativeFont(font)
741 Dim nativeFormat = getNativeStringFormat(stringFormat)
742 Dim boundingBox As RectangleF
743 SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, boundingBox, codepointsFitted, linesFilled))
744 measureString.Width = boundingBox.Width
745 measureString.Height = boundingBox.Height
746 End Function
747
748Public
749
750 Function MeasureCharacterRanges(s As String, font As Font, ByRef layoutRect As RectangleF, stringFormat As StringFormat) As System.Collections.Generic.IList<Region>
751 Dim wcs As PCWSTR
752 Dim len = GetStr(s, wcs)
753 MeasureCharacterRanges = MeasureCharacterRanges(wcs, len, font, layoutRect, stringFormat)
754 End Function
755
756 Function MeasureCharacterRanges(str As PCWSTR, length As Long, font As Font, ByRef layoutRect As RectangleF, stringFormat As StringFormat) As System.Collections.Generic.IList<Region>
757 If ActiveBasic.IsNothing(stringFormat) Then
758 stringFormat = New StringFormat
759 End If
760 Dim count As Long
761 SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(stringFormat.nativeFormat, count))
762 Dim nativeRegions As **GpRegion 'ここで = GC_mallocとすると、エラーになる。
763 nativeRegions = GC_malloc(count * SizeOf(*GpRegion))
764 Dim regions = New System.Collections.Generic.List<Region>(count)
765 MeasureCharacterRanges = regions
766
767 Dim i As Long
768 For i = 0 To ELM(count)
769 Dim t = regions[i]
770 nativeRegions[i] = t.nativeRegion
771 Next
772 Dim nativeFont = getNativeFont(font)
773 SetStatus(GdipMeasureCharacterRanges(nativeGraphics, str, length, nativeFont, layoutRect, stringFormat.nativeFormat, count, nativeRegions))
774 End Function
775
776 'DrawDriverString
777 'MeasureDriverString
778
779 Sub DrawCachedBitmap(cb As CachedBitmap, x As Long, y As Long)
780 SetStatus(GdipDrawCachedBitmap(nativeGraphics, cb.nativeCachedBitmap, x, y))
781 End Sub
782
783 Sub DrawImage(image As Image, ByRef point As PointF)
784 DrawImage(image, point.X, point.Y)
785 End Sub
786
787 Sub DrawImage(image As Image, x As Single, y As Single)
788 Dim nativeImage = getNativeImage(image)
789 SetStatus(GdipDrawImage(nativeGraphics, nativeImage, x, y))
790 End Sub
791
792 Sub DrawImage(image As Image, ByRef rect As RectangleF)
793 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
794 End Sub
795
796 Sub DrawImage(image As Image, x As Single, y As Single, width As Single, height As Single)
797 Dim nativeImage = getNativeImage(image)
798 SetStatus(GdipDrawImageRect(nativeGraphics, nativeImage, x, y, width, height))
799 End Sub
800
801 Sub DrawImage(image As Image, ByRef point As Point)
802 DrawImage(image, point.X, point.Y)
803 End Sub
804
805 Sub DrawImage(image As Image, x As Long, y As Long)
806 Dim nativeImage = getNativeImage(image)
807 SetStatus(GdipDrawImageI(nativeGraphics, nativeImage, x, y))
808 End Sub
809
810 Sub DrawImage(image As Image, ByRef rect As Rectangle)
811 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
812 End Sub
813
814 Sub DrawImage(image As Image, x As Long, y As Long, width As Long, height As Long)
815 Dim nativeImage = getNativeImage(image)
816 SetStatus(GdipDrawImageRectI(nativeGraphics, nativeImage, x, y, width, height))
817 End Sub
818
819 ' Affine Draw Image
820 ' destPoints.length = 3: rect => parallelogram
821 ' destPoints[0] <=> top-left corner of the source rectangle
822 ' destPoints[1] <=> top-right corner
823 ' destPoints[2] <=> bottom-left corner
824 ' destPoints.length = 4: rect => quad
825 ' destPoints[3] <=> bottom-right corner
826
827 Sub DrawImage(image As Image, destPoints As *PointF, count As Long)
828 If count <> 3 And count <> 4 Then
829 SetStatus(InvalidParameter)
830 End If
831
832 Dim nativeImage = getNativeImage(image)
833 SetStatus(GdipDrawImagePoints(nativeGraphics, nativeImage, destPoints, count))
834 End Sub
835
836 Sub DrawImage(image As Image, destPoints As *Point, count As Long)
837 If count <> 3 And count <> 4 Then
838 SetStatus(InvalidParameter)
839 End If
840
841 Dim nativeImage = getNativeImage(image)
842 SetStatus(GdipDrawImagePointsI(nativeGraphics, nativeImage, destPoints, count))
843 End Sub
844
845 Sub DrawImage(image As Image, ByRef destRect As Rectangle, ByRef src As Rectangle, srcUnit As GraphicsUnit)
846 DrawImage(image, destRect, src.X, src.Y, src.Width, src.Height, srcUnit)
847 End Sub
848
849 Sub DrawImage(image As Image, ByRef destRect As RectangleF, ByRef src As RectangleF, srcUnit As GraphicsUnit)
850 DrawImage(image, destRect, src.X, src.Y, src.Width, src.Height, srcUnit)
851 End Sub
852
853 Sub DrawImage(image As Image, x As Long, y As Long, ByRef src As Rectangle, srcUnit As GraphicsUnit)
854 Dim nativeImage = getNativeImage(image)
855 SetStatus(GdipDrawImagePointRectI(nativeGraphics, nativeImage, x, y, src.X, src.Y, src.Width, src.Height, srcUnit))
856 End Sub
857
858 Sub DrawImage(image As Image, x As Single, y As Single, ByRef src As RectangleF, srcUnit As GraphicsUnit)
859 Dim nativeImage = getNativeImage(image)
860 SetStatus(GdipDrawImagePointRect(nativeGraphics, nativeImage, x, y, src.X, src.Y, src.Width, src.Height, srcUnit))
861 End Sub
862
863 Sub DrawImage(image As Image, destPoints As *Point, count As Long, ByRef src As Rectangle, srcUnit As GraphicsUnit, _
864 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
865
866 Dim nativeImage = getNativeImage(image)
867 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
868 SetStatus(GdipDrawImagePointsRectI(nativeGraphics, nativeImage, destPoints, count,
869 src.X, src.Y, src.Width, src.Height, srcUnit, nativeImageAttr, callback, callbackData))
870 End Sub
871
872 Sub DrawImage(image As Image, destPoints As *PointF, count As Long, ByRef src As RectangleF, srcUnit As GraphicsUnit,
873 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
874
875 Dim nativeImage = getNativeImage(image)
876 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
877 SetStatus(GdipDrawImagePointsRect(nativeGraphics, nativeImage, destPoints, count,
878 src.X, src.Y, src.Width, src.Height, srcUnit, nativeImageAttr, callback, callbackData))
879 End Sub
880
881 Sub DrawImage(image As Image, ByRef destRect As RectangleF,
882 srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
883 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
884
885 Dim nativeImage = getNativeImage(image)
886 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
887 SetStatus(GdipDrawImageRectRect(nativeGraphics, nativeImageAttr,
888 destRect.X, destRect.Y, destRect.Width, destRect.Height, srcx, srcy, srcwidth, srcheight,
889 srcUnit, nativeImageAttr, callback, callbackData))
890 End Sub
891
892 Sub DrawImage(image As Image, ByRef destRect As Rectangle,
893 srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
894 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
895
896 Dim nativeImage = getNativeImage(image)
897 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
898 SetStatus(GdipDrawImageRectRectI(nativeGraphics, nativeImage,
899 destRect.X, destRect.Y, destRect.Width, destRect.Height,
900 srcx, srcy, srcwidth, srcheight, srcUnit, nativeImageAttr, callback, callbackData))
901 End Sub
902
903 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As PointF,
904 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
905
906 Dim nativeImage = getNativeImage(metafile)
907 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
908 Dim procData As Detail.EnumerateMetafileProcData
909 procData.Proc = callback
910 procData.Data = callbackData
911 SetStatus(GdipEnumerateMetafileDestPoint(nativeGraphics,
912 nativeImage, destPoint, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
913 End Sub
914
915 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As Point,
916 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
917
918 Dim nativeImage = getNativeImage(metafile)
919 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
920 Dim procData As Detail.EnumerateMetafileProcData
921 procData.Proc = callback
922 procData.Data = callbackData
923 SetStatus(GdipEnumerateMetafileDestPointI(nativeGraphics,
924 nativeImage, destPoint, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
925 End Sub
926
927 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As RectangleF,
928 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
929
930 Dim nativeImage = getNativeImage(metafile)
931 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
932 Dim procData As Detail.EnumerateMetafileProcData
933 procData.Proc = callback
934 procData.Data = callbackData
935 SetStatus(GdipEnumerateMetafileDestRect(nativeGraphics,
936 nativeImage, destRect, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
937 End Sub
938
939 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As Rectangle,
940 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
941
942 Dim nativeImage = getNativeImage(metafile)
943 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
944 Dim procData As Detail.EnumerateMetafileProcData
945 procData.Proc = callback
946 procData.Data = callbackData
947 SetStatus(GdipEnumerateMetafileDestRectI(nativeGraphics,
948 nativeImage, destRect, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
949 End Sub
950
951 Sub EnumerateMetafile(metafile As Metafile, destPoints As *PointF, count As Long,
952 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
953
954 Dim nativeImage = getNativeImage(metafile)
955 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
956 Dim procData As Detail.EnumerateMetafileProcData
957 procData.Proc = callback
958 procData.Data = callbackData
959 SetStatus(GdipEnumerateMetafileDestPoints(nativeGraphics,
960 nativeImage,destPoints, count, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
961 End Sub
962
963 Sub EnumerateMetafile(metafile As Metafile, destPoints As *Point, count As Long,
964 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
965
966 Dim nativeImage = getNativeImage(metafile)
967 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
968 Dim procData As Detail.EnumerateMetafileProcData
969 procData.Proc = callback
970 procData.Data = callbackData
971 SetStatus(GdipEnumerateMetafileDestPointsI(nativeGraphics,
972 nativeImage,destPoints, count, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
973 End Sub
974
975 Sub EnumerateMetafile(metafile As Metafile,
976 ByRef destPoint As PointF, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
977 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
978
979 Dim nativeImage = getNativeImage(metafile)
980 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
981 Dim procData As Detail.EnumerateMetafileProcData
982 procData.Proc = callback
983 procData.Data = callbackData
984 SetStatus(GdipEnumerateMetafileSrcRectDestPoint(nativeGraphics,
985 nativeImage, destPoint, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
986 End Sub
987
988 Sub EnumerateMetafile(metafile As Metafile,
989 ByRef destPoint As Point, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
990 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
991
992 Dim nativeImage = getNativeImage(metafile)
993 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
994 Dim procData As Detail.EnumerateMetafileProcData
995 procData.Proc = callback
996 procData.Data = callbackData
997 SetStatus(GdipEnumerateMetafileSrcRectDestPointI(nativeGraphics,
998 nativeImage, destPoint, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
999 End Sub
1000
1001 Sub EnumerateMetafile(metafile As Metafile,
1002 ByRef destRect As RectangleF, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
1003 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1004
1005 Dim nativeImage = getNativeImage(metafile)
1006 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1007 Dim procData As Detail.EnumerateMetafileProcData
1008 procData.Proc = callback
1009 procData.Data = callbackData
1010 SetStatus(GdipEnumerateMetafileSrcRectDestRect(nativeGraphics,
1011 nativeImage, destRect, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1012 End Sub
1013
1014 Sub EnumerateMetafile(metafile As Metafile,
1015 ByRef destRect As Rectangle, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
1016 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1017
1018 Dim nativeImage = getNativeImage(metafile)
1019 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1020 Dim procData As Detail.EnumerateMetafileProcData
1021 procData.Proc = callback
1022 procData.Data = callbackData
1023 SetStatus(GdipEnumerateMetafileSrcRectDestRectI(nativeGraphics,
1024 nativeImage, destRect, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1025 End Sub
1026
1027 Sub EnumerateMetafile(metafile As Metafile,
1028 destPoints As *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
1029 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1030
1031 Dim nativeImage = getNativeImage(metafile)
1032 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1033 Dim procData As Detail.EnumerateMetafileProcData
1034 procData.Proc = callback
1035 procData.Data = callbackData
1036 SetStatus(GdipEnumerateMetafileSrcRectDestPoints(nativeGraphics,
1037 nativeImage, destPoints, count, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1038 End Sub
1039
1040 Sub EnumerateMetafile(metafile As Metafile,
1041 destPoints As *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
1042 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1043
1044 Dim nativeImage = getNativeImage(metafile)
1045 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1046 Dim procData As Detail.EnumerateMetafileProcData
1047 procData.Proc = callback
1048 procData.Data = callbackData
1049 SetStatus(GdipEnumerateMetafileSrcRectDestPointsI(nativeGraphics, nativeImage,
1050 destPoints, count, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1051 End Sub
1052
1053 Sub SetClip(g As Graphics)
1054 SetClip(g, System.Drawing.Drawing2D.CombineMode.Replace)
1055 End Sub
1056
1057 Sub SetClip(g As Graphics, combineMode As Drawing2D.CombineMode)
1058 SetStatus(GdipSetClipGraphics(nativeGraphics, g.nativeGraphics, combineMode))
1059 End Sub
1060
1061 Sub SetClip(ByRef rc As RectangleF)
1062 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1063 End Sub
1064
1065 Sub SetClip(ByRef rc As RectangleF, combineMode As Drawing2D.CombineMode)
1066 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
1067 End Sub
1068
1069 Sub SetClip(ByRef rc As Rectangle)
1070 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1071 End Sub
1072
1073 Sub SetClip(ByRef rc As Rectangle, combineMode As Drawing2D.CombineMode)
1074 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
1075 End Sub
1076
1077 Sub SetClip(path As GraphicsPath)
1078 SetClip(path, System.Drawing.Drawing2D.CombineMode.Replace)
1079 End Sub
1080
1081 Sub SetClip(path As GraphicsPath, combineMode As Drawing2D.CombineMode)
1082 SetStatus(GdipSetClipPath(nativeGraphics, path.nativePath, combineMode))
1083 End Sub
1084
1085 Sub SetClip(region As Region)
1086 SetClip(region, System.Drawing.Drawing2D.CombineMode.Replace)
1087 End Sub
1088
1089 Sub SetClip(region As Region, combineMode As Drawing2D.CombineMode)
1090 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, combineMode))
1091 End Sub
1092
1093 Sub SetClip(hrgn As HRGN)
1094 SetClip(hrgn, System.Drawing.Drawing2D.CombineMode.Replace)
1095 End Sub
1096
1097 Sub SetClip(hrgn As HRGN, combineMode As Drawing2D.CombineMode)
1098 SetStatus(GdipSetClipHrgn(nativeGraphics, hrgn, combineMode))
1099 End Sub
1100
1101 Sub IntersectClip(ByRef rc As RectangleF)
1102 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Intersect))
1103 End Sub
1104
1105 Sub IntersectClip(ByRef rc As Rectangle)
1106 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Intersect))
1107 End Sub
1108
1109 Sub IntersectClip(region As Region)
1110 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Intersect))
1111 End Sub
1112
1113 Sub ExcludeClip(ByRef rc As RectangleF)
1114 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Exclude))
1115 End Sub
1116
1117 Sub ExcludeClip(ByRef rc As Rectangle)
1118 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Exclude))
1119 End Sub
1120
1121 Sub ExcludeClip(region As Region)
1122 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Exclude))
1123 End Sub
1124
1125 Sub ResetClip()
1126 SetStatus(GdipResetClip(nativeGraphics))
1127 End Sub
1128
1129 Sub TranslateClip(dx As Single, dy As Single)
1130 SetStatus(GdipTranslateClip(nativeGraphics, dx, dy))
1131 End Sub
1132
1133 Sub TranslateClip(dx As Long, dy As Long)
1134 SetStatus(GdipTranslateClipI(nativeGraphics, dx, dy))
1135 End Sub
1136
1137 Const Function IsVisible(x As Long, y As Long) As Boolean
1138 Dim b = FALSE As BOOL
1139 SetStatus(GdipIsVisiblePointI(nativeGraphics, x, y, b))
1140 IsVisible = b As Boolean
1141 End Function
1142
1143 Const Function IsVisible(ByRef pt As Point) As Boolean
1144 IsVisible(pt.X, pt.Y)
1145 End Function
1146
1147 Const Function IsVisible(x As Long, y As Long, width As Long, height As Long) As Boolean
1148 Dim b = FALSE As BOOL
1149 SetStatus(GdipIsVisibleRectI(nativeGraphics, x, y, width, height, b))
1150 IsVisible = b As Boolean
1151 End Function
1152
1153 Const Function IsVisible(ByRef rc As Rectangle) As Boolean
1154 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
1155 End Function
1156
1157 Const Function IsVisible(x As Single, y As Single) As Boolean
1158 Dim b = FALSE As BOOL
1159 SetStatus(GdipIsVisiblePoint(nativeGraphics, x, y, b))
1160 IsVisible = b As Boolean
1161 End Function
1162
1163 Const Function IsVisible(ByRef pt As PointF) As Boolean
1164 IsVisible = IsVisible(pt.X, pt.Y)
1165 End Function
1166
1167 Const Function IsVisible(x As Single, y As Single, width As Single, height As Single) As Boolean
1168 Dim b = FALSE As BOOL
1169 SetStatus(GdipIsVisibleRect(nativeGraphics, x, y, width, height, b))
1170 IsVisible = b As Boolean
1171 End Function
1172
1173 Const Function IsVisible(ByRef rc As RectangleF) As Boolean
1174 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
1175 End Function
1176
1177 Const Function Save() As Drawing2D.GraphicsState
1178 SetStatus(GdipSaveGraphics(nativeGraphics, Save))
1179 End Function
1180
1181 Sub Restore(gstate As Drawing2D.GraphicsState)
1182 SetStatus(GdipRestoreGraphics(nativeGraphics, gstate))
1183 End Sub
1184
1185 Function BeginContainer(ByRef dstrect As RectangleF, ByRef srcrect As RectangleF, unit As GraphicsUnit) As Drawing2D.GraphicsContainer
1186 SetStatus(GdipBeginContainer(nativeGraphics, dstrect, srcrect, unit, BeginContainer))
1187 End Function
1188
1189 Function BeginContainer(ByRef dstrect As Rectangle, ByRef srcrect As Rectangle, unit As GraphicsUnit) As Drawing2D.GraphicsContainer
1190 SetStatus(GdipBeginContainerI(nativeGraphics, dstrect, srcrect, unit, BeginContainer))
1191 End Function
1192
1193 Function BeginContainer() As Drawing2D.GraphicsContainer
1194 SetStatus(GdipBeginContainer2(nativeGraphics, BeginContainer))
1195 End Function
1196
1197 Sub EndContainer(state As Drawing2D.GraphicsContainer)
1198 SetStatus(GdipEndContainer(nativeGraphics, state))
1199 End Sub
1200
1201 Sub AddMetafileComment(data As *Byte, sizeData As DWord)
1202 SetStatus(GdipComment(nativeGraphics, sizeData, data))
1203 End Sub
1204
1205 Static Function GetHalftonePalette() As HPALETTE
1206 GdipCreateHalftonePalette()
1207 End Function
1208
1209 Function NativeGraphics() As *GpGraphics
1210 NativeGraphics = nativeGraphics
1211 End Function
1212
1213 Sub Graphics(graphics As *GpGraphics)
1214 nativeGraphics = graphics
1215 End Sub
1216
1217Private
1218 Static Function getNativePen(pen As Pen) As *GpPen
1219 If ActiveBasic.IsNothing(pen) Then
1220 getNativePen = 0
1221 Else
1222 getNativePen = pen.NativePen
1223 End If
1224 End Function
1225
1226 Static Function getNativeStringFormat(sf As StringFormat) As *GpStringFormat
1227 If ActiveBasic.IsNothing(sf) Then
1228 getNativeStringFormat = 0
1229 Else
1230 getNativeStringFormat = sf.nativeFormat
1231 End If
1232 End Function
1233
1234 Static Function getNativeBrush(br As Brush) As *GpBrush
1235 If ActiveBasic.IsNothing(br) Then
1236 getNativeBrush = 0
1237 Else
1238 getNativeBrush = br.nativeBrush
1239 End If
1240 End Function
1241
1242 Static Function getNativeFont(font As Font) As *GpFont
1243 If ActiveBasic.IsNothing(font) Then
1244 getNativeFont = 0
1245 Else
1246 getNativeFont = font.NativeFont
1247 End If
1248 End Function
1249
1250 Static Function getNativeImage(image As Image) As *GpImage
1251 If ActiveBasic.IsNothing(image) Then
1252 getNativeImage = 0
1253 Else
1254 getNativeImage = image.nativeImage
1255 End If
1256 End Function
1257
1258 Static Function getNativeImageAttributes(imageAttr As ImageAttributes) As *GpImageAttributes
1259 If ActiveBasic.IsNothing(imageAttr) Then
1260 getNativeImageAttributes = 0
1261 Else
1262 getNativeImageAttributes = imageAttr.nativeImage
1263 End If
1264 End Function
1265
1266 nativeGraphics As *GpGraphics
1267End Class
1268
1269End Namespace
1270End Namespace
Note: See TracBrowser for help on using the repository browser.