📄 default.js
字号:
}
}
function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile)
{
try
{
var projItems = proj.ProjectItems
var strTemplatePath = wizard.FindSymbol('TEMPLATES_PATH');
var strTpl = '';
var strName = '';
var strTextStream = InfFile.OpenAsTextStream(1, -2);
while (!strTextStream.AtEndOfStream)
{
strTpl = strTextStream.ReadLine();
if (strTpl != '')
{
strName = strTpl;
var strTarget = GetTargetName(strName, strProjectName);
var strTemplate = strTemplatePath + '\\' + strTpl;
var strFile = strProjectPath + '\\' + strTarget;
var reCopyOnly = /\.(:?bmp|ico|gif|rtf|css)$/i;
var bCopyOnly = reCopyOnly.test(strFile); //"true" will only copy the file from strTemplate to strTarget without rendering/adding to the project
if(strTpl.search(/(?:root\.rc2|resource\.h)/i) == -1)
{
wizard.RenderTemplate(strTemplate, strFile, bCopyOnly);
if(strTarget.search(/\.(?:h|cpp)$/) != -1)
{
SetPlatformsCode(strFile);
if(wizard.FindSymbol('WTL_USE_CPP_FILES') && strTarget.search(/\.cpp$/) != -1)
SplitCode(strFile);
}
proj.Object.AddFile(strFile);
}
else
SplitResourceFile(proj, strTemplate, strFile);
}
}
strTextStream.Close();
}
catch(e)
{
throw e;
}
}
function AddPlatformFile(proj, strTemplate, PlatFormFile)
{
wizard.RenderTemplate(strTemplate, PlatFormFile);
proj.Object.AddFile(PlatFormFile);
}
/******************************************************************************
Description: Process and rename a resource file depending on the project
selected platforms
******************************************************************************/
function SplitResourceFile(proj, strTemplate, strFile)
{
var ppcFile = strFile.replace(/\./, "ppc.");
var spFile = strFile.replace(/\./, "sp.");
if(wizard.FindSymbol("POCKETPC2003_UI_MODEL"))
AddPlatformFile(proj, strTemplate, ppcFile);
if(wizard.FindSymbol("SMARTPHONE2003_UI_MODEL"))
AddPlatformFile(proj, strTemplate, spFile);
if(wizard.FindSymbol("DUAL_UI_MODEL"))
{
wizard.AddSymbol("DUAL_UI_MODEL", false);
SetPlatformsCode(ppcFile);
wizard.AddSymbol("POCKETPC2003_UI_MODEL", false);
SetPlatformsCode(spFile);
wizard.AddSymbol("POCKETPC2003_UI_MODEL", true);
wizard.AddSymbol("DUAL_UI_MODEL", true);
}
else
SetPlatformsCode(wizard.FindSymbol("POCKETPC2003_UI_MODEL") ? ppcFile : spFile);
}
/******************************************************************************
Description: Add the function members body to a .cpp file and remove them
from the matching header. Do nothing if no matching .h file.
cppPath: Path name to a .cpp file
******************************************************************************/
function SplitCode(cppPath)
{
var fso = new ActiveXObject('Scripting.FileSystemObject');
var hPath = cppPath.replace(/.cpp$/, ".h");
if (!fso.FileExists(hPath))
return;
var cppFile = fso.GetFile(cppPath);
var hFile = fso.GetFile(hPath);
var tsh = hFile.OpenAsTextStream(1);
var hText = tsh.ReadAll();
tsh.Close();
var tscpp = cppFile.OpenAsTextStream(8);
var ClassPattern = /^[ \t]*class[ \t]+(\w+)[\s\S]+?(?:^[ \t]*\};$)/mg
var ClassInfo = hText.match(ClassPattern);
var numClass = ClassInfo.length;
for (nc = 0 ; nc < numClass; nc++)
{
var ClassText = ClassInfo[nc];
ClassText.match(ClassPattern);
var ClassName = RegExp.$1;
var FnPattern = /(^(?:[ \t]+\w+)*[ \t]+(\w+)\([^\)]*\))([\s]*\{([^\}]*\{[^\}]*\})*[^\}]*\}+?)/mg
var FnPatternIf = /(^(?:#if.+\s+)*(?:[ \t]+\w+)*[ \t]+(\w+)\([^\)]*\))([\s]*\{([^\}]*\{[^\}]*\})*[^\}]*\}+?(?:\s+#e(?:ndif|lif|lse)[^\r\n]*)*)/mg
var FnInfo = ClassText.match(FnPatternIf);
var numFn = FnInfo.length;
for (n = 0 ; n < numFn; n++)
{
var FnTextIf = FnInfo[n];
var FnTextIf = FnTextIf.match(FnPatternIf);
var FnDef = RegExp.$1;
var FnName = RegExp.$2;
var FnBody = RegExp.$3;
var FnFullName = ClassName + "::" + FnName;
FnDef = FnDef.replace(FnName, FnFullName);
FnDef = FnDef.replace(/^\t(?:\s*virtual\s+)*/, "");
FnBody = FnBody.replace(/^\t/mg, "");
tscpp.Write(FnDef);
tscpp.Write(FnBody);
tscpp.WriteBlankLines(2);
var FnText = FnTextIf.input.match(FnPattern);
var FnDecl = RegExp.$1 + ";";
ClassText = ClassText.replace(FnText, FnDecl);
}
hText = hText.replace(ClassInfo[nc], ClassText);
}
tscpp.Close();
tsh = hFile.OpenAsTextStream(2);
tsh.Write(hText);
tsh.Close();
}
/******************************************************************************
Description: Process the platform dependant code depending on the project
selected platforms:
//?ppc or //?sp
Platform dependant code
//?sp or //?ppc Optional alternative
Optional alternate platform code
//?end
FileName: Path name to a file
******************************************************************************/
function SetPlatformsCode(FileName)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFile(FileName);
var ts = f.OpenAsTextStream();
var text = ts.ReadAll();
ts.Close();
var PlatformPattern = /(?:\r\n)?(^\/{2}\?(?:ppc|sp)\r\n)(?:^.*\r\n)+?(\/{2}\?(?:ppc|sp)\r\n)?(?:^.*\r\n)*?(^\/{2}\?end\r\n)/m
var ppcPattern = /^\/{2}\?ppc\r\n/m
var spPattern = /^\/{2}\?sp\r\n/m
var endPattern =/^\/{2}\?end\r\n/m
var PlatformInfo = text.match(PlatformPattern);
while (PlatformInfo != null)
{
var PlatformText = PlatformInfo[0];
var type;
if(RegExp.$2.length)
if(RegExp.$1 == "//?ppc\r\n")
type = "ppcDual";
else
type = "spDual";
else
if(RegExp.$1 == "//?ppc\r\n")
type = "ppcSingle";
else
type = "spSingle";
if(wizard.FindSymbol("DUAL_UI_MODEL"))
{
switch (type)
{
case "ppcDual":
PlatformText = PlatformText.replace("//?sp", "#else");
case "ppcSingle":
PlatformText = PlatformText.replace("//?ppc", "#ifdef WIN32_PLATFORM_PSPC");
break;
case "spDual":
PlatformText = PlatformText.replace("//?ppc", "#else");
case "spSingle":
PlatformText = PlatformText.replace("//?sp", "#ifdef WIN32_PLATFORM_WFSP");
break;
}
PlatformText = PlatformText.replace("//?end", "#endif");
}
else if(wizard.FindSymbol("POCKETPC2003_UI_MODEL"))
switch (type)
{
case "ppcDual":
PlatformText = PlatformText.replace(/\/\/\?sp[\s\S]*\r\n/, "");
case "spDual":
PlatformText = PlatformText.replace(/(?:\r\n)?\/\/\?sp[\s\S]*\/\/\?ppc/, "");
case "ppcSingle":
PlatformText = PlatformText.replace(ppcPattern, "");
PlatformText = PlatformText.replace(endPattern, "");
break;
case "spSingle":
PlatformText = "";
}
else // if(wizard.FindSymbol("SMARTPHONE2003_UI_MODEL"))
switch (type)
{
case "spDual":
PlatformText = PlatformText.replace(/\/\/\?ppc[\s\S]*\r\n/, "");
case "ppcDual":
PlatformText = PlatformText.replace(/(?:\r\n)?\/\/\?ppc[\s\S]*\/\/\?sp/, "");
case "spSingle":
PlatformText = PlatformText.replace(spPattern, "");
PlatformText = PlatformText.replace(endPattern, "");
break;
case "ppcSingle":
PlatformText = "";
}
text = text.replace(PlatformInfo[0], PlatformText);
PlatformInfo = text.match(PlatformPattern);
}
ts = fso.CreateTextFile(FileName);
ts.Write(text);
ts.Close();
}
function SetViewSymbols(strBaseName)
{
var strViewClass;
if(wizard.FindSymbol("WTL_USE_VIEW"))
{
var strViewFile = strBaseName + "View";
wizard.AddSymbol("WTL_VIEW_FILE", strViewFile);
strViewClass = "C" + strViewFile;
}
wizard.AddSymbol("WTL_VIEWTYPE_GENERIC", false);
wizard.AddSymbol("WTL_VIEWTYPE_AX", false);
wizard.AddSymbol("WTL_VIEWTYPE_FORM", false);
wizard.AddSymbol("WTL_VIEWTYPE_PROPSHEET", false);
var strView = wizard.FindSymbol("WTL_COMBO_VIEW_TYPE");
switch(strView)
{
case "WTL_VIEWTYPE_FORM":
wizard.AddSymbol("WTL_USE_VIEW_CLASS", true);
wizard.AddSymbol("WTL_VIEWTYPE_FORM", true);
if(wizard.FindSymbol("WTL_ENABLE_AX") && wizard.FindSymbol("WTL_HOST_AX"))
wizard.AddSymbol("WTL_VIEW_BASE_CLASS", "CAxDialogImpl");
else
wizard.AddSymbol("WTL_VIEW_BASE_CLASS", "CDialogImpl");
break;
case "WTL_VIEWTYPE_PROPSHEET":
wizard.AddSymbol("WTL_USE_VIEW_CLASS", true);
wizard.AddSymbol("WTL_VIEWTYPE_PROPSHEET", true);
wizard.AddSymbol("WTL_VIEW_BASE_CLASS", "CPropertySheetImpl");
if(wizard.FindSymbol("WTL_ENABLE_AX") && wizard.FindSymbol("WTL_HOST_AX"))
wizard.AddSymbol("WTL_PROPPAGE_BASE_CLASS", "CAxPropertyPageImpl");
else
wizard.AddSymbol("WTL_PROPPAGE_BASE_CLASS", "CPropertyPageImpl");
break;
case "WTL_VIEWTYPE_AX":
wizard.AddSymbol("WTL_HOST_AX", true);
wizard.AddSymbol("WTL_VIEWTYPE_AX", true);
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEW_BASE", "CAxWindow");
}
else
strViewClass = "CAxWindow"
break;
case "WTL_VIEWTYPE_EDIT":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_EDIT", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CEdit");
}
else
strViewClass = "CEdit"
break;
case "WTL_VIEWTYPE_LISTVIEW":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_REPORT | LVS_SHOWSELALWAYS");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_LISTVIEW", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CListViewCtrl");
}
else
strViewClass = "CListViewCtrl"
break;
case "WTL_VIEWTYPE_TREEVIEW":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_TREEVIEW", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CTreeViewCtrl");
}
else
strViewClass = "CTreeViewCtrl"
break;
case "WTL_VIEWTYPE_HTML":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | HS_CONTEXTMENU");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_HTML", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CHtmlCtrl");
}
else
strViewClass = "CHtmlCtrl"
break;
case "WTL_VIEWTYPE_INKX":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | IS_BOTTOMVOICEBAR");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_INKX", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CInkXCtrl");
}
else
strViewClass = "CInkXCtrl"
break;
case "WTL_VIEWTYPE_RICHINK":
wizard.AddSymbol("WTL_VIEW_STYLES", "WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | IS_BOTTOMVOICEBAR");
if(wizard.FindSymbol("WTL_USE_VIEW_CLASS"))
{
wizard.AddSymbol("WTL_VIEWTYPE_RICHINK", true);
wizard.AddSymbol("WTL_VIEW_BASE", "CRichInkCtrl");
}
else
strViewClass = "CRichInkCtrl"
break;
default:
wizard.AddSymbol("WTL_USE_VIEW_CLASS", true);
wizard.AddSymbol("WTL_VIEWTYPE_GENERIC", true);
if(wizard.FindSymbol("WTL_VIEW_SCROLL"))
if(wizard.FindSymbol("WTL_VIEW_ZOOM"))
wizard.AddSymbol("WTL_SCROLL_CLASS", "CZoomScrollImpl");
else
wizard.AddSymbol("WTL_SCROLL_CLASS", "CScrollImpl");
break;
}
wizard.AddSymbol("WTL_VIEW_CLASS", strViewClass);
}
function SetWtlDeviceResourceConfigurations(selProj)
{
var ProjWiz = new ActiveXObject("ProjWiz.SDProjWiz2.2");
var projectName = wizard.FindSymbol("PROJECT_NAME");
projectName = projectName.toLowerCase();
for (var fileIdx = 1; fileIdx <= selProj.Files.Count; fileIdx++)
{
var file = selProj.Files.Item(fileIdx);
if (file.Extension.toLowerCase() == ".rc")
{
for (var fileCfgIdx = 1; fileCfgIdx <= file.FileConfigurations.Count; fileCfgIdx++)
{
var fileCfg = file.FileConfigurations.Item(fileCfgIdx);
var cfgName = fileCfg.Name;
var fileName = file.Name.toLowerCase();
var cfg;
for (var i = 1; i <= selProj.Configurations.Count; i++)
{
if (selProj.Configurations.Item(i).Name == cfgName)
{
// this condition will ALWAYS be hit eventually, and
// cfg will always be assigned by the end of the loop
cfg = selProj.Configurations.Item(i);
break;
}
}
var platformName = cfg.Platform.Name;
var symbol = ProjWiz.GetBaseNativePlatformProperty(platformName, "UISymbol");
var CLTool = cfg.Tools("VCCLCompilerTool");
CLTool.PreprocessorDefinitions += ";" + symbol;
if (symbol == "POCKETPC2003_UI_MODEL")
{
if (fileName == projectName + "ppc.rc")
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = false;
}
else
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = true;
}
}
else if (symbol == "SMARTPHONE2003_UI_MODEL")
{
if (fileName == projectName + "sp.rc" || fileName == "resourcesp.h")
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = false;
}
else
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = true;
}
}
else if (symbol == "AYGSHELL_UI_MODEL")
{
if (fileName == projectName + "ayg.rc")
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = false;
}
else
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = true;
}
}
else if (symbol == "STANDARDSHELL_UI_MODEL")
{
if (fileName == projectName + ".rc")
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = false;
}
else
{
file.FileConfigurations.Item(fileCfgIdx).ExcludedFromBuild = true;
}
}
else
{
//wizard.ReportError("Error: unknown UI model [" + symbol + "]");
}
}
}
}
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -