source: Include/basic/prompt.sbp@ 16

Last change on this file since 16 was 1, checked in by (none), 18 years ago
File size: 20.4 KB
Line 
1'prompt.sbp
2
3
4#ifndef _INC_PROMPT
5#define _INC_PROMPT
6
7
8#include <api_imm.sbp>
9
10Dim _PromptSys_hWnd As HWND
11Dim _PromptSys_dwThreadID As DWord
12Dim _PromptSys_bInitFinish As Long
13
14'text
15Dim _PromptSys_LogFont As LOGFONT
16Dim _PromptSys_hFont As HFONT
17Dim _PromptSys_FontSize As SIZE
18Dim _PromptSys_InputStr[255] As Byte
19Dim _PromptSys_InputLen As Long
20Dim _PromptSys_KeyChar As Byte
21Dim _PromptSys_CurPos As POINTAPI
22Dim _PromptSys_Buffer[100] As BytePtr
23Dim _PromptSys_TextColor[100] As DWordPtr
24Dim _PromptSys_BackColor[100] As DWordPtr
25Dim _PromptSys_NowTextColor As DWord
26Dim _PromptSys_NowBackColor As DWord
27Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION
28
29
30_PromptSys_InputLen=-1
31
32'graphic
33Dim _PromptSys_hBitmap As HBITMAP
34Dim _PromptSys_hMemDC As HDC
35Dim _PromptSys_ScreenSize As SIZE
36Dim _PromptSys_GlobalPos As POINTAPI
37
38
39_PromptSys_bInitFinish=0
40CreateThread(
41 0,
42 0,
43 AddressOf(PromptMain) As LPTHREAD_START_ROUTINE,
44 0 As VoidPtr,
45 0,
46 _PromptSys_dwThreadID)
47Do
48 Sleep(20)
49Loop Until _PromptSys_bInitFinish
50
51Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
52 Dim i As Long, i2 As Long, i3 As Long
53 Dim hOldFont As HFONT
54 Dim sz As SIZE
55 Dim temporary[2] As Byte
56
57 hOldFont=SelectObject(hDC,_PromptSys_hFont)
58
59 'Scroll
60 Dim rc As RECT
61 GetClientRect(_PromptSys_hWnd,rc)
62 While (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy>rc.bottom and _PromptSys_CurPos.y>0
63 HeapFree(_System_hProcessHeap,0,_PromptSys_Buffer[0])
64 HeapFree(_System_hProcessHeap,0,_PromptSys_TextColor[0])
65 HeapFree(_System_hProcessHeap,0,_PromptSys_BackColor[0])
66 For i=0 To 100-1
67 _PromptSys_Buffer[i]=_PromptSys_Buffer[i+1]
68 _PromptSys_TextColor[i]=_PromptSys_TextColor[i+1]
69 _PromptSys_BackColor[i]=_PromptSys_BackColor[i+1]
70 Next
71 _PromptSys_Buffer[100]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255)
72 _PromptSys_TextColor[100]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255*SizeOf(LONG_PTR))
73 _PromptSys_BackColor[100]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255*SizeOf(LONG_PTR))
74
75 _PromptSys_CurPos.y=_PromptSys_CurPos.y-1
76
77 'Redraw
78 StartLine=-1
79 Wend
80
81 i=0
82 While i*_PromptSys_FontSize.cy<rc.bottom and i<=100
83 If StartLine=-1 or (StartLine<=i and i<=EndLine) Then
84 GetTextExtentPoint32(hDC,_PromptSys_Buffer[i],lstrlen(_PromptSys_Buffer[i]),sz)
85 BitBlt(hDC,_
86 sz.cx, i*_PromptSys_FontSize.cy, _
87 rc.right, _PromptSys_FontSize.cy, _
88 _PromptSys_hMemDC,sz.cx,i*_PromptSys_FontSize.cy,SRCCOPY)
89
90 i3=lstrlen(_PromptSys_Buffer[i])
91 For i2=0 To i3-1
92 SetTextColor(hDC,_PromptSys_TextColor[i][i2])
93 If _PromptSys_BackColor[i][i2]=-1 Then
94 SetBkMode(hDC,TRANSPARENT)
95 Else
96 SetBkMode(hDC,OPAQUE)
97 SetBkColor(hDC,_PromptSys_BackColor[i][i2])
98 End If
99
100 temporary[0]=_PromptSys_Buffer[i][i2]
101 If IsDBCSLeadByte(temporary[0]) Then
102 temporary[1]=_PromptSys_Buffer[i][i2+1]
103 temporary[2]=0
104 Else
105 temporary[1]=0
106 End If
107 TextOut(hDC,i2*_PromptSys_FontSize.cx,i*_PromptSys_FontSize.cy,_
108 temporary,lstrlen(temporary))
109
110 If IsDBCSLeadByte(temporary[0]) Then i2=i2+1
111 Next
112 End If
113
114 i=i+1
115 Wend
116
117 SelectObject(hDC,hOldFont)
118End Sub
119
120Sub PRINT_ToPrompt(buf As String)
121 EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
122
123 Dim hDC As HDC
124 Dim StartLine As Long
125 Dim i2 As Long, i3 As Long
126
127 StartLine=_PromptSys_CurPos.y
128
129 'Addition
130 i2=0
131 Do
132 If buf[i2]=9 Then 'tab
133 i3=8-(_PromptSys_CurPos.x mod 8)
134
135 FillMemory(_PromptSys_Buffer[_PromptSys_CurPos.y]+_PromptSys_CurPos.x,i3,Asc(" "))
136
137 i2=i2+1
138 _PromptSys_CurPos.x=_PromptSys_CurPos.x+i3
139 Continue
140 End If
141
142 If buf[i2]=13 and buf[i2+1]=10 Then '\r\n
143 i2=i2+2
144 _PromptSys_CurPos.y=_PromptSys_CurPos.y+1
145 _PromptSys_CurPos.x=0
146 Continue
147 End If
148
149 If buf[i2]=0 Then Exit Do
150 _PromptSys_Buffer[_PromptSys_CurPos.y][_PromptSys_CurPos.x]=buf[i2]
151 _PromptSys_TextColor[_PromptSys_CurPos.y][_PromptSys_CurPos.x]=_PromptSys_NowTextColor
152 _PromptSys_BackColor[_PromptSys_CurPos.y][_PromptSys_CurPos.x]=_PromptSys_NowBackColor
153
154 i2=i2+1
155 _PromptSys_CurPos.x=_PromptSys_CurPos.x+1
156 Loop
157
158 'Draw the text buffer added
159 hDC=GetDC(_PromptSys_hWnd)
160 DrawPromptBuffer(hDC,StartLine,_PromptSys_CurPos.y)
161 ReleaseDC(_PromptSys_hWnd,hDC)
162
163 LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
164End Sub
165
166Function PromptProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT
167 Dim hIMC As HIMC
168 Dim hDC As HDC
169 Dim ps As PAINTSTRUCT
170 Dim TempStr As String
171 Dim temporary[255] As Byte
172 Dim CompForm As COMPOSITIONFORM
173 Dim hGlobal As HGLOBAL
174 Dim pTemp As BytePtr
175
176 Select Case message
177 Case WM_CREATE
178 hDC=GetDC(hWnd)
179 _PromptSys_hBitmap=CreateCompatibleBitmap(hDC,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy)
180 _PromptSys_hMemDC=CreateCompatibleDC(hDC)
181 SelectObject(_PromptSys_hMemDC,_PromptSys_hBitmap)
182
183 'Initialize for Win9x
184 Dim hOldBrush As HBRUSH
185 hOldBrush=SelectObject(_PromptSys_hMemDC,GetStockObject(BLACK_BRUSH))
186 PatBlt(_PromptSys_hMemDC,0,0,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy,PATCOPY)
187 SelectObject(_PromptSys_hMemDC,hOldBrush)
188
189 Dim hOldFont As HFONT
190 Dim tm As TEXTMETRIC
191 hOldFont=SelectObject(_PromptSys_hMemDC,_PromptSys_hFont)
192 GetTextExtentPoint32(_PromptSys_hMemDC," ",1,_PromptSys_FontSize)
193 GetTextMetrics(_PromptSys_hMemDC,tm)
194 SelectObject(_PromptSys_hMemDC,hOldFont)
195 _PromptSys_FontSize.cy=tm.tmHeight
196
197 ReleaseDC(hWnd,hDC)
198 Case WM_PAINT
199 hDC=BeginPaint(hWnd,ps)
200 BitBlt(hDC,0,0,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy,_PromptSys_hMemDC,0,0,SRCCOPY)
201 DrawPromptBuffer(hDC,-1,0)
202 EndPaint(hWnd,ps)
203
204 _PromptSys_bInitFinish=1
205 Case WM_SETFOCUS
206 If _PromptSys_InputLen<>-1 Then
207 hIMC=ImmGetContext(hWnd)
208 If hIMC Then
209 CompForm.dwStyle=CFS_POINT
210 CompForm.ptCurrentPos.x=_PromptSys_CurPos.x*_PromptSys_FontSize.cx
211 CompForm.ptCurrentPos.y=_PromptSys_CurPos.y*_PromptSys_FontSize.cy
212 ImmSetCompositionWindow(hIMC,CompForm)
213 ImmSetCompositionFont(hIMC,_PromptSys_LogFont)
214 End If
215 ImmReleaseContext(hWnd,hIMC)
216
217 CreateCaret(hWnd,NULL,9,6)
218 SetCaretPos(_PromptSys_CurPos.x*_PromptSys_FontSize.cx, _
219 (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy-7)
220 ShowCaret(hWnd)
221 End If
222 Case WM_KILLFOCUS
223 HideCaret(hWnd)
224 DestroyCaret()
225 Case WM_KEYDOWN
226 If _PromptSys_InputLen=-1 Then
227 _PromptSys_KeyChar=wParam As Byte
228 End If
229 Case WM_CHAR
230 If _PromptSys_InputLen<>-1 Then
231 If wParam=VK_BACK Then
232 If _PromptSys_InputLen Then
233 _PromptSys_InputLen=_PromptSys_InputLen-1
234 _PromptSys_InputStr[_PromptSys_InputLen]=0
235
236 _PromptSys_CurPos.x=_PromptSys_CurPos.x-1
237 _PromptSys_Buffer[_PromptSys_CurPos.y][_PromptSys_CurPos.x]=0
238 End If
239 ElseIf wParam=VK_RETURN Then
240 _PromptSys_InputStr[_PromptSys_InputLen]=0
241 _PromptSys_InputLen=-1
242 TempStr=Ex"\r\n"
243 ElseIf wParam=&H16 Then
244 'Paste Command(Use Clippboard)
245 OpenClipboard(hWnd)
246 hGlobal=GetClipboardData(CF_TEXT)
247 If hGlobal=0 Then PromptProc=0:Exit Function
248 pTemp=GlobalLock(hGlobal) As *Byte
249
250 TempStr=ZeroString(lstrlen(pTemp)+1)
251 lstrcpy(StrPtr(TempStr),pTemp)
252
253 lstrcpy((VarPtr(_PromptSys_InputStr[0])+_PromptSys_InputLen) As *Byte,pTemp)
254 _PromptSys_InputLen=_PromptSys_InputLen+lstrlen(pTemp)
255
256 GlobalUnlock(hGlobal)
257 CloseClipboard()
258 Else
259 _PromptSys_InputStr[_PromptSys_InputLen]=wParam As Byte
260 _PromptSys_InputLen=_PromptSys_InputLen+1
261
262 temporary[0]=wParam As Byte
263 temporary[1]=0
264 TempStr=temporary
265 End If
266
267 SendMessage(hWnd,WM_KILLFOCUS,0,0)
268 PRINT_ToPrompt(TempStr)
269 SendMessage(hWnd,WM_SETFOCUS,0,0)
270 End If
271 Case WM_DESTROY
272 DeleteDC(_PromptSys_hMemDC)
273 DeleteObject(_PromptSys_hBitmap)
274
275 PostQuitMessage(0)
276 Case Else
277 PromptProc=DefWindowProc(hWnd,message,wParam,lParam)
278 Exit Function
279 End Select
280 PromptProc=0
281End Function
282
283Function PromptMain(dwData As Long) As Long
284 Dim i As Long
285
286 'Allocate
287 For i=0 To 100
288 _PromptSys_Buffer[i]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255)
289 _PromptSys_TextColor[i]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255*SizeOf(LONG_PTR))
290 _PromptSys_BackColor[i]=HeapAlloc(_System_hProcessHeap,HEAP_ZERO_MEMORY,255*SizeOf(LONG_PTR))
291 Next
292
293 'Current Colors initialize
294 _PromptSys_NowTextColor=RGB(255,255,255)
295 _PromptSys_NowBackColor=RGB(0,0,0)
296
297 'Setup
298 _PromptSys_ScreenSize.cx=GetSystemMetrics(SM_CXSCREEN)
299 _PromptSys_ScreenSize.cy=GetSystemMetrics(SM_CYSCREEN)
300
301 'LogFont initialize
302 _PromptSys_LogFont.lfHeight=-16
303 _PromptSys_LogFont.lfWidth=0
304 _PromptSys_LogFont.lfEscapement=0
305 _PromptSys_LogFont.lfOrientation=0
306 _PromptSys_LogFont.lfWeight=0
307 _PromptSys_LogFont.lfItalic=0
308 _PromptSys_LogFont.lfUnderline=0
309 _PromptSys_LogFont.lfStrikeOut=0
310 _PromptSys_LogFont.lfCharSet=SHIFTJIS_CHARSET
311 _PromptSys_LogFont.lfOutPrecision=OUT_DEFAULT_PRECIS
312 _PromptSys_LogFont.lfClipPrecision=CLIP_DEFAULT_PRECIS
313 _PromptSys_LogFont.lfQuality=DEFAULT_QUALITY
314 _PromptSys_LogFont.lfPitchAndFamily=FIXED_PITCH
315 lstrcpy(_PromptSys_LogFont.lfFaceName,"MS 明朝")
316
317 _PromptSys_hFont=CreateFontIndirect(_PromptSys_LogFont)
318
319 'Critical Section
320 InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
321
322 'Regist Prompt Class
323 Dim wcl As WNDCLASSEX
324 FillMemory(VarPtr(wcl),Len(wcl),0)
325 wcl.cbSize=Len(wcl)
326 wcl.hInstance=GetModuleHandle(0)
327 wcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS
328 wcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))
329 wcl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_WINLOGO))
330 wcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))
331 wcl.lpszClassName="PROMPT"
332 wcl.lpfnWndProc=AddressOf(PromptProc)
333 wcl.hbrBackground=GetStockObject(BLACK_BRUSH)
334 RegisterClassEx(wcl)
335
336 'Create Prompt Window
337 _PromptSys_hWnd=CreateWindowEx(WS_EX_CLIENTEDGE,"PROMPT","BASIC PROMPT",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,GetModuleHandle(0),0)
338 ShowWindow(_PromptSys_hWnd,SW_SHOW)
339
340 Dim msg As MSG, iResult As Long
341 Do
342 iResult=GetMessage(msg,0,0,0)
343 If iResult=0 or iResult=-1 Then Exit Do
344 TranslateMessage(msg)
345 DispatchMessage(msg)
346 Loop
347
348 EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
349 For i=0 to 100
350 HeapFree(_System_hProcessHeap,0,_PromptSys_Buffer[i])
351 HeapFree(_System_hProcessHeap,0,_PromptSys_TextColor[i])
352 HeapFree(_System_hProcessHeap,0,_PromptSys_BackColor[i])
353 Next
354 LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
355
356 DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
357
358 ExitProcess(0)
359End Function
360
361
362'----------------------
363' Prompt text Commands
364'----------------------
365
366Macro CLS()(num As Long)
367 Dim i As Long
368 Dim hOldBrush As HBRUSH
369
370 'When parameter was omitted, num is set to 1
371 If num=0 Then num=1
372
373 If num=1 or num=3 Then
374 'Clear the text screen
375 For i=0 To 100
376 FillMemory(_PromptSys_Buffer[i],255,0)
377 Next
378 _PromptSys_CurPos.x=0
379 _PromptSys_CurPos.y=0
380 End If
381
382 If num=2 or num=3 Then
383 'Clear the graphics screen
384 hOldBrush=SelectObject(_PromptSys_hMemDC,GetStockObject(BLACK_BRUSH))
385 PatBlt(_PromptSys_hMemDC,0,0,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy,PATCOPY)
386 SelectObject(_PromptSys_hMemDC,hOldBrush)
387 End If
388
389 'Redraw
390 InvalidateRect(_PromptSys_hWnd,ByVal 0,0)
391End Macro
392
393Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
394 _PromptSys_NowTextColor=GetBasicColor(TextColorCode)
395 If BackColorCode=-1 Then
396 _PromptSys_NowBackColor=-1
397 Else
398 _PromptSys_NowBackColor=GetBasicColor(BackColorCode)
399 End If
400End Macro
401
402'---------- Defined in "command.sbp" ----------
403'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
404'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
405'----------------------------------------------
406Sub INPUT_FromPrompt(ShowStr As String)
407 Dim i As Long ,i2 As Long, i3 As Long
408 Dim buf As String
409
410*InputReStart
411
412 PRINT_ToPrompt(ShowStr)
413
414 'Input by keyboard
415 _PromptSys_InputLen=0
416 SendMessage(_PromptSys_hWnd,WM_SETFOCUS,0,0)
417 While _PromptSys_InputLen<>-1
418 Sleep(10)
419 Wend
420 SendMessage(_PromptSys_hWnd,WM_KILLFOCUS,0,0)
421
422 'Set value to variable
423 i=0
424 i2=0
425 buf=ZeroString(lstrlen(_PromptSys_InputStr))
426 While 1
427 i3=0
428 While 1
429 If _PromptSys_InputStr[i2]=Asc(",") Then
430 buf.Chars[i3]=0
431 Exit While
432 End If
433
434 buf.Chars[i3]=_PromptSys_InputStr[i2]
435
436 If _PromptSys_InputStr[i2]=0 Then Exit While
437
438 i2=i2+1
439 i3=i3+1
440 Wend
441
442 Select Case _System_InputDataType[i]
443 Case _System_Type_Double
444 SetDouble(_System_InputDataPtr[i],Val(buf))
445 Case _System_Type_Single
446 SetSingle(_System_InputDataPtr[i],Val(buf))
447 Case _System_Type_Int64,_System_Type_QWord
448 SetQWord(_System_InputDataPtr[i],Val(buf))
449 Case _System_Type_Long,_System_Type_DWord
450 SetDWord(_System_InputDataPtr[i],Val(buf))
451 Case _System_Type_Integer,_System_Type_Word
452 SetWord(_System_InputDataPtr[i],Val(buf))
453 Case _System_Type_Char,_System_Type_Byte
454 SetByte(_System_InputDataPtr[i],Val(buf))
455
456 Case _System_Type_String
457 Dim pTempStr As *String
458 pTempStr=_System_InputDataPtr[i] As *String
459
460 pTempStr->Length=i3
461 pTempStr->Chars=_System_realloc(pTempStr->Chars,pTempStr->Length+1)
462 memcpy(pTempStr->Chars,buf.Chars,pTempStr->Length)
463 pTempStr->Chars[pTempStr->Length]=0
464 End Select
465
466 i=i+1
467 If _System_InputDataPtr[i]=0 and _PromptSys_InputStr[i2]=Asc(",") Then
468 PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
469 Goto *InputReStart
470 ElseIf _PromptSys_InputStr[i2]=0 Then
471 If _System_InputDataPtr[i]<>0 Then
472 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
473 Goto *InputReStart
474 Else
475 Exit While
476 End If
477 End If
478
479 i2=i2+1
480 Wend
481End Sub
482
483Sub PRINTUSING_ToPrompt(UsingStr As String)
484 PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
485End Sub
486
487Macro LOCATE(x As Long, y As Long)
488 Dim i As Long, i2 As Long
489
490 If x<0 Then x=0
491 If y<0 Then y=0
492 If y>100 Then y=100
493
494 _PromptSys_CurPos.x=x
495 _PromptSys_CurPos.y=y
496
497 i=0
498 While _PromptSys_Buffer[y][i]
499 i=i+1
500 Wend
501
502 If i<x Then
503 FillMemory(_PromptSys_Buffer[y]+i,x-i,Asc(" "))
504 For i2=i To x-1
505 _PromptSys_BackColor[y][i2]=-1
506 Next
507 End If
508End Macro
509
510
511'-------------------
512' Graphics Commands
513'-------------------
514
515Macro CIRCLE(x As Long , y As Long, radius As Long)(ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
516 '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
517 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
518
519 Dim hDC As Long
520 Dim hPen As Long, hOldPen As Long
521 Dim hBrush As Long, hOldBrush As Long
522 Dim radi2 As Long
523 Dim sw As Long
524 Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
525
526 hPen=CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
527 If bFill Then
528 hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
529 Else
530 hBrush=GetStockObject(NULL_BRUSH)
531 End If
532
533 hDC=GetDC(_PromptSys_hWnd)
534 SelectObject(hDC,hPen)
535 SelectObject(hDC,hBrush)
536 hOldPen=SelectObject(_PromptSys_hMemDC,hPen)
537 hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
538
539 If Aspect<1 Then
540 radi2=CDbl(radius)*Aspect
541 Else
542 radi2=radius
543 radius=CDbl(radius)/Aspect
544 End If
545
546 If StartPos=0 And EndPos=0 Then
547 Ellipse(hDC,x-radius,y-radi2,x+radius,y+radi2)
548 Ellipse(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2)
549 Else
550 StartPos=StartPos*100
551 EndPos=EndPos*100
552
553 If StartPos<0 Or EndPos<0 Then
554 sw=1
555 Else
556 sw=0
557 End If
558
559 If StartPos<0 Then StartPos=StartPos*-1
560 If EndPos<0 Then EndPos=EndPos*-1
561
562 If StartPos<=78.5 Then
563 i1=78
564 i2=Int(StartPos)
565 ElseIf StartPos<=235.5 Then
566 StartPos=StartPos-78.5
567 i1=78-Int(StartPos)
568 i2=78
569 ElseIf StartPos<=392.5 Then
570 StartPos=StartPos-235.5
571 i1=-78
572 i2=78-Int(StartPos)
573 ElseIf StartPos<=549.5 Then
574 StartPos=StartPos-392.5
575 i1=-78+Int(StartPos)
576 i2=-78
577 ElseIf StartPos<=628 Then
578 StartPos=StartPos-549.5
579 i1=78
580 i2=-78+Int(StartPos)
581 End If
582
583 If EndPos<=78.5 Then
584 i3=78
585 i4=Int(EndPos)
586 ElseIf EndPos<=235.5 Then
587 EndPos=EndPos-78.5
588 i3=78-Int(EndPos)
589 i4=78
590 ElseIf EndPos<=392.5 Then
591 EndPos=EndPos-235.5
592 i3=-78
593 i4=78-Int(EndPos)
594 ElseIf EndPos<=549.5 Then
595 EndPos=EndPos-392.5
596 i3=-78+Int(EndPos)
597 i4=-78
598 ElseIf EndPos<=628 Then
599 EndPos=EndPos-549.5
600 i3=78
601 i4=-78+Int(EndPos)
602 End If
603
604 If sw Then
605 Pie(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
606 Pie(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
607 Else
608 Arc(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
609 Arc(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
610 End If
611 End If
612
613 ReleaseDC(_PromptSys_hWnd,hDC)
614 SelectObject(_PromptSys_hMemDC,hOldPen)
615 SelectObject(_PromptSys_hMemDC,hOldBrush)
616 DeleteObject(hPen)
617 If bFill Then DeleteObject(hBrush)
618End Macro
619
620Macro LINE(sx As Long, sy As Long, bStep As Long, ex As Long, ey As Long)(ColorCode As Long, fType As Long, BrushColor As Long)
621 '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
622 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
623 Dim temp As Long
624
625 If sx=&H80000000 And sy=&H80000000 Then
626 sx=_PromptSys_GlobalPos.x
627 sy=_PromptSys_GlobalPos.y
628 End If
629
630 If bStep Then
631 ex=sx+ex
632 ey=sy+ey
633 Else
634 If fType Then
635 'ラインの場合(四角形でない場合)
636 If sx>ex Then
637 temp=ex
638 ex=sx
639 sx=temp
640 End If
641 If sy>ey Then
642 temp=ey
643 ey=sy
644 sy=temp
645 End If
646 End If
647 End If
648
649 Dim hDC As Long
650 Dim hPen As Long, hOldPen As Long
651 Dim hBrush As Long, hOldBrush As Long
652
653 hDC=GetDC(_PromptSys_hWnd)
654 hPen=CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
655 If fType=2 Then
656 hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
657 Else
658 hBrush=GetStockObject(NULL_BRUSH)
659 End If
660
661 SelectObject(hDC,hPen)
662 SelectObject(hDC,hBrush)
663 hOldPen=SelectObject(_PromptSys_hMemDC,hPen)
664 hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
665
666 Select Case fType
667 Case 0
668 'line
669 MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
670 LineTo(_PromptSys_hMemDC,ex,ey)
671 SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
672 MoveToEx(hDC,sx,sy,ByVal NULL)
673 LineTo(hDC,ex,ey)
674 SetPixel(hDC,ex,ey,GetBasicColor(ColorCode))
675 Case Else
676 'Rectangle
677 Rectangle(hDC,sx,sy,ex+1,ey+1)
678 Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
679 End Select
680
681 ReleaseDC(_PromptSys_hWnd,hDC)
682 SelectObject(_PromptSys_hMemDC,hOldPen)
683 SelectObject(_PromptSys_hMemDC,hOldBrush)
684 DeleteObject(hPen)
685 If fType=2 Then DeleteObject(hBrush)
686
687 _PromptSys_GlobalPos.x=ex
688 _PromptSys_GlobalPos.y=ey
689End Macro
690
691Macro PSET(x As Long, y As Long)(ColorCode As Long)
692 '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
693 'PSet (x,y),ColorCode
694
695 Dim hDC As Long
696
697 hDC=GetDC(_PromptSys_hWnd)
698 SetPixel(hDC,x,y,GetBasicColor(ColorCode))
699 SetPixel(_PromptSys_hMemDC,x,y,GetBasicColor(ColorCode))
700 ReleaseDC(_PromptSys_hWnd,hDC)
701
702 _PromptSys_GlobalPos.x=x
703 _PromptSys_GlobalPos.y=y
704End Macro
705
706Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
707 '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
708 'Paint (x,y),BrushColor,LineColor
709
710 Dim hDC As Long
711 Dim hBrush As Long, hOldBrush As Long
712
713 hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
714
715 hDC=GetDC(_PromptSys_hWnd)
716 SelectObject(hDC,hBrush)
717 hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
718
719 ExtFloodFill(hDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
720 ExtFloodFill(_PromptSys_hMemDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
721
722 ReleaseDC(_PromptSys_hWnd,hDC)
723 SelectObject(_PromptSys_hMemDC,hOldBrush)
724 DeleteObject(hBrush)
725End Macro
726
727
728'-----------
729' Functions
730'-----------
731
732Function Inkey$() As String
733 If _PromptSys_KeyChar=0 Then
734 Inkey$=""
735 Else
736 Inkey$=Chr$(_PromptSys_KeyChar)
737 End If
738 _PromptSys_KeyChar=0
739End Function
740
741Function Input$(length As Long) As String
742 Dim i As Long
743
744 If length<=0 Then
745 Input$=""
746 Exit Function
747 End If
748
749 i=0
750 While 1
751 If _PromptSys_KeyChar Then
752 Input$=Input$+Chr$(_PromptSys_KeyChar)
753 _PromptSys_KeyChar=0
754 i=i+1
755 If i>=length Then
756 Exit While
757 End If
758 End If
759 Sleep(1)
760 Wend
761End Function
762
763
764#endif '_INC_PROMPT
Note: See TracBrowser for help on using the repository browser.