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

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

GDI+をコンパイルできるように修正。FontFamily, Penの追加。サンプルとして、Step 32のGDI+版を制作。
(#56)

File size: 49.6 KB
RevLine 
[33]1' Classes/System/Drawing/Graphics.ab
2
[635]3Namespace System
4Namespace Drawing
5
[698]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
[104]37
[698]38Delegate Function EnumerateMetafileProc(recordType As EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
39
40Namespace Detail
41
42TypeDef NativeEnumerateMetafileProc = *Function(recordType As 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 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
[33]57Class Graphics
58Public
59 '=========================================================================
60 ' Properties
61 '=========================================================================
62 Const Function Clip() As Region
[698]63 Clip = New Region
64 SetStatus(GdipGetClip(nativeGraphics, Clip.nativeRegion))
[33]65 End Function
66
[698]67 Sub Clip(region As Region)
68 Imports System.Drawing.Drawing2D
69 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, CombineMode.Replace))
[33]70 End Sub
71
72 Const Function ClipBounds() As RectangleF
[698]73 SetStatus(GdipGetClipBounds(nativeGraphics, ClipBounds))
[33]74 End Function
75
[698]76 Const Function ClipBoundsI() As Rectangle
77 SetStatus(GdipGetClipBoundsI(nativeGraphics, ClipBoundsI))
[33]78 End Function
[698]79/*
80 Const Function CompositingMode() As Drawing2D.CompositingMode
81 SetStatus(GdipGetCompositingMode(nativeGraphics, CompositingMode))
82 End Function
[33]83
[698]84 Sub CompositingMode(mode As Drawing2D.CompositingMode)
85 SetStatus(GdipSetCompositingMode(nativeGraphics, mode))
[33]86 End Sub
87
[698]88 Function CompositingQuality() As Drawing2D.CompositingQuality
89 SetStatus(GdipGetCompositingQuality(nativeGraphics, CompositingQuality))
[33]90 End Function
91
[698]92 Sub CompositingQuality(cq As Drawing2D.CompositingQuality)
93 Return SetStatus(GdipSetCompositingQuality(nativeGraphics, cq))
[33]94 End Sub
[698]95*/
[33]96 Const Function DpiX() As Single
[698]97 SetStatus(GdipGetDpiX(nativeGraphics, DpiX))
[33]98 End Function
99
100 Const Function DpiY() As Single
[698]101 SetStatus(GdipGetDpiY(nativeGraphics, DpiY))
[33]102 End Function
[698]103/*
104 Const Function InterpolationMode() As Drawing2D.InterpolationMode
105 SetStatus(GdipGetInterpolationMode(nativeGraphics, InterpolationMode))
[33]106 End Function
107
[698]108 Sub InterpolationMode(im As Drawing2D.InterpolationMode)
109 InterpolationMode = SetStatus(GdipSetInterpolationMode(nativeGraphics, im))
[33]110 End Sub
[698]111*/
112 Const Function IsClipEmpty() As Boolean
[33]113 Dim b = FALSE As BOOL
114 SetStatus(GdipIsClipEmpty(nativeGraphics, b))
[698]115 IsClipEmpty = b As Boolean
[33]116 End Function
117
[698]118 Const Function IsVisibleClipEmpty() As Boolean
[33]119 Dim b = FALSE As BOOL
120 SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, b))
[698]121 IsVisibleClipEmpty = b As Boolean
[33]122 End Function
123
[698]124 Sub PageScale(scale As Single)
125 SetStatus(GdipSetPageScale(nativeGraphics, scale))
126 End Sub
[33]127
128 Const Function PageScale() As Single
[698]129 SetStatus(GdipGetPageScale(nativeGraphics, PageScale))
[33]130 End Function
[698]131/*
[33]132 Const Function PageUnit() As GraphicsUnit
[698]133 SetStatus(GdipGetPageUnit(nativeGraphics, PageUnit))
[33]134 End Function
[698]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))
[33]143 End Function
[698]144*/
145 Sub PixelOffsetMode(mode As Drawing2D.PixelOffsetMode)
146 SetStatus(GdipSetPixelOffsetMode(nativeGraphics, mode))
[33]147 End Sub
148
149 Function RenderingOrigin() As Point
[698]150 With RenderingOrigin
151 .X = 0
152 .Y = 0
153 SetStatus(GdipGetRenderingOrigin(nativeGraphics, .X, .Y))
154 End With
[33]155 End Function
156
157 Sub RenderingOrigin(pt As Point)
[698]158 SetStatus(GdipSetRenderingOrigin(nativeGraphics, pt.X, pt.Y))
[33]159 End Sub
[698]160/*
161 Function SmoothingMode() As Drawing2D.SmoothingMode
162 SetStatus(GdipGetSmoothingMode(nativeGraphics, SmoothingMode))
[33]163 End Function
[698]164*/
165 Sub SmoothingMode(mode As Drawing2D.SmoothingMode)
166 SetStatus(GdipSetSmoothingMode(nativeGraphics, mode))
[33]167 End Sub
168
169 Function TextContrast() As DWord
[698]170 SetStatus(GdipGetTextContrast(nativeGraphics, TextContrast))
[33]171 End Function
172
173 Sub TextContrast(contrast As DWord)
[698]174 SetStatus(GdipSetTextContrast(nativeGraphics, contrast))
[33]175 End Sub
[698]176/*
177 Function TextRenderingHint() As Text.TextRenderingHint
178 SetStatus(GdipGetTextRenderingHint(nativeGraphics, ByVal VarPtr(TextRenderingHint)))
[33]179 End Function
[698]180*/
[33]181 Sub TextRenderingHint(mode As TextRenderingHint)
[698]182 SetStatus(GdipSetTextRenderingHint(nativeGraphics, mode))
[33]183 End Sub
184
[698]185 Function Transform() As Drawing2D.Matrix
186 Dim native As *GpMatrix
187 SetStatus(GdipGetWorldTransform(nativeGraphics, native))
188 Transform = New Drawing2D.Matrix(native)
[33]189 End Function
190
[698]191 Sub Transform(matrix As Drawing2D.Matrix)
192 SetStatus(GdipSetWorldTransform(nativeGraphics, matrix.nativeMatrix))
[33]193 End Sub
194
195 Function VisibleClipBounds() As RectangleF
[698]196 SetStatus(GdipGetVisibleClipBounds(nativeGraphics, VisibleClipBounds))
[33]197 End Function
198
[698]199 Function VisibleClipBoundsI() As Rectangle
200 SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, VisibleClipBoundsI))
201 End Function
202
[33]203 '=========================================================================
204 ' Methods
205 '=========================================================================
[212]206 Static Function FromHDC(hdc As HDC) As Graphics
[698]207 Dim graphics = 0 As *GpGraphics
208 SetStatus(GdipCreateFromHDC(hdc, graphics))
209 Return New Graphics(graphics)
[33]210 End Function
211
[212]212 Static Function FromHDC(hdc As HDC, hdevice As HANDLE) As Graphics
[698]213 Dim graphics = 0 As *GpGraphics
214 SetStatus(GdipCreateFromHDC2(hdc, hdevice, graphics))
215 Return New Graphics(graphics)
[33]216 End Function
217
[698]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)
[33]222 End Function
223
[698]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)
[33]232 End Function
233
[212]234 Static Function FromImage(image As Image) As Graphics
[698]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)
[33]241 End Function
242
[698]243 Sub Dispose()
244 GdipDeleteGraphics(nativeGraphics)
245 nativeGraphics = 0
[33]246 End Sub
247
248 Sub ~Graphics()
[698]249 Dispose()
[33]250 End Sub
251
252 Sub Flush()
[698]253 GdipFlush(nativeGraphics, System.Drawing.Drawing2D.FlushIntention.Flush)
[33]254 End Sub
255
[698]256 Sub Flush(intention As Drawing2D.FlushIntention)
[33]257 GdipFlush(nativeGraphics, intention)
258 End Sub
259
260 Function GetHDC() As HDC
[698]261 GetHDC = 0
262 SetStatus(GdipGetDC(nativeGraphics, GetHDC))
[33]263 End Function
264
265 Sub ReleaseHDC(hdc As HDC)
266 SetStatus(GdipReleaseDC(nativeGraphics, hdc))
267 End Sub
268
[698]269 Sub ResetTransform()
270 SetStatus(GdipResetWorldTransform(nativeGraphics))
271 End Sub
[33]272
[698]273 Sub MultiplyTransform(matrix As Drawing2D.Matrix)
274 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, System.Drawing.Drawing2D.MatrixOrder.Prepend))
275 End Sub
[33]276
[698]277 Sub MultiplyTransform(matrix As Drawing2D.Matrix, order As Drawing2D.MatrixOrder)
278 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, order))
279 End Sub
[33]280
[698]281 Sub TranslateTransform(dx As Single, dy As Single)
282 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
283 End Sub
[33]284
[698]285 Sub TranslateTransform(dx As Single, dy As Single, order As Drawing2D.MatrixOrder)
286 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order))
287 End Sub
[33]288
[698]289 Sub ScaleTransform(sx As Single, sy As Single)
290 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
291 End Sub
[33]292
[698]293 Sub ScaleTransform(sx As Single, sy As Single, order As Drawing2D.MatrixOrder)
294 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order))
295 End Sub
[33]296
[698]297 Sub RotateTransform(angle As Single)
298 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, System.Drawing.Drawing2D.MatrixOrder.Prepend))
299 End Sub
[33]300
[698]301 Sub RotateTransform(angle As Single, order As Drawing2D.MatrixOrder)
302 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order))
303 End Sub
[33]304
[698]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
[33]308
[698]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
[33]312
[698]313 Const Function GetNearestColor(color As Color) As Color
314 GetNearestColor = color
315 SetStatus(GdipGetNearestColor(nativeGraphics, GetNearestColor))
[33]316 End Function
317
[698]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
[33]321
[698]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
[33]325
[698]326 Sub DrawLines(pen As Pen, points As *PointF, count As Long)
327 SetStatus(GdipDrawLines(nativeGraphics, pen.NativePen, points, count))
328 End Sub
[33]329
[698]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
[33]333
[698]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
[33]337
[698]338 Sub DrawLines(pen As Pen, points As *Point, count As Long)
339 SetStatus(GdipDrawLinesI(nativeGraphics, pen.NativePen, points, count))
340 End Sub
[33]341
[698]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
[33]345
[698]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
[33]349
[698]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
[33]353
[698]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
[33]357
[698]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
[33]361
[698]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
[33]365
[698]366 Sub DrawBeziers(pen As Pen, points As *PointF, count As Long)
367 SetStatus(GdipDrawBeziers(nativeGraphics, pen.NativePen, points, count))
368 End Sub
[33]369
[698]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
[33]373
[698]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
[33]377
[698]378 Sub DrawBeziers(pen As Pen, points As *Point, count As Long)
379 SetStatus(GdipDrawBeziersI(nativeGraphics, pen.NativePen, points, count))
380 End Sub
[33]381
[698]382 Sub DrawRectangle(pen As Pen, ByRef rect As RectangleF)
383 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
384 End Sub
[33]385
[698]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
[33]389
[698]390 Sub DrawRectangles(pen As Pen, rects As *RectangleF, count As Long)
391 SetStatus(GdipDrawRectangles(nativeGraphics, pen.NativePen, rects, count))
392 End Sub
[33]393
[698]394 Sub DrawRectangle(pen As Pen, ByRef rect As Rectangle)
395 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
396 End Sub
[33]397
[698]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
[33]401
[698]402 Sub DrawRectangles(pen As Pen, rects As *Rectangle, count As Long)
403 SetStatus(GdipDrawRectanglesI(nativeGraphics, pen.NativePen, rects, count))
404 End Sub
[33]405
[698]406 Sub DrawEllipse(pen As Pen, ByRef rect As RectangleF)
407 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
408 End Sub
[33]409
[698]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
[33]413
[698]414 Sub DrawEllipse(pen As Pen, ByRef rect As Rectangle)
415 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
416 End Sub
[33]417
[698]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
[33]421
[698]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
[33]425
[698]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
[33]429
[698]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
[33]433
[698]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
[33]437
[698]438 Sub DrawPolygon(pen As Pen, points As *PointF, count As Long)
439 SetStatus(GdipDrawPolygon(nativeGraphics, pen.NativePen, points, count))
440 End Sub
[33]441
[698]442 Sub DrawPolygon(pen As Pen, points As *Point, count As Long)
443 SetStatus(GdipDrawPolygonI(nativeGraphics, pen.NativePen, points, count))
444 End Sub
[33]445
[698]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
[33]452
[698]453 Sub DrawCurve(pen As Pen, points As *PointF, count As Long)
454 SetStatus(GdipDrawCurve(nativeGraphics, pen.NativePen, points, count))
455 End Sub
[33]456
[698]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
[33]460
[698]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
[33]464
[698]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
[33]468
[698]469 Sub DrawCurve(pen As Pen, points As *Point, count As Long)
470 SetStatus(GdipDrawCurveI(nativeGraphics, pen.NativePen, points, count))
471 End Sub
[33]472
[698]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
[33]476
[698]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
[33]480
[698]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
[33]484
[698]485 Sub DrawClosedCurve(pen As Pen, points As *PointF, count As Long)
486 SetStatus(GdipDrawClosedCurve(nativeGraphics, pen.NativePen, points, count))
487 End Sub
[33]488
[698]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
[33]492
[698]493 Sub DrawClosedCurve(pen As Pen, points As *Point, count As Long)
494 SetStatus(GdipDrawClosedCurveI(nativeGraphics, pen.NativePen, points, count))
495 End Sub
[33]496
[698]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
[33]500
[698]501 Sub Clear(color As Color)
502 SetStatus(GdipGraphicsClear(nativeGraphics, color))
503 End Sub
[33]504
[698]505 Sub FillRectangle(brush As Brush, ByRef rect As RectangleF)
506 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
507 End Sub
[33]508
[698]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
[33]512
[698]513 Sub FillRectangles(brush As Brush, rects As *RectangleF, count As Long)
514 SetStatus(GdipFillRectangles(nativeGraphics,brush.nativeBrush,rects, count))
515 End Sub
[33]516
[698]517 Sub FillRectangle(brush As Brush, ByRef rect As Rectangle)
518 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
519 End Sub
[33]520
[698]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
[33]524
[698]525 Sub FillRectangles(brush As Brush, rects As *Rectangle, count As Long)
526 SetStatus(GdipFillRectanglesI(nativeGraphics, brush.nativeBrush, rects, count))
527 End Sub
[33]528
[698]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
[33]532
[698]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
[33]536
[698]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
[33]540
[698]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
[33]544
[698]545 Sub FillEllipse(brush As Brush, ByRef rect As RectangleF)
546 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
547 End Sub
[33]548
[698]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
[33]552
[698]553 Sub FillEllipse(brush As Brush, ByRef rect As Rectangle)
554 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
555 End Sub
[33]556
[698]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
[33]560
[698]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
[33]564
[698]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
[33]568
[698]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
[33]572
[698]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
[33]576
[698]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
[33]583
[698]584 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long)
585 SetStatus(GdipFillClosedCurve(nativeGraphics, brush.nativeBrush, points, count))
586 End Sub
[33]587
[698]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
[33]591
[698]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
[33]595
[698]596 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long)
597 SetStatus(GdipFillClosedCurveI(nativeGraphics, brush.nativeBrush, points, count))
598 End Sub
[33]599
[698]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
[33]603
[698]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
[33]607
[698]608 Sub FillRegion(brush As Brush, region As Region)
609 SetStatus(GdipFillRegion(nativeGraphics, brush.nativeBrush, region.nativeRegion))
610 End Sub
[33]611
[698]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
[33]619
[698]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
[33]628
[698]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
[33]635
[698]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
[33]639
[698]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
[33]648
[698]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
[33]654
[698]655 Function MeasureString(s As String, font As Font) As SizeF
656 Dim pt As PointF
657 MeasureString = MeasureString(s, font, pt, Nothing)
[33]658 End Function
659
[698]660 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF) As SizeF
661 MeasureString = MeasureString(s, font, layoutRectSize, Nothing)
[33]662 End Function
663
[698]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)
[33]668 End Function
669
[698]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)
[33]674 End Function
675
[698]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)
[33]680 End Function
681
[698]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)
[33]686 End Function
687
[698]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)
[33]691 End Function
692
[698]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)
[33]695 End Function
696
[698]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)
[33]699 End Function
700
[698]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)
[33]710 End Function
711
[698]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)
[33]721 End Function
722
[698]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))
[33]725 End Function
726
[698]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)
[33]737 End Function
738
[698]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
[33]746 End Function
747
[698]748Public
[33]749
[698]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)
[33]754 End Function
755
[698]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
[33]759 End If
[698]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
[33]766
767 Dim i As Long
[698]768 For i = 0 To ELM(count)
769 Dim t = regions[i]
770 nativeRegions[i] = t.nativeRegion
[33]771 Next
[698]772 Dim nativeFont = getNativeFont(font)
773 SetStatus(GdipMeasureCharacterRanges(nativeGraphics, str, length, nativeFont, layoutRect, stringFormat.nativeFormat, count, nativeRegions))
[33]774 End Function
775
[698]776 'DrawDriverString
777 'MeasureDriverString
[33]778
[698]779 Sub DrawCachedBitmap(cb As CachedBitmap, x As Long, y As Long)
780 SetStatus(GdipDrawCachedBitmap(nativeGraphics, cb.nativeCachedBitmap, x, y))
781 End Sub
[33]782
[698]783 Sub DrawImage(image As Image, ByRef point As PointF)
784 DrawImage(image, point.X, point.Y)
785 End Sub
[33]786
[698]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
[33]791
[698]792 Sub DrawImage(image As Image, ByRef rect As RectangleF)
793 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
794 End Sub
[33]795
[698]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
[33]800
[698]801 Sub DrawImage(image As Image, ByRef point As Point)
802 DrawImage(image, point.X, point.Y)
803 End Sub
[33]804
[698]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
[33]809
[698]810 Sub DrawImage(image As Image, ByRef rect As Rectangle)
811 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
812 End Sub
[33]813
[698]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
[33]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
[698]827 Sub DrawImage(image As Image, destPoints As *PointF, count As Long)
[33]828 If count <> 3 And count <> 4 Then
[698]829 SetStatus(InvalidParameter)
[33]830 End If
831
[698]832 Dim nativeImage = getNativeImage(image)
833 SetStatus(GdipDrawImagePoints(nativeGraphics, nativeImage, destPoints, count))
834 End Sub
[33]835
[698]836 Sub DrawImage(image As Image, destPoints As *Point, count As Long)
[33]837 If count <> 3 And count <> 4 Then
[698]838 SetStatus(InvalidParameter)
[33]839 End If
840
[698]841 Dim nativeImage = getNativeImage(image)
842 SetStatus(GdipDrawImagePointsI(nativeGraphics, nativeImage, destPoints, count))
843 End Sub
[33]844
[698]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
[33]848
[698]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
[33]852
[698]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
[33]857
[698]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
[33]862
[698]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)
[33]865
[698]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
[33]871
[698]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)
[33]874
[698]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
[33]880
[698]881 Sub DrawImage(image As Image, ByRef destRect As RectangleF,
[33]882 srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
[698]883 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
[33]884
[698]885 Dim nativeImage = getNativeImage(image)
886 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
887 SetStatus(GdipDrawImageRectRect(nativeGraphics, nativeImageAttr,
[33]888 destRect.X, destRect.Y, destRect.Width, destRect.Height, srcx, srcy, srcwidth, srcheight,
889 srcUnit, nativeImageAttr, callback, callbackData))
[698]890 End Sub
[33]891
[698]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)
[33]895
[698]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
[33]902
[698]903 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As PointF,
904 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]905
[698]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
[33]914
[698]915 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As Point,
916 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]917
[698]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
[33]926
[698]927 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As RectangleF,
928 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]929
[698]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
[33]938
[698]939 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As Rectangle,
940 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]941
[698]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
[33]950
[698]951 Sub EnumerateMetafile(metafile As Metafile, destPoints As *PointF, count As Long,
952 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]953
[698]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
[33]962
[698]963 Sub EnumerateMetafile(metafile As Metafile, destPoints As *Point, count As Long,
964 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
[33]965
[698]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
[33]974
[698]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)
[33]978
[698]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
[33]987
[698]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)
[33]991
[698]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
[33]1000
[698]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)
[33]1004
[698]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
[33]1013
[698]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)
[33]1017
[698]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
[33]1026
[698]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)
[33]1030
[698]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
[33]1039
[698]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)
[33]1043
[698]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
[33]1052
[698]1053 Sub SetClip(g As Graphics)
1054 SetClip(g, System.Drawing.Drawing2D.CombineMode.Replace)
1055 End Sub
[33]1056
[698]1057 Sub SetClip(g As Graphics, combineMode As Drawing2D.CombineMode)
1058 SetStatus(GdipSetClipGraphics(nativeGraphics, g.nativeGraphics, combineMode))
1059 End Sub
[33]1060
[698]1061 Sub SetClip(ByRef rc As RectangleF)
1062 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1063 End Sub
[33]1064
[698]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
[33]1068
[698]1069 Sub SetClip(ByRef rc As Rectangle)
1070 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1071 End Sub
[33]1072
[698]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
[33]1076
[698]1077 Sub SetClip(path As GraphicsPath)
1078 SetClip(path, System.Drawing.Drawing2D.CombineMode.Replace)
1079 End Sub
[33]1080
[698]1081 Sub SetClip(path As GraphicsPath, combineMode As Drawing2D.CombineMode)
1082 SetStatus(GdipSetClipPath(nativeGraphics, path.nativePath, combineMode))
1083 End Sub
[33]1084
[698]1085 Sub SetClip(region As Region)
1086 SetClip(region, System.Drawing.Drawing2D.CombineMode.Replace)
1087 End Sub
[33]1088
[698]1089 Sub SetClip(region As Region, combineMode As Drawing2D.CombineMode)
1090 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, combineMode))
1091 End Sub
[33]1092
[698]1093 Sub SetClip(hrgn As HRGN)
1094 SetClip(hrgn, System.Drawing.Drawing2D.CombineMode.Replace)
1095 End Sub
[33]1096
[698]1097 Sub SetClip(hrgn As HRGN, combineMode As Drawing2D.CombineMode)
1098 SetStatus(GdipSetClipHrgn(nativeGraphics, hrgn, combineMode))
1099 End Sub
[33]1100
[698]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
[33]1104
[698]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
[33]1108
[698]1109 Sub IntersectClip(region As Region)
1110 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Intersect))
1111 End Sub
[33]1112
[698]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
[33]1116
[698]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
[33]1120
[698]1121 Sub ExcludeClip(region As Region)
1122 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Exclude))
1123 End Sub
[33]1124
[698]1125 Sub ResetClip()
1126 SetStatus(GdipResetClip(nativeGraphics))
1127 End Sub
[33]1128
[698]1129 Sub TranslateClip(dx As Single, dy As Single)
1130 SetStatus(GdipTranslateClip(nativeGraphics, dx, dy))
1131 End Sub
[33]1132
[698]1133 Sub TranslateClip(dx As Long, dy As Long)
1134 SetStatus(GdipTranslateClipI(nativeGraphics, dx, dy))
1135 End Sub
[33]1136
[698]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
[33]1141 End Function
1142
[698]1143 Const Function IsVisible(ByRef pt As Point) As Boolean
1144 IsVisible(pt.X, pt.Y)
[33]1145 End Function
1146
[698]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
[33]1151 End Function
1152
[698]1153 Const Function IsVisible(ByRef rc As Rectangle) As Boolean
1154 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
[33]1155 End Function
1156
[698]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
[33]1161 End Function
1162
[698]1163 Const Function IsVisible(ByRef pt As PointF) As Boolean
1164 IsVisible = IsVisible(pt.X, pt.Y)
[33]1165 End Function
1166
[698]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
[33]1171 End Function
1172
[698]1173 Const Function IsVisible(ByRef rc As RectangleF) As Boolean
1174 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
[33]1175 End Function
1176
[698]1177 Const Function Save() As Drawing2D.GraphicsState
1178 SetStatus(GdipSaveGraphics(nativeGraphics, Save))
[33]1179 End Function
1180
[698]1181 Sub Restore(gstate As Drawing2D.GraphicsState)
1182 SetStatus(GdipRestoreGraphics(nativeGraphics, gstate))
1183 End Sub
[33]1184
[698]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))
[33]1187 End Function
1188
[698]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))
[33]1191 End Function
1192
[698]1193 Function BeginContainer() As Drawing2D.GraphicsContainer
1194 SetStatus(GdipBeginContainer2(nativeGraphics, BeginContainer))
[33]1195 End Function
1196
[698]1197 Sub EndContainer(state As Drawing2D.GraphicsContainer)
1198 SetStatus(GdipEndContainer(nativeGraphics, state))
1199 End Sub
[33]1200
[698]1201 Sub AddMetafileComment(data As *Byte, sizeData As DWord)
1202 SetStatus(GdipComment(nativeGraphics, sizeData, data))
1203 End Sub
[33]1204
[698]1205 Static Function GetHalftonePalette() As HPALETTE
1206 GdipCreateHalftonePalette()
[33]1207 End Function
1208
[698]1209 Function NativeGraphics() As *GpGraphics
1210 NativeGraphics = nativeGraphics
[33]1211 End Function
1212
[698]1213 Sub Graphics(graphics As *GpGraphics)
1214 nativeGraphics = graphics
1215 End Sub
[33]1216
[698]1217Private
1218 Static Function getNativePen(pen As Pen) As *GpPen
1219 If ActiveBasic.IsNothing(pen) Then
1220 getNativePen = 0
[33]1221 Else
[698]1222 getNativePen = pen.NativePen
[33]1223 End If
1224 End Function
1225
[698]1226 Static Function getNativeStringFormat(sf As StringFormat) As *GpStringFormat
1227 If ActiveBasic.IsNothing(sf) Then
1228 getNativeStringFormat = 0
[33]1229 Else
[698]1230 getNativeStringFormat = sf.nativeFormat
[33]1231 End If
1232 End Function
1233
[698]1234 Static Function getNativeBrush(br As Brush) As *GpBrush
1235 If ActiveBasic.IsNothing(br) Then
1236 getNativeBrush = 0
[33]1237 Else
[698]1238 getNativeBrush = br.nativeBrush
[33]1239 End If
1240 End Function
1241
[698]1242 Static Function getNativeFont(font As Font) As *GpFont
1243 If ActiveBasic.IsNothing(font) Then
1244 getNativeFont = 0
[33]1245 Else
[698]1246 getNativeFont = font.NativeFont
[33]1247 End If
1248 End Function
1249
[698]1250 Static Function getNativeImage(image As Image) As *GpImage
1251 If ActiveBasic.IsNothing(image) Then
1252 getNativeImage = 0
[33]1253 Else
[698]1254 getNativeImage = image.nativeImage
[33]1255 End If
1256 End Function
1257
[698]1258 Static Function getNativeImageAttributes(imageAttr As ImageAttributes) As *GpImageAttributes
1259 If ActiveBasic.IsNothing(imageAttr) Then
1260 getNativeImageAttributes = 0
[33]1261 Else
[698]1262 getNativeImageAttributes = imageAttr.nativeImage
[33]1263 End If
1264 End Function
1265
1266 nativeGraphics As *GpGraphics
1267End Class
1268
[635]1269End Namespace
1270End Namespace
Note: See TracBrowser for help on using the repository browser.