home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tutorial / tvguid03.cpp < prev    next >
C/C++ Source or Header  |  1998-01-19  |  2KB  |  80 lines

  1. /*---------------------------------------------------------*/
  2. /*                                                         */
  3. /*   Turbo Vision 1.0                                      */
  4. /*   TVGUID03 Demo Source File                             */
  5. /*   Copyright (c) 1991 by Borland International           */
  6. /*                                                         */
  7. /*---------------------------------------------------------*/
  8.  
  9. #define Uses_TApplication
  10. #define Uses_TKeys
  11. #define Uses_TRect
  12. #define Uses_TMenuBar
  13. #define Uses_TSubMenu
  14. #define Uses_TMenuItem
  15. #define Uses_TStatusLine
  16. #define Uses_TStatusItem
  17. #define Uses_TStatusDef
  18. #define Uses_TDeskTop
  19. #include <tvision/tv.h>
  20.  
  21. const int cmMyFileOpen = 200; // assign new command values
  22. const int cmMyNewWin   = 201;
  23.  
  24.  
  25. class TMyApp : public TApplication
  26. {
  27.  
  28. public:
  29.     TMyApp();
  30.     static TStatusLine *initStatusLine( TRect r );
  31.     static TMenuBar *initMenuBar( TRect r );
  32.     // new for tvguid03
  33. };
  34.  
  35. TMyApp::TMyApp() :
  36.     TProgInit( &TMyApp::initStatusLine,
  37.                &TMyApp::initMenuBar,
  38.                &TMyApp::initDeskTop
  39.              )
  40. {
  41. }
  42.  
  43. TStatusLine *TMyApp::initStatusLine(TRect r)
  44. {
  45.     r.a.y = r.b.y - 1;     // move top to 1 line above bottom
  46.     return new TStatusLine( r,
  47.         *new TStatusDef( 0, 0xFFFF ) +
  48.         // set range of help contexts
  49.             *new TStatusItem( 0, kbF10, cmMenu ) +
  50.             *new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit ) +
  51.             // define an item
  52.             *new TStatusItem( "~Alt-F3~ Close", kbAltF3, cmClose )
  53.             // and another one
  54.         );
  55. }
  56.  
  57. // new for tvguid03:
  58. TMenuBar *TMyApp::initMenuBar( TRect r )
  59. {
  60.  
  61.     r.b.y = r.a.y + 1;    // set bottom line 1 line below top line
  62.     return new TMenuBar( r,
  63.         *new TSubMenu( "~F~ile", kbAltF )+
  64.             *new TMenuItem( "~O~pen", cmMyFileOpen, kbF3, hcNoContext, "F3" )+
  65.             *new TMenuItem( "~N~ew",  cmMyNewWin,   kbF4, hcNoContext, "F4" )+
  66.             newLine()+
  67.             *new TMenuItem( "E~x~it", cmQuit, cmQuit, hcNoContext, "Alt-X" )+
  68.         *new TSubMenu( "~W~indow", kbAltW )+
  69.             *new TMenuItem( "~N~ext", cmNext,     kbF6, hcNoContext, "F6" )+
  70.             *new TMenuItem( "~Z~oom", cmZoom,     kbF5, hcNoContext, "F5" )
  71.         );
  72. }
  73.  
  74. int main()
  75. {
  76.     TMyApp myApp;
  77.     myApp.run();
  78.     return 0;
  79. }
  80.