Ignore:
Timestamp:
May 9, 2007, 10:26:36 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

GDI+に対して名前空間で囲ったものの、現在コンパイルできないため分岐させておく

Location:
branch/egtra-gdiplus
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branch/egtra-gdiplus/Classes/System/Drawing/Font.ab

    r212 r241  
    22#define _GDIPLUSFONT_H
    33
    4 #require <GdiPlus.ab>
     4#require <GdiPlusTypes.ab>
     5#require <GdiPlusGpStubs.ab>
     6#require <GdiPlusFlat.ab>
    57#require <Classes/System/Drawing/misc.ab>
    68#require <Classes/System/Drawing/Graphics.ab>
    79
     10Namespace System
     11Namespace Drawing
     12
    813Class FontFamily : End Class
     14
     15Namespace Text
    916Class FontCollection : End Class
     17End Namespace
     18
     19'Todo: コンストラクタ内での別コンストラクタ呼出を修正せよ
    1020
    1121Class Font
     
    1424
    1525    Sub Font(/*IN*/ hdc As HDC)
    16         Dim font = 0 As *GpFont
    17         lastResult = GdipCreateFontFromDC(hdc, font)
     26        Dim font = 0 As *Gdiplus.GpFont
     27        lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font)
    1828        SetNativeFont(font)
    1929    End Sub
    2030
    2131    Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTA)
    22         Dim font = 0 As *GpFont
    23         lastResult =GdipCreateFontFromLogfontA(hdc, logfont, font)
     32        Dim font = 0 As *Gdiplus.GpFont
     33        lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontA(hdc, logfont, font)
    2434        SetNativeFont(font)
    2535    End Sub
    2636
    2737    Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTW)
    28         Dim font = 0 As *GpFont
    29         lastResult =GdipCreateFontFromLogfontW(hdc, logfont, font)
     38        Dim font = 0 As *Gdiplus.GpFont
     39        lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontW(hdc, logfont, font)
    3040        SetNativeFont(font)
    3141    End Sub
    3242
    3343    Sub Font(/*IN*/ hdc As HDC, /*IN const*/ hfont As HFONT)
    34         Dim font = 0 As *GpFont
     44        Dim font = 0 As *Gdiplus.GpFont
    3545        If hfont <> 0 Then
    3646            Dim lf As LOGFONTA
    37             If GetObjectA(hfont, sizeof (LOGFONTA), lf) <> 0 Then
    38                 lastResult = GdipCreateFontFromLogfontA(hdc, lf, font)
     47            If GetObjectA(hfont, SizeOf (LOGFONTA), lf) <> 0 Then
     48                lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontA(hdc, lf, font)
    3949            Else
    40                 lastResult = GdipCreateFontFromDC(hdc, font)
     50                lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font)
    4151            End If
    4252        Else
    43             lastResult = GdipCreateFontFromDC(hdc, font)
     53            lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font)
    4454        End If
    4555        SetNativeFont(font)
     
    5969        /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit)
    6070
    61         Dim font = 0 As *GpFont
    62         lastResult = GdipCreateFont(
    63             family.NativeFamily, emSize, style, unit, font)
     71        Dim font = 0 As *Gdiplus.GpFont
     72        lastResult = Gdiplus.DllExports.GdipCreateFont(family.NativeFamily, emSize, style, unit, font)
    6473        SetNativeFont(font)
    6574    End Sub
     
    95104    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single,
    96105        /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit,
    97         /*IN const*/ ByRef fontCollection As FontCollection)
     106        /*IN const*/ ByRef fontCollection As Text.FontCollection)
    98107
    99108        nativeFont = 0
     
    104113        lastResult = family.GetLastStatus()
    105114
    106         If lastResult <> Ok Then
    107             nativeFamily = FontFamily.GenericSansSerif()->NativeFamily
    108             lastResult = FontFamily.GenericSansSerif()->lastResult
    109             If lastResult <> Ok Then
     115        If lastResult <> Gdiplus.Status.Ok Then
     116            nativeFamily = FontFamily.GenericSansSerif().NativeFamily
     117            lastResult = FontFamily.GenericSansSerif().lastResult
     118            If lastResult <> Gdiplus.Status.Ok Then
    110119                Exit Sub
    111120            End If
    112121        End If
    113122
    114         lastResult = GdipCreateFont(
     123        lastResult = Gdiplus.DllExports.GdipCreateFont(
    115124            nativeFamily, emSize, style, unit, nativeFont)
    116125
    117         If lastResult <> Ok Then
    118             nativeFamily = FontFamily.GenericSansSerif()->NativeFamily
    119             lastResult = FontFamily.GenericSansSerif()->lastResult
    120             If lastResult <> Ok Then
     126        If lastResult <> Gdiplus.Status.Ok Then
     127            nativeFamily = FontFamily.GenericSansSerif().NativeFamily
     128            lastResult = FontFamily.GenericSansSerif().lastResult
     129            If lastResult <> Gdiplus.Status.Ok Then
    121130                Exit Sub
    122131            End If
    123132
    124             lastResult = GdipCreateFont(
    125                 nativeFamily, emSize, style, unit, nativeFont)
     133            lastResult = Gdiplus.DllExports.GdipCreateFont(nativeFamily, emSize, style, unit, nativeFont)
    126134        End If
    127135    End Sub
     
    129137    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single,
    130138        /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit,
    131         /*IN const*/ fontCollection As FontCollection)
    132 #ifdef __STRING_IS_NOT_UNICODE
    133         Dim oldAlloc = _System_AllocForConvertedString
    134         _System_AllocForConvertedString = AddressOf (_System_malloc)
    135         Dim name = ToWCStr(familyName)
    136         Font(name, emSize, style, unit, fontCollection)
    137         _System_free(name)
    138         _System_AllocForConvertedString = oldAlloc
    139 #else
    140         Font(familyName.Chars, emSize, style, unit, fontCollection)
    141 #endif
    142     End Sub
    143 
    144     Const Function GetLogFontA(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTA) As Status
     139        /*IN const*/ fontCollection As Text.FontCollection)
     140        Font(ToWCStr(familyName), emSize, style, unit, fontCollection)
     141    End Sub
     142
     143    Const Function GetLogFontA(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTA) As Gdiplus.Status
    145144        Dim nativeGraphics As *GpGraphics
    146145        If VarPtr(g) <> 0 Then
    147146            nativeGraphics = g.nativeGraphics
    148147        End If
    149         Return SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf))
    150     End Function
    151 
    152     Const Function GetLogFontW(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTW) As Status
     148        Return SetStatus(Gdiplus.DllExports.GdipGetLogFontA(nativeFont, nativeGraphics, lf))
     149    End Function
     150
     151    Const Function GetLogFontW(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTW) As Gdiplus.Status
    153152        Dim nativeGraphics As *GpGraphics
    154153        If VarPtr(g) <> 0 Then
    155154            nativeGraphics = g.nativeGraphics
    156155        End If
    157         Return SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf))
    158     End Function
    159 
    160     Const Function GetLogFont(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONT) As Status
     156        Return SetStatus(Gdiplus.DllExports.GdipGetLogFontW(nativeFont, nativeGraphics, lf))
     157    End Function
     158
     159    Const Function GetLogFont(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONT) As Gdiplus.Status
    161160        Dim nativeGraphics As *GpGraphics
    162161        If VarPtr(g) <> 0 Then
     
    164163        End If
    165164#ifdef UNICODE
    166         Return SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf))
     165        Return SetStatus(Gdiplus.DllExports.GdipGetLogFontW(nativeFont, nativeGraphics, lf))
    167166#else
    168         Return SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf))
     167        Return SetStatus(Gdiplus.DllExports.GdipGetLogFontA(nativeFont, nativeGraphics, lf))
    169168#endif
    170169    End Function
    171170
    172171    Const Function Clone() As Font
    173         Dim cloneFont = 0 As *GpFont
    174         SetStatus(GdipCloneFont(nativeFont, cloneFont))
     172        Dim cloneFont = 0 As *Gdiplus.GpFont
     173        SetStatus(Gdiplus.DllExports.GdipCloneFont(nativeFont, cloneFont))
    175174        Return New Font(cloneFont, lastResult)
    176175    End Function
    177176
     177    Sub Dispose()
     178        Gdiplus.DllExports.GdipDeleteFont(nativeFont)
     179        nativeFont = 0
     180    End Sub
     181
    178182    Sub ~Font()
    179         GdipDeleteFont(nativeFont)
     183        If nativeFont <> 0 Then
     184            Dispose()
     185        End If
    180186    End Sub
    181187
     
    185191
    186192    Const Function Style() As Long
    187         SetStatus(GdipGetFontStyle(nativeFont, Style))
     193        SetStatus(Gdiplus.DllExports.GdipGetFontStyle(nativeFont, Style))
    188194    End Function
    189195
    190196    Const Function Size() As Single
    191         SetStatus(GdipGetFontSize(nativeFont, Size))
    192     End Function
    193 
    194     Const Function SizeInPoints() As Single
     197        SetStatus(Gdiplus.DllExports.GdipGetFontSize(nativeFont, Size))
     198    End Function
     199
     200'   Const Function SizeInPoints() As Single
    195201
    196202    Const Function Unit() As GraphicsUnit
    197         SetStatus(GdipGetFontUnit(nativeFont, Unit))
    198     End Function
    199 
    200     Const Function LastStatus() As Status
     203        SetStatus(Gdiplus.DllExports.GdipGetFontUnit(nativeFont, Unit))
     204    End Function
     205
     206    Const Function LastStatus() As Gdiplus.Status
    201207        Return lastResult
    202208    End Function
     
    207213
    208214    Const Function GetHeight() As Single
    209         SetStatus(GdipGetFontHeight(nativeFont, 0, GetHeight))
     215        SetStatus(Gdiplus.DllExports.GdipGetFontHeight(nativeFont, 0, GetHeight))
    210216    End Function
    211217
    212218    Const Function GetHeight(/*IN const*/ g As Graphics) As Single
    213         Dim nativeGraphics As *GpGraphics
     219        Dim nativeGraphics As *Gdiplus.GpGraphics
    214220        If VarPtr(g) <> 0 Then
    215221            nativeGraphics = g.NativeGraphics
    216222        End If
    217         SetStatus(GdipGetFontHeight(nativeFont, nativeGraphics, GetHeight))
     223        SetStatus(Gdiplus.DllExports.GdipGetFontHeight(nativeFont, nativeGraphics, GetHeight))
    218224    End Function
    219225
    220226    Const Function GetHeight(/*IN*/ dpi As Single) As Single
    221         SetStatus(GdipGetFontHeightGivenDPI(nativeFont, dpi, GetHeight))
     227        SetStatus(Gdiplus.DllExports.GdipGetFontHeightGivenDPI(nativeFont, dpi, GetHeight))
    222228    End Function
    223229
    224230'    Const Function FontFamily(/*OUT*/ ByRef family As FontFamily)
    225 '       If VarPtr(family) = 0 Then
    226 '           Return SetStatus(Status.InvalidParameter)
    227 '       End If
    228 '       Dim status = GdipGetFamily(nativeFont, family->nativeFamily)
    229 '       family->SetStatus(status)
     231'       family = New FontFamily
     232'       Dim status = GdipGetFamily(nativeFont, family.nativeFamily)
     233'       family.SetStatus(status)
    230234'       Return SetStatus(status)
    231235'   End Function
     
    245249    'Const Function GdiVerticalFont() As Boolean
    246250
    247     Const Function NativeFont() As *GpFont
     251    Const Function NativeFont() As *Gdiplus.GpFont
    248252        Return nativeFont
    249253    End Function
     
    270274    'Const Function SizeInPoint() As Boolean
    271275
    272     Const Function NativeFont() As *GpFont
     276    Const Function NativeFont() As *Gdiplus.GpFont
    273277        Return nativeFont
    274278    End Function
     
    315319    End Sub
    316320
    317 Private
    318 '   Sub Font(ByRef f As Font)
    319 
    320 Protected
    321     Sub Font(f As *GpFont, status As Status)
     321'Protected
     322    Sub Font(f As *Gdiplus.GpFont, status As Gdiplus.Status)
    322323        lastResult = status
    323324        SetNativeFont(f)
    324325    End Sub
    325 
    326     Sub SetNativeFont(f As *GpFont)
     326Protected
     327    Sub SetNativeFont(f As *Gdiplus.GpFont)
    327328        nativeFont = f
    328329    End Sub
    329330
    330     Const Function SetStatus(s As Status) As Status
    331         If s <> Status.Ok Then
     331    Const Function SetStatus(s As Gdiplus.Status) As Gdiplus.Status
     332        If s <> Gdiplus.Status.Ok Then
    332333            lastResult = s
    333334            Return s
     
    338339
    339340Protected
    340     nativeFont As *GpFont
    341     /*mutable*/ lastResult As Status
     341    nativeFont As *Gdiplus.GpFont
     342    /*mutable*/ lastResult As Gdiplus.Status
    342343End Class
    343344
     345End Namespace 'Drawing
     346End Namespace 'System
     347
    344348#endif
Note: See TracChangeset for help on using the changeset viewer.