home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
MENU-HOT.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
12KB
|
261 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME MENU-HOT.DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
fTmenuHOT% ( I$(1), LastI% H$(1), O?(1), T%(1), Exet$, SN% )
There are 4 arrays that control fTmenuHOT%. Each of them should be
DIMed from element ZERO and, in there own way, control a particular
part of the function.
I$() Element 0 holds the command string for the menu.
All other items hold the items of the menu.
LastI% IF < 1 THEN LastI% = UBOUND( I$(1) )
H$() IF UBOUND( H$(1) ) > 0 THEN
fHelpLine$ is used to save the area used for item help
item by item help is display with each selection
help area is restored
ELSE
No help is displayed
END IF
O?() This array MUST equal or greater in elements to LastI%
IF O?(i%) > 0 THEN
The item is considered to be in an "ON" status
The value of O?(i%) is the ASCII value of the "HOT-KEY" or
search key (the 1st character of the item)
ELSE
The item is considered to be in an "OFF" status and the user
will not be able to select that/those item(s)
END IF
T%() LastT% = UBOUND( T%(1) )
IF LastT% = 0 THEN
No "tagging" is preformed and the function returns the "hit"
item number
ELSE
The function returns the number of items that are ON
<F-4> will turn all items "OFF"
<F-9> will turn all items "ON"
IF LastT% => LastI% THEN
All items can be tagged (ON/OFF) and <ENTER> will exit
Each item has an array element that will either be ZERO/OFF
or > ZERO/ON
ELSEif LastT% < LastI%
T%(i%) = Tagged Item N° in the order they were tagged
IF LastT% < LastI% THEN
The function automatically exits when the array is full
<F-9> is not functional in this case
END IF
END IF
END IF
Exet$ holds any key-presses you require to exit the function
ie: Exet$ = CHR$(027,0,0,068) would exit on <ESC> and <F-10>
Sn% The element number to start at
ZERO will result in the 1st "ON" item being selected
The following TYPE is loaded from I$(0) with the following results:
' ┌───────────────────┐
'┌┤ GENERAL MENU TYPE ├───────────────────────────
TYPE TmenuTYPE '│└───────────────────┘
SetUp AS BYTE '│ if 0 then TmenuSETUP will be called
Row AS BYTE '│ starting row ( box border if .Brdr > 0 )
Col AS BYTE '│ starting col ( box border if .Brdr > 0 )
Iwide AS BYTE '│ MAX item width
IRows AS BYTE '│ N° if item rows 1, 2, 3, 4 etc
ICols AS BYTE '│ N° of item columns 1, 2, 3, 4 etc
Vert AS BYTE '│ Vertical YES/NO
Wrap AS BYTE '│ Wrap ON/OFF
HKs AS BYTE '│ 0 = NONE : 1 = ALPHA : 2 = HOT-KEY : >2 = TAG
'─────────────────────────┤
AttrN AS BYTE '│ Normal
AttrL AS BYTE '│ Letter HI-light or Tagged Item
AttrB AS BYTE '│ select Bar
AttrO AS BYTE '│ "OFF" item
'─────────────────────────┤
Srow AS BYTE '│ all 3 of these are computed by fTmenuBox$ when
Scol AS BYTE '│ .Srow > 0 else if .Srow = 0 then ignored
Srows AS BYTE '│ values used by fTmenuHOT% if .Srow > 0
Aattr AS BYTE '│ arrow attribute if > 0 else Battr used
'─────────────────────────┤
Brdr AS BYTE '│ Border style SEE: TBoxDRAW
Battr AS BYTE '│ Border attribute
Shdo AS BYTE '│ Shadow style SEE: DrawTShadow
Sattr AS BYTE '│ Shadow attribute
Tpos AS BYTE '│ Title Position
END TYPE '└──────────────┤ 22 bytes ├──────────────────────
─────────────────────────────────────────────────────────────────────────────
───────────────────────── SOME OTHER HAPPENINGs ─────────────────────────────
─────────────────────────────────────────────────────────────────────────────
The function(s) return either:
1) A positive number if <ENTER> was pressed for the selected item
2) A negative number if a "bail out" key was pressed for the "hot" item
3) The number of Tagged items if .HKs > 2
AND
The exiting key-press is in the keyboard buffer
ie: G$ = INKEY$ will gather the key-press for you
IF any of the first 5 bytes of I$(0) = CHR$(0) THEN TmenuSETUP will be
called automatically
NOTE: if HOT KEYS are used remember:
TmenuSETUP also changes/creates the correct printable item STRs
so it cannot be called twice unless the items have been reset to
the "_Hello World" style
A menu can have any, all, or any combination of O?(), T%(), and H$():
To make life just a bit easier there are a series of functions that
automatically allow for menu calling without DIMing the "unused" arrays.
NOTE: Even though fTmenuHOT% is a fully functional routine I would be
extremely hard pressed to conceive of a single menu that would/could
require all of it's properties to be in use at the same time.
Instead, it would be advisable to use either the ready made CALLs as
shown below or to introduce your own "specialized" routines.
eg: A menu that allowed "T"agging would normally have all it's
items in an "ON" status and would generally not use the item by
item "H"elp lines.
In these function names: "H" = item by item Help
"O" = item by item On/Off switching
"T" = item tagging
the presence or absence of these letters explain the required/automatic
portions thereof.
fTmenu% ( I$(), LastI%, H$, Exet$, Sn% )
fTmenuH% ( I$(), LastI%, H$(), Exet$, Sn% )
fTmenuHO% ( I$(), LastI%, H$(), O?(), Exet$, Sn% )
fTmenuHT% ( I$(), LastI%, H$, T%(), Exet$, Sn% )
fTmenuO% ( I$(), LastI%, H$, O?(), T%(), Exet$, Sn% )
fTmenuOT% ( I$(), LastI%, H$, O?(), T%(), Exet$, Sn% ) (questionable use)
fTmenuT% ( I$(), LastI%, H$, T%(), Exet$, Sn% )
fTmenuHOT% ( I$(), LastI%, H$(), O?(), T%(), Exet$, Sn% ) (questionable use)
In the functions above H$ (as a single variable) will cause the help line
to be saved / printed with H$ / and restored upon exiting
─────────────────────────────────────────────────────────────────────────────
──────────────────────────── A SAMPLE PROGRAM ───────────────────────────────
─────────────────────────────────────────────────────────────────────────────
Below is a simple program that will allow you to test the properties
of this menu system.
NOTE: the TYPE is used here to simplify the process but in a working
program I$(0) would hold this information
I$(0) = CHR$(0,0,0,5,3,0,0,0,0,1,31,27,113,25,1,23,1,8,2) + "TITLE"
NOTE: if you are going to use "HOT KEYS" then you will not want to
have more than 26 items (normally)
$endif
$STACK 32766
$STRING 8
$ERROR ALL ON
$INCLUDE "DAS-NB01.INC"
$INCLUDE "DAS-NB02.INC"
$INCLUDE "DAS-NBT1.INC"
$INCLUDE "DAS-NBT3.INC"
LastI% = 50
HelpOn? = 1
ScrnBackGrnd? = 112
ExetKey$ = CHR$(027,000)
DIM tM AS TmenuTYPE
tM.Setup = 0 ' = 0 for automatic set-up & centering
tM.Row = 0 ' 1st row ( will center if 0 )
tM.Col = 0 ' 1st column ( will center if 0 )
tM.IWide = 0 ' will compute automatically
tM.IRows = 9 ' N° of items down
tM.ICols = 3 ' N° of items across
tM.Vert = 0 ' 0 = Col/Row order 1 = Row/Col order
tM.Wrap = 1 ' Wrap ON/OFF 0, 1, 2
tM.HKs = 4 ' 0 = no search 1 = Alpha 2 = HOT KEYs >2 = Tag
tM.Srow = 1 ' if > 0 then TsliderV is employed (computed)
tM.Scol = 0 ' (computed)
tM.Srows = 0 ' (computed)
tM.Aattr = 30 ' if > 0 attr of arrow(s) else = Battr
tM.AttrN = 031 ' Normal Item : HiWhite/Blue
tM.AttrL = 027 ' HotKey : HiCyan/Blue
tM.AttrB = 113 ' Selection Bar : Blue/White
tM.AttrO = 025 ' Off/Tagged Item(s) : HiBlue/Blue
tM.BrDr = 1 ' Box Border (0 = no border) SEE: TBoxDRAW
tM.Battr = 023 ' Box Color Attribute : White/Blue
tM.Shdo = 1 ' Shadow type SEE: DrawShadow
tM.Sattr = 008 ' Shadow Color Attribute : Grey/Black
tM.Tpos = 4 ' Title Position SEE: MakeTbox
Title$ = "DEMO MENU"
' ───────────────────────────────────────────────────────────────────────────
' ──────────── create required arrays, etc. ────────────────────────────────
' ───────────────────────────────────────────────────────────────────────────
DIM I$(LastI%) : I$(0) = tM + Title$
DIM O?(LastI%) : QfillBarr O?(1), 1, LastI%
O?(23) = 0
IF HelpOn? = 0 THEN DIM H$(0) ELSE DIM H$(LastI%)
IF tM.HKs > 2 THEN DIM T%(LastI%) ELSE DIM T%(0)
IF tM.HKs = 2 THEN S$ = "_"
FOR I? = 1 TO LastI%
I$(I?) = S$ + CHR$(I?+64) + " Selection"
IF HelpOn? THEN H$(I?) = "THIS IS HELP FOR SELECTION " + CHR$(I?+64)
NEXT
' ───────────────────────────────────────────────────────────────────────────
' ──────────── run the menu routine ────────────────────────────────────────
' ───────────────────────────────────────────────────────────────────────────
DO
TBoxFILL 1, 1, 25, 80, 177, ScrnBackGrnd?
ClearKeyboard
S% = ABS( S% )
S% = fTmenuHOT%( I$(), LastI%, H$(), O?(), T%(), ExetKey$, S% )
G$ = INKEY$
CLS
IF G$ = CHR$(013) THEN
IF UBOUND( T%(1) ) = 0 THEN
PRINT USING "You selected N° ###"; S%
ELSE
PRINT USING "You selected ### items"; S%
END IF
DELAY 2
ELSE
CLS
PRINT "You pressed <ESC> to bail out!
EXIT LOOP
END IF
LOOP
END
' ────────────────────────────────────────────────────────────────────────────
FUNCTION fGetKey% () LOCAL PUBLIC '┌────────────────────────────────────
'│centralize all incoming key presses
WHILE NOT INSTAT : WEND '│rem this line out if used with EVENTs
FUNCTION = CVI(INKEY$+CHR$(0)) '│read next key press
'│
END FUNCTION '└────────────────────────────────────
' ────────────────────────────────────────────────────────────────────────────