home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progpas
/
tegl6b.arj
/
INTROPAK.EXE
/
lha
/
MENUDEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-06-26
|
16KB
|
394 lines
{-----------------------------------------------------------------------------}
{ TEGL Windows ToolKit II }
{ Copyright (C) 1990, TEGL Systems Corporation }
{ All Rights Reserved. }
{-----------------------------------------------------------------------------}
{$M 16384, 64000, 655000 }
{$I switches.inc}
USES
Dos,
crt,
errorlog,
TGraph,
{$IFNDEF TEGLDEMO}
teglfnt2,
{$ENDIF}
TeglFont,
FastGrph,
TEGLIntr,
TEGLMenu,
TEGLUnit,
virtmem,
teglmain;
const
BeepTimes : word = 3;
DropClick : word = 0;
DropClick1 : boolean = TRUE;
DropClick2 : boolean = FALSE;
DropClick3 : boolean = FALSE;
{ This event provides the standard exit. }
{$F+}
Function ExitOption(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
BEGIN
AbortExit('Menu keys test');
END;
{ This event is only added by the AddEntry event. When clicked on, this
event drops its own option menu entry from the menu.}
{$F+}
Function DeleteEntry(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var OM : optionmptr;
begin
{returns the related Option Menu chain}
OM := GetFSOM(fs);
{Drops the current option entry, using the
ms^.clicknumber as the entry number}
DropOptionEntry(OM,ms^.clicknumber);
deleteEntry := 1;
end;
{ AddEntries demonstrates how you can retrieve the current Option Menu and
its related Option entry and insert another option entry into the current
option menu.}
{$F+}
Function AddEntries(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var OM : optionmptr;
begin
{returns the related Option Menu chain}
OM := GetFSOM(fs);
{sets the Option entry position in preparation of inserting another
entry. If the option entry number is 0, DefineOptions will create
an entry at the beginning of the chain. }
SetCurrentOEPos(OM,ms^.clicknumber-1);
{use the standard DefineOptions()
DefineOptionsRadio()
DefineOptionsCheck()
or DefineOptionsSub()
to create a new entry}
DefineOptions(OM,'~D~elete Entry ',TRUE,deleteentry);
AddEntries := 1;
end;
{ You can change the action of the menu bar to drop down menus in which the
menu drops with a passing of the mouse. "dropclick" is an automatic variable
which is by the menu routines before calling this event. The value in the
"dropclick" is either 0 or 1 as passed by the DefineOptionsRadio() below. }
{$F+}
Function DropClickToggle(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
begin
{resets the complete mouseclick chain stored in a FS to MSClick or
MSSense. MSClick is a boolean value of 0, and MSSense is 1.}
ResetMSClickSense(fs^.relatedstack,boolean(dropclick));
DropClickToggle := 1;
end;
{ Acknowledge is a simple event that aknowledges that it has been called
by beeping. The number of beeps is controlled by the variable Beeptimes;
which is an automatic variable updated by the menu routines. For more
info on automatic variables, look at the menu defines for DefineOptionsRadio(). }
{$F+}
Function Acknowledge(fs:ImageStkPtr; ms: MsClickPtr) : Word;
{$F-}
var i : word;
BEGIN
{Use WaitforUserRelease to wait for the user to release either the key
or mouse button before proceeding. Waiting for the user to release the
mouse button is not necessary in a menu since the menu waits for you
to release before calling the event. However if you use the same event
for icons or other defined mouse click areas, this event may be
called several times before the button is release.}
WaitForUserRelease;
for i:=1 to BeepTimes do
begin
Beep(1000,1,150);
Beep(500,1,50);
end;
Acknowledge := 1;
END;
{ Defining the option menus may be defined within a procedure or at the
MAIN part of the program. }
procedure CreateMenuBarEvents;
VAR om1,om2,om3,om4,om5,om6 : optionmptr;
begin
{StandardFont is set with the initialization of TEGL in Fastgrph.
When creating Option menus, the proportional flag is saved with
each option menu, therefore if you wish to have non-proportional
menus, you must set the proportional flag off before creating
the option menu.}
setproportional(True);
{OM1 is a standard menu with each entry attached to the Acknowledge event.
The dashed line is used to indicate a line separator between topics.}
{$IFNDEF TEGLDEMO}
standardfont := @ROMAN25;
{$ELSE}
standardfont := @font14;
{$ENDIF}
OM1 := CreateOptionMenu(standardfont);
DefineOptions(OM1,'DeskTop Info...',TRUE,Acknowledge);
DefineOptions(OM1,'--',FALSE,nilunitproc);
DefineOptions(OM1,'Calculator',TRUE,Acknowledge);
DefineOptions(OM1,'Clock',TRUE,Acknowledge);
DefineOptions(OM1,'Snapshot',TRUE,Acknowledge);
{OM2 uses a combination of several features offered in TEGLMENU.
The first is the ">" symbol in Open. This symbol tells the option
menu (when listing) to right justify the remaining portion of the
text.
The curly brackets around F1^ will display F1^ in tiny font.
The tilde ~ character indicates the underscoring of the enclosed
characters, of which the first character becomes the default keyboard
activator.
Global key clicks like Alt-x and ctrl-F1 must be defined using the
definelocal and defineglobal key clicks. The menu routine only
recognizes alphabets and numeric characters when attaching
local key clicks. }
SetMenuMargin(0);
OM2 := CreateOptionMenu(standardfont);
DefineOptions(OM2,'Open >{ctrl-F1}',TRUE,Acknowledge);
DefineOptions(OM2,'Show ~I~nfo...',FALSE,Acknowledge);
DefineOptions(OM2,'--',FALSE,nilunitproc);
DefineOptions(OM2,'~N~ew Folder...',FALSE,Acknowledge);
DefineOptions(OM2,'~C~lose',FALSE,Acknowledge);
DefineOptions(OM2,'Close ~W~indow',FALSE,Acknowledge);
DefineOptions(OM2,'--',FALSE,nilunitproc);
DefineOptions(OM2,'~F~ormat...',TRUE,Acknowledge);
DefineOptions(OM2,'To ~O~utput',TRUE,Acknowledge);
DefineOptions(OM2,'{ALT-X}~Q~uit',TRUE,exitoption);
DefineGlobalKeyClickArea(NIL,NIL,$082d,false,exitoption);
DefineGlobalKeyClickArea(NIL,NIL,$003b,false,Acknowledge);
{ setommaxwidth(om2,50); }
{ DefineOptionsRadio provides a method of toggling between options or
group of options. The controlling variable is updated automatically
by the menu handler before the your event is called. You can use
"Nilunitproc" if you don't need any other activity after the user
has toggle the appropriate menu choices.
The parameters 1,2,3,4 in DefineOptionsRadio is the value that is used
to compare against the variable BeepTimes in determing whether or not
the entry is prefixed with a check mark. When defining radio
entries, be sure to set the menu margins to 10 or more pixels to
allow room for the check mark symbol.}
SetMenuMargin(10);
OM3 := CreateOptionMenu(standardfont);
DefineOptionsRadio(OM3,'~C~lick Menus',TRUE,DropClickToggle,0,DropClick);
DefineOptionsRadio(OM3,'~D~rop Menus',TRUE,DropClickToggle,1,DropClick);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsCheck(OM3,'~A~-Toggle',TRUE,nilunitproc,DropClick1);
DefineOptionsCheck(OM3,'~B~-Toggle',TRUE,nilunitproc,DropClick2);
DefineOptionsCheck(OM3,'~C~-Toggle',TRUE,nilunitproc,DropClick3);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsCheck(OM3,'~S~ound On',TRUE,Acknowledge,BeepStatus);
DefineOptions(OM3,'-',FALSE,nilunitproc);
DefineOptionsRadio(OM3,'Beep ~1~ time ',TRUE,Acknowledge,1,BeepTimes);
DefineOptionsRadio(OM3,'Beep ~2~ times',TRUE,Acknowledge,2,BeepTimes);
DefineOptionsRadio(OM3,'Beep ~3~ times',FALSE,Acknowledge,3,BeepTimes);
DefineOptionsRadio(OM3,'Beep ~4~ times',TRUE,Acknowledge,4,BeepTimes);
{Two other unique features of TEGLMENU is used in this option menu. The
Addentries event is added as a menu entry, which when activated, inserts
another option entry above the current entry. The inserted entry is a
delete option entry, which when activated, will delete itself from the
option menu. Refer to the events above to see how this is done...
The Delete entry at the bottom of the menu demonstrates that even the
last entry can be deleted.
The defineoptionsSub() is introduced here, allowing the linking of
several option menus including itself for a recursive chaining of menus.
Again watch for the menumargins. A margin must be provided on the right
side for displaying the submenu symbol (). In the example below, the
largest entry is longer than the defineoptionsSub entry, thereby
allowing us to use a menu margin of 5 without the submenu symbol
overlapping with our option entry text.}
SetMenuMargin(5);
OM4 := CreateOptionMenu(standardfont);
DefineOptions(OM4,'~A~dd More Entries ',TRUE,Addentries);
DefineOptions(OM4,'Chance ~I~nfo...',TRUE,Acknowledge);
DefineOptions(OM4,'~F~rame Test Write...',TRUE,Acknowledge);
DefineOptions(OM4,'~C~redit Option.',TRUE,Acknowledge);
DefineOptions(OM4,'~D~os Shell...',TRUE,Acknowledge);
DefineOptionsSub(OM4,'~S~ort Options',TRUE,OM3);
DefineOptionsSub(OM4,'More ~O~ptions',TRUE,OM2);
DefineOptionsSub(OM4,'~R~ecursive',TRUE,OM4);
DefineOptions(OM4,'--',FALSE,nilunitproc);
DefineOptions(OM4,'Select Nothing...',TRUE,Acknowledge);
DefineOptions(OM4,'Show Memory...',TRUE,Acknowledge);
DefineOptions(OM4,'Show ~B~utton Status',TRUE,Acknowledge);
DefineOptions(OM4,'Set ~M~ouse Sensivity',TRUE,Acknowledge);
DefineOptions(OM4,'--',FALSE,nilunitproc);
DefineOptions(OM4,'~A~dd More Entries ',TRUE,Addentries);
DefineOptions(OM4,'Delete ~E~ntry ',TRUE,deleteentry);
{TEGL automatically converts menus to menus with sliders when the
number of entries displayed is greater than the screen size. You
can adjust the display number to a smaller size}
SetOMDisplaynum(om4,15);
{The last option menu demonstrates the ability to create long menu
entries. The current maximum is set to 40 characters per menu entry.
You can change this by changing the constant MaxTextStringSize which is
defined at the top of the TEGLMENU module.
Notice the use of the | character in |Types |Variables |Attributes and
|Objects. This is the tab expansion character allowing simple formating
on the menu. }
OM5 := CreateOptionMenu(standardfont);
DefineOptions(OM5,'~S~tandard Unit Dependencies',TRUE,Acknowledge);
DefineOptions(OM5,'The System Unit',TRUE,Acknowledge);
DefineOptions(OM5,'The Printer Unit',TRUE,Acknowledge);
DefineOptions(OM5,'--',FALSE,nilunitproc);
DefineOptions(OM5,'The Dos Unit',TRUE,Acknowledge);
DefineOptions(OM5,'Constants |Types |Variables',TRUE,Acknowledge);
DefineOptions(OM5,'Methods |Attributes |Objects',TRUE,Acknowledge);
DefineOptions(OM5,'File |Streams |TEGL',TRUE,Acknowledge);
DefineOptions(OM5,'~A~dd More Entries ',TRUE,Addentries);
DefineOptions(OM5,'--',FALSE,nilunitproc);
DefineOptions(OM5,'Interrupt Support Procedures',TRUE,Acknowledge);
DefineOptions(OM5,'Disk Status Functions',TRUE,Acknowledge);
DefineOptions(OM5,'File-Handling Procedures and functions',TRUE,Acknowledge);
SetTEGLFont(standardfont);
CreateBarMenu(0,0,getmaxx);
SetBarMenuMargin(24);
OutBarOption(' ~D~esk ',OM1);
setmousebutton(stackptr^.msptr,2);
OutBarOption(' ~F~ile ',OM2);
OutBarOption(' ~V~iew ',OM3);
OutBarOption(' A ~S~econd Chance ',OM4);
OutBarOption(' Standard ~U~nits ',OM5);
OutBarEvent(' ~B~eep ',Acknowledge);
ResetMSClickSense(stackptr,boolean(dropclick));
{Define the ESC key to simulate a function key for escaping from menus}
DefineglobalKeyClickArea(stackptr,NIL,$0001,FALSE,nilunitproc);
{If you don't need it later, you can use the following to drop the ESC}
{DropKeyClick(NIL,$0001,nilunitproc); }
end;
BEGIN
easytegl;
{There are a number of variables that are used to control the visual
aspects of the menus. The MC table stores the setup values for the
menu in which you can create a similar table with your default values
and simply assign the whole table to MC.
As an example, a HERC_MC table has been created for your in TEGLMENU. If
you are using a Hercules monitor you can use the following statement
to set your menu defaults immediately.
IF Getmaxcolor < 2 then (* set B/W parms *)
MC := HERC_MC;
If you only need to set a few default parameters, here is a quick summary
of the functions that are available that you may use to control your menu
displays....
SetOptionMenuColors(activecolor,inactivecolor:Word);
... Sets the active and inactive text entry colors within the menu.
The default colors is set to Black and lightgray respectively.
SetOptionMenuBorderColor(Color:Word);
... Sets the Border color around the menu.
The default border color is black.
SetBarTextColor(Color:Word);
... Sets the text color on the bar menu. Default is Black.
SetBarMenuMargin(margin:Word);
... Sets the left margin on the Bar menu. Useful if you wish to display an
icon at the upper left corner of the bar menu. The default is an
indentation of 16 pixels from the left part of the bar menu.
SetBarMenuColor(Color:Word);
... Sets the Bar menu Color. Default is white.
SetBarBorderOff;
... Sets the Border off. Default is on.
SetBarBorderColor(Color:Word);
... Sets the Bar Border color and turns the border on. Default is black.
SetHideSubMenu(on_off:Boolean);
... You can choose whether to hide the option menu after the user makes a
selection. The default is the menu remains shown until the event
completes its task and returns.
SetMenuMargin(pixsize:word);
... Sets the option menu margin. The default is 10 pixels before the
option entry text. A minimum of 10 pixels is needed for check mark
option entries.
SetMenuTabsize(charnum:word);
... Sets the number of characters for tab expansion. A tab is represented
by the | character. The default is 8 characters.
SetSeparatorLine(mask:word);
... Sets the mask for the line separator. A dotted line is $EE and a
solidline is $FF. The default is a solidline.
SetInactiveJaggies(on_off:Boolean);
... Inactive option entries may be displayed with jagged characters. The
default is off.
SetOMSliderSize(width,height:word);
... Sets the width and height of the slider buttons. Minimum button size
is 9x9}
SetOMSliderSize(15,12);
SetHideSubMenu(FALSE);
SetMenuTabsize(12);
{ SetSeparatorLine($EE);} {creates dashed separator lines}
CreateMenuBarEvents;
{Sets the ctrlbreak key to the exit event}
SetCtrlBreakFS(ExitOption);
TEGLSupervisor;
END.