home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
601-625
/
apd617
/
chris_evans
/
graphicalwindows.amos
/
graphicalwindows.amosSourceCode
Wrap
AMOS Source Code
|
1986-08-03
|
9KB
|
267 lines
'---------------------------
' GRAPHICAL WINDOW TUTORIAL
' by
' Chris Evans
' 44 Shady Lane - RR7
' St. Thomas, ONT
' Canada N5P 3T2 (letters welcome)
'---------------------------
'
' Windowing gives programs a professional look, but coders
' often don't use WIND OPEN because it creates windows
' that are short on beauty, and long on problems if you
' use the CLS command. In the program below, a WINOPEN
' procedure was created to avoid both the above. The
' result is a window that has an Intuition-style
' rectangular title bar, and better graphical style
' borders which are both created in REDRAW.
'
' Two screens are used so that when the rubber band
' (perimeter) line is displayed, one screen can hold an
' untouched image of the window which can be copied back
' onto the screen containing the unwanted lines after the
' user moves the mouse. In this way no lines are ever
' left on the screen that are not necessary, so there is
' no "garbage". The command WIND SAVE allows the window
' to be moved without corrupting the underlying screen.
'
Global XONE,YONE,XTWO,YTWO
Screen Open 1,640,200,4,Hires
Curs Off
Flash Off
Cls 0
Palette 0,$FFF,$F00,$F
Screen Open 0,640,200,4,Hires
Curs Off
Flash Off
Cls 0
Palette 0,$FFF,$F00,$F
'
'-------------------------------------
' Wind Save allows the window(s) to
' be moved without corrupting the
' underlying screen.
'-------------------------------------
'
Wind Save
WINOPEN[128,33,47,7,"TOTALLY AMOS"]
WINTEXT[0,0,"Devoted to totally interesting information",1]
WINTEXT[0,1,"about AMOS programming. Try dragging the",1]
WINTEXT[0,2,"title bar. When you click the close",1]
WINTEXT[0,3,"gadget the window will disappear and the",1]
WINTEXT[0,4,"program will end.",1]
Screen Copy 0 To 1
Do
If Mouse Key=1
CHECK
End If
Loop
'
'-------------------------------------
' The procedure WINOPEN opens a
' window and calls the procedure
' REDRAW.
'-------------------------------------
'
Procedure WINOPEN[XO,YO,XT,YT,TITLE$]
'
'----------------------------------------------------------------
' The parameters for WINOPEN are:
'
' 1) XO = The X Graphic co-ordinate for the top left corner.
' 2) YO = The Y Graphic co-ordinate for the top left corner.
' 3) XT = The number of characters wide
' 4) YT = The number of characters high
' 5) TITLE$ = Contains the title for the top bar
'
' WINOPEN assumes you want to create Window 1.
'----------------------------------------------------------------
'
Wind Open 1,XO,YO,XT,YT
Window 1
REDRAW[XO,YO,XT,YT,TITLE$]
XONE=XO : XTWO=XT : YONE=YO : YTWO=YT
End Proc
'
'-------------------------------------
' The procedure REDRAW draws
' graphics on Window 1 making it
' look like an Intuition window.
'-------------------------------------
'
Procedure REDRAW[XO,YO,XT,YT,TITLE$]
Window 1
Ink 3
Bar XO,YO To XO+(XT*8)-8,YO+(YT*8)-1
Ink 2
Box XO,YO To XO+(XT*8)-8,YO+(YT*8)-1
Bar XO,YO To XO+(XT*8)-8,YO+8
Ink 0
Gr Writing 0
Text XO+24,YO+7,TITLE$
DRA_CLOSE[XO,YO]
End Proc
'
'-------------------------------------
' The procedure WINTEXT allows you
' to put text inside the window
' using the Text feature.
'-------------------------------------
'
Procedure WINTEXT[X,Y,TXT$,C0L]
'
'---------------------------------------------------
' The parameters of WINTEXT are:
'
' 1) X = The X position (similar to Locate)
' 2) Y = The Y position (similar to Locate)
' 3) TXT$ = What is put at X,Y
' 4) C0L = The ink colour of the text
'
' WINTEXT uses Gr Writing 0. Don't change this
' or it could corrupt the blue window area.
'----------------------------------------------------
'
Ink 1
Gr Writing 0
Text XONE+5+(X*8),YONE+(Y*8)+17,TXT$
End Proc
'
'--------------------------------------
' The procedure DRA_CLOSE draws the
' Intuition style close gadget. A
' re-sizer gadget is omitted because
' it serves no purpose in the Amos
' environment; the coder will draw
' the window to fit the information.
'--------------------------------------
'
Procedure DRA_CLOSE[X,Y]
Ink 2
Box X+0,Y+0 To X+9,Y+8
Box X+1,Y+1 To X+8,Y+7
Ink 0
Box X+2,Y+2 To X+7,Y+6
Ink 1
Bar X+3,Y+3 To X+6,Y+5
End Proc
'
'-------------------------------------
' The procedure CHECK is called
' whenever the left mouse button is
' pressed (look at the main loop).
' If the mouse cursor is on the
' close gadget then the window is
' closed and the program ends. (If
' you want to change that, put what
' you want in place of line 168..
' If the mouse cursor is on the
' title bar, the procedure MOVEBAR
' is called.
'--------------------------------------
'
Procedure CHECK
XM=X Screen(X Mouse)
YM=Y Screen(Y Mouse)
If XM>XONE-3 and XM<XONE+9
If YM>YONE-1 and YM<YONE+9
Window 1
Wind Close
End
End If
End If
If XM>XONE+9 and XM<XONE+(XTWO*8)-10
If YM>YONE-1 and YM<YONE+9
MOVEBAR
End If
End If
End Proc
'
Procedure MOVEBAR
Screen To Front 1 : Rem Remember that the user is seeing Screen 1
Screen 1
'
'---------------------------------------------
' Here, the position of the mouse cursor is
' found, and the difference between the
' mouse cursor location and the top left
' corner is found. This is done so that
' the box doesn't jump to somewhere else on
' the screen.
'---------------------------------------------
'
XM=X Screen(X Mouse)
YM=Y Screen(Y Mouse)
XD=XM-XONE
YD=YM-YONE
'
'The following Repeat and Until statements wait for the
'user to let go of the left mouse button.
'
Repeat
'
'Here, the placement of the mouse cursor is found
'again.
'
XM=X Screen(X Mouse)
YM=Y Screen(Y Mouse)
'
'The rubber band line is drawn to show where the
'window will move to.
'
Box XM-XD,YM-YD To XM-XD-1+(XTWO*8-7),YM-YD+(YTWO*8-1)
'
'------------------------------------------
' The following 5 lines wait for the
' user to either:
'
' 1) Move the mouse.
' 2) Let go of the left mouse button.
'------------------------------------------
'
Do
Exit If X Screen(X Mouse)<>XM
Exit If Y Screen(Y Mouse)<>YM
Exit If Mouse Key<>1
Loop
'
'The next line copies the display of Screen 0 to Screen 1.
'
Screen Copy 0 To 1
'
Until Mouse Key<>1
'
Screen To Front 0 : Rem The user is now seeing Screen 0
Screen 0
Window 1 : Rem Close
Wind Close : Rem window 1
'
'The next four lines figure out where the new window
'will appear.
'
FINALXONE=XM-XD
FINALYONE=YM-YD
DIFFERENCEX=FINALXONE mod 16
FINALXONE=FINALXONE-DIFFERENCEX
'
'------------------------------------------------------
'The next five lines re-open window 1 in its new
'position and put the text on top of it again. You
'will notice that the position isn't exactly where you
'left the mouse cursor. The position was pushed back
'to the nearest multiple of 16. This is done because
'AMOS won't accept boundaries that aren't multiples
'of 16 since the blitter chip is used for these windows.
'-------------------------------------------------------
'
WINOPEN[FINALXONE,FINALYONE,XTWO,YTWO,"TOTALLY AMOS"]
WINTEXT[0,0,"Devoted to totally interesting information",1]
WINTEXT[0,1,"about AMOS programming. Try dragging the",1]
WINTEXT[0,2,"title bar. When you click the close",1]
WINTEXT[0,3,"gadget the window will disappear and the",1]
WINTEXT[0,4,"program will end.",1]
'
Screen Copy 0 To 1 : Rem The newly created screen is now
' copied back to screen 1.
'
End Proc