Mouse
anew 滑鼠視窗
256 value WindowSize_W
256 value WindowSize_H
256 value WindowPosition_X
256 value WindowPosition_Y
create Buf_Picture WindowSize_W WindowSize_H * cell * allot
0 Buf_Picture !
0 Buf_Picture 4 + !
ColorObject TheNextColor \ 使用 顏色物件
:Object 滑鼠 <Super Window \ 宣告 滑鼠
: 顏色變更 ( R G B --- )
rgb NewColor: TheNextColor
TheNextColor ?ColorCheck
LineColor: dc
;
: 畫點 ( x y --- )
TheNextColor SetPixel: dc
;
:M StartSize: ( -- w h ) \ 此物件的大小
WindowSize_W WindowSize_H
;M
:M StartPos: ( -- x y ) \ 物件在 桌面的位置
WindowPosition_X WindowPosition_Y
;M
:M WindowTitle: ( -- Zstring ) \ 此物件的標題
z" 滑鼠"
;M
:M On_Paint: { \ temp$ -- } \ all window refreshing is done by On_Paint:
255 255 0 顏色變更
WindowPosition_X random
WindowPosition_Y random
s" 隨機" TextOut: dc
Buf_Picture @ WindowPosition_X - 5 -
Buf_Picture 4 + @ WindowPosition_Y - 25 -
s" 按鍵拖曳" TextOut: dc
;M
:M On_Init: ( -- ) \ things to do at the start of window creation
On_Init: super \ do anything superclass needs
;M
:M WM_MOUSEMOVE ( h m w l -- res )
MK_RBUTTON
MK_LBUTTON or
set-mousexy and ( 有拖曳的效果 )
IF
Paint: self
Buf_Picture GetCursorPos ( --- )
then
0
;M
:M WM_LBUTTONDOWN ( h m w l -- res )
Paint: self
Buf_Picture GetCursorPos ( --- )
0
;M
;Object
\ -----------------------------------------------------------------------
: end-demo ( -- ) \ close the demo window
Close: 滑鼠 ;
: demo ( -- ) \ start running the demo program
Start: 滑鼠
;
demo