Changeset 132 for Include/Classes/System
- Timestamp:
- Mar 4, 2007, 11:28:44 PM (18 years ago)
- Location:
- Include/Classes/System
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/String.ab
r125 r132 1 ' Classes/System/String.ab 2 3 #require <basic/function.sbp> 4 1 5 Class String 2 6 m_Length As Long … … 57 61 End Sub 58 62 59 Const Function Operator [] (n As Long) As Char63 Const Function Operator [] (n As Long) As Char 60 64 Return Chars[n] 61 65 End Function 62 66 63 Sub Operator []= (n As Long, c As Char)67 Sub Operator []= (n As Long, c As Char) 64 68 Chars[n] = c 65 69 End Sub 66 70 67 Const Function Operator + ( lpszText As *Char) As String68 Return Concat( lpszText, lstrlen(lpszText))71 Const Function Operator + (pszText As *Char) As String 72 Return Concat(pszText, lstrlen(pszText)) 69 73 End Function 70 74 … … 73 77 End Function 74 78 75 Const Function Operator & ( lpszText As *Char) As String76 Dim tempString = This + lpszText79 Const Function Operator & (pszText As *Char) As String 80 Dim tempString = This + pszText 77 81 Return tempString 78 82 End Function … … 83 87 End Function 84 88 85 Function Operator== (ByRef objString As String) As Long 86 If lstrcmp(This, objString) = 0 Then 87 Return _System_TRUE 88 Else 89 Return _System_FALSE 90 End If 91 End Function 92 93 Function Operator== (lpszText As *Char) As Long 94 If lstrcmp(This, lpszText) = 0 Then 95 Return _System_TRUE 96 Else 97 Return _System_FALSE 98 End If 99 End Function 100 101 Function Operator<> (ByRef objString As String) As Long 102 Return lstrcmp(This, objString) 103 End Function 104 105 Function Operator<> (lpszText As *Char) As Long 106 Return lstrcmp(This, lpszText) 107 End Function 108 109 Function Operator< (ByRef objString As String) As Long 110 If lstrcmp(This, objString) < 0 Then 111 Return _System_TRUE 112 Else 113 Return _System_FALSE 114 End If 115 End Function 116 117 Function Operator< (lpszText As *Char) As Long 118 If lstrcmp(This, lpszText) < 0 Then 119 Return _System_TRUE 120 Else 121 Return _System_FALSE 122 End If 123 End Function 124 125 Function Operator> (ByRef objString As String) As Long 126 If lstrcmp(This, objString) > 0 Then 127 Return _System_TRUE 128 Else 129 Return _System_FALSE 130 End If 131 End Function 132 133 Function Operator> (lpszText As *Char) As Long 134 If lstrcmp(This, lpszText) > 0 Then 135 Return _System_TRUE 136 Else 137 Return _System_FALSE 138 End If 139 End Function 140 141 Function Operator<= (ByRef objString As String) As Long 142 If lstrcmp(This, objString) <= 0 Then 143 Return _System_TRUE 144 Else 145 Return _System_FALSE 146 End If 147 End Function 148 149 Function Operator<= (lpszText As *Char) As Long 150 If lstrcmp(This, lpszText) <= 0 Then 151 Return _System_TRUE 152 Else 153 Return _System_FALSE 154 End If 155 End Function 156 157 Function Operator>= (ByRef objString As String) As Long 158 If lstrcmp(This, objString) => 0 Then 159 Return _System_TRUE 160 Else 161 Return _System_FALSE 162 End If 163 End Function 164 165 Function Operator>= (lpszText As *Char) As Long 166 If lstrcmp(This, lpszText) => 0 Then 167 Return _System_TRUE 168 Else 169 Return _System_FALSE 170 End If 171 End Function 172 173 Function StrPtr() As *Char 89 Const Function Operator == (ByRef objString As String) As Boolean 90 Return _System_StrCmp(This, objString) = 0 91 End Function 92 93 Const Function Operator == (text As *Char) As Long 94 Return _System_StrCmp(This, text) = 0 95 End Function 96 97 Const Function Operator <> (ByRef objString As String) As Boolean 98 Return _System_StrCmp(This, objString) 99 End Function 100 101 Const Function Operator <> (text As *Char) As Boolean 102 Return _System_StrCmp(This, text) 103 End Function 104 105 Const Function Operator < (ByRef objString As String) As Boolean 106 Return _System_StrCmp(This, objString) < 0 107 End Function 108 109 Const Function Operator < (text As *Char) As Boolean 110 Return _System_StrCmp(This, text) < 0 111 End Function 112 113 Const Function Operator > (ByRef objString As String) As Boolean 114 Return _System_StrCmp(This, objString) > 0 115 End Function 116 117 Const Function Operator > (text As *Char) As Boolean 118 Return _System_StrCmp(This, text) > 0 119 End Function 120 121 Const Function Operator <= (ByRef objString As String) As Boolean 122 Return _System_StrCmp(This, objString) <= 0 123 End Function 124 125 Const Function Operator <= (text As *Char) As Boolean 126 Return _System_StrCmp(This, text) <= 0 127 End Function 128 129 Const Function Operator >= (ByRef objString As String) As Boolean 130 Return _System_StrCmp(This, objString) => 0 131 End Function 132 133 Const Function Operator >= (text As *Char) As Boolean 134 Return _System_StrCmp(This, text) => 0 135 End Function 136 137 Const Function StrPtr() As *Char 174 138 Return Chars 175 139 End Function … … 248 212 End Sub 249 213 250 Function Concat(lpszText As *Char, textLength As Long) As String 214 Const Function Clone() As String 215 Return This 216 End Function 217 218 Const Function Concat(lpszText As *Char, textLength As Long) As String 251 219 Dim tempString As String 252 220 With tempString … … 259 227 End Function 260 228 261 Function Contains(ByRef objString As String) As BOOL 262 If IndexOf(objString, 0, m_Length) >= 0 Then 263 Return _System_TRUE 264 Else 265 Return _System_FALSE 266 End If 267 End Function 268 269 Function Contains(lpszText As *Char) As BOOL 270 If IndexOf(lpszText, 0, m_Length) >= 0 Then 271 Return _System_TRUE 272 Else 273 Return _System_FALSE 274 End If 275 End Function 276 277 Function IndexOf(lpszText As *Char) As Long 229 Const Function Contains(ByRef objString As String) As Boolean 230 Return IndexOf(objString, 0, m_Length) >= 0 231 End Function 232 233 Const Function Contains(lpszText As *Char) As Boolean 234 Return IndexOf(lpszText, 0, m_Length) >= 0 235 End Function 236 237 Const Function IndexOf(lpszText As *Char) As Long 278 238 Return IndexOf(lpszText, 0, m_Length) 279 239 End Function 280 240 281 Function IndexOf(lpszText As *Char, startIndex As Long) As Long241 Const Function IndexOf(lpszText As *Char, startIndex As Long) As Long 282 242 Return IndexOf(lpszText, startIndex, m_Length - startIndex) 283 243 End Function 284 244 285 Function IndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long 286 Dim length As Long 287 length = lstrlen(lpszText) 245 Const Function IndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long 246 Dim length = lstrlen(lpszText) 288 247 289 248 If startIndex < 0 Then Return -1 … … 306 265 End Function 307 266 308 Function LastIndexOf(lpszText As *Char) As Long267 Const Function LastIndexOf(lpszText As *Char) As Long 309 268 Return LastIndexOf(lpszText, m_Length - 1, m_Length) 310 269 End Function 311 270 312 Function LastIndexOf(lpszText As *Char, startIndex As Long) As Long271 Const Function LastIndexOf(lpszText As *Char, startIndex As Long) As Long 313 272 Return LastIndexOf(lpszText As *Char, startIndex, startIndex + 1) 314 273 End Function 315 274 316 Function LastIndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long 317 Dim length As Long 318 length = lstrlen(lpszText) 275 Const Function LastIndexOf(lpszText As *Char, startIndex As Long, count As Long) As Long 276 Dim length = lstrlen(lpszText) 319 277 320 278 If startIndex < 0 Or startIndex > m_Length - 1 Then Return -1 … … 337 295 End Function 338 296 339 Function StartsWith(lpszText As *Char) As BOOL 340 If IndexOf(lpszText) = 0 Then 341 Return _System_TRUE 342 Else 343 Return _System_FALSE 344 End If 345 End Function 346 347 Function EndsWith(lpszText As *Char) As BOOL 348 If LastIndexOf(lpszText) = m_Length - lstrlen(lpszText) Then 349 Return _System_TRUE 350 Else 351 Return _System_FALSE 352 End If 353 End Function 354 355 Function Insert(startIndex As Long, text As *Char) As Long 356 Dim length As Long 357 length = lstrlen(text) 358 359 If startIndex < 0 Or startIndex > m_Length Then Return -1 360 361 Dim newChars As *Char 362 newChars = _System_malloc(SizeOf (Char) * (length + m_Length + 1)) 363 If newChars = 0 Then Return -1 364 365 memcpy(newChars, Chars, SizeOf (Char) * startIndex) 366 memcpy(VarPtr(newChars[startIndex]), text, SizeOf (Char) * length) 367 memcpy(VarPtr(newChars[startIndex + length]), VarPtr(Chars[startIndex]), SizeOf (Char) * (m_Length - startIndex + 1)) 368 369 _System_free(Chars) 370 Chars = newChars 371 m_Length = length + m_Length 372 Return m_Length 373 End Function 374 375 Function SubString(startIndex As Long) As String 297 Const Function StartsWith(lpszText As *Char) As Boolean 298 Return IndexOf(lpszText) = 0 299 End Function 300 301 Const Function EndsWith(lpszText As *Char) As Boolean 302 Return LastIndexOf(lpszText) = m_Length - lstrlen(lpszText) 303 End Function 304 305 Const Function Insert(startIndex As Long, text As String) As String 306 Return Insert(startIndex, text.Chars, text.Length) 307 End Function 308 309 Const Function Insert(startIndex As Long, text As *Char) As String 310 Return Insert(startIndex, text, lstrlen(text)) 311 End Function 312 313 Const Function Insert(startIndex As Long, text As *Char, length As Long) As String 314 If startIndex < 0 Or startIndex > m_Length Or length < 0 Then 315 Debug 'ArgumentOutOfRangeException 316 317 End If 318 Insert.ReSize(m_Length + length) 319 memcpy(Insert.Chars, Chars, SizeOf (Char) * startIndex) 320 memcpy(VarPtr(Insert.Chars[startIndex]), text, SizeOf (Char) * length) 321 memcpy(VarPtr(Insert.Chars[startIndex + length]), VarPtr(Chars[startIndex]), SizeOf (Char) * (m_Length - startIndex + 1)) 322 End Function 323 324 Const Function SubString(startIndex As Long) As String 376 325 Return SubString(startIndex, m_Length - startIndex) 377 326 End Function 378 327 379 Function SubString(startIndex As Long, length As Long) As String328 Const Function SubString(startIndex As Long, length As Long) As String 380 329 If startIndex < 0 Or length <= 0 Then Return "" 381 330 If startIndex + length > m_Length Then Return "" … … 388 337 End Function 389 338 390 Function Remove(startIndex As Long) As Long 391 If startIndex < 0 Or startIndex > m_Length Then Return -1 392 Chars[startIndex] = 0 393 m_Length = startIndex 394 Return m_Length 395 End Function 396 397 Function Remove(startIndex As Long, count As Long) As Long 398 If startIndex < 0 Or count < 0 Then Return -1 399 If startIndex + count > m_Length Then Return -1 400 401 Dim newChars As *Char 402 newChars = _System_malloc(SizeOf (Char) * (m_Length - count + 1)) 403 If newChars = 0 Then Return -1 404 405 memcpy(newChars, Chars, SizeOf (Char) * startIndex) 406 memcpy(VarPtr(newChars[startIndex]), VarPtr(Chars[startIndex + count]), SizeOf (Char) * (m_Length - startIndex - count)) 407 newChars[m_Length - count] = 0 408 409 _System_free(Chars) 410 Chars = newChars 411 m_Length = m_Length - count 412 Return m_Length 413 End Function 414 415 Function IsNullOrEmpty() As BOOL 416 If m_Length = 0 Then 417 Return _System_TRUE 418 Else 419 Return _System_FALSE 420 End If 421 End Function 422 423 424 Sub Replace(oldChar As Char, newChar As Char) 425 Dim i As Long 426 For i = 0 To ELM(m_Length) 427 If Chars[i] = oldChar Then 428 Chars[i] = newChar 339 Const Function Remove(startIndex As Long) As String 340 Remove.ReSize(startIndex) 341 memcpy(Remove.Chars, This.Chars, SizeOf (Char) * startIndex) 342 End Function 343 344 Const Function Remove(startIndex As Long, count As Long) As String 345 Remove.ReSize(m_Length - count) 346 memcpy(Remove.Chars, This.Chars, SizeOf (Char) * startIndex) 347 memcpy(VarPtr(Remove.Chars[startIndex]), VarPtr(This.Chars[startIndex + count]), SizeOf (Char) * startIndex) 348 End Function 349 /* 350 Static Function IsNullOrEmpty(s As String) As Boolean 351 If s <> Nothing Then 352 If s.m_Length > 0 Then 353 Return True 429 354 End If 430 Next 431 End Sub 432 433 Sub Replace(ByRef oldStr As String, ByRef newStr As String) 434 Replace(oldStr, oldStr.m_Length, newStr, newStr.m_Length) 435 End Sub 436 437 Sub Replace(oldStr As PCSTR, newStr As PCSTR) 438 Replace(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr)) 439 End Sub 440 441 Sub Replace(oldStr As PCSTR, oldLen As Long, newStr As PCSTR, newLen As Long) 442 Dim tempString As String 443 With tempString 444 Dim current = 0 As Long 445 Do 446 Dim pos As Long 447 pos = IndexOf(oldStr, current) 448 If pos = -1 Then 449 Exit Do 355 End If 356 Return False 357 End Function 358 */ 359 Const Function Replace(oldChar As Char, newChar As Char) As String 360 Replace = Copy(This) 361 With Replace 362 Dim i As Long 363 For i = 0 To ELM(.m_Length) 364 If .Chars[i] = .oldChar Then 365 .Chars[i] = .newChar 450 366 End If 451 .Append(Chars + current, pos - current) 452 .Append(newStr, newLen) 453 current = pos + oldLen 454 Loop 455 .Append(Chars + current, m_Length - current) 367 Next 456 368 End With 457 Swap(tempString) 458 End Sub 369 End Function 370 371 Const Function Replace(ByRef oldStr As String, ByRef newStr As String) As String 372 ' If oldStr = Nothing Then Throw ArgumentNullException 373 ' 374 ' If newStr = Nothing Then 375 ' Return ReplaceCore(oldStr, oldStr.m_Length, "", 0) 376 ' Else 377 Return ReplaceCore(oldStr, oldStr.m_Length, newStr, newStr.m_Length) 378 ' End If 379 End Function 380 381 Const Function Replace(oldStr As *Char, newStr As *Char) 382 If oldStr = 0 Then Debug 'Throw ArgumentNullException 383 If newStr = 0 Then newStr = "" 384 Return ReplaceCore(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr)) As String 385 End Function 386 387 Const Function Replace(oldStr As *Char, oldLen As Long, newStr As *Char, newLen As Long) As String 388 If oldStr = 0 Then Debug 'Throw ArgumentNullException 389 If newStr = 0 Then 390 newStr = "" 391 newLen = 0 392 End If 393 Return ReplaceCore(oldStr, oldLen, newStr, newLen) 394 End Function 459 395 460 396 Sub ToLower() … … 474 410 Sub Swap(ByRef x As String) 475 411 Dim tempLen As Long 476 Dim tempChars As PSTR412 Dim tempChars As *Char 477 413 tempLen = x.m_Length 478 414 tempChars = x.Chars … … 485 421 Override Function ToString() As String 486 422 Return This 423 End Function 424 425 Static Function Copy(s As String) As String 426 Copy.Resize(s.m_Length) 427 memcpy(Copy.Chars, This.Chars, SizeOf (Char) * m_Length) 487 428 End Function 488 429 … … 504 445 End Function 505 446 447 Function ReplaceCore(oldStr As *Char, oldLen As Long, newStr As *Char, newLen As Long) As String 448 If oldLen = 0 Then 449 Debug 'Throw ArgumentException 450 End If 451 Dim tmp As String 452 With tmp 453 Dim current = 0 As Long 454 Do 455 Dim pos = IndexOf(oldStr, current) 456 If pos = -1 Then 457 Exit Do 458 End If 459 .Append(VarPtr(Chars[current]), pos - current) 460 .Append(newStr, newLen) 461 current = pos + oldLen 462 Loop 463 .Append(VarPtr(Chars[current]), m_Length - current) 464 End With 465 Return tmp 466 End Function 467 506 468 End Class 507 469 -
Include/Classes/System/Windows/Forms/Control.ab
r77 r132 56 56 Class AsyncInvokeData 57 57 Public 58 FuncPtr As *Function(p As VoidPtr) As VoidPtr , p As VoidPtr58 FuncPtr As *Function(p As VoidPtr) As VoidPtr 59 59 Data As *VoidPtr 60 60 AsyncResult As *AsyncResultForInvoke … … 64 64 Inherits IWin32Window 65 65 Public 66 ' Properties 66 '--------------------------------------------------------------------------- 67 ' Public Properties 67 68 68 69 Function AllowDrop() As BOOL … … 223 224 End Sub 224 225 226 Function Parent() As *Control 227 Return parent 228 End Function 229 230 Static Function DefaultBackColor() As Color 231 Return Color.FromArgb(255, 255, 255) 232 End Function 233 234 '--------------------------------------------------------------------------- 225 235 ' Constractors 226 236 … … 240 250 End Sub 241 251 242 Sub Control( text As String, left As Long, top As Long, width As Long, height As Long)252 Sub Control(ByRef text As String, left As Long, top As Long, width As Long, height As Long) 243 253 This.text = text 244 254 bkColor = DefaultBackColor … … 252 262 End Sub 253 263 254 Function Parent() As *Control 255 Return parent 256 End Function 257 258 Static Function DefaultBackColor() As Color 259 Return Color.FromArgb(255, 255, 255) 260 End Function 261 264 '--------------------------------------------------------------------------- 262 265 ' Destractor 263 266 … … 268 271 End Sub 269 272 270 ' Methods 273 '--------------------------------------------------------------------------- 274 ' Public Methods 271 275 272 276 ' 同期関数呼出、Controlが作成されたスレッドで関数を実行する。 … … 345 349 346 350 Protected 347 ' Properties 351 '--------------------------------------------------------------------------- 352 ' Protected Properties 348 353 ' Const Virtual Function CanRaiseEvents() As BOOL 349 354 Virtual Function CreateParams() As *CreateParams … … 364 369 ' Virtual Sub Cursor(ByRef c As Cursor) 365 370 366 ' Methods 371 '--------------------------------------------------------------------------- 372 ' Protected Methods 367 373 Virtual Sub CreateHandle() 368 374 Dim createParams = CreateParams() … … 406 412 Case WM_ERASEBKGND 407 413 ' OnPaintBackgroundに移すべき 408 Dim hdc As HDC 409 hdc = .WParam As HDC 414 Dim hdc = .WParam As HDC 410 415 Dim hbr = CreateSolidBrush(bkColor.ToCOLORREF()) 411 416 Dim hbrOld = SelectObject(hdc, hbr) 412 Dim rc As RECT 413 rc = wnd.ClientRect 417 Dim rc = wnd.ClientRect 414 418 Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom) 415 419 SelectObject(hdc, hbrOld)
Note:
See TracChangeset
for help on using the changeset viewer.