[241] | 1 | ' Classes/System/Drawing/Brush.ab
|
---|
| 2 |
|
---|
| 3 | #require <GdiPlusFlat.ab>
|
---|
| 4 |
|
---|
| 5 | Namespace System
|
---|
| 6 | Namespace Drawing
|
---|
| 7 |
|
---|
| 8 | Class Brush
|
---|
| 9 | 'Inherits ICloneable, IDisposable
|
---|
| 10 | Public
|
---|
| 11 | Virtual Sub ~Brush()
|
---|
| 12 | Dispose()
|
---|
| 13 | End Sub
|
---|
| 14 |
|
---|
| 15 | Sub Dispose()
|
---|
| 16 | If nativeBrush <> 0 Then
|
---|
| 17 | Gdiplus.DllExports.GdipDeleteBrush(nativeBrush)
|
---|
| 18 | nativeBrush = 0
|
---|
| 19 | End If
|
---|
| 20 | End Sub
|
---|
| 21 |
|
---|
| 22 | /*Const Override*/ Virtual Function Clone() As Brush
|
---|
| 23 | Dim brush = 0 As *GpBrush
|
---|
| 24 |
|
---|
| 25 | SetStatus(GdiPlus.DllExports.GdipCloneBrush(nativeBrush, brush))
|
---|
| 26 |
|
---|
| 27 | Clone = New Brush(brush, lastResult)
|
---|
| 28 |
|
---|
| 29 | If newBrush = Nothing Then
|
---|
| 30 | GdiPlus.DllExports.GdipDeleteBrush(brush)
|
---|
| 31 | End If
|
---|
| 32 | End Sub
|
---|
| 33 | /*
|
---|
| 34 | Const Function GetType() As BrushType
|
---|
| 35 | GetType = -1 As BrushType
|
---|
| 36 | SetStatus(GdiPlus.DllExports.GdipGetBrushType(nativeBrush, GetType))
|
---|
| 37 | End Function
|
---|
| 38 | */
|
---|
| 39 | Function GetLastStatus() As Gdiplus.Status
|
---|
| 40 | GetLastStatus = lastResult
|
---|
| 41 | lastResult = Gdiplus.Status.Ok
|
---|
| 42 | End Function
|
---|
| 43 |
|
---|
| 44 | Function NativeBrush() AS *GpBrush
|
---|
| 45 | Return nativeBrush
|
---|
| 46 | End Function
|
---|
| 47 |
|
---|
| 48 | 'Protected
|
---|
| 49 | Sub Brush()
|
---|
| 50 | SetStatus(Gdiplus.Status.NotImplemented)
|
---|
| 51 | End Sub
|
---|
| 52 |
|
---|
| 53 | 'Protected
|
---|
| 54 | Sub Brush(nativeBrush As *GpBrush, status As Gdiplus.Status)
|
---|
| 55 | lastResult = status
|
---|
| 56 | SetNativeBrush(nativeBrush)
|
---|
| 57 | End Sub
|
---|
| 58 |
|
---|
| 59 | Protected
|
---|
| 60 | Sub SetNativeBrush(nativeBrush As *GpBrush)
|
---|
| 61 | This.nativeBrush = nativeBrush
|
---|
| 62 | End Sub
|
---|
| 63 |
|
---|
| 64 | Function SetStatus(status As Gdiplus.Status) As Gdiplus.Status
|
---|
| 65 | If status != Gdiplus.Status.Ok Then
|
---|
| 66 | lastResult = status
|
---|
| 67 | End If
|
---|
| 68 | Return status
|
---|
| 69 | End Function
|
---|
| 70 |
|
---|
| 71 | nativeBrush As *GpBrush
|
---|
| 72 | /*Mutable*/ lastResult As Gdiplus.Status
|
---|
| 73 | End Class
|
---|
| 74 |
|
---|
| 75 | class SolidBrush
|
---|
| 76 | Inherits Brush
|
---|
| 77 | Public
|
---|
| 78 |
|
---|
| 79 | Sub SolidBrush(color As Color)
|
---|
| 80 | Dim brush = 0 As *GpSolidFill
|
---|
| 81 | lastResult = GdiPlus.DllExports.GdipCreateSolidFill(color.Value, brush)
|
---|
| 82 | SetNativeBrush(brush)
|
---|
| 83 | End Sub
|
---|
| 84 |
|
---|
| 85 | Const Function GetColor(ByRef color As Color) As Gdiplus.Status
|
---|
| 86 | Dim argb As ARGB
|
---|
| 87 | SetStatus(GdiPlus.DllExports.GdipGetSolidFillColor(nativeBrush As *GpSolidFill, argb))
|
---|
| 88 | color = New Color(argb)
|
---|
| 89 | Return lastResult
|
---|
| 90 | End Function
|
---|
| 91 |
|
---|
| 92 | Function SetColor(color As Color) As Gdiplus.Status
|
---|
| 93 | Return SetStatus(GdiPlus.DllExports.GdipSetSolidFillColor(nativeBrush As *GpSolidFill, color.Value))
|
---|
| 94 | End Function
|
---|
| 95 |
|
---|
| 96 | 'Protected
|
---|
| 97 | Sub SolidBrush()
|
---|
| 98 | End Sub
|
---|
| 99 | End Class
|
---|
| 100 |
|
---|
| 101 | End Namespace 'Drawing
|
---|
| 102 | End Namespace 'System
|
---|