Changeset 241 for branch/egtra-gdiplus/Classes/System/Drawing/Font.ab
- Timestamp:
- May 9, 2007, 10:26:36 PM (18 years ago)
- Location:
- branch/egtra-gdiplus
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branch/egtra-gdiplus/Classes/System/Drawing/Font.ab
r212 r241 2 2 #define _GDIPLUSFONT_H 3 3 4 #require <GdiPlus.ab> 4 #require <GdiPlusTypes.ab> 5 #require <GdiPlusGpStubs.ab> 6 #require <GdiPlusFlat.ab> 5 7 #require <Classes/System/Drawing/misc.ab> 6 8 #require <Classes/System/Drawing/Graphics.ab> 7 9 10 Namespace System 11 Namespace Drawing 12 8 13 Class FontFamily : End Class 14 15 Namespace Text 9 16 Class FontCollection : End Class 17 End Namespace 18 19 'Todo: コンストラクタ内での別コンストラクタ呼出を修正せよ 10 20 11 21 Class Font … … 14 24 15 25 Sub Font(/*IN*/ hdc As HDC) 16 Dim font = 0 As *G pFont17 lastResult = Gdip CreateFontFromDC(hdc, font)26 Dim font = 0 As *Gdiplus.GpFont 27 lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font) 18 28 SetNativeFont(font) 19 29 End Sub 20 30 21 31 Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTA) 22 Dim font = 0 As *G pFont23 lastResult = GdipCreateFontFromLogfontA(hdc, logfont, font)32 Dim font = 0 As *Gdiplus.GpFont 33 lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontA(hdc, logfont, font) 24 34 SetNativeFont(font) 25 35 End Sub 26 36 27 37 Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTW) 28 Dim font = 0 As *G pFont29 lastResult = GdipCreateFontFromLogfontW(hdc, logfont, font)38 Dim font = 0 As *Gdiplus.GpFont 39 lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontW(hdc, logfont, font) 30 40 SetNativeFont(font) 31 41 End Sub 32 42 33 43 Sub Font(/*IN*/ hdc As HDC, /*IN const*/ hfont As HFONT) 34 Dim font = 0 As *G pFont44 Dim font = 0 As *Gdiplus.GpFont 35 45 If hfont <> 0 Then 36 46 Dim lf As LOGFONTA 37 If GetObjectA(hfont, sizeof (LOGFONTA), lf) <> 0 Then38 lastResult = Gdip CreateFontFromLogfontA(hdc, lf, font)47 If GetObjectA(hfont, SizeOf (LOGFONTA), lf) <> 0 Then 48 lastResult = Gdiplus.DllExports.GdipCreateFontFromLogfontA(hdc, lf, font) 39 49 Else 40 lastResult = Gdip CreateFontFromDC(hdc, font)50 lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font) 41 51 End If 42 52 Else 43 lastResult = Gdip CreateFontFromDC(hdc, font)53 lastResult = Gdiplus.DllExports.GdipCreateFontFromDC(hdc, font) 44 54 End If 45 55 SetNativeFont(font) … … 59 69 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit) 60 70 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) 64 73 SetNativeFont(font) 65 74 End Sub … … 95 104 Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, 96 105 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit, 97 /*IN const*/ ByRef fontCollection As FontCollection)106 /*IN const*/ ByRef fontCollection As Text.FontCollection) 98 107 99 108 nativeFont = 0 … … 104 113 lastResult = family.GetLastStatus() 105 114 106 If lastResult <> Ok Then107 nativeFamily = FontFamily.GenericSansSerif() ->NativeFamily108 lastResult = FontFamily.GenericSansSerif() ->lastResult109 If lastResult <> Ok Then115 If lastResult <> Gdiplus.Status.Ok Then 116 nativeFamily = FontFamily.GenericSansSerif().NativeFamily 117 lastResult = FontFamily.GenericSansSerif().lastResult 118 If lastResult <> Gdiplus.Status.Ok Then 110 119 Exit Sub 111 120 End If 112 121 End If 113 122 114 lastResult = Gdip CreateFont(123 lastResult = Gdiplus.DllExports.GdipCreateFont( 115 124 nativeFamily, emSize, style, unit, nativeFont) 116 125 117 If lastResult <> Ok Then118 nativeFamily = FontFamily.GenericSansSerif() ->NativeFamily119 lastResult = FontFamily.GenericSansSerif() ->lastResult120 If lastResult <> Ok Then126 If lastResult <> Gdiplus.Status.Ok Then 127 nativeFamily = FontFamily.GenericSansSerif().NativeFamily 128 lastResult = FontFamily.GenericSansSerif().lastResult 129 If lastResult <> Gdiplus.Status.Ok Then 121 130 Exit Sub 122 131 End If 123 132 124 lastResult = GdipCreateFont( 125 nativeFamily, emSize, style, unit, nativeFont) 133 lastResult = Gdiplus.DllExports.GdipCreateFont(nativeFamily, emSize, style, unit, nativeFont) 126 134 End If 127 135 End Sub … … 129 137 Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, 130 138 /*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 145 144 Dim nativeGraphics As *GpGraphics 146 145 If VarPtr(g) <> 0 Then 147 146 nativeGraphics = g.nativeGraphics 148 147 End If 149 Return SetStatus(Gdip GetLogFontA(nativeFont, nativeGraphics, lf))150 End Function 151 152 Const Function GetLogFontW(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTW) As Status148 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 153 152 Dim nativeGraphics As *GpGraphics 154 153 If VarPtr(g) <> 0 Then 155 154 nativeGraphics = g.nativeGraphics 156 155 End If 157 Return SetStatus(Gdip GetLogFontW(nativeFont, nativeGraphics, lf))158 End Function 159 160 Const Function GetLogFont(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONT) As Status156 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 161 160 Dim nativeGraphics As *GpGraphics 162 161 If VarPtr(g) <> 0 Then … … 164 163 End If 165 164 #ifdef UNICODE 166 Return SetStatus(Gdip GetLogFontW(nativeFont, nativeGraphics, lf))165 Return SetStatus(Gdiplus.DllExports.GdipGetLogFontW(nativeFont, nativeGraphics, lf)) 167 166 #else 168 Return SetStatus(Gdip GetLogFontA(nativeFont, nativeGraphics, lf))167 Return SetStatus(Gdiplus.DllExports.GdipGetLogFontA(nativeFont, nativeGraphics, lf)) 169 168 #endif 170 169 End Function 171 170 172 171 Const Function Clone() As Font 173 Dim cloneFont = 0 As *G pFont174 SetStatus(Gdip CloneFont(nativeFont, cloneFont))172 Dim cloneFont = 0 As *Gdiplus.GpFont 173 SetStatus(Gdiplus.DllExports.GdipCloneFont(nativeFont, cloneFont)) 175 174 Return New Font(cloneFont, lastResult) 176 175 End Function 177 176 177 Sub Dispose() 178 Gdiplus.DllExports.GdipDeleteFont(nativeFont) 179 nativeFont = 0 180 End Sub 181 178 182 Sub ~Font() 179 GdipDeleteFont(nativeFont) 183 If nativeFont <> 0 Then 184 Dispose() 185 End If 180 186 End Sub 181 187 … … 185 191 186 192 Const Function Style() As Long 187 SetStatus(Gdip GetFontStyle(nativeFont, Style))193 SetStatus(Gdiplus.DllExports.GdipGetFontStyle(nativeFont, Style)) 188 194 End Function 189 195 190 196 Const Function Size() As Single 191 SetStatus(Gdip GetFontSize(nativeFont, Size))192 End Function 193 194 Const Function SizeInPoints() As Single197 SetStatus(Gdiplus.DllExports.GdipGetFontSize(nativeFont, Size)) 198 End Function 199 200 ' Const Function SizeInPoints() As Single 195 201 196 202 Const Function Unit() As GraphicsUnit 197 SetStatus(Gdip GetFontUnit(nativeFont, Unit))198 End Function 199 200 Const Function LastStatus() As Status203 SetStatus(Gdiplus.DllExports.GdipGetFontUnit(nativeFont, Unit)) 204 End Function 205 206 Const Function LastStatus() As Gdiplus.Status 201 207 Return lastResult 202 208 End Function … … 207 213 208 214 Const Function GetHeight() As Single 209 SetStatus(Gdip GetFontHeight(nativeFont, 0, GetHeight))215 SetStatus(Gdiplus.DllExports.GdipGetFontHeight(nativeFont, 0, GetHeight)) 210 216 End Function 211 217 212 218 Const Function GetHeight(/*IN const*/ g As Graphics) As Single 213 Dim nativeGraphics As *G pGraphics219 Dim nativeGraphics As *Gdiplus.GpGraphics 214 220 If VarPtr(g) <> 0 Then 215 221 nativeGraphics = g.NativeGraphics 216 222 End If 217 SetStatus(Gdip GetFontHeight(nativeFont, nativeGraphics, GetHeight))223 SetStatus(Gdiplus.DllExports.GdipGetFontHeight(nativeFont, nativeGraphics, GetHeight)) 218 224 End Function 219 225 220 226 Const Function GetHeight(/*IN*/ dpi As Single) As Single 221 SetStatus(Gdip GetFontHeightGivenDPI(nativeFont, dpi, GetHeight))227 SetStatus(Gdiplus.DllExports.GdipGetFontHeightGivenDPI(nativeFont, dpi, GetHeight)) 222 228 End Function 223 229 224 230 ' 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) 230 234 ' Return SetStatus(status) 231 235 ' End Function … … 245 249 'Const Function GdiVerticalFont() As Boolean 246 250 247 Const Function NativeFont() As *G pFont251 Const Function NativeFont() As *Gdiplus.GpFont 248 252 Return nativeFont 249 253 End Function … … 270 274 'Const Function SizeInPoint() As Boolean 271 275 272 Const Function NativeFont() As *G pFont276 Const Function NativeFont() As *Gdiplus.GpFont 273 277 Return nativeFont 274 278 End Function … … 315 319 End Sub 316 320 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) 322 323 lastResult = status 323 324 SetNativeFont(f) 324 325 End Sub 325 326 Sub SetNativeFont(f As *G pFont)326 Protected 327 Sub SetNativeFont(f As *Gdiplus.GpFont) 327 328 nativeFont = f 328 329 End Sub 329 330 330 Const Function SetStatus(s As Status) AsStatus331 If s <> Status.Ok Then331 Const Function SetStatus(s As Gdiplus.Status) As Gdiplus.Status 332 If s <> Gdiplus.Status.Ok Then 332 333 lastResult = s 333 334 Return s … … 338 339 339 340 Protected 340 nativeFont As *G pFont341 /*mutable*/ lastResult As Status341 nativeFont As *Gdiplus.GpFont 342 /*mutable*/ lastResult As Gdiplus.Status 342 343 End Class 343 344 345 End Namespace 'Drawing 346 End Namespace 'System 347 344 348 #endif
Note:
See TracChangeset
for help on using the changeset viewer.