home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / appgen / vgcmdw.cpp < prev    next >
C/C++ Source or Header  |  1998-10-20  |  8KB  |  314 lines

  1. //=======================================================================
  2. //@V@:Note: This file generated by vappgen V 1.00.
  3. //    vgcmdw.cpp:    Source for vgCmdWindow class
  4. //=======================================================================
  5.  
  6. #include <v/vnotice.h>    // for vNoticeDialog
  7. #include <v/vkeys.h>    // to map keys
  8. #include <v/vos.h>    // OS helper
  9. #include <v/vynreply.h>    // for overwrite
  10. #include <fstream.h>
  11.  
  12. #include "vgcmdw.h"    // our header
  13. #include "vgcode.h"
  14.  
  15. //    Start defines for the main window with 100
  16.  
  17.     enum {
  18.     m_Generate = 100,    // Generate menu
  19.     m_GenStdApp,        // A standard app
  20.     m_GenExtraDialog    // An extra dialog
  21.       };
  22.  
  23.     static vMenu FileMenu[] =
  24.       {
  25.     {"Exit", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
  26.     {NULL}
  27.       };
  28.  
  29.     static vMenu GenerateMenu[] =
  30.       {
  31.     {"Standard Application",m_GenStdApp , isSens, notChk, noKeyLbl, noKey, noSub},
  32.     {"Extra Dialog",m_GenExtraDialog , isSens, notChk, noKeyLbl, noKey, noSub},
  33.     {NULL}
  34.       };
  35.  
  36.     static vMenu StandardMenu[] =
  37.       {
  38.     {"File", M_File, isSens, notUsed, notUsed, noKey, &FileMenu[0]},
  39.     {"Generate", m_Generate, isSens, notUsed, notUsed, noKey, &GenerateMenu[0]},
  40.     {NULL}
  41.       };
  42.  
  43.     static CommandObject ToolBar[] =
  44.       {
  45.     {C_Button,m_GenStdApp,0,"Standard App",NoList,CA_None,isSens,NoFrame,0,0,0,
  46.         "Generate a Standard V Application"},
  47.     {C_Button,m_GenExtraDialog,0,"Extra Dialog",NoList,CA_None,isSens,NoFrame,0,0,0,
  48.         "Generate an additional Dialog"},
  49.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  50.       }; 
  51.  
  52.  
  53. //====================>>> vgCmdWindow::vgCmdWindow <<<====================
  54.   vgCmdWindow::vgCmdWindow(char* name, int width, int height) :
  55.     vCmdWindow(name, width, height)
  56.   {
  57.     UserDebug1(Constructor,"vgCmdWindow::vgCmdWindow(%s) Constructor\n",name)
  58.  
  59.     // The Menu Bar
  60.     vgMenu = new vMenuPane(StandardMenu);
  61.     AddPane(vgMenu);
  62.  
  63.     // The Command Pane
  64.     vgCmdPane = new vCommandPane(ToolBar);
  65.     AddPane(vgCmdPane);
  66.  
  67.     // The Canvas
  68.     vgCanvas = new vgTextCanvasPane;
  69.     AddPane(vgCanvas);
  70.  
  71.     // Show Window
  72.  
  73.     ShowWindow();
  74.  
  75.     // Setup default options
  76.     strcpy(opts.appName,"my");
  77.     strcpy(opts.fileName,"my");
  78.     strcpy(opts.title, "My V App");
  79.     vOS vos;
  80.     if (vos.vGetEnvVal("HOMEV",opts.home,99) < 1)
  81.     strcpy(opts.home, DEF_HOMEV);
  82.  
  83.     opts.addDialog = 1;
  84.     opts.addModal = 1;
  85.     opts.extraDialog = 0;
  86.     opts.addMake = 1;
  87.     opts.addVproj = 1;
  88.     opts.addMenu = 1;
  89.     opts.addToolBar = 1;
  90.     opts.addStatus = 1;
  91.     opts.addDate = 0;
  92.     opts.addTimer = 0;
  93.     opts.vScroll = 1;
  94.     opts.hScroll = 1;
  95.     opts.winSDI = 0;
  96.     opts.canvasType = Canvas;
  97.  
  98.   }
  99.  
  100. //====================>>> vgCmdWindow::~vgCmdWindow <<<====================
  101.   vgCmdWindow::~vgCmdWindow()
  102.   {
  103.     UserDebug(Destructor,"vgCmdWindow::~vgCmdWindow() destructor\n")
  104.  
  105.     // Now put a delete for each new in the constructor.
  106.  
  107.     delete vgMenu;
  108.     delete vgCmdPane;
  109.     delete vgCanvas;
  110.  
  111.   }
  112.  
  113. //====================>>> vgCmdWindow::KeyIn <<<====================
  114.   void vgCmdWindow::KeyIn(vKey keysym, unsigned int shift)
  115.   {
  116.     vCmdWindow::KeyIn(keysym, shift);
  117.   }
  118.  
  119. //====================>>> vgCmdWindow::WindowCommand <<<====================
  120.   void vgCmdWindow::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
  121.   {
  122.     // Default: route menu and toolbar commands here
  123.  
  124.  
  125.     UserDebug1(CmdEvents,"vgCmdWindow:WindowCommand(%d)\n",id)
  126.  
  127.     switch (id)
  128.       {
  129.     //@V@:Case M_New
  130.     case M_New:
  131.       {
  132.         vNoticeDialog note(this);
  133.         note.Notice("New");
  134.         break;
  135.       }    //@V@:EndCase
  136.  
  137.     //@V@:Case M_Open
  138.     case M_Open:
  139.       {
  140.         vNoticeDialog note(this);
  141.         note.Notice("Open");
  142.         break;
  143.       }    //@V@:EndCase
  144.  
  145.     //@V@:Case M_Save
  146.     case M_Save:
  147.       {
  148.         vNoticeDialog note(this);
  149.         note.Notice("Save");
  150.         break;
  151.       }    //@V@:EndCase
  152.  
  153.     //@V@:Case M_SaveAs
  154.     case M_SaveAs:
  155.       {
  156.         vNoticeDialog note(this);
  157.         note.Notice("Save As");
  158.         break;
  159.       }    //@V@:EndCase
  160.  
  161.     //@V@:Case M_Exit
  162.     case M_Exit:
  163.       {
  164.         theApp->Exit();
  165.         break;
  166.       }    //@V@:EndCase
  167.  
  168.     case m_GenStdApp:
  169.       {
  170.         strcpy(opts.appName,"my");        // initial names
  171.         strcpy(opts.fileName,"my");
  172.         strcpy(opts.title, "My V App");
  173.         vgModalDialog vgMDlg(this);
  174.         if (vgMDlg.vgAction("Generate Standard V Appication", opts))
  175.           {
  176.         char name[100];
  177.         strcpy(name,opts.fileName); strcat(name,"app.cpp");
  178.         ifstream ifile(name);        // see if open
  179.         if (ifile)
  180.           {
  181.             ifile.close();
  182.             vYNReplyDialog ynd(this);
  183.             if (ynd.AskYN("An application with this name exists. Overwrite it?") != 1)
  184.             break;
  185.           }
  186.  
  187.         opts.extraDialog = 0;
  188.         vgCanvas->DrawText("************************************************\n");
  189.         vgCanvas->DrawText("Generated class ");
  190.         vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("App            -> ");
  191.         vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("app[.cpp & .h]\n");
  192.         genApp(opts);
  193.  
  194.         vgCanvas->DrawText("Generated class ");
  195.         vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("CmdWindow      -> ");
  196.         vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("cmdw[.cpp & .h]\n");
  197.         genCmdw(opts);
  198.  
  199.         if (opts.canvasType == NoCanvas)
  200.             vgCanvas->DrawText("No Canvas Pane generated\n");
  201.         else
  202.          {
  203.  
  204.            vgCanvas->DrawText("Generated class ");
  205.            vgCanvas->DrawText(opts.appName); 
  206.            if (opts.canvasType == Canvas)
  207.              {
  208.                vgCanvas->DrawText("CanvasPane     -> ");
  209.                genCnv(opts);
  210.              }
  211.            else if (opts.canvasType == Text)
  212.              {
  213.                vgCanvas->DrawText("TextCanvasPane -> ");
  214.                genTextCnv(opts);
  215.              }
  216.            else if (opts.canvasType == OpenGL)
  217.              {
  218.                vgCanvas->DrawText("vOpenGLCnvPane -> ");
  219.                genOGLCnv(opts);
  220.              }
  221.  
  222.            vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("cnv[.cpp & .h]\n");
  223.          }
  224.  
  225.         if (opts.addDialog)
  226.           {
  227.             vgCanvas->DrawText("Generated class ");
  228.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("Dialog         -> ");
  229.             vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("dlg[.cpp & .h]\n");
  230.             genDlg(opts);
  231.           }
  232.  
  233.         if (opts.addModal)
  234.           {
  235.             vgCanvas->DrawText("Generated class ");
  236.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("ModalDialog    -> ");
  237.             vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("mdlg[.cpp & .h]\n");
  238.             genMDlg(opts);
  239.           }
  240.  
  241.         if (opts.addMake)
  242.           {
  243.             vgCanvas->DrawText("Generated makefile.");
  244.             vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText(" for V application ");
  245.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText(".\n");
  246.             genMake(opts);
  247.           }
  248.  
  249.         if (opts.addVproj)
  250.           {
  251.             vgCanvas->DrawText("Generated V Project File ");
  252.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText(".vpj");
  253.             genProject(opts);
  254.           }
  255.  
  256.             vgCanvas->DrawText("\nDone.\n");
  257.         vgCanvas->DrawText("************************************************\n");
  258.           }
  259.  
  260.         break;
  261.       }    //@V@:EndCase
  262.  
  263.         case m_GenExtraDialog:    // An extra dialog
  264.       {
  265.         opts.extraDialog = 1;
  266.         strcpy(opts.appName,"xtra");
  267.         strcpy(opts.fileName,"xtra");
  268.         strcpy(opts.title, "Extra Dialog");
  269.         vgdlgModalDialog vgdlgMDlg(this);
  270.         if (vgdlgMDlg.vgdlgAction("Generate Extra Dialog", opts))
  271.           {
  272.         char name[100];
  273.         strcpy(name,opts.fileName);
  274.         if (opts.addDialog)
  275.             strcat(name,"dlg.cpp");
  276.         else
  277.             strcat(name,"mdlg.cpp");
  278.         ifstream ifile(name);        // see if open
  279.         if (ifile)
  280.           {
  281.             ifile.close();
  282.             vYNReplyDialog ynd(this);
  283.             if (ynd.AskYN("A dialog with this name exists. Overwrite it?") != 1)
  284.             break;
  285.           }
  286.         vgCanvas->DrawText("************************************************\n");
  287.         if (opts.addDialog)
  288.           {
  289.             vgCanvas->DrawText("Generated class ");
  290.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("Dialog         -> ");
  291.             vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("dlg[.cpp & .h]\n");
  292.             genDlg(opts);
  293.           }
  294.         else if (opts.addModal)
  295.           {
  296.             vgCanvas->DrawText("Generated class ");
  297.             vgCanvas->DrawText(opts.appName); vgCanvas->DrawText("ModalDialog    -> ");
  298.             vgCanvas->DrawText(opts.fileName); vgCanvas->DrawText("mdlg[.cpp & .h]\n");
  299.             genMDlg(opts);
  300.           }
  301.             vgCanvas->DrawText("\n!!!! You must add this dialog to your app manually!\nDone.\n");
  302.         vgCanvas->DrawText("************************************************\n");
  303.           }
  304.         break;
  305.       }
  306.  
  307.     default:        // route unhandled commands up
  308.       {
  309.         vCmdWindow::WindowCommand(id, val, cType);
  310.         break;
  311.       }
  312.       }
  313.   }
  314.