home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 15
/
CD_ASCQ_15_070894.iso
/
vrac
/
dnalib7a.zip
/
HORZMENU.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-05-14
|
7KB
|
340 lines
DECLARE SUB CalcByte(Attr%,LowByte%,HiByte%)
DECLARE SUB Clicked(Rgt%,Lft%,Row%,Col%)
DECLARE SUB HideCursor()
DECLARE SUB ShowCursor()
SUB HorizontalMenu(Choices$(),BarSave$,HiLight%,Mouse%,HPointer%,HotKey%,BarAttr%,HiAttr%,MenuRow%,Gap%,Marker%) PUBLIC
$CODE SEG "DNASEG1"
CalcByte HiAttr%,HiFG%,HiBG%
CalcByte BarAttr%,BarFG%,BarBG%
'first we initialize these to zero
i% = 0
j% = 0
Maxlength% = 0
'next we count the choices and set the result to count%
DO
INCR i%
INCR j%
IF LEN(Choices$(i%)) = 0 THEN
DECR i%
ELSE
Fixedup$ = REMOVE$(Choices$(i%),"@")
Maxlength% = Maxlength% + LEN(Fixedup$)
END IF
LOOP WHILE i% = j%
Count% = i%
DIM Position%(1 TO Count%)
'here we do a bit of checking to see if the menu bar will fit
IF Maxlength% + ((Gap% * Count%) + Gap%) > 80 THEN
COLOR 0,7
LOCATE 12,27,0
PRINT "Horizontal Menu is too big";
EXIT SUB
END IF
'I am using the variable Marker to talk between horizontal and
'and vertical menus, if Esc is used to cancel the pulldown in
'the vertical menu, then marker is reset to zero, if marker
'contains a value then SelectionMade is preset to 1, so from
'horizontal menu, Marker carries the cursor position for the
'location of the pulled down menu, and either returns with that
'same value or a reset to zero.
IF Marker% = 0 THEN
SelectionMade% = 0
HPointer% = 0
ELSE
IF Marker% = 99 THEN
Marker% = 0
END IF
SelectionMade% = 1
END IF
'I test the condition of HPointer to see if the vertical menu has
'changed it's position, the vertical menu can increment or decrement
'the variable HPointer and controls the choice when pulldown is active.
IF Marker% > 0 THEN
IF HPointer% > Count% THEN
Pointer% = 1
ELSEIF HPointer% < 1 THEN
Pointer% = Count%
ELSE
Pointer% = HPointer%
END IF
END IF
'just paint a back ground for the horizontal menu
IF Marker% = 0 THEN
LOCATE MenuRow%,1,0
COLOR BarFG%,BarBG%
PRINT SPACE$(80);
END IF
Jump:
DO
GOSUB PrintRoutine
IF SelectionMade% THEN
EXIT SUB
END IF
WHILE NOT INSTAT
IF Mouse% THEN
Rgt% = 0:Lft% = 0:MRow% = 0:MCol% = 0
ShowCursor
Clicked Rgt%,Lft%,MRow%,MCol%
IF Lft% AND MRow% = MenuRow% THEN
FOR i% = 1 TO Count%
IF MCol% >= Position%(i%) AND MCol% < Position%(i%) + LEN(REMOVE$(Choices$(i%),"@")) THEN
Pointer% = i%
SelectionMade% = 1
GOTO Jump
END IF
NEXT i%
END IF
END IF
WEND
Ky$ = INKEY$
IF LEN(Ky$) = 1 THEN
Chose% = ASC(Ky$)
ELSE
Chose% = -ASC(RIGHT$(Ky$,1))
END IF
SELECT CASE Chose%
CASE -16
TestKey$ = "Q"
GOSUB AltKeys
CASE -17
TestKey$ = "W"
GOSUB AltKeys
CASE -18
TestKey$ = "E"
GOSUB AltKeys
CASE -19
TestKey$ = "R"
GOSUB AltKeys
CASE -20
TestKey$ = "T"
GOSUB AltKeys
CASE -21
TestKey$ = "Y"
GOSUB AltKeys
CASE -22
TestKey$ = "U"
GOSUB AltKeys
CASE -23
TestKey$ = "I"
GOSUB AltKeys
CASE -24
TestKey$ = "O"
GOSUB AltKeys
CASE -25
TestKey$ = "P"
GOSUB AltKeys
CASE -30
TestKey$ = "A"
GOSUB AltKeys
CASE -31
TestKey$ = "S"
GOSUB AltKeys
CASE -32
TestKey$ = "D"
GOSUB AltKeys
CASE -33
TestKey$ = "F"
GOSUB AltKeys
CASE -34
TestKey$ = "G"
GOSUB AltKeys
CASE -35
TestKey$ = "H"
GOSUB AltKeys
CASE -36
TestKey$ = "J"
GOSUB AltKeys
CASE -37
TestKey$ = "K"
GOSUB AltKeys
CASE -38
TestKey$ = "L"
GOSUB AltKeys
CASE -44
TestKey$ = "Z"
GOSUB AltKeys
CASE -45
TestKey$ = "X"
GOSUB AltKeys
CASE -46
TestKey$ = "C"
GOSUB AltKeys
CASE -47
TestKey$ = "V"
GOSUB AltKeys
CASE -48
TestKey$ = "B"
GOSUB AltKeys
CASE -49
TestKey$ = "N"
GOSUB AltKeys
CASE -50
TestKey$ = "M"
GOSUB AltKeys
CASE -75 'left arrow
IF Pointer% THEN
IF Pointer% > 1 THEN 'if Pointer is greater than Count
DECR Pointer%
ELSE
Pointer% = Count%
END IF
ELSE
Pointer% = Count%
END IF
CASE -77 'right arrow
IF Pointer% THEN
IF Pointer% < Count% THEN 'if Pointer is greater than Count
INCR Pointer%
ELSE
Pointer% = 1
END IF
ELSE
Pointer% = 1
END IF
CASE 13 'enter key
IF Pointer% THEN
SelectionMade% = 1
END IF
CASE 65 TO 90,97 TO 122
TestKey$ = UCASE$(Ky$)
GOSUB AltKeys
CASE 27 'Esc key
SelectionMade% = 1
HPointer% = 0: Marker% = 0
Pointer% = 0: HiLight% = 0
CASE ELSE
SelectionMade% = 1
HPointer% = 0: Marker% = 0
Pointer% = 0: HiLight% = 0
BEEP
END SELECT
LOOP
EXIT SUB
'----------------------------------------------------------------------------
AltKeys:
Ptr% = 1
FOR i% = 1 TO Count%
IF INSTR(Choices$(i%),"@") > 0 THEN
HotKeyPos% = INSTR(Choices$(i%),"@")
HotKey$ = UCASE$(MID$(Choices$(i%),(HotKeyPos% + 1),1))
IF HotKey$ = TestKey$ THEN
Pointer% = i%
Ptr% = 0
SelectionMade% = 1
END IF
END IF
NEXT i%
IF Ptr% THEN
Pointer% = 0: HiLight% = 0: Marker% = 0: HPointer% = 0
SelectionMade% = 1
BEEP
END IF
RETURN
'----------------------------------------------------------------------------
PrintRoutine:
IF HiLight% THEN
OnOff% = Hotkey%
ELSE
OnOff% = BarFG%
END IF
IF Mouse% THEN HideCursor
FOR k% = 1 TO Count% 'this looks for the pointer
IF k% = Pointer% THEN 'and calculates the column
IF k% > 1 THEN 'to start printing the hi lite
Total% = 0
FOR l% = 1 TO (k% - 1)
INCR Total%,(Gap%)
Fixedup$ = REMOVE$(Choices$(l%),"@")
Total% = Total% + LEN(Fixedup$)
NEXT l%
Colpos% = Total% + (Gap% + 1)
ELSE
Colpos% = Gap% + 1
END IF
COLOR HiFG%,HiBG%
LOCATE MenuRow%,Colpos%,0
Position%(k%) = Colpos%
Marker% = Colpos%
HPointer% = Pointer%
PRINT REMOVE$(Choices$(k%),"@");
ELSE
IF k% > 1 THEN 'this determines the column
Total% = 0 'position for printing the
FOR l% = 1 TO (k% - 1) 'rest of the menu
INCR Total%,(Gap%)
Fixedup$ = REMOVE$(Choices$(l%),"@")
Total% = Total% + LEN(Fixedup$)
NEXT l%
Colpos% = Total% + (Gap% + 1)
ELSE
Colpos% = Gap% + 1
END IF
LOCATE MenuRow%,Colpos%,0
Position%(k%) = Colpos%
IF INSTR(Choices$(k%),"@") > 0 THEN
HotKeyPos% = INSTR(Choices$(k%),"@")
Fixedup$ = REMOVE$(Choices$(k%),"@")
COLOR BarFG%,BarBG%
PRINT Fixedup$;
LOCATE MenuRow%,Colpos% + (HotKeyPos% - 1),0
COLOR OnOff%,BarBG%
HotKey$ = MID$(Choices$(k%),(HotKeyPos% + 1),1)
PRINT HotKey$;
ELSE
COLOR BarFG%,BarBG%
PRINT Choices$(k%);
END IF
END IF
NEXT k%
IF Pointer% = 0 THEN
IF HiLight% = 0 THEN
EndAddress% = MenuRow% * 160
StartAddress% = EndAddress% - 160
DEF SEG = &HB800
BarSave$ = PEEK$(StartAddress%,EndAddress%)
END IF
END IF
RETURN
'----------------------------------------------------------------------------
END SUB