Changeset 137 for Include/Classes/System
- Timestamp:
- Mar 7, 2007, 5:36:31 PM (18 years ago)
- Location:
- Include/Classes/System/Drawing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Drawing/Font.ab
r104 r137 3 3 4 4 #require <GdiPlus.ab> 5 #require <Classes/System/Drawing/misc.ab> 5 6 #require <Classes/System/Drawing/Graphics.ab> 6 7 … … 64 65 End Sub 65 66 66 Sub Font(/*IN const*/ familyName As *WCHAR, /*IN*/ emSize As Single) 67 Font(familyName, emSize, FontStyleRegular, UnitPoint, ByVal 0) 68 End Sub 69 70 Sub Font(/*IN const*/ familyName As *WCHAR, /*IN*/ emSize As Single, 67 Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single) 68 Font(familyName, emSize, FontStyleRegular, Unit.Point, ByVal 0) 69 End Sub 70 71 Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single) 72 Font(familyName, emSize, FontStyleRegular, Unit.Point, ByVal 0) 73 End Sub 74 75 Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, 71 76 /*IN*/ style As Long) 72 Font(familyName, emSize, style, UnitPoint, ByVal 0) 73 End Sub 74 75 Sub Font(/*IN const*/ familyName As *WCHAR, /*IN*/ emSize As Single, 77 Font(familyName, emSize, style, Unit.Point, ByVal 0) 78 End Sub 79 80 Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, 81 /*IN*/ style As Long) 82 Font(familyName, emSize, style, Unit.Point, ByVal 0) 83 End Sub 84 85 Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, 76 86 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit) 77 87 Font(familyName, emSize, style, unit, ByVal 0) 78 88 End Sub 79 89 80 Sub Font(/*IN const*/ familyName As *WCHAR, /*IN*/ emSize As Single, 90 Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, 91 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit) 92 Font(familyName, emSize, style, unit, ByVal 0) 93 End Sub 94 95 Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, 81 96 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit, 82 97 /*IN const*/ ByRef fontCollection As FontCollection) … … 112 127 End Sub 113 128 129 Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, 130 /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit, 131 /*IN const*/ ByRef fontCollection As FontCollection) 132 #ifdef __STRING_IS_NOT_UNICODE 133 Dim name = _System_MultiByteToWideChar(familyName) 134 Font(name, emSize, style, unit, fontCollection) 135 _System_free(name) 136 #else 137 Font(familyName.Chars, emSize, style, unit, fontCollection) 138 #endif 139 End Sub 140 114 141 Const Function GetLogFontA(/*IN const*/ ByRef g As Graphics, /*OUT*/ ByRef lf As LOGFONTA) As Status 115 142 Dim nativeGraphics As *GpGraphics … … 128 155 End Function 129 156 157 Const Function GetLogFont(/*IN const*/ ByRef g As Graphics, /*OUT*/ ByRef lf As LOGFONTA) As Status 158 Dim nativeGraphics As *GpGraphics 159 If VarPtr(g) <> 0 Then 160 nativeGraphics = g.nativeGraphics 161 End If 162 #ifdef UNICODE 163 Return SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf)) 164 #else 165 Return SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf)) 166 #endif 167 End Function 168 130 169 Const Function Clone() As *Font 131 170 Dim cloneFont = 0 As *GpFont … … 138 177 End Sub 139 178 140 Const Function IsAvailable() As B OOL179 Const Function IsAvailable() As Boolean 141 180 Return nativeFont <> 0 142 181 End Function … … 150 189 End Function 151 190 191 Const Function SizeInPoints() As Single 192 152 193 Const Function Unit() As GraphicsUnit 153 194 SetStatus(GdipGetFontUnit(nativeFont, Unit)) … … 158 199 End Function 159 200 160 Const Function Height() As Single161 Return GetHeight() 201 Const Function Height() As Long 202 Return GetHeight() As Long 162 203 End Function 163 204 … … 187 228 ' End Function 188 229 230 Const Function Bold() As Boolean 231 Dim lf As LOGFONT 232 GetLogFont(0, lf) 233 Return lf.lfWeight > FW_BOLD 234 End Function 235 236 Const Function GdiCharSet() As Byte 237 Dim lf As LOGFONT 238 GetLogFont(0, lf) 239 Return lf.lfCharSet 240 End Function 241 242 'Const Function GdiVerticalFont() As Boolean 243 189 244 Const Function NativeFont() As *GpFont 190 245 Return nativeFont 191 246 End Function 247 248 'Const Function IsSystemFont() As Boolean 249 250 Const Function Italic() As Boolean 251 Dim lf As LOGFONT 252 GetLogFont(0, lf) 253 Return lf.lfItalic <> FALSE 254 End Function 255 256 Const Function Name() As String 257 #ifdef __STRING_IS_NOT_UNICODE 258 Dim lf As LOGFONTA 259 GetLogFontA(0, lf) 260 #else 261 Dim lf As LOGFONTW 262 GetLogFontW(0, lf) 263 #endif 264 Return lf.lfFaceName 265 End Function 266 267 'Const Function SizeInPoint() As Boolean 268 269 Const Function NativeFont() As *GpFont 270 Return nativeFont 271 End Function 272 273 Const Function StrikeOut() As Boolean 274 Dim lf As LOGFONT 275 GetLogFont(0, lf) 276 Return lf.fdwStrikeOut <> FALSE 277 End Function 278 279 Const Function Style() As FontStyle 280 Dim lf As LOGFONT 281 GetLogFont(0, lf) 282 Return (((lf.lfWeight > FW_BOLD) And FontStyle.Bold) Or _ 283 ((lf.lfItatlic <> FALSE) And FontStyle.Italic) Or _ 284 ((lf.fdwStrikeOut <> FALSE) And FontStyle.Strickeout) Or _ 285 ((lf.fdwUnderline <> FALSE) And FontStyle.Underline)) As FontStyle 286 End Function 287 288 'Const Function SystemFontName() As String 289 290 Const Function Underline() As Boolean 291 Dim lf As LOGFONT 292 GetLogFont(0, lf) 293 Return lf.fdwUnderline <> FALSE 294 End Function 295 296 Override Function ToString() As String 297 Return Name 298 End Function 299 300 Const Function ToHfont() As HFONT 301 Dim lf As LOGFONT 302 GetLogFont(ByVal 0, lf) 303 Return CreateFontIndirect(lf) 304 End Function 305 306 Const Sub ToLogFont(ByRef lf As LOGFONT) 307 GetLogFont(ByVal 0, lf) 308 End Sub 309 310 Const Sub ToLogFont(ByRef lf As LOGFONT, ByRef g As Graphics) 311 GetLogFont(g, lf) 312 End Sub 313 192 314 193 315 Private -
Include/Classes/System/Drawing/misc.ab
r104 r137 36 36 End Enum 37 37 38 Enum FontStyle 39 Regular = 0 40 Bold = 1 41 Italic = 2 42 Strikeout = 4 43 Underline = 8 44 End Enum 45 46 38 47 #endif '__SYSTEM_DRAWING_MISC_AB__
Note:
See TracChangeset
for help on using the changeset viewer.