home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / oop.swg / 0014_OOPMENU.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  69 lines

  1. {
  2. Menus in TV are instances of class tMenuBar, accessed via Pointer Type
  3. pMenuBar. A Complete menu is a Single-linked list, terminated With a NIL
  4. Pointer. Each item or node is just a Record that holds inFormation on
  5. what the node displays and responds to, and a Pointer to the next menu
  6. node in the list.
  7.  
  8. I've written out a short bit of TV menu code that you can Compile and
  9. play With, and then you can highlight parts that you don't understand
  10. when you send back your reply.
  11. }
  12.  
  13. Program TestMenu;
  14.  
  15. Uses
  16.   Objects, Drivers, Views, Menus, App;
  17.  
  18. Const
  19.   cmOpen  = 100;  (* Command message Constants *)
  20.   cmClose = 101;
  21.  
  22. Type
  23.   pTestApp = ^tTestApp;
  24.   tTestApp = Object(tApplication)
  25.     Procedure InitMenuBar; Virtual;    (* Do-nothing inherited method *)
  26.   end;                                 (* which you override          *)
  27.  
  28. (* Set up the menu by filling in the inherited method *)
  29. Procedure tTestApp.InitMenuBar;
  30. Var
  31.   vRect : tRect;
  32.  
  33. begin
  34.   GetExtent(vRect);
  35.   vRect.B.Y := vRect.A.Y + 1;
  36.   MenuBar := New(pMenuBar, Init(vRect, NewMenu(
  37.     NewSubMenu('~F~ile', hcNoConText, NewMenu(
  38.       NewItem('~O~pen', 'Alt-O', kbAltO, cmOpen, hcNoConText,
  39.       NewItem('~C~lose', 'Alt-C', kbAltC, cmClose, hcNoConText,
  40.       NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoConText,
  41.       NIL)))),
  42.     NewSubMenu('~E~dit', hcNoConText, NewMenu(
  43.       NewItem('C~u~t', 'Alt-U', kbAltU, cmCut, hcNoConText,
  44.       NewItem('Cop~y~', 'Alt-Y', kbAltY, cmCopy, hcNoConText,
  45.       NewItem('~P~aste', 'Alt-P', kbAltP, cmPaste, hcNoConText,
  46.       NewItem('C~l~ear', 'Alt-L', kbAltL, cmClear, hcNoConText,
  47.       NIL))))),
  48.     NewSubMenu('~W~indow', hcNoConText, NewMenu(
  49.         NewItem('Ca~s~cade', 'Alt-S', kbAltS, cmCascade, hcNoConText,
  50.       NewItem('~T~ile', 'Alt-T', kbAltT, cmTile, hcNoConText,
  51.       NIL))),
  52.     NIL))))
  53.   ))
  54. end;
  55.  
  56. Var
  57.   vApp : pTestApp;
  58.  
  59. begin
  60.   New(vApp, Init);
  61.   if vApp = NIL then
  62.     begin
  63.       WriteLn('Couldn''t instantiate the application');
  64.       Exit;
  65.     end;
  66.   vApp^.Run;
  67.   vApp^.Done;
  68. end.
  69.