home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / texted / vedapp.cpp < prev    next >
C/C++ Source or Header  |  1999-02-18  |  5KB  |  182 lines

  1. //=======================================================================
  2. //@V@:Note: This file generated by vgen V1.00 (12:04:59 PM 23 Sep 1996).
  3. //    vedapp.cpp:    Source for vedApp class
  4. //=======================================================================
  5.  
  6. #include "vedapp.h"        // Header file
  7.  
  8. //=========================>>> vedApp::vedApp <<<==========================
  9.   vedApp::vedApp(char* name, int sdi, int h, int w) : vApp(name, sdi, h, w)
  10.   {
  11.     // Constructor
  12.  
  13.    _vedCmdWin = 0;
  14. #ifdef DEVEL
  15.    _emulation = See;
  16. #else
  17.    _emulation = Generic;
  18. #endif
  19.   }
  20.  
  21. //=========================>>> vedApp::vedApp <<<==========================
  22.   vedApp::~vedApp()
  23.   {
  24.     // Desstructor
  25. //   if (_vedCmdWin)
  26. //    delete _vedCmdWin;
  27.   }
  28.  
  29. //=====================>>> vedApp::NewAppWin <<<==========================
  30.   vWindow* vedApp::NewAppWin(vWindow* win, char* name,
  31.     int w, int h, vAppWinInfo* winInfo)
  32.   {
  33.     vAppWinInfo* awinfo = winInfo;
  34.     char *appname = name;
  35.  
  36.     if (!*name)
  37.       {
  38.      appname = "V Text Editor";        // Default name
  39.       }
  40.     
  41.     UserDebug1(Build,"vedApp::NewAppWin(%s)\n",appname);
  42.  
  43.     // Create the first window using provided CmdWindow
  44.  
  45.     _vedCmdWin = (vedCmdWindow*) win;
  46.     if (!_vedCmdWin)
  47.       {
  48.     _vedCmdWin = new vedCmdWindow(appname, w, h);
  49.       }
  50.  
  51.     if (!awinfo)
  52.     awinfo = new vAppWinInfo(appname);
  53.  
  54.     return vApp::NewAppWin(_vedCmdWin, appname, w, h, awinfo);
  55.   }
  56.  
  57. //============================>>> vedApp::Exit <<<===========================
  58.   void vedApp::Exit(void)
  59.   {
  60.     // This is called to close all windows.
  61.  
  62.     UserDebug(Build,"vedApp::Exit()\n");
  63.  
  64.     vApp::Exit();        // Default behavior
  65.   }
  66.  
  67. //======================>>> vedApp::CloseAppWin <<<===========================
  68.   void vedApp::CloseLastCmdWindow(vWindow* win, int exitcode)
  69.   {
  70. #ifndef V_VersionWindows
  71.     vApp::CloseLastCmdWindow(win,exitcode);
  72. #endif
  73.   }
  74.  
  75. //======================>>> vedApp::CloseAppWin <<<===========================
  76.   int vedApp::CloseAppWin(vWindow* win)
  77.   {
  78.     // This will be called BEFORE a window has been unregistered or
  79.     // closed.  Default behavior: unregister and close the window.
  80.  
  81.     vedCmdWindow* cw = (vedCmdWindow*)win;
  82.     if (cw->CheckClose())
  83.         return vApp::CloseAppWin(win);
  84.     return 0;
  85.   }
  86.  
  87. //=====================>>> vedApp::AppCommand <<<==============================
  88.   void vedApp::AppCommand(vWindow* win, ItemVal id, ItemVal val, CmdType cType)
  89.   {
  90.     // Commands not processed by the window will be passed here
  91.  
  92.     UserDebug1(Build,"vedApp::AppCmd(ID: %d)\n",id);
  93.     switch (id)
  94.       {
  95.  
  96.     case M_New:
  97.       {
  98.         (void*) theApp->NewAppWin(0, "V Text Editor", 100, 50);
  99.         return;
  100.       }
  101.  
  102.     case M_Open:
  103.       {
  104.         vedCmdWindow* cw;
  105.         cw = (vedCmdWindow*) theApp->NewAppWin(0, "V Text Editor", 100, 50);
  106.         cw->WindowCommand((ItemVal)M_Open,(ItemVal)0,(CmdType)0);
  107.         return;
  108.       }
  109.       }
  110.  
  111.  
  112.     vApp::AppCommand(win, id, val, cType);
  113.   }
  114.  
  115. //=========================>>> vedApp::KeyIn <<<==============================
  116.   void vedApp::KeyIn(vWindow* win, vKey key, unsigned int shift)
  117.   {
  118.     // Key strokes not processed by the window will be passed here
  119.  
  120.     vApp::KeyIn(win, key, shift);
  121.   }
  122.  
  123. //###########################################################################
  124.  
  125.   static vedApp ved_App("V Text Editor");    // The instance of the app
  126.  
  127. //============================>>> AppMain <<<==============================
  128.   int AppMain(int argc, char** argv)
  129.   {
  130.     // Use AppMain to create the main window
  131.  
  132.  
  133.     vedCmdWindow* cw;        // Pointer to instance of first window
  134.  
  135.     cw = (vedCmdWindow*) theApp->NewAppWin(0, "V Text Editor", 500, 250);
  136.  
  137.     if (argc > 1)
  138.       {
  139.      theApp->CheckEvents();    // make sure window up
  140.         for (int ix = 1 ; ix < argc ; ++ix)
  141.           {
  142.               if (argv[ix][0] == '-' || argv[ix][0] == '/')    // switch
  143.                 {
  144.                   switch (argv[ix][1])
  145.                     {
  146.                       case 'e':
  147.                       case 'E':
  148.                         {
  149.                           switch (argv[ix][2])
  150.                             {
  151.                               case 's':
  152.                               case 'S':
  153.                                 {
  154.                                   ((vedApp*)theApp)->SetEmulation(See);
  155.                                   break;
  156.                                 }
  157.                               default:
  158.                                   break;
  159.                             }
  160.                break;
  161.                         }
  162.  
  163.                       default:
  164.                           break;
  165.                     }
  166.                 }
  167.               else    // a file name: project or source
  168.                 {
  169.                   cw->OpenFile(argv[1]);    // open a file in first window
  170.                 }
  171.           }
  172.       }
  173.     else
  174.       {
  175.  
  176.       }
  177.  
  178.     cw->WindowCommand(M_SetEmulation,
  179.         (ItemVal)((vedApp*)theApp)->GetEmulation(),(CmdType)0);
  180.     return 0;
  181.   }
  182.