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

  1. //=======================================================================
  2. //@V@:Note: This file generated by vappgen V 1.00.
  3. //    vgmdlg.cpp:    Source for vgModalDialog class
  4. //=======================================================================
  5.  
  6. #include "vgmdlg.h"
  7. #include <v/vnotice.h>
  8. #include <v/vfilesel.h>
  9.  
  10. //@V@:BeginIDs
  11.     enum {
  12.     lblMainMsg = 1000,
  13.  
  14.     frmNames,
  15.     lblAppName,            // App name
  16.     txiAppName,
  17.     lblFileName,        // file base name
  18.     txiFileName,
  19.     lblTitle,            // app title
  20.     txiTitle,
  21.  
  22.     frmCmdWin,            // frame for cmdwin stuff
  23.     lblCmdWin,
  24.     blkCmdWin,
  25.     chkGenMenu,            // if include menu par
  26.     chkGenTool,            // if generate toolbar
  27.     chkWinSDI,            // if Windows SDI
  28.     chkGenStatus,        // if generate status bar
  29.     chkGenDate,
  30.     chkAddTimer,         // if add code for a timer
  31.  
  32.     frmCanvas,            // frame for canvas stuff
  33.     lblCanvas,
  34.     blkCanvas,
  35.     chkVScroll,            // for vert scroll
  36.     chkHScroll,            // for horiz scroll
  37.     rdbStdCnv,            // Standard Canvas
  38.     rdbTextCnv,            // Text Canvas
  39.     rdbNoCnv,            // no canvas
  40.     rdbOGLCnv,            // vBaseGLCanvasPane
  41.  
  42.     frmOther,            // frame for other options
  43.     lblOther,
  44.     blkOther,
  45.     chkGenDialog,        // if generate a dialog
  46.     chkGenModal,        // if generate a modal dialog
  47.     chkGenMake,            // if generate make file
  48.     chkGenProj,            // if generate project file
  49.     lblHOMEV,
  50.     txiHOMEV,
  51.  
  52.     btnSetPath,            // to set save path
  53.     blkLast
  54.   };
  55. //@V@:EndIds
  56.  
  57. //@V@:BeginDialogCmd DefaultCmds
  58.     static DialogCmd DefaultCmds[] =
  59.       {
  60.     {C_Label, lblMainMsg, 0,"X",NoList,CA_MainMsg,isSens,NoFrame, 0, 0},
  61.  
  62.     {C_Frame, frmNames, 0, "",NoList,CA_NoBorder,isSens,NoFrame, 0,lblMainMsg},
  63.     {C_Label, lblAppName, 0,"Application Base Name:",
  64.         NoList, CA_None, isSens,frmNames,0, 0, 0,
  65.         "Specify base part of dialog class name"},
  66.     {C_TextIn, txiAppName, 0,"x",
  67.         NoList, CA_None, isSens,frmNames,lblAppName, 0, 0,
  68.         "Specify base part of dialog class name"},
  69.     {C_Label, lblFileName, 0,"       File Base Name:",
  70.         NoList, CA_None, isSens,frmNames,0, txiAppName,0,
  71.         "Specify base part of generated file names"},
  72.     {C_TextIn, txiFileName, 0,"x",
  73.         NoList, CA_None, isSens,frmNames,lblAppName, txiAppName,0,
  74.         "Specify base part of generated file names"},
  75.     {C_Label, lblTitle, 0,  "    Application Title:",
  76.         NoList, CA_None, isSens,frmNames,0, txiFileName,0,
  77.         "Specify title for application"},
  78.     {C_TextIn, txiTitle, 0,"x",
  79.         NoList, CA_None, isSens,frmNames,lblAppName, txiFileName,0,
  80.         "Specify title for application"},
  81.  
  82.  
  83.     {C_Frame, frmCmdWin, 0, "",NoList,CA_NoBorder,isSens,NoFrame, 0,frmNames},
  84.     {C_Label, lblCmdWin, 0, "Command Window Options",
  85.         NoList, CA_None, isSens,frmCmdWin,0, 0},
  86.     {C_Blank, blkCmdWin, 0, " ",
  87.         NoList, CA_None, isSens,frmCmdWin,0, lblCmdWin},
  88.     {C_CheckBox, chkGenTool, 1, "Include Tool Bar         ",
  89.         NoList, CA_None, isSens,frmCmdWin,blkCmdWin, lblCmdWin,0,
  90.         "Include a Tool Bar in App command window"},
  91.     {C_CheckBox, chkGenStatus, 1, "Include Status Bar",
  92.         NoList, CA_None, isSens,frmCmdWin,chkGenTool, lblCmdWin,0,
  93.         "Include a Status Bar in App command window"},
  94.       {C_CheckBox, chkGenMenu, 1, "Include Menu Bar         ",
  95.         NoList, CA_None, isSens,frmCmdWin,blkCmdWin, chkGenTool,0,
  96.         "Include a menu bar in command window"},
  97.     {C_CheckBox, chkGenDate, 0, "Time/Date on Status Bar",
  98.         NoList, CA_None, isSens,frmCmdWin,chkGenMenu, chkGenStatus,0,
  99.         "Include code to display time/date on Status Bar"},
  100.       {C_CheckBox, chkWinSDI, 0,  "Windows SDI (MDI Default)",
  101.         NoList, CA_None, isSens,frmCmdWin,blkCmdWin,chkGenMenu, 0,
  102.         "Generate MS-Windows SDI App (MDI is default Windows App)"},
  103.       {C_CheckBox, chkAddTimer, 0,  "Add vTimer to CommandWindow",
  104.         NoList, CA_None, isSens,frmCmdWin,chkGenMenu,chkGenDate, 0,
  105.         "Add code for a vTimer to the CommandWindow"},
  106.  
  107.  
  108.     {C_Frame, frmCanvas, 0, "",NoList,CA_NoBorder,isSens,NoFrame, 0,frmCmdWin},
  109.     {C_Label, lblCanvas, 0, "Canvas Options",
  110.         NoList, CA_None, isSens,frmCanvas,0, 0},
  111.     {C_Blank, blkCanvas, 0, " ",
  112.         NoList, CA_None, isSens,frmCanvas,0, lblCanvas},
  113.     {C_CheckBox, chkVScroll, 1, "Vertical Scroll Bar      ",
  114.         NoList, CA_None, isSens,frmCanvas,blkCanvas, lblCanvas,0,
  115.         "Start app with vertical scroll bar shown"},
  116.     {C_CheckBox, chkHScroll, 1, "Horizontal Scroll Bar",
  117.         NoList, CA_None, isSens,frmCanvas,chkVScroll, lblCanvas,0,
  118.         "Start app with horizontal scroll bar shown"},
  119.     {C_RadioButton, rdbStdCnv, 1, "vCanvasPane              ",
  120.         NoList, CA_None, isSens,frmCanvas,blkCanvas, chkVScroll, 0,
  121.         "App based on vCanvasPane"},
  122.     {C_RadioButton, rdbTextCnv, 0, "vTextCanvasPane",
  123.         NoList, CA_None, isSens,frmCanvas,rdbStdCnv, chkVScroll,0,
  124.         "App based on vTextCanvasPane"},
  125.     {C_RadioButton, rdbOGLCnv, 0, "vBaseGLCanvasPane",
  126.         NoList, CA_None, isSens,frmCanvas,blkCanvas, rdbStdCnv,0,
  127.         "App based on vBaseGLCanvasPane"},
  128.     {C_RadioButton, rdbNoCnv, 0, "No Canvas Pane",
  129.         NoList, CA_None, isSens,frmCanvas,rdbStdCnv, rdbStdCnv,0,
  130.         "App has no canvas pane"},
  131.  
  132.     {C_Frame, frmOther, 0, "",NoList,CA_NoBorder,isSens,NoFrame, 0,frmCanvas},
  133.     {C_Label, lblOther, 0, "Other Options",
  134.         NoList, CA_None, isSens,frmOther,0, 0},
  135.     {C_Blank, blkOther, 0, " ",
  136.         NoList, CA_None, isSens,frmOther,0, lblOther},
  137.  
  138.     {C_CheckBox, chkGenDialog, 1, "Generate Modeless Dialog ",
  139.         NoList, CA_None, isSens,frmOther,blkOther, lblOther,0,
  140.         "Generate code for one modeless dialog with app"},
  141.     {C_CheckBox, chkGenModal, 0, "Generate Modal Dialog",
  142.         NoList, CA_None, isSens,frmOther,chkGenDialog, lblOther,0,
  143.         "Generate code for one modal dialog with app"},
  144.       {C_CheckBox, chkGenMake, 0, "Generate GNU makefile",
  145.         NoList, CA_None, isSens,frmOther,blkOther, chkGenModal,0,
  146.         "Generate GNU make compatible makefile"},
  147.       {C_CheckBox, chkGenProj, 1, "Generate V IDE Project",
  148.         NoList, CA_None, isSens,frmOther,chkGenDialog, chkGenModal,0,
  149.         "Generate V IDE Project file"},
  150.     {C_Label, lblHOMEV, 0," HOMEV:",
  151.         NoList, CA_None, isSens,frmOther,blkOther, chkGenMake,0,
  152.         "Default location of V files - HOMEV in makefile"},
  153.     {C_TextIn, txiHOMEV, 0,"x",
  154.         NoList, CA_Small, isSens,frmOther,lblHOMEV, chkGenMake,20,
  155.         "Default location of V files - HOMEV in makefile"},
  156.   
  157.     {C_Button, btnSetPath, 0, " Set Save Path ",NoList,CA_None,
  158.         isSens,NoFrame,0, frmOther,0,
  159.         "Specify file path to save generated files"},
  160.     {C_Blank, blkLast, 0, "           ",
  161.         NoList,CA_None, isSens,NoFrame,btnSetPath, frmOther},
  162.     {C_Button, M_Cancel, 0, " Cancel ",NoList,CA_None,
  163.         isSens,NoFrame,blkLast, frmOther},
  164.     {C_Button, M_OK, 0, " Generate ", NoList, CA_DefaultButton, 
  165.         isSens, NoFrame, M_Cancel, frmOther,0,
  166.         "Generate code"},
  167.  
  168.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  169.     };
  170. //@V@:EndDialogCmd
  171.  
  172. //==========================>>> SetCmdObjAttr <<<==============================
  173.   void SetCmdObjTitle(CommandObject* cList, ItemVal id, char* newtitle)
  174.   {
  175.     // This is called to change the attrs field of the item with given id
  176.  
  177.     // scan the entire list
  178.  
  179.     int ix;
  180.     for (ix = 0 ; cList && (cList[ix].cmdType != C_EndOfList) ; ++ix)
  181.       {
  182.     if (cList[ix].cmdId == id)        // the one we want!
  183.       {
  184.         cList[ix].title = newtitle;        // change
  185.         break;
  186.       }
  187.       }
  188.    }
  189.  
  190. //======================>>> vgModalDialog::vgModalDialog <<<==================
  191.   vgModalDialog::vgModalDialog(vBaseWindow* bw, char* title) :
  192.     vModalDialog(bw,title)
  193.   {
  194.     UserDebug(Constructor,"vgModalDialog::vgModalDialog()\n")
  195.   }
  196.  
  197. //===================>>> vgModalDialog::~vgModalDialog <<<====================
  198.   vgModalDialog::~vgModalDialog()
  199.   {
  200.     UserDebug(Destructor,"vgModalDialog::~vgModalDialog() destructor\n")
  201.   }
  202.  
  203. //====================>>> vgModalDialog::vgAction <<<====================
  204.   int vgModalDialog::vgAction(char* msg, vgOptions& op)
  205.   {
  206.     ItemVal ans,rval;
  207.  
  208.     SetCmdObjTitle(DefaultCmds,txiAppName,op.appName);
  209.     SetCmdObjTitle(DefaultCmds,txiFileName,op.fileName);
  210.     SetCmdObjTitle(DefaultCmds,txiTitle,op.title);
  211.     SetCmdObjTitle(DefaultCmds,txiHOMEV,op.home);
  212.  
  213.     AddDialogCmds(DefaultCmds);        // add the predefined commands
  214.  
  215. TRYAGAIN:
  216.     ans = ShowModalDialog(msg,rval);
  217.     if (ans == M_Cancel)
  218.     return 0;
  219.  
  220.     // Retrieve values from fields of the dialog
  221.  
  222.     (void) GetTextIn(txiAppName,op.appName,99);
  223.     (void) GetTextIn(txiFileName,op.fileName,99);
  224.     (void) GetTextIn(txiTitle,op.title,99);
  225.     (void) GetTextIn(txiHOMEV,op.home,99);
  226.     op.addDialog = GetValue(chkGenDialog);
  227.     op.addModal = GetValue(chkGenModal);
  228.     op.addMake = GetValue(chkGenMake);
  229.     op.addVproj = GetValue(chkGenProj);
  230.     op.addToolBar = GetValue(chkGenTool);
  231.     op.addStatus = GetValue(chkGenStatus);
  232.     op.addMenu = GetValue(chkGenMenu);
  233.     op.addTimer = GetValue(chkAddTimer);
  234.     if (op.addStatus)
  235.     op.addDate = GetValue(chkGenDate);
  236.     else
  237.     op.addDate = 0;
  238.     op.vScroll = GetValue(chkVScroll);
  239.     op.hScroll = GetValue(chkHScroll);
  240.     if (GetValue(rdbStdCnv) == 1)
  241.     op.canvasType = Canvas;
  242.     else if (GetValue(rdbTextCnv) == 1)
  243.     op.canvasType = Text;
  244.     else if (GetValue(rdbOGLCnv) == 1)
  245.     op.canvasType = OpenGL;
  246.     else
  247.     op.canvasType = NoCanvas;
  248.  
  249.     op.winSDI = GetValue(chkWinSDI);
  250.  
  251.     if (!op.addMenu && !op.addToolBar)
  252.       {
  253.     vNoticeDialog note(this);
  254.     note.Notice("You must include at least a Menu OR a Tool Bar.");
  255.     goto TRYAGAIN;
  256.       }
  257.  
  258.     // *** Add code to process dialog values here
  259.  
  260.     return ans == M_OK;
  261.   }
  262.  
  263. //====================>>> vgModalDialog::DialogCommand <<<====================
  264.   void vgModalDialog::DialogCommand(ItemVal id, ItemVal retval, CmdType ctype)
  265.   {
  266.     UserDebug2(CmdEvents,"vgModalDialog::DialogCommand(id:%d, val:%d)\n",id, retval)
  267.  
  268.     switch (id)        // We will do some things depending on value
  269.       {
  270.      case chkGenStatus:    // Need to toggle sensitivity of Date
  271.       {
  272.         if (retval == 1)
  273.           {
  274.         SetValue(chkGenDate,1,Sensitive);
  275.           }
  276.         else
  277.           {
  278.         SetValue(chkGenDate,0,Value);
  279.         SetValue(chkGenDate,0,Sensitive);
  280.           }
  281.         break;
  282.       }
  283.  
  284.     case btnSetPath:        // set path to save in
  285.       {
  286.         char path[100];
  287.         int tmp = 0;
  288.         (void) GetTextIn(txiFileName,path,99);
  289.         strcat(path,"app.cpp");    // use xxapp.cpp as default name
  290.         vFileSelect fsel(this);
  291.  
  292.         int oans = fsel.FileSelectSave("Generate code to directory",
  293.         path,99,NULL,tmp);
  294.         break;
  295.       }
  296.       }
  297.  
  298.     vModalDialog::DialogCommand(id,retval,ctype);
  299.   }
  300.