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