home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
MENU-DD.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
17KB
|
309 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME MENU-DD .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 ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
****************************************************************************
** ** ** ** ** ** ** ** ** GENERAL CHIT-CHAT ** ** ** ** ** ** ** ** ** **
****************************************************************************
This menu system can easily handle a whole program or a simple little pop-up
event/box. Getting all the data DIMed and set just right can be a real pain
but there is just no way to make it much easier and still keep all the power
that is available. The best deal would be to use this file as a test program
for your data and once it's correct transfer it into your program or drop it
all into a file.
Five arrays are used to import data into the menu and they are discussed
below. In addition there are two strings that control the "look" and "feel"
of the menu and provide your program with many possibilities, one of which,
should meet any requirement(s) you need.
By changing the border type, centering, wrap, and auto-open values you can
create your own best set-up. These, and other values, are carried into the
menu by a single string.
TYPE TempTYPE '┌─────────────────────────
BarRow AS BYTE '│ row # for bar items
BarCol AS BYTE '│ starting column of bar items
BarCols AS BYTE '│ # of columns for bar items
Center AS BYTE '│ >0 center bar items on row =0 left justify
BrdrOn AS BYTE '│ border style 0 = none, 1 = underline line, 2 = box
AutoOpen AS BYTE '│ automatically open DD boxes when BAR item is hot
WrapOn AS BYTE '│ wrap cursor selections if > last goto first, etc.
ShdoOn AS BYTE '│ shadow effect for DD boxes SEE: DrawTShadow
Sattr AS BYTE '│ if .ShdoOn what attribute to use
END TYPE '└────────────────────────────────────────────────
DIM tDDsetup AS TempTYPE
M$(0) = tDDsetup + "[ tMain Menup ]"
BYTE #1 Top row for BAR MENU
If BYTE #7 = 2 then this row would be the top of the box
else the actual BAR MENU would reside here
BYTE #2 Left most column for BAR MENU
BYTE #3 Total number of columns for BAR MENU
BYTE #4 Center BarMenu Items?
defines how the BAR MENU items will be printed
IF Center? > 0 then it will appear like PB's menu
IF Center? = 0 then it would look like:
[ File Edit Search Run Compile Options Debug ]
where the items fill in from the left like GUI menus
BYTE #5 Bar Menu border style
defines how many rows are used for the BAR MENU
0 = like PB's menu
1 = a single line "──────────" under the items
this one is good for pop-up boxes, etc.
2 = a full box around the menu ( like old TurboBasic's )
in this case you can also send a "TITLE" that will be printed
top row, center
Which ever you choose the dropdown boxes will have a simple
box around them and the action is automatic so you don't need
to send any further boxing commands except for color attrs.
BYTEs #10-> Title for BarMenu box IF BYTE #6 = 2
BYTE #6 Automatically open 1st DropDown menus?
determines how the first dropdowns will open.
IF = 0 then the user will have to press <ENTER> or <DOWN>
to open the dropdowns
IF > 0 then the first dropdowns will automatically open
when the BAR ITEM is "HOT" and there is a dropdown
to be had. This is PB's style.
This value also affects how <ESC> is handled
BYTE #7 Wrap selection bar?
handles the "UP", "DOWN", "LEFT", "RIGHT" keys and what happens when
the first or last item is currently selected and a further command is
incoming to go "past" the boundary.
If > 0 then it will act like PB's menu
If = 0 then the key-press will be ignored
BYTE #8 Shadow style on DropDown menu boxes:
BYTE #9 Shadow color attribute
SEE: DrawTShadow
NOTE: The menu expects the shadow to be in position #1 (lower right)
so if you use position #2 your 1st DDs will have to start in
column 3 or greater. Positions 3 and 4 will not look good as
the shadow will encroach upon the Bar Menu.
BYTEs #10 and up SEE: BYTE #5
Why call 2 routines for each menu?
MenuDD only gets the environment ready to act, and prints the BAR MENU on
the screen. If the area the BAR MENU will reside over needs to be saved
it will be up to you to capture it. SEE: fTBoxREAD$ This allows your
program to continue on until the user elects to go to the menu, like in
GUI programs. [HELP] [ABOUT] (remember?) Then, when/if the menu is actually
required you simply call fMenuDD$ and instantly you're in business! You can
start at any "ON" item so, if your user presses <ALT>H (for example) you
could automatically jump to item #2 which would be the 1st item under the
first BAR ITEM. fMenuDD$ returns the actual key-press that was used to exit
the menu: <ENTER> or one of your choosing, and the selection made is carried
in a parameter variable SelNo? Upon exiting, all dropdowns are closed but
the BAR MENU is still up and the set-up is unchanged so it can be called
again and again with no other calls to MenuDD. So, for those small programs,
that can be handled by a single menu structure, you would only call MenuDD
only once.
NOTE: <ENTER> is the only key that will automatically exit the menu unless
you provide other keys for this function
<ENTER> is also the only key that will return a selection value >0
<ESC> only closes opened dropdowns and will not exit the menu unless
it has been sent as a "HOT KEY" and then only
1) if Auto-Open is "OFF" and the user is at the BAR MENU
2) if Auto-Open is "ON" and the user is in the 1st DropDown
****************************************************************************
** ** ** ** ** ** ** ** ** ** RULES OF ENGAGEMENT ** ** ** ** ** ** ** ** **
****************************************************************************
The menu is controlled by 4 arrays:
M$() item names VALUES: NULL or not
LEVEL 1 items can not be NULL
All NULL items are replaced with a "├─────┤"
in the pulldown menus
ALL NULL items must be "OFF" ie: O?(x) = 0
H$() help line VALUES: NULL or not
IF UBOUND(H$(1)) < UBOUND(M$(1)) THEN Help is OFF
LINE 25 is stored and then used to Tprint the
help string(s) to that line
MAX Visible length of H$(x) = 78
IF H$(x) = "" AND Help is active LINE 25 is blank
L?() item levels VALUES: the level of the item 1,2,3,etc
1 = bar items
2 = first pull-down under bar item
O?() ON/OFF flag VALUES: 0 = OFF : 1-255 = ON
OFF items are deemed to be childless
They may, in fact, have children but the
kids are inaccessible as the item is OFF
To change status of a level 1 item you must reopen
the menu
The 1st item of the BAR MENU MUST BE ACTIVE!
A?() Color Attributes
Each level of the menu has it's own set of attributes.
A?() can be DIMed A?(0:5,0:LastL?) or
A?(0:5,1:LastL?) or
A?(1:5,0:LastL?) or
A?(1:5,1:LastL?)
** "HOT KEYS" are not mandatory
** Embedded color commands SHOULD NOT precede a HOT KEY declaration, if any.
ie: "_File" won't work
"_File: MYFILE.BAS" is just fine
"File" is ok too
** It is assumed that all arrays are equally DIMed ( except H$() )
** An incoming Starting selection number CANNOT be in an OFF status.
a test is made and if this happens then the starting item will revert
to item #1
IF, however, you access a child of an OFF item unpredictable results
will occur. ie: it doesn't seem to crash but.........
$ENDIF
$STRING 32
$STACK 16384
$INCLUDE "DAS-NB01.INC"
$INCLUDE "DAS-NB02.INC"
$INCLUDE "DAS-NBT1.INC"
$INCLUDE "DAS-NBT3.INC"
COLOR 7, 0, 0
CLS
Ioff$ = "xOFF" ' 2 little ON/OFF menu messages
Ion$ = "uON " ' notice that we're changing attributes too
'┌───────┬────────────────────────────────────────> ATTRIBUTES
'│ │ ┌──────┬───────────────────────────────> ON/OFF switches
'│ │ │ │ ┌──────┬──────────────────────> ITEM Levels
'│ │ │ │ │ │ ┌───────┬────────────> ITEM strings
'│ │ │ │ │ │ │ │ ┌───────┬──> HELP strings
'A?(1,1)=0 : O?(xx)=0 : L?(xx)=0 : M$(xx)="" : H$(xx)=""
DIM A?(5,4), O?(26), L?(26), M$(26), H$(26)
O?(01) = 1 : L?(01) = 1 : M$(01) = "Bar Item _1"
O?(02) = 101 : L?(02) = 2 : M$(02) = "DropDown _1B1 " + Ioff$
O?(03) = 102 : L?(03) = 2 : M$(03) = "_Bar Item 2 " + Ion$
O?(04) = 103 : L?(04) = 2 : M$(04) = "DropDown _3B1"
O?(05) = 0 : L?(05) = 2 : M$(05) = ""
O?(06) = 104 : L?(06) = 2 : M$(06) = "DropDown _5B1"
O?(07) = 1 : L?(07) = 2 : M$(07) = "DropDown _6B1 u"
O?(08) = 105 : L?(08) = 3 : M$(08) = "DropDown _1B1"
O?(09) = 106 : L?(09) = 3 : M$(09) = "DropDown _2B1"
O?(10) = 107 : L?(10) = 3 : M$(10) = "_Finished <ALT> X"
O?(11) = 0 : L?(11) = 1 : M$(11) = "Bar Item _2"
O?(12) = 108 : L?(12) = 2 : M$(12) = "DropDown _1B2"
O?(13) = 109 : L?(13) = 2 : M$(13) = "DropDown _2B2"
O?(14) = 1 : L?(14) = 2 : M$(14) = "DropDown _3B2 u"
O?(15) = 110 : L?(15) = 3 : M$(15) = "DropDown _1B2"
O?(16) = 111 : L?(16) = 3 : M$(16) = "DropDown _2B2"
O?(17) = 1 : L?(17) = 3 : M$(17) = "DropDown _3B2 "
O?(18) = 112 : L?(18) = 4 : M$(18) = "DropDown _1B2"
O?(19) = 113 : L?(19) = 4 : M$(19) = "DropDown _2B2"
O?(20) = 114 : L?(20) = 2 : M$(20) = "DropDown _4B2"
O?(21) = 115 : L?(21) = 1 : M$(21) = "_No Children"
O?(22) = 1 : L?(22) = 1 : M$(22) = "Bar Item _4"
O?(23) = 116 : L?(23) = 2 : M$(23) = "DropDown _1B4"
O?(24) = 1 : L?(24) = 2 : M$(24) = "DropDown _2B4 u"
O?(25) = 117 : L?(25) = 3 : M$(25) = "DropDown _1B4"
O?(26) = 118 : L?(26) = 3 : M$(26) = "DropDown _2B4"
'┌──────────────────────
FOR X? = 1 TO UBOUND( H$(1) ) '│ some dummy help
H$(X?) = USING$("THIS IS HELP FOR ITEM N° ##",X?) '│ messages or you can
NEXT '│ REDIM H$(0) if you
'REDIM H$(0) '│ with no help at all
'┌───────────────┴─────────────────────
FOR L? = 1 TO 4 '│ each level of the menu can have
FOR A? = 1 TO 5 '│ a different color scheme
READ A?(A?,L?) '│ this is a little extra work but only
NEXT '│ once and the data is easily stored
NEXT '│ in a file
' Norm 1stL SELb OFF Brdr '│ A? can be DIMed A?(0,0) or A?(1,1)
DATA 113, 116, 079, 120, 112 '├> BAR MENU ( level 1 )
DATA 113, 116, 031, 120, 112 '├> 1st DropDowns ( level 2 )
DATA 31, 27, 113, 25, 30 '├> 2ed DropDowns ( level 3 )
DATA 31, 27, 113, 25, 30 '├> 3rd DropDowns ( level 4 )
'└─────────────────────────────────────
'M$(0) carries┌────────────────────────> top row
'several byte │ ┌──────────────────────> left most column
'values into │ │ ┌────────────────────> number of columns
'the function │ │ │ ┌───────────────────> center bar items
'and saves a │ │ │ │ ┌────────────────> border type (0, 1 or 2)
'group of │ │ │ │ │ ┌──────────────> wrap selection bar
'parameters! │ │ │ │ │ │ ┌────────────> auto-open ON/OFF
' │ │ │ │ │ │ │ ┌──────────> shadow style
' │ │ │ │ │ │ │ │ ┌────────> shadow attribute
' │ │ │ │ │ │ │ │ │ ┌───> menu title
' │ │ │ │ │ │ │ │ │ │
' │ │ │ │ │ │ │ │ │ │
M$(0) = CHR$(001,001,080,000,001,001,000,001,008) + "[ tMain Menup ]"
Exet$ = CHR$(000,045,027,000) ' <ALT>X and <ESC>
TBoxFILL 1, 1, 25, 80, 177, 25
DO
IF TopRow$ = "" THEN
TopRow$ = fTmenuDDopen$( M$(), L?(), O?(), A?(), Exet$ )
END IF
'┌───────────────────────────────
SelNo? = fTmenuDD?( M$(), H$(), SelNo? ) '│ call the menu function but
O$ = INKEY$ '│ read key-press
IF O$ = CHR$(000,045) THEN GOTO ENDofPROG '│ <ALT>X was pressed
M$ = USING$(" YOU SELECTED: ## ",SelNo?) '│ our little message
SELECT CASE O?(SelNo?) '│
CASE 101 '│ This is an ON/OFF item on a
IF MID$( M$(2), 18, 3 ) = "OFF" THEN '│ DropDown so we don't have
MID$( M$(2), 16, 5 ) = Ion$ '│ to recall MenuDD after the
ELSE '│ change
MID$( M$(2), 16, 5 ) = Ioff$ '│
END IF '│
CASE 102 '│ This selection turns Bar Item2
TopRow$ = "" '│ ON/OFF so we have to recall
IF O?(11) = 0 THEN '│ MenuDD to have the change
O?(11) = 1 '│ take effect.
MID$( M$(3), 16, 5 ) = Ioff$ '│
SelNo? = 11 '│ Here we make Bar Item2 the
ELSE '│ "hot" selection as it is
O?(11) = 0 '│ now in an "ON" status
MID$( M$(3), 16, 5 ) = Ion$ '│ But here it is "OFF" so not
END IF '│
CASE 0, 107 : EXIT LOOP '│ <ESC> returns a 0 so we could
CASE ELSE '├┐ use another CASE for it ──┐
Tprint 20, 1, M$, 112 '│└ all other menu selections │
DELAY 2 '│ do their own thing(s) │
TBoxFILL 20, 1, 1, 18, 177, 25 '│ │
END SELECT '│ or │
LOOP UNTIL SelNo? = 0 '│ this would work also <──────┘
'├───────────────────────────────
TBoxWRITE TopRow$ '│ NOTE how I used values >100
END '│ for the ON/OFF on those items
'│ that could return from the
ENDofPROG: '│ function and 1 for those items
CLS '│ that could not return. This
PRINT "YOU PRESSED <ALT>X" '│ allows me to have a SELECT
END '│ CASE in 101,102,103 order
' ───────────────────────────────────────────┴───────────────────────────────
FUNCTION fGetKey% LOCAL PUBLIC
WHILE NOT INSTAT : WEND
FUNCTION = CVI( INKEY$ + CHR$(0) )
END FUNCTION