home *** CD-ROM | disk | FTP | other *** search
- Program NestTTT5_Demo_1;
-
- {Similar to NestDem1 except a user hook was added}
-
- uses CRT,FastTTT5,DOS,WinTTT5,KeyTTT5,StrnTTT5,NestTTT5;
-
-
- var
- Hyphens,
- EndProgram: Boolean;
- Main_Menu,
- Long_menu,
- File_Menu, {dummy menu is a short cut to represent}
- Utility_Menu, {all the other menus that would be used}
- Dummy_Menu:Nest_Menu; {in a large system. }
-
-
- Procedure SetUp_Menus;
- begin
- Initialize_Menu(Main_Menu,'Sprint',0,0); {14}
- Initialize_Menu(File_Menu,'File',22,12);
- Initialize_Menu(Utility_Menu,'Utility',19,13);
- Initialize_Menu(Long_Menu,'Potpourri',19,10);
- Initialize_Menu(Dummy_Menu,'A N Other',0,0);
- end; {of proc SetUp_Menus}
-
- Procedure Define_Main_Menu;
- {}
- begin
- Add_Topic(Main_Menu,'File * Alt-F',true,#161,101,@File_Menu);
- Add_Topic(Main_Menu,'Edit' ,true,#0 ,0,@Dummy_Menu);
- Add_Topic(Main_Menu,'-' ,true,#0 ,0 ,nil);
- Add_Topic(Main_Menu,'Insert' ,true,#0,103,@Dummy_Menu);
- Add_Topic(Main_Menu,'Typestyle' ,true,#0,104,@Dummy_Menu);
- Add_Topic(Main_Menu,'Style' ,true,#0,105,@Dummy_Menu);
- Add_Topic(Main_Menu,'Layout' ,true,#0,0,@Dummy_Menu);
- Add_Topic(Main_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Main_Menu,'Print' ,false,#0,107,@Dummy_Menu);
- Add_Topic(Main_Menu,'Window' ,true,#0,108,@Dummy_Menu);
- Add_Topic(Main_Menu,'Utilities * Alt-U' ,true,#150,109,@Utility_Menu);
- Add_Topic(Main_Menu,'Customize' ,true,#0,110,@Dummy_Menu);
- Add_Topic(Main_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Main_Menu,'Quit' ,true,#173,999,nil);
- end; {of proc Define_Main_Menu}
-
- Procedure Define_File_Menu;
- {}
- begin
- Add_Topic(File_Menu,'New' ,true,#0,201,nil);
- Add_Topic(File_Menu,'Open' ,true,#0,202,nil);
- Add_Topic(File_Menu,'Close' ,true,#0,203,nil);
- Add_Topic(File_Menu,'Insert' ,true,#0,204,nil);
- Add_Topic(File_Menu,'-' ,true,#0,0,nil);
- Add_Topic(File_Menu,'Save' ,true,#0,205,nil);
- Add_Topic(File_Menu,'Write As' ,true,#0,206,nil);
- Add_Topic(File_Menu,'Revert to Saved',true,#0,207,nil);
- Add_Topic(File_Menu,'-' ,true,#0,0,nil);
- Add_Topic(File_Menu,'Translate' ,true,#0,208,nil);
- Add_Topic(File_Menu,'File Manager' ,true,#0,209,nil);
- Add_Topic(File_Menu,'Pick from List' ,true,#0,210,nil);
- end; {of proc Define_File_Menu}
-
- Procedure Define_Long_Menu;
- {}
- begin
- Add_Topic(Long_Menu,'bottom of File' ,true,#0,71,nil);
- Add_Topic(Long_Menu,'Bottom of screen',true,#0,72,nil);
- Add_Topic(Long_Menu,'case Rotate' ,true,#0,73,nil);
- Add_Topic(Long_Menu,'case Switch' ,true,#0,74,nil);
- Add_Topic(Long_Menu,'center Tab' ,true,#0,75,nil);
- Add_Topic(Long_Menu,'Decimal tab' ,true,#0,76,nil);
- Add_Topic(Long_Menu,'delete Line' ,true,#0,77,nil);
- Add_Topic(Long_Menu,'delete Word' ,true,#0,78,nil);
- Add_Topic(Long_Menu,'delete Sentence',true,#0,79,nil);
- Add_Topic(Long_Menu,'delete Paragraph',true,#0,80,nil);
- Add_Topic(Long_Menu,'delete End of line' ,true,#0,81,nil);
- Add_Topic(Long_Menu,'reformat Document',true,#0,82,nil);
- Add_Topic(Long_Menu,'eXchange cases' ,true,#0,73,nil);
- Add_Topic(Long_Menu,'lookup Zip' ,true,#0,74,nil);
- Add_Topic(Long_Menu,'Underline' ,true,#0,75,nil);
- Add_Topic(Long_Menu,'Italicize' ,true,#0,76,nil);
- Add_Topic(Long_Menu,'go Home' ,true,#0,77,nil);
- Add_Topic(Long_Menu,'Cancel undo' ,true,#0,78,nil);
- end; {of proc Define_Long_Menu}
-
- Procedure Define_Utility_Menu;
- {}
- begin
- Hyphens := true;
- Add_Topic(Utility_Menu,'Spelling' ,true,#0,901,nil);
- Add_Topic(Utility_Menu,'Hyphenation * On ' ,true,#0,902,nil);
- Add_Topic(Utility_Menu,'Thesaurus' ,true,#0,903,nil);
- Add_Topic(Utility_Menu,'Glossary' ,true,#0,904,nil);
- Add_Topic(Utility_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Utility_Menu,'Arrange-Sort',true,#0,905,nil);
- Add_Topic(Utility_Menu,'Line Drawing',true,#0,906,nil);
- Add_Topic(Utility_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Utility_Menu,'Potpourri *',true,#0,907,@Long_Menu);
- Add_Topic(Utility_Menu,'QuickCard' ,true,#0,908,nil);
- Add_Topic(Utility_Menu,'Macros' ,true,#0,909,nil);
- Add_Topic(Utility_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Utility_Menu,'Back Up Demo *',true,#0,910,nil);
- end; {of proc Define_Utility_Menu}
-
- Procedure Define_Dummy_Menu;
- {}
- begin
- Add_Topic(Dummy_Menu,'Ignite' ,true,#0,801,nil);
- Add_Topic(Dummy_Menu,'Check Boosters',true,#0,802,nil);
- Add_Topic(Dummy_Menu,'Fire Retros' ,true,#0,803,nil);
- Add_Topic(Dummy_Menu,'Shutdown' ,true,#0,804,nil);
- Add_Topic(Dummy_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Dummy_Menu,'Launch' ,true,#0,805,nil);
- Add_Topic(Dummy_Menu,'Remove Suit',false,#0,806,nil);
- Add_Topic(Dummy_Menu,'-' ,true,#0,0,nil);
- Add_Topic(Dummy_Menu,'Abort Mission',true,#0,807,nil);
- Add_Topic(Dummy_Menu,'Panic' ,true,#0,808,nil);
- end; {of proc Define_Dummy_Menu}
-
- Procedure Paint_Screen;
- {makes the screen look like a word processor}
- begin
- ClearText(1,1,80,25,lightgray,blue);
- WriteAt(1,25,black,lightgray,
- Padleft('Press F10 or / for menu. Alt-X to quit',80,' '));
- Plainwrite(1,1,
- '[ T 1 2 3 4 5 6 7 ]');
- Plainwrite(5,3,'Imagine you have written a wordprocessing program and you want');
- PlainWrite(5,4,'to give the program a full and powerful menu system. The NestTTT');
- PlainWrite(5,5,'unit will give you all the power you need and more!');
- PlainWrite(5,7,'For starters, press the F10 key or the slash key, and roam around');
- Plainwrite(5,8,'the menu a little. Features include: capital letter selection, ');
- Plainwrite(5,9,'optional HotKey selection, point and shoot (with full mouse support),');
- Plainwrite(5,10,'non-selectable topics, line separators, auto positioning of menus and');
- PlainWrite(5,11,'sub menus. The list goes on and on...');
- PlainWrite(5,13,'When a menu "system" has been defined, it''s easy to call up any of the');
- PlainWrite(5,14,'nested menus and bypass all the parent menus. For example, press Alt-U');
- Plainwrite(5,15,'while no menu is on display - the Utility menu will automatically pop-up');
- Plainwrite(5,16,'at the top level.');
- PlainWrite(5,18,'All of the topics that are highlighted with an asterisk "*" are designed');
- Plainwrite(5,19,'to illustrate some of the features of the menu. For example, select the');
- Plainwrite(5,20,'Utility option from the main menu, or press Alt-U, and select the Potpourri');
- Plainwrite(5,21,'topic. This is a menu that exceeds the no. of display lines - the menu');
- Plainwrite(5,22,'will automatically scroll the topics. Also, select the Hyphenation topic');
- Plainwrite(5,23,'to see a topic that can switch between two or more displays.');
- end; {of proc Paint_Screen}
-
- Procedure Dummy_Activity(var Finish:byte);
- {Saves writing a lot of real life procedures for the demo}
- begin
- TempMessageBox(20,5,white,red,3,'Just imagine I did something!');
- Finish := DontClear; {return to same place in the menu}
- end; {of proc Dummy_Activity}
-
- {$F+}
- Procedure Menu_Hook(var Ch:char; Code : integer);
- begin
- Case Ch of
- #173: begin
- Reset_StartUp_Mode;
- Halt;
- end;
- end;
- end;
- {$F-}
-
-
- {$F+}
- Procedure Action(Var Code: integer; var Finish:byte);
- {This is the main procedure the controls the execution of all
- the menu options.}
- begin
- Case Code of
- 902: begin
- If Hyphens then
- Modify_Topic_name(Utility_Menu,2,'Hyphenation * Off')
- else
- Modify_Topic_name(Utility_Menu,2,'Hyphenation * On ');
- Hyphens := not Hyphens;
- Finish := RefreshTopic;
- end;
- 910: begin
- TempMessageBox(20,5,white,red,3,'We will back up one level');
- Finish := ClearCurrent;
- end;
- 999: begin
- sound(1000);delay(2);nosound;
- Endprogram := true;
- Finish := ClearAll;
- end;
- else Dummy_Activity(Finish);
- end; {case}
- end; {of proc Action}
- {$F-}
-
- Procedure Menu_Loop;
- {}
- var Ch : char;
- begin
- EndProgram := false;
- Repeat
- Ch := Getkey;
- Case Ch of
- #178, {Alt-M}
- '/',
- #196 : Show_Nest(Main_menu); {F10}
- #161 : Show_Nest(File_Menu); {Alt F}
- #150 : Show_Nest(Utility_menu); {Alt U}
- #027,
- #173 : Endprogram := true; {Alt X}
- end;
- Until EndProgram;
- end; {of proc Menu_Loop}
-
-
- begin {The main program}
- ClearText(1,1,80,25,white,black);
- SetUp_menus;
- Define_Main_Menu;
- Define_File_menu;
- Define_Utility_Menu;
- Define_Dummy_Menu;
- Define_Long_Menu;
- Nest_Despatcher := @Action;
- With NTTT do {optionally modify default colors etc.}
- begin
- AllowEsc := false;
- LeftSide := false;
- BoxFCol := black;
- BoxBCol := lightgray;
- CapFCol := white;
- BacCol := lightgray;
- NorFCol := Black;
- LoFCol := blue;
- HiFCol := Lightgray;
- HiBCol := blue;
- LeftChar := ' ';
- RightChar := ' ';
- end;
- Nest_UserHook := @Menu_Hook;
- Paint_Screen;
- Menu_Loop;
- Delete_All_Topics(Utility_Menu);
- Delete_All_Topics(File_Menu);
- Delete_All_Topics(Main_Menu);
- Delete_All_Topics(Dummy_Menu);
- Reset_StartUp_Mode;
- end.
-