Changeset 701 for trunk


Ignore:
Timestamp:
2009/04/02 17:27:22 (3 years ago)
Author:
egtra
Message:

BrushとStringFormatを追加
(#241)

Location:
trunk/ab5.0/ablib
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/TestCase/UI_Sample/step32_AnalogWatch_Gdiplus.ab

    r698 r701  
    1313#require <Classes/System/Drawing/FontFamily.ab> 
    1414#require <Classes/System/Drawing/Pen.ab> 
     15#require <Classes/System/Drawing/Brush.ab> 
     16#require <Classes/System/Drawing/StringFormat.ab> 
     17#require <Classes/System/Drawing/Image.ab> 
    1518#require <Classes/System/Drawing/Drawing2D/misc.ab> 
    1619#require <Classes/System/Drawing/Drawing2D/Matrix.ab> 
     
    3639Imports ActiveBasic.Math 
    3740Imports System 
     41Imports System.Drawing 
     42Imports System.Drawing.Drawing2D 
    3843 
    3944#resource "UI_Sample.rc" 
     
    7681 
    7782    Sub OnDestroy(sender As Object, e As EventArgs) 
    78 '       GdiplusShutdown(gdipToken) 
     83        GdiplusShutdown(gdipToken) 
    7984    End Sub 
    8085 
     
    96101 
    97102    Sub OnPaint_(sender As Object, e As PaintDCArgs) 
    98         Imports System.Drawing 
    99  
    100103        Dim pos As PointF 
    101104 
     
    136139        g.DrawLine(pen, CenterPos, pos) 
    137140        pen.Dispose() 
     141 
     142        Dim pt1 = [0, 0] As Point 
     143        Dim pt2 As Point 
     144        pt2.X = rc.right 
     145        pt2.Y = rc.bottom 
     146        Dim br = New LinearGradientBrush(pt1, pt2, &haa00ff40 As Color, &h66ffcc00 As Color) 'New SolidBrush(&h8080ff00) 
     147        br.GammaCorrection = True 
     148        Dim f = New Font("Verdana", 20.0) 
     149        Dim s = "Step32. Analog whach" As String 
     150        g.RotateTransform(25) 
     151        g.DrawString(s, f, br, 10.0, 10.0) 
     152        f.Dispose() 
     153        br.Dispose() 
     154 
    138155        g.Dispose() 
    139156    End Sub 
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Font.ab

    r698 r701  
    283283        nativeFont = 0 
    284284        Dim family = Nothing As FontFamily 
    285         Dim nativeFamily = family.NativeFamily 
     285        Dim nativeFamily As *GpFontFamily 
    286286 
    287287        Try 
    288288            family = New FontFamily(familyName, fontCollection) 
     289            nativeFamily = family.NativeFamily 
    289290        Catch e As Exception 
    290291            nativeFamily = FontFamily.GenericSansSerif().NativeFamily 
     
    292293 
    293294        Try 
    294             SetStatus(GdipCreateFont(nativeFamily, emSize, style, unit, nativeFont)) 
     295            SetStatus(GdipCreateFont(nativeFamily, emSize, style, unit As Long, nativeFont)) 
    295296        Catch e As Exception 
    296297            nativeFamily = FontFamily.GenericSansSerif().NativeFamily 
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Graphics.ab

    r700 r701  
    44Namespace Drawing 
    55 
    6 Class Brush 
    7 Public 
    8     nativeBrush As *GpBrush 
    9 End Class 
    10 Class StringFormat 
    11 Public 
    12     nativeFormat As *GpStringFormat  
    13 End Class 
    14 Class Image 
    15 Public 
    16     nativeImage As *GpImage 
    17 End Class 
    186Class ImageAttributes 
    197Public 
     
    2917Class GraphicsPath 
    3018Public 
     19    Sub GraphicsPath(native As *GpPath) 
     20        nativePath = native 
     21    End Sub 
     22    Function NativePath() As *GpPath 
     23    End Function 
    3124    nativePath As *GpPath 
    3225End Class 
     
    508501 
    509502    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)) 
     503        SetStatus(GdipFillRectangle(nativeGraphics, brush.NativeBrush, x, y, width, height)) 
    511504    End Sub 
    512505 
    513506    Sub FillRectangles(brush As Brush, rects As *RectangleF, count As Long) 
    514         SetStatus(GdipFillRectangles(nativeGraphics,brush.nativeBrush,rects, count)) 
     507        SetStatus(GdipFillRectangles(nativeGraphics,brush.NativeBrush,rects, count)) 
    515508    End Sub 
    516509 
     
    520513 
    521514    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)) 
     515        SetStatus(GdipFillRectangleI(nativeGraphics, brush.NativeBrush, x, y, width, height)) 
    523516    End Sub 
    524517 
    525518    Sub FillRectangles(brush As Brush, rects As *Rectangle, count As Long) 
    526         SetStatus(GdipFillRectanglesI(nativeGraphics, brush.nativeBrush, rects, count)) 
     519        SetStatus(GdipFillRectanglesI(nativeGraphics, brush.NativeBrush, rects, count)) 
    527520    End Sub 
    528521 
     
    532525 
    533526    Sub FillPolygon(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode) 
    534         SetStatus(GdipFillPolygon(nativeGraphics, brush.nativeBrush, points, count, fillMode)) 
     527        SetStatus(GdipFillPolygon(nativeGraphics, brush.NativeBrush, points, count, fillMode)) 
    535528    End Sub 
    536529 
     
    540533 
    541534    Sub FillPolygon(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode) 
    542         SetStatus(GdipFillPolygonI(nativeGraphics, brush.nativeBrush, points, count, fillMode)) 
     535        SetStatus(GdipFillPolygonI(nativeGraphics, brush.NativeBrush, points, count, fillMode)) 
    543536    End Sub 
    544537 
     
    548541 
    549542    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)) 
     543        SetStatus(GdipFillEllipse(nativeGraphics, brush.NativeBrush, x, y, width, height)) 
    551544    End Sub 
    552545 
     
    556549 
    557550    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)) 
     551        SetStatus(GdipFillEllipseI(nativeGraphics, brush.NativeBrush, x, y, width, height)) 
    559552    End Sub 
    560553 
     
    564557 
    565558    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)) 
     559        SetStatus(GdipFillPie(nativeGraphics, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle)) 
    567560    End Sub 
    568561 
     
    572565 
    573566    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)) 
     567        SetStatus(GdipFillPieI(nativeGraphics, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle)) 
    575568    End Sub 
    576569 
     
    579572            Throw New ArgumentNullException("brush or path or both") 
    580573        End If 
    581         SetStatus(GdipFillPath(nativeGraphics, brush.nativeBrush, path.nativePath)) 
     574        SetStatus(GdipFillPath(nativeGraphics, brush.NativeBrush, path.nativePath)) 
    582575    End Sub 
    583576 
    584577    Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long) 
    585         SetStatus(GdipFillClosedCurve(nativeGraphics, brush.nativeBrush, points, count)) 
     578        SetStatus(GdipFillClosedCurve(nativeGraphics, brush.NativeBrush, points, count)) 
    586579    End Sub 
    587580 
    588581    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)) 
     582        SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.NativeBrush, points, count, 0.5, fillMode)) 
    590583    End Sub 
    591584 
    592585    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)) 
     586        SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.NativeBrush, points, count, tension, fillMode)) 
    594587    End Sub 
    595588 
    596589    Sub FillClosedCurve(brush As Brush, points As *Point, count As Long) 
    597         SetStatus(GdipFillClosedCurveI(nativeGraphics, brush.nativeBrush, points, count)) 
     590        SetStatus(GdipFillClosedCurveI(nativeGraphics, brush.NativeBrush, points, count)) 
    598591    End Sub 
    599592 
    600593    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)) 
     594        SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.NativeBrush, points, count, 0.5, fillMode)) 
    602595    End Sub 
    603596 
    604597    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)) 
     598        SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.NativeBrush, points, count, tension, fillMode)) 
    606599    End Sub 
    607600 
    608601    Sub FillRegion(brush As Brush, region As Region) 
    609         SetStatus(GdipFillRegion(nativeGraphics, brush.nativeBrush, region.nativeRegion)) 
     602        SetStatus(GdipFillRegion(nativeGraphics, brush.NativeBrush, region.nativeRegion)) 
    610603    End Sub 
    611604 
     
    629622    Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, ByRef layoutRect As RectangleF, stringFormat = Nothing As StringFormat) 
    630623        Dim nativeFont = getNativeFont(font) 
    631         Dim nativeFormat = getNativeStringFormat(stringFormat) 
     624        Dim nativeFormat = GetNativeStringFormat(stringFormat) 
    632625        Dim nativeBrush = getNativeBrush(brush) 
    633626        SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, nativeBrush)) 
     
    739732    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 
    740733        Dim nativeFont = getNativeFont(font) 
    741         Dim nativeFormat = getNativeStringFormat(stringFormat) 
     734        Dim nativeFormat = GetNativeStringFormat(stringFormat) 
    742735        Dim boundingBox As RectangleF 
    743736        SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, boundingBox, codepointsFitted, linesFilled)) 
     
    759752        End If 
    760753        Dim count As Long 
    761         SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(stringFormat.nativeFormat, count)) 
     754        SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(stringFormat.NativeFormat, count)) 
    762755        Dim nativeRegions As **GpRegion 'ここで = GC_mallocとすると、エラーになる。 
    763756        nativeRegions = GC_malloc(count * SizeOf(*GpRegion)) 
     
    771764        Next 
    772765        Dim nativeFont = getNativeFont(font) 
    773         SetStatus(GdipMeasureCharacterRanges(nativeGraphics, str, length, nativeFont, layoutRect, stringFormat.nativeFormat, count, nativeRegions)) 
     766        SetStatus(GdipMeasureCharacterRanges(nativeGraphics, str, length, nativeFont, layoutRect, stringFormat.NativeFormat, count, nativeRegions)) 
    774767    End Function 
    775768 
     
    12241217    End Function 
    12251218 
    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  
    12341219    Static Function getNativeBrush(br As Brush) As *GpBrush 
    12351220        If ActiveBasic.IsNothing(br) Then 
    12361221            getNativeBrush = 0 
    12371222        Else 
    1238             getNativeBrush = br.nativeBrush 
     1223            getNativeBrush = br.NativeBrush 
    12391224        End If 
    12401225    End Function 
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Image.ab

    r635 r701  
    66Class Image 
    77Public 
     8    Sub Image(native As *GpImage) 
     9        nativeImage = native 
     10    End Sub 
     11 
    812    Function NativeImage() As *GpImage 
    913        Return nativeImage 
    1014    End Function 
    11 Private 
     15'Private 
    1216    nativeImage As *GpImage 
    1317End Class 
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Pen.ab

    r698 r701  
    2727            Throw New ArgumentNullException("brush") 
    2828        End If 
    29         SetStatus(GdipCreatePen2(brush.nativeBrush, width, 0 /*GraphicsUnit.World As GpUnit*/, nativePen)) 
     29        SetStatus(GdipCreatePen2(brush.NativeBrush, width, 0 /*GraphicsUnit.World As GpUnit*/, nativePen)) 
    3030    End Sub 
    3131 
     
    268268            getNativeBrush = 0 
    269269        Else 
    270             getNativeBrush = br.nativeBrush 
     270            getNativeBrush = br.NativeBrush 
    271271        End If 
    272272    End Function 
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/misc.ab

    r700 r701  
    2727 
    2828Enum GraphicsUnit 
    29     World       ' 0 
    30     Display     ' 1 
    31     Pixel       ' 2 
    32     Point       ' 3 
    33     Inch        ' 4 
    34     Document    ' 5 
    35     Millimeter  ' 6 
     29    World = 0 
     30    Display = 1 
     31    Pixel = 2 
     32    Point = 3 
     33    Inch = 4 
     34    Document = 5 
     35    Millimeter = 6 
    3636End Enum 
    3737 
  • trunk/ab5.0/ablib/src/GdiPlusFlat.ab

    r700 r701  
    152152Declare Function GdipCloneBrush Lib "gdiplus.dll" (ByVal brush As *GpBrush, ByRef cloneBrush As *GpBrush) As GpStatus 
    153153Declare Function GdipDeleteBrush Lib "gdiplus.dll" (ByVal brush As *GpBrush) As GpStatus 
    154 Declare Function GdipGetBrushType Lib "gdiplus.dll" (ByVal brush As *GpBrush, ByRef brushType As *GpBrushType) As GpStatus 
     154Declare Function GdipGetBrushType Lib "gdiplus.dll" (ByVal brush As *GpBrush, ByRef brushType As GpBrushType) As GpStatus 
    155155 
    156156' HatchBrush APIs 
     
    188188Declare Function GdipCreateLineBrushFromRectI Lib "gdiplus.dll" (ByRef rect As GpRect, ByVal color1 As ARGB, ByVal color2 As ARGB, ByVal mode As Long /*LinearGradientMode*/, ByVal wrapMode As GpWrapMode, ByRef lineGradient As *GpLineGradient) As GpStatus 
    189189Declare Function GdipCreateLineBrushFromRectWithAngle Lib "gdiplus.dll" (ByRef rect As GpRectF, ByVal color1 As ARGB, ByVal color2 As ARGB, ByVal angle As Single, ByVal isAngleScalable As BOOL, ByVal wrapMode As GpWrapMode, ByRef lineGradient As *GpLineGradient) As GpStatus 
    190 Declare Function GdipCreateLineBrushFromRectWithAngleI Lib "gdiplus.dll" (ByRef rect As GpRect, ByVal color1 As ARGB, ByVal color2 As ARGB, ByVal angle As Single, ByVal isAngleScalable As BOOL, ByRef lineGradient As *GpLineGradient) As GpStatus 
     190Declare Function GdipCreateLineBrushFromRectWithAngleI Lib "gdiplus.dll" (ByRef rect As GpRect, ByVal color1 As ARGB, ByVal color2 As ARGB, ByVal angle As Single, ByVal isAngleScalable As BOOL, ByVal wrapMode As GpWrapMode, ByRef lineGradient As *GpLineGradient) As GpStatus 
    191191Declare Function GdipSetLineColors Lib "gdiplus.dll" (ByVal brush As *GpLineGradient, ByVal color1 As ARGB, ByVal color2 As ARGB) As GpStatus 
    192192Declare Function GdipGetLineColors Lib "gdiplus.dll" (ByVal brush As *GpLineGradient, ByVal colors As *ARGB) As GpStatus 
     
    223223Declare Function GdipGetPathGradientPath Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal path As *GpPath) As GpStatus 
    224224Declare Function GdipSetPathGradientPath Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal path As *GpPath) As GpStatus 
    225 Declare Function GdipGetPathGradientCenterPoint Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal points As *GpPointF) As GpStatus 
    226 Declare Function GdipGetPathGradientCenterPointI Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal points As *GpPoint) As GpStatus 
    227 Declare Function GdipSetPathGradientCenterPoint Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal points As *GpPointF) As GpStatus 
    228 Declare Function GdipSetPathGradientCenterPointI Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByVal points As *GpPoint) As GpStatus 
     225Declare Function GdipGetPathGradientCenterPoint Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef points As GpPointF) As GpStatus 
     226Declare Function GdipGetPathGradientCenterPointI Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef points As GpPoint) As GpStatus 
     227Declare Function GdipSetPathGradientCenterPoint Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef points As GpPointF) As GpStatus 
     228Declare Function GdipSetPathGradientCenterPointI Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef points As GpPoint) As GpStatus 
    229229Declare Function GdipGetPathGradientRect Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef rect As GpRectF) As GpStatus 
    230230Declare Function GdipGetPathGradientRectI Lib "gdiplus.dll" (ByVal brush As *GpPathGradient, ByRef rect As GpRect) As GpStatus 
Note: See TracChangeset for help on using the changeset viewer.