home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
subroutines
/
win_button.amos
/
win_button.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1993-07-26
|
3KB
|
171 lines
' *******************
' *** WIN-Buttons ***
' *******************
' *** This routine draws & uses the same buttons used in Microsoft Windows.
' *** Open screen.
Screen Open 0,640,200,8,Hires
Curs Off
Flash Off
Pen 1
Paper 0
Cls 0
' *** Button palette, NOTE :- The first 4 colours are used by the buttons,
' so they must stay the same.
Palette $CCC,$0,$FFF,$777
' *** Define global variable.
Global AN
' *** Draw screen.
WINBUT[50,50,100,100,"(IC)001",0]
WINBUT[150,50,250,100,"(IC)002",0]
WINBUT[400,50,500,90,"HELLO",0]
WINBUT[10,5,100,40,"QUIT",0]
WINBUT[10,130,629,140,"These buttons can contain either TEXT or ICONS...",1]
' *** Main loop.
Do
R[50,50,100,100,"(IC)001"]
If AN
Bell 96
End If
R[150,50,250,100,"(IC)002"]
If AN
Bell 94
End If
R[10,5,100,40,"QUIT"]
If AN
Bell 20
Exit
End If
R[400,50,500,90,"HELLO"]
If AN
Bell 90
End If
Loop
' *** Quit.
Direct
' *** This procedure draws the button.
' *** X1,Y1 - X2,Y2 - Coords of button.
' T$ - Text inside button, if T$="(IC)001" then
' icon 1 will be placed inside the button.
' IN - If IN=0 then the button will be facing outwards,
' but if IN=1 then the button will be facing inwards.
Procedure WINBUT[X1,Y1,X2,Y2,T$,IN]
Ink 1
Box X1-1,Y1-1 To X2+1,Y2+1
Box X1-2,Y1 To X2+2,Y2
Ink 0
Bar X1,Y1 To X2,Y2
If IN=0
Ink 2
Draw X1,Y2 To X1,Y1
Draw X1+1,Y2-1 To X1+1,Y1
Draw X1,Y1 To X2,Y1
Ink 3
Draw X2,Y1 To X2,Y2
Draw X2-1,Y1+1 To X2-1,Y2
Draw X2,Y2 To X1+1,Y2
Else
Ink 3
Draw X1,Y2 To X1,Y1
Draw X1+1,Y2 To X1+1,Y1
Draw X1,Y1 To X2,Y1
End If
If T$<>""
If Left$(T$,4)="(IC)"
IC=Val(Mid$(T$,5,3))
AA=Icon Base(IC)
W=(Deek(AA)*16)/2
X=(((X2-X1)/2)+X1)-W
H=Deek(AA+2)/2
Y=(((Y2-Y1)/2)+Y1)-H
Paste Icon X+(IN*2),Y+IN,IC
Else
W=Text Length(T$)/2
X=(((X2-X1)/2)+X1)-W
H=Text Base/2
Y=(((Y2-Y1)/2)+Y1)-H+Text Base
Ink 1,0
Text X+(IN*2),Y+IN,T$
End If
End If
End Proc
' *** This procedure chacks for a button press.
' *** Same rules apply for the above procedure, just make sure that
' the button being pressed is facing outwards.
Procedure R[X1,Y1,X2,Y2,T$]
M=Mouse Key
X3=X Screen(X Mouse)
Y3=Y Screen(Y Mouse)
AN=0
If X3<X1 or X3>X2 or Y3<Y1 or Y3>Y2 or M=0
Pop Proc
End If
WINBUT[X1,Y1,X2,Y2,T$,1]
Repeat
X3=X Screen(X Mouse)
Y3=Y Screen(Y Mouse)
If X3<X1 or X3>X2 or Y3<Y1 or Y3>Y2
Goto FIN
End If
Until Mouse Key=0
AN=M
FIN:
WINBUT[X1,Y1,X2,Y2,T$,0]
End Proc[AN]