home *** CD-ROM | disk | FTP | other *** search
- MENDOW21.INC (Window & Menuing Routines for TURBO PASCAL)
- Written By Amram Elye Dworkin
- Lead PC Programmer
- Potomac ADP.
- (301) 984-5533 (voice)
- 10-01-86
-
- The MENDOW21.INC Routines Allow A User To Easily Create WINDOWS & MENUS.
- Both The Windows & the Menus have a pleasing double line border around them.
- MENDOW21 also allows Windowed Data Entry Screen Generation, but that feature
- is not fully implemented as of this writing. Heres How You Use MENDOW21.INC:
-
- 1) Include the MENDOW21.INC file in your system. IT SHOULD BE GLOBAL.
- 2) Place call for Procedure DetermineDisplay at beginning of your
- code.
-
- e.g. BEGIN
- DetermineDisplay;
- ;
- ; your program goes here
- ;
- END.
- ==============================================================================
- 3) If you want MENUS:
-
- a) Define a variable in your program as type 'WindowPtr'
-
- e.g VAR
- MyWindow : WindowPtr;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- b) Define a variable in your program as type 'INTEGER'
-
- e.g. VAR
- MyMenuOption : INTEGER;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- c) Define a variable in your program as type 'DrawRec'
-
- e.g. VAR
- MyMenu : DrawRec;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- d) Define the following fields in the menu variable:
- Count = Number Of Menu Options (2..50)
- Default = The Default Menu Options (1..Count)
- Title = Title Of Menu ( STRING[74] )
- DrawRecAr[1].Col = Top Left Column Of Menu (1..77)
- DrawRecAr[1].Row = Top Left Row Of Menu (1.22)
- DrawRecAr[2].Col = Bottom Right Column of Menu (3..80)
- DrawRecAr[2].Row = Bottom Right Row Of Menu (3..24)
- DrawRecAr[n].DrawDat = Each Item To Be Listed In The Menu
- n = Item Number
-
- e.g. MyMenu.Count := 3;
- MyMenu.Default := 1;
- MyMenu.Title := 'My Favorite Menu';
- MyMenu.DrawRecAr[1].Col := 3;
- MyMenu.DrawRecAr[1].Row := 4;
- MyMenu.DrawRecAr[2].Col := 50;
- MyMenu.DrawRecAr[2].Row := 8;
- MyMenu.DrawRecAr[1].DrawDat := 'Option 1 To List';
- MyMenu.DrawRecAr[2].DrawDat := 'Option 2 To List';
- MyMenu.DrawRecAr[3].DrawDat := 'Option 3 To List';
- OR
- WITH MyMenu DO
- BEGIN
- Count := 3;
- Default := 1;
- Title := 'My Favorite Menu';
- DrawRecAr[1].Col := 3;
- DrawRecAr[1].Row := 4;
- DrawRecAr[2].Col := 50;
- DrawRecAr[2].Row := 8;
- DrawRecAr[1].DrawDat := 'Option 1 To List';
- DrawRecAr[2].DrawDat := 'Option 2 To List';
- DrawRecAr[3].DrawDat := 'Option 3 To List';
- END;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- e) To Call The Menu Up use the Function Make_Menu;
- The Function Has 3 Paramaters. They are:
- Menu Record ( type DrawRec )
- Window Pointer ( type WindowPtr )
- Clear menu Flag ( type Boolean )
- NOTE1: On Exit From Function Make_Menu the Integer Variable
- to the left of the := sign will contain the number of
- the option chosen. The rest is UP TO YOU.
- NOTE2: The Clear Menu Flag determines whether the menu is
- cleared off the screen after an option is chosen
- NOTE3: The WindowPtr Variable Must be present but is only used
- if the Clear Menu Flag is set to FALSE.
- NOTE4: Since the addition of Moving Menus the Menu Record var
- may be changed on exit from Make_Menu the. The Draw
- RecAr[1..2].Row & DrawRecAr[1..2].Col vars will be
- changed to the new menu positions if the menu has been
- moved.
-
- e.g MyMenuOption := Make_Menu(MyMenu,MyWindow,TRUE);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- f) If you chose FALSE for the Clear Menu Flag, you may delete the
- window from within you program by the Procedure DRestoreWindow;
- This procedure has 3 paramteres. They are:
- Window Pointer ( type WindowPtr )
- Top Column Offset (Always use 0)
- Top Row Offset (Always use 0)
-
- e.g. DRestoreWindow(MyWindow,0,0);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- COMPLETE MENU EXAMPLE
- ---------------------
-
- PROGRAM MenuDemo;
-
- (*$IMENOWS.INC *)
- VAR
- MyMenu : DrawRec;
- MyWindow : WindowPtr;
- MyMenuOption : INTEGER;
-
- BEGIN
- DetermineDisplay;
- WITH MyMenu DO
- BEGIN
- Count := 3;
- Default := 1;
- Title := MyFavoriteMenu;
- DrawRecAr[1].Col := 3;
- DrawRecAr[1].Row := 4;
- DrawRecAr[2].Col := 50;
- DrawRecAr[2].Row := 8;
- DrawRecAr[1].DrawDat := 'Option 1 To List';
- DrawRecAr[2].DrawDat := 'Option 2 To List';
- DrawRecAr[2].DrawDat := 'Option 3 To List';
- END; { WITH MyMenu }
-
- MyMenuOption := Make_Menu(MyMenu,MyWindow,TRUE);
- CASE MyMenuOption OF
- 0 : WRITELN('<ESC> Pressed. No Option Chosen');
- 1 : WRITELN('Option 1 Chosen');
- 2 : WRITELN('Option 2 Chosen');
- 3 : WRITELN('Option 3 Chosen');
- ELSE
- WRITELN('This Should Never Happen');
- END; { CASE MyMenuOption }
- END. { MenuDemo }
- ==============================================================================
- 3) If You Want Windows:
-
- a) Define a variable in you program as type 'BOOLEAN'
-
- e.g MyErrCode : BOOLEAN;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- b) Define a variable in your program as type 'WindowPtr'
-
- e.g. MyWindow : WindowPtr;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- c) Create a window by calling the Function Make_Window. This
- function has 7 parameters. They are:
- Top Column (1..74)
- Top Row (1..22)
- Bottom Column (3..80)
- Bottom Row (4..25)
- Window Title ( STRING[74] )
- Window Pointer ( type WindowPtr )
- Clear Window Flag ( type Boolean )
-
- NOTE1: The Title MUST present even if it is just ''.
- NOTE2: The Clear Window Flag determines whether the screen INSIDE
- the window is to be cleared.
- NOTE3: The BOOLEAN value returned will be TRUE if an error was
- encountered on creation of the window and FALSE if no
- error was found.
-
-
- e.g. MyErrCode := Make_Window(4,4,50,12,'My Test Window',
- MyWindow,TRUE);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- d) Once the window is in place you may use it just like it was
- a mini-screen. GOTOXY()'s will work as if the top right
- corner of the window is (0,0). CLRSCR's will clear only the
- window, etc..
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- e) To delete the window from the screen you must use the Function
- DRestoreWindow. This funciton has 3 parameters. They are:
- Window Pointer ( type WindowPtr )
- Top Column Offset (Always use 0)
- Top Row Offset (Always use 0)
- NOTE1: If you use parameters other than '0' for the offsets the
- old screen will be restored onto a different part of the
- screen. (Might be useful to you but I've never used that
- feature.)
-
- e.g. DRestoreWindow(MyWindow,0,0);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- COMPLETE WINDOW EXAMPLE
- -----------------------
-
- PROGRAM WindowDemo;
-
- (*$IMENDOW21.INC *)
-
- VAR
- MyWindow : WindowPtr;
- MyErrCode : BOOLEAN;
-
- BEGIN
- DetermineDisplay;
- MyErrCode := Make_Window(10,8,55,12,'My Test Window',
- MyWindow,TRUE);
- GOTOXY(1,1);
- WRITELN('This is the top of the WINDOW');
- READLN;
- CLRSCR; { This will clear only the WINDOW }
- WRITELN('Hit <RETURN> To Exit Window');
- READLN;
- DRestoreWindow(MyWindow,0,0);
- END. { WindowDemo }
-
-
- ==============================================================================
-
- NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES NOTES
-
- 1) When using the Make_Menu Option the Up & Down cursor control Arrow keys
- will move the highlighted bar up and down the options. The bar will wrap
- around (from last option to first option & vice versa). To select an
- menu option simply press the <RETURN> key when the bar is on the high-
- lighted option. To exit menu without choosing an option press the <ESC>
- key.
-
- 2) When in the Make_Menu Option, the system will automatically check the first
- character of your options. If they are non repeating then simply pressing
- that character is the same as moving the highlighted bar to that option and
- pressing <RETURN>. If the characters are repeated then you must use the
- space bar.
- e.g. Read A Record } since none of these options starts with
- Write A Record } the same letter you could simply type
- Clear A Record } 'R','W', or 'C' for desired action.
-
- Read A Record } Since 'Concat' & 'Clear' both start with
- Concat A Record } 'C' you would have to use the cursor to
- Clear A Record } move highlight bar to desired action.
-
- 3) You can, if you wish, put more than one window up on the screen at once
- simply by calling the Make_Window function multiple times in you program.
- If you do this you must use the RestoreWindow (rather than the DRestore.
- Window) procedure to restore all but the first window you opened. The
- first window must be restored using the DRestoreWindow procedure. This is
- because the Make_Window & Make_Menu functions use the heap to save the old
- screens and the DRestoreWindow procedure frees up the space that was being
- used. This means if you don't clear your windows in the order you created
- them AND you use DRestoreWindow rather that RestoreWindow you will screw
- things up in a big way. However, if you do not use the DRestoreWindow
- procedure to clear the first window you called, the heap will never be
- cleared and a lot of good memory will be wasted.
-
- 4) Along the same lines as Note 3 is the observation that if you put variables
- on the heap then use the DRestoreWindow procedure your variables will be
- lost as the heap pointer is restored to its position before the creation of
- the window. WATCH OUT FOR THIS AS IT IS A BITCH TO FIND WHILE DEBUGGING !
-
- 5) The MENDOW21.INC File has some other relatively interesting functions and
- procedures that might be worth looking at if you have the time and energy.
- I find, however, that I do not usually need anything except the Make_Menu
- & Make_Window fuctions to make my life complete (Oh. And A Bad Woman, of
- course.)
-
- 6) Much as I would like to say I wrote all of these routines myself the truth
- is that I based them on a set of rather mundane (but brilliant) primitives
- that someone (who shall remain nameless until he/she calls me at
- (301)984-5533) wrote & put out onto the the BBS's. To him/her I tip my
- hat and say between the two of us we make beautiful music.
-
- 7) These routines & my descriptions look like they are a bitch but in reality
- this stuff is beyond simple to use. LOOK AT THE EXAMPLES AT THE END OF
- EACH MAJOR SECTION for an idea on their ease of use.
-
- 8) I would like to hear from you on how to improve these routines. If you
- have a good idea (or if you improve them yourself) drop me a note, or the
- updated programs on the COLOSSUS II Bulletin board (301)428-9044. Leave
- the message to AMI DWORKIN or call me on my voice line (301)984-5533 from
- 9:30-5:00 M-F. (The Name is Pronounced Ah-Mee not Ay-Mee. Yes I am male.)
-
- NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW
-
- 1) The Menu Positions must now be defined in the MenuRec variable (they were
- explicitly stated in the Make_Menu Call in version 1.0). This change is
- to allow for the new MOVABLE MENUs feature.
-
- 2) The MOVABLE MENUs feature allows you to move a menu around the screen in
- order to see what was underneath. To do so a new set of keys have been
- added to the accepted menu keys. The 'Up Arrow, Down Arrow, ESC, &
- Carriage Return' set have been expanded to allow the use of the 'INSERT'
- key. The insert key puts the user in the MOVE MENU mode.
-
- 3) When in the MOVE MENUs mode there are 16 keys available to the user. These
- are:
- Up Arrow : Moves the menu up a row
- Down Arrow : Moves the menu down a row
- Left Arrow : Moves the menu left a column
- Right Arrow : Moves the menu right a column
- Pg Up : Moves the menu to the top of the screen at the
- current column position
- Pg Down : Moves the menu to the bottom of the screen at the
- current column position
- '1'..'9' : Changes the movement factor to number of row/cols
- specified (if you typed '9' the arrow keys would
- move the menu 9 spaces in their re-
- pective directions)
- Ins : Exits user from MOVE MENU mode back into SELECT
- MENU OPTION mode
-
- 4) I have gotten a few comments that an example file might be nice so I
- have added the EXMENDOW.PAS file for this purpose.
-
- END NEW-END NEW-END NEW-END NEW-END NEW-END NEW-END NEW-END NEW-END NEW
-
-
-
- Revision History
-
- MENDOWS : 11-01-85
- Original Menu/Window driving primitives
-
- MENDOW10 : 4-01-86
- Program specified menuing
- Multiple windowing
- Letter triggered menu options
- Heap Management trimmed down (transparent to user)
-
- MENDOW20 : 9-01-86 (not released into PD)
- Bug preventing use of single letter menu option 'P' fixed
- Row/Column Specs Moved to within menu record
- Simple 4 arrow Cursror controlled menu movement added/tested
- New Keyboard Read Routines Added (transparent to user)
-
- MENDOW21 : 10-01-86 (released to PD)
- Minor Bugs in Movable Menus fixed
- Pg Up, Pg Dn, '1'..'9' features added to Movable Menus
- Row Column Specs set to new menu positions if Menu Move used
- Executable Example Added to the MENDOWnn.ARC
- Bug causing windows to be drawn 1 line to long and Restored without the
- bottom line fixed
-
-
- FUTURE THOUGHTS
- Some time soon (when I have the time) I hope to:
- Complete Windowed Data Entry Screen Generation
- Add MOVE WINDOWS Option
- Allow Option on Window Framing (i.e. Single/Double/No Line Borders)
- Allow Multi Columned Menus (don't hold you breath on this one)
-
- ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY ENJOY
-
- Acknowledgements: I would like to thank
- The unknown author of WINDOS.PAS on who's Window Generation primitives I have
- based this whole include system.
- The equally unknown author (I wish these guys/gals would leave their names on
- the software they make PD) of RDIBMKBD.PAS who's Keyboard Read routine I
- have used to replace mine.
- THANKS Y'ALL. You write a mean PD Include.
-
- And most of all to David Bryant without who's help this would have been em-
- inently possible (he didn't help a bit) but who happens to be one HEAVY
- DUTY professional and my best friend.
-
- Amram E. Dworkin - Programmer At Large