// CppCatListDialogGenerator.cpp: implementation of the CAtlCatListDialogGenerator class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AtlCatListDialogGenerator.h"
#include "XmlClassInfo.h"
#include "XmlMemberInfo.h"
#include "XmlFormInfo.h"
#include "XmlBaseFormItem.h"
#include "XmlFormItem_Static.h"
#include "XmlFormItem_TextBox.h"
#include "XmlFormItem_CheckBox.h"
#include "XmlFormItem_ComboBox.h"
#include "XmlProjectSettings.h"
#include "XmlGuiCategoryInfoList.h"
#include "XmlGuiCategoryInfo.h"
#include "XmlGuiCategoryField.h"
#include "XmlMemberValidation_StaticEnum.h"
#include "XmlMemberValidation_StaticEnumItem.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAtlCatListDialogGenerator::CAtlCatListDialogGenerator()
{
}
CAtlCatListDialogGenerator::~CAtlCatListDialogGenerator()
{
}
void CAtlCatListDialogGenerator::Generate()
{
GenerateHeader();
GenerateImplementation();
}
void CAtlCatListDialogGenerator::GenerateHeader()
{
string fileName;
string pathName;
// header file generation
//
headCode_ = "";
Head_generateHeader();
Head_generateIfDefBegin();
Head_generateIncludeSection();
Head_generateForwardDeclarations();
Head_generateDefineSection();
Head_generateClassBegin();
Head_generateConstructor();
Head_generateDestructor();
Head_generatePublicMethods();
Head_generateDialogData();
Head_generateOverrides();
Head_generateMessageMap();
Head_generateProtectedMembers();
Head_generateDataMembers();
Head_generateClassEnd();
Head_generateIfDefEnd();
// save implementation file
//
pathName = BuildGeneratedSourcePath() + "\\include\\";
fileName = GetDlgName() + ".h";
SaveFile(pathName + fileName, headCode_);
hGeneratedFiles_[fileName] = pathName + fileName;
}
void CAtlCatListDialogGenerator::GenerateImplementation()
{
string fileName;
string pathName;
// generate implementation file
//
implCode_ = "";
Impl_generateHeader();
Impl_generateIncludeSection();
Impl_generateDebugSymbols();
Impl_generateMainTitle();
Impl_generateConstructor();
Impl_generateDestructor();
Impl_generatePublicMethods();
Impl_generateMessageMap();
Impl_generateOnInitDialog();
Impl_generateOnSize();
Impl_generateProtectedMembers();
// save implementation file
//
pathName = BuildGeneratedSourcePath() + "\\src\\";
fileName = GetDlgName() + ".cpp";
SaveFile(pathName + fileName, implCode_);
cppGeneratedFiles_[fileName] = pathName + fileName;
}
void CAtlCatListDialogGenerator::Head_generateHeader()
{
headCode_ += "// " + GetDlgName() + ".h : header file" + xCrLf;
headCode_ += "//" + xCrLf + xCrLf;
headCode_ += GetGenerationTimeStamp();
}
void CAtlCatListDialogGenerator::Head_generateIfDefBegin()
{
headCode_ += "#if !defined(" + DefineOf(GetDlgName()) + ")" + xCrLf;
headCode_ += "#define " + DefineOf(GetDlgName()) + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateIncludeSection()
{
headCode_ += "#include \"stdafx.h\"" + xCrLf;
headCode_ += "#include \"resource.h\"" + xCrLf;
headCode_ += "#include \"" + GetResourceFileName() + ".h\"" + xCrLf;
headCode_ += "#include \"ICellListener.h\"" + xCrLf;
headCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateForwardDeclarations()
{
headCode_ += "// forward declarations" + xCrLf;
headCode_ += "//" + xCrLf;
headCode_ += "class " + GetClassName() + ";" + xCrLf;
headCode_ += "class CAsOptionListWnd;" + xCrLf;
headCode_ += "class CAsBaseCell;" + xCrLf;
headCode_ += "class CAsGenericTextCell;" + xCrLf;
headCode_ += "class CAsCheckBoxCell;" + xCrLf;
headCode_ += "class CAsNumericTextCell;" + xCrLf;
headCode_ += "class CAsComboBoxCell;" + xCrLf;
headCode_ += "class CAsHexadecimalTextCell;" + xCrLf;
headCode_ += xCrLf;
if (classInfo_->GetCardinalityInfo()->GetCardinality() != enCardinality_SingleInstance)
headCode_ += "class " + GetClassName() + GetCardinalityPostfix(classInfo_) + ";" + xCrLf;
headCode_ += "class " + GetClassName() + ";" + xCrLf;
headCode_ += "class " + GetMainDlgName() + ";" + xCrLf;
headCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateClassBegin()
{
headCode_ += "/////////////////////////////////////////////////////////////////////////////" + xCrLf;
headCode_ += "// " + GetDlgName() + " dialog" + xCrLf + xCrLf;
headCode_ += "class " + GetDlgName() + " : public CDialog," + xCrLf;
headCode_ += xTab + xTab + xTab + "public ICellListener" + xCrLf;
headCode_ += "{" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateConstructor()
{
headCode_ += "public:" + xCrLf;
headCode_ += xTab + GetDlgName() + "(CWnd* pParent = NULL);" + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateDestructor()
{
headCode_ += xTab + "virtual ~" + GetDlgName() + "();" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generatePublicMethods()
{
enCardinality c;
c = classInfo_->GetCardinalityInfo()->GetCardinality();
headCode_ += xTab + "public:" + xCrLf;
if (c == enCardinality_Map) {
string mapDecl;
string mapName;
mapDecl = "I" + GetClassName() + GetCardinalityPostfix(classInfo_) + "* ";
mapName = GetCamelCase(GetClassName()) + GetCardinalityPostfix(classInfo_);
headCode_ += xTab + "virtual void SetData(" + mapDecl + mapName + ", I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + ", HTREEITEM parentItem, " + GetMainDlgName() + "* mainDialog);" + xCrLf;
} else {
headCode_ += xTab + "virtual void SetData(I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + ");" + xCrLf;
}
headCode_ += xTab + "virtual void StoreData();" + xCrLf;
headCode_ += xCrLf;
headCode_ += xTab + "// implementation of ICellListener" + xCrLf;
headCode_ += xTab + "//" + xCrLf;
headCode_ += "public:" + xCrLf;
headCode_ += xTab + "bool OnValueChanged(const string& fieldName, double oldValue, double newValue);" + xCrLf;
headCode_ += xTab + "bool OnValueChanged(const string& fieldName, long oldValue, long newValue);" + xCrLf;
headCode_ += xTab + "bool OnValueChanged(const string& fieldName, bool oldValue, bool newValue);" + xCrLf;
headCode_ += xTab + "bool OnValueChanged(const string& fieldName, string oldValue, string newValue);" + xCrLf;
headCode_ += xCrLf;
/*** OLD
headCode_ += xTab + "public:" + xCrLf;
headCode_ += xTab + "virtual void SetData(I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + ");" + xCrLf;
headCode_ += xTab + "virtual void StoreData();" + xCrLf;
headCode_ += xCrLf;
***/
}
void CAtlCatListDialogGenerator::Head_generateDialogData()
{
// dialog data section
//
headCode_ += "// Dialog Data" + xCrLf;
headCode_ += xTab + "//{{AFX_DATA(" + GetDlgName() + ")" + xCrLf;
headCode_ += "enum { IDD = IDD_CFG_TEMPLATE };" + xCrLf;
headCode_ += xTab + xTab + "// NOTE: the ClassWizard will add data members here" + xCrLf;
headCode_ += xTab + "//}}AFX_DATA" + xCrLf + xCrLf;
// declaration of option tree items
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* element;
CXmlMemberInfo* member;
string fieldName;
string fieldMemberId;
string memberVariableName;
categoryInfoList = classInfo_->GetCategoryInfoList();
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
fieldMemberId = categoryField->GetMemberId();
element = classInfo_->GetMemberById(fieldMemberId);
if (element == NULL)
continue;
member = dynamic_cast<CXmlMemberInfo*>(element);
if (member == NULL)
continue;
memberVariableName = GetCamelCase(member->GetName()) + "_";
if (member->IsHidden()) {
headCode_ += xTab + "// --- HIDDEN --- " + memberVariableName + xCrLf;
continue;
}
if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
headCode_ += xTab + "CAsComboBoxCell* " + GetCamelCase(member->GetName()) + "_;" + xCrLf;
continue;
}
if (member->GetDataType() == enDataType_String) {
switch (member->GetStringMemberGuiInfo()->GetDisplayMode()) {
case enDoubleMemberDisplayMode_GenericNumber:
if(member->IsReadOnly())
headCode_ += xTab + "CAsBaseCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
else
headCode_ += xTab + "CAsGenericTextCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
}
continue;
}
if (member->GetDataType() == enDataType_Double) {
switch (member->GetDoubleMemberGuiInfo()->GetDisplayMode()) {
case enDoubleMemberDisplayMode_GenericNumber:
headCode_ += xTab + "CAsNumericTextCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
}
continue;
}
if (member->GetDataType() == enDataType_Long) {
switch (member->GetLongMemberGuiInfo()->GetDisplayMode()) {
case enLongMemberDisplayMode_Decimal:
headCode_ += xTab + "CAsNumericTextCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
case enLongMemberDisplayMode_Hex:
headCode_ += xTab + "CAsHexadecimalTextCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
}
continue;
}
if (member->GetDataType() == enDataType_Boolean) {
switch (member->GetBooleanMemberGuiInfo()->GetDisplayMode()) {
case enBooleanMemberDisplayMode_None:
headCode_ += xTab + "// -- NOT VISIBLE -- CAsCheckBoxCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
case enBooleanMemberDisplayMode_CheckBox:
headCode_ += xTab + "CAsCheckBoxCell* " + GetCamelCase(element->GetName()) + "_;" + xCrLf;
break;
}
continue;
}
}
}
}
void CAtlCatListDialogGenerator::Head_generateOverrides()
{
headCode_ += "// Overrides" + xCrLf;
headCode_ += xTab + "// ClassWizard generated virtual function overrides" + xCrLf;
headCode_ += xTab + "//{{AFX_VIRTUAL(" + GetDlgName() + ")" + xCrLf;
headCode_ += xTab + "protected:" + xCrLf;
headCode_ += xTab + "//virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support" + xCrLf;
headCode_ += xTab + "//}}AFX_VIRTUAL" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateMessageMap()
{
headCode_ += "// Implementation" + xCrLf;
headCode_ += "//" + xCrLf;
headCode_ += "protected:" + xCrLf;
headCode_ += xCrLf;
headCode_ += xTab + "// Generated message map functions" + xCrLf;
headCode_ += xTab + "//{{AFX_MSG(" + GetDlgName() + ")" + xCrLf;
headCode_ += xTab + "virtual BOOL OnInitDialog();" + xCrLf;
headCode_ += xTab + "afx_msg void OnSize(UINT nType, int cx, int cy);" + xCrLf;
headCode_ += xTab + "//}}AFX_MSG" + xCrLf;
headCode_ += xTab + "DECLARE_MESSAGE_MAP()" + xCrLf;
headCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateProtectedMembers()
{
headCode_ += xTab + "// Implementation" + xCrLf;
headCode_ += xTab + "//" + xCrLf;
headCode_ += xTab + "protected:" + xCrLf;
headCode_ += xTab + xTab +"DECLARE_DYNCREATE(" + GetDlgName() + ");" + xCrLf;
headCode_ += xCrLf;
headCode_ += xTab + xTab + "virtual void DisplayData();" + xCrLf;
headCode_ += xTab + xTab + "virtual void OnOK();" + xCrLf;
headCode_ += xTab + xTab + "virtual void OnCancel();" + xCrLf;
headCode_ += xTab + xTab + "LRESULT OnTreeItemChanged(NMHDR* pNotifyStruct, LRESULT* plResult);" + xCrLf;
headCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateDataMembers()
{
headCode_ += xTab + "// data members" + xCrLf;
headCode_ += xTab + "//" + xCrLf;
headCode_ += xTab + "protected:" + xCrLf;
headCode_ += xTab + "I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + "_;" + xCrLf;
headCode_ += xTab + "CAsOptionListWnd* optionList_;" + xCrLf;
headCode_ += xTab + "bool initialized_;" + xCrLf;
enCardinality c;
c = classInfo_->GetCardinalityInfo()->GetCardinality();
if (c == enCardinality_Map) {
headCode_ += xTab + "HTREEITEM parentItem_;" + xCrLf;
headCode_ += xTab + GetMainDlgName() + "* mainDialog_;" + xCrLf;
headCode_ += xTab + "I" + GetClassName() + GetCardinalityPostfix(classInfo_) + "* map_;" + xCrLf;
}
headCode_ += xCrLf;
/***
headCode_ += xTab + "// data members" + xCrLf;
headCode_ += xTab + "//" + xCrLf;
headCode_ += xTab + "protected:" + xCrLf;
headCode_ += xTab + "I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + "_;" + xCrLf;
headCode_ += xTab + "COptionTree optionTree_;" + xCrLf;
headCode_ += xTab + "bool initialized_;" + xCrLf;
headCode_ += xCrLf;
***/
}
void CAtlCatListDialogGenerator::Head_generateClassEnd()
{
headCode_ += "};" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Head_generateIfDefEnd()
{
headCode_ += "#endif // !defined(" + DefineOf(GetDlgName()) + ")" + xCrLf + xCrLf;
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION FILE GENERATORS
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void CAtlCatListDialogGenerator::Impl_generateHeader()
{
implCode_ += "// " + GetDlgName() + ".cpp : implementation file" + xCrLf;
implCode_ += "//" + xCrLf;
implCode_ += GetGenerationTimeStamp();
implCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateIncludeSection()
{
implCode_ += "#include \"stdafx.h\"" + xCrLf;
implCode_ += "#include \"" + GetDlgName() + ".h\"" + xCrLf;
implCode_ += "#include \"" + GetClassName() + ".h\"" + xCrLf;
if (classInfo_->GetCardinalityInfo()->GetCardinality() != enCardinality_SingleInstance)
implCode_ += "#include \"" + GetClassName() + GetCardinalityPostfix(classInfo_) + ".h\"" + xCrLf;
implCode_ += "#include \"" + GetMainDlgName() + ".h\"" + xCrLf;
implCode_ += "#include \"resource.h\"" + xCrLf;
implCode_ += "#include \"AsBaseCell.h\"" + xCrLf;
implCode_ += "#include \"AsGenericTextCell.h\"" + xCrLf;
implCode_ += "#include \"AsCheckBoxCell.h\"" + xCrLf;
implCode_ += "#include \"AsComboBoxCell.h\"" + xCrLf;
implCode_ += "#include \"AsNumericTextCell.h\"" + xCrLf;
implCode_ += "#include \"AsHexadecimalTextCell.h\"" + xCrLf;
implCode_ += "#include \"AsOptionListWnd.h\"" + xCrLf;
implCode_ += "#include \"AsOptionList.h\"" + xCrLf;
implCode_ += "#include \"AsOptionGroup.h\"" + xCrLf;
implCode_ += "#include \"AsOptionRow.h\"" + xCrLf;
implCode_ += "#include \"AsCellEnum.h\"" + xCrLf;
implCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateDebugSymbols()
{
/*
implCode_ += "#ifdef _DEBUG" + xCrLf;
implCode_ += "#define new DEBUG_NEW" + xCrLf;
implCode_ += "#undef THIS_FILE" + xCrLf;
implCode_ += "static char THIS_FILE[] = __FILE__;" + xCrLf;
implCode_ += "#endif" + xCrLf + xCrLf;
*/
}
void CAtlCatListDialogGenerator::Impl_generateMainTitle()
{
implCode_ += "/////////////////////////////////////////////////////////////////////////////" + xCrLf;
implCode_ += "// " + GetClassName() + " dialog" + xCrLf + xCrLf;
implCode_ += "IMPLEMENT_DYNCREATE(" + GetDlgName() + ", CDialog)" + xCrLf;
implCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateConstructor()
{
implCode_ += GetDlgName() +"::" + GetDlgName() + "(CWnd* pParent /*=NULL*/):" + xCrLf;
implCode_ += xTab + "CDialog(" + GetDlgName() + "::IDD, pParent)," + xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_(NULL)," + xCrLf;
implCode_ += xTab + "initialized_(false)," + xCrLf;
implCode_ += xTab + "optionList_(NULL)";
// initialization of option tree items
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* element;
CXmlMemberInfo* member;
string fieldName;
categoryInfoList = classInfo_->GetCategoryInfoList();
if (categoryInfoList->GetSize()) {
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
element = classInfo_->GetMember(fieldName);
member = dynamic_cast<CXmlMemberInfo*>(element);
if (member && !member->IsHidden()) {
implCode_ += "," + xCrLf;
implCode_ += xTab + GetCamelCase(member->GetName()) + "_(NULL)";
if (i == (categoryInfoList->GetSize() - 1) && j == (categoryInfo->GetFieldCount() - 1))
break;
}
}
}
}
implCode_ += xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "//{{AFX_DATA_INIT(" + GetDlgName() + ")" + xCrLf;
implCode_ += xTab + xTab + "// NOTE: the ClassWizard will add member initialization here" + xCrLf;
implCode_ += xTab + "//}}AFX_DATA_INIT" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateDestructor()
{
implCode_ += GetDlgName() +"::~" + GetDlgName() + "()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "if (optionList_)" + xCrLf;
implCode_ += xTab + xTab + "delete optionList_;" + xCrLf;
implCode_ += "}" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generatePublicMethods()
{
// SetData
//
enCardinality c;
string mapDecl;
string mapName;
c = classInfo_->GetCardinalityInfo()->GetCardinality();
if (c == enCardinality_Map) {
mapDecl = "I" + GetClassName() + GetCardinalityPostfix(classInfo_) + "* ";
mapName = GetCamelCase(GetClassName()) + GetCardinalityPostfix(classInfo_);
implCode_ += "void " + GetDlgName() + "::SetData(" + mapDecl + mapName + ", I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + ", HTREEITEM parentItem, " + GetMainDlgName() + "* mainDialog)" + xCrLf;
} else {
implCode_ += "void " + GetDlgName() + "::SetData(I" + GetClassName() + "* " + GetCamelCase(classInfo_->GetName()) + ")" + xCrLf;
}
implCode_ += "{" + xCrLf;
implCode_ += xTab + "USES_CONVERSION;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "if (!initialized_)" + xCrLf;
implCode_ += xTab + xTab + "OnInitDialog();" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_ = " + GetCamelCase(classInfo_->GetName()) + ";" + xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->AddRef();" + xCrLf;
if (c == enCardinality_Map) {
implCode_ += xTab + "parentItem_ = parentItem;" + xCrLf;
implCode_ += xTab + "mainDialog_ = mainDialog;" + xCrLf;
implCode_ += xTab + "map_ = " + mapName + ";" + xCrLf;
implCode_ += xTab + "map_->AddRef();" + xCrLf;
}
implCode_ += xCrLf;
implCode_ += xTab + "// display data" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
implCode_ += xTab + "DisplayData();" + xCrLf;
implCode_ += xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
// StoreData
//
implCode_ += "void " + GetDlgName() + "::StoreData()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "USES_CONVERSION;" + xCrLf;
implCode_ += xTab + "if (!GetSafeHwnd() || " + GetCamelCase(classInfo_->GetName()) + "_ == NULL)" + xCrLf;
implCode_ += xTab + xTab + "return;" + xCrLf;
implCode_ += xCrLf;
// store data
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* element;
CXmlMemberInfo* member;
string fieldName;
CString tmp;
categoryInfoList = classInfo_->GetCategoryInfoList();
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
implCode_ += xTab + "/////////////////////////////////////////////////////////" + xCrLf;
implCode_ += xTab + "// get fields from category \"" + categoryInfo->GetCaption() + "\"" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
element = classInfo_->GetMember(fieldName);
if (element == NULL)
continue;
member = dynamic_cast<CXmlMemberInfo*>(element);
if (member == NULL)
continue;
if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
if (member->GetDataType() == enDataType_String)
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->put_" + element->GetName() + "(A2W(" + GetCamelCase(member->GetName()) + "_->GetSelectedItemKey().c_str()));" + xCrLf;
else
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->put_" + element->GetName() + "((en" + member->GetName() + ")" + GetCamelCase(member->GetName()) + "_->GetSelectedItemKey());" + xCrLf;
continue;
}
// store only members that are not readonly (read-only members did not change)
//
if (!member->IsReadOnly() && !member->IsHidden()) {
string cName;
string mName;
cName = classInfo_->GetName();
mName = member->GetName();
switch (element->GetDataType()) {
case enDataType_String:
implCode_ += xTab + GetCamelCase(cName) + "_->put_" + mName + "(A2W(" + GetCamelCase(mName) + "_->GetText().c_str()));" + xCrLf;
break;
case enDataType_Boolean:
implCode_ += xTab + GetCamelCase(cName) + "_->put_" + mName + "(" + GetCamelCase(mName) + "_->GetChecked() ? VARIANT_TRUE : VARIANT_FALSE);" + xCrLf;
break;
case enDataType_Long:
case enDataType_Double:
implCode_ += xTab + GetCamelCase(cName) + "_->put_" + mName + "(" + GetCamelCase(mName) + "_->GetValue());" + xCrLf;
break;
}
}
}
}
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->Release();" + xCrLf;
if (c == enCardinality_Map)
implCode_ += xTab + "map_->Release();" + xCrLf;
implCode_ += xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
// generate implementation of ICellListener
//
string n;
string p;
string parentPath;
parentPath = GetParentPath(NULL, parentStack_);
n = classInfo_->GetName();
implCode_ += "bool " + GetDlgName() + "::OnValueChanged(const string& fieldName, double oldValue, double newValue)" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "return true;" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
implCode_ += "bool " + GetDlgName() + "::OnValueChanged(const string& fieldName, long oldValue, long newValue)" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "return true;" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
implCode_ += "bool " + GetDlgName() + "::OnValueChanged(const string& fieldName, bool oldValue, bool newValue)" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "return true;" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
implCode_ += "bool " + GetDlgName() + "::OnValueChanged(const string& fieldName, string oldValue, string newValue)" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "USES_CONVERSION;" + xCrLf;
if (c == enCardinality_Map) {
p = GetCardinalityPostfix(classInfo_);
implCode_ += xTab + "if (fieldName == \"" + classInfo_->GetCardinalityInfo()->GetMapSortKey() + "\") {" + xCrLf;
implCode_ += xTab + xTab + "bool ret;" + xCrLf;
implCode_ += xTab + xTab + "string key;" + xCrLf;
implCode_ += xTab + xTab + "I" + GetClassName() + "* item;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + xTab + "map_->FindItem(A2W(newValue.c_str()), &item);" + xCrLf;
implCode_ += xTab + xTab + "if (item != NULL) {" + xCrLf;
implCode_ += xTab + xTab + xTab + "MessageBox(\"Key already exists\", \"Error\");" + xCrLf;
implCode_ += xTab + xTab + xTab + "return false;" + xCrLf;
implCode_ += xTab + xTab + "}" + xCrLf;
implCode_ += xTab + xTab + "map_->ReplaceKey(A2W(oldValue.c_str()), A2W(newValue.c_str()));" + xCrLf;
implCode_ += xTab + xTab + "ret = mainDialog_->ReplaceMapKey" + parentPath + "_" + n + p + "_" + n + "(parentItem_, oldValue, newValue);" + xCrLf;
implCode_ += xTab + xTab + "return ret;" + xCrLf;
implCode_ += xTab + "}" + xCrLf;
}
implCode_ += xCrLf;
implCode_ += xTab + "return true;" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateMessageMap()
{
implCode_ += "BEGIN_MESSAGE_MAP(" + GetDlgName() + ", CDialog)" + xCrLf;
implCode_ += xTab + "//{{AFX_MSG_MAP(getDlgName())" + xCrLf;
implCode_ += xTab + "ON_WM_CREATE()" + xCrLf;
implCode_ += xTab + "ON_WM_SIZE()" + xCrLf;
implCode_ += xTab + "//}}AFX_MSG_MAP" + xCrLf;
implCode_ += "END_MESSAGE_MAP()" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateOnInitDialog()
{
implCode_ += "/////////////////////////////////////////////////////////////////////////////" + xCrLf;
implCode_ += "// " + GetDlgName() + " message handlers" + xCrLf + xCrLf;
implCode_ += "BOOL " + GetDlgName() + "::OnInitDialog()" + xCrLf ;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "initialized_ = true;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "CDialog::OnInitDialog();" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "ModifyStyle(WS_POPUP, WS_CHILD | WS_CLIPCHILDREN);" + xCrLf;
implCode_ += xTab + "ShowWindow(SW_HIDE);" + xCrLf;
implCode_ += xCrLf;
// create optiontree
//
implCode_ += xTab + "// create optionList_" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
implCode_ += xTab + "CRect rc;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "GetClientRect(rc);" + xCrLf;
implCode_ += xTab + "optionList_ = new CAsOptionListWnd;" + xCrLf;
implCode_ += xTab + "if (!optionList_->Create(rc, this)) {" + xCrLf;
implCode_ += xTab + xTab + "TRACE0(\"Failed to create options control.\\r\\n\");" + xCrLf;
implCode_ += xTab + xTab + "return FALSE;" + xCrLf;
implCode_ += xTab + "}" + xCrLf;
implCode_ += xTab + "optionList_->SetFontInfo(\"tahoma\", 11, false);" + xCrLf;
implCode_ += xCrLf;
// optiontree population
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* element;
CXmlMemberInfo* member;
string fieldName;
CString tmp;
categoryInfoList = classInfo_->GetCategoryInfoList();
implCode_ += xTab + "CAsOptionList* optionList = NULL;" + xCrLf;
implCode_ += xTab + "CAsOptionGroup* newGroup = NULL;" + xCrLf;
implCode_ += xTab + "CAsOptionRow* newRow = NULL;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "optionList = optionList_->GetOptionList();" + xCrLf;
if (categoryInfoList->GetSorted())
implCode_ += xTab + "optionList->SetSorted(true);" + xCrLf;
else
implCode_ += xTab + "optionList->SetSorted(false);" + xCrLf;
implCode_ += xCrLf;
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
implCode_ += xTab + "// category \"" + categoryInfo->GetCaption() + "\"" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
implCode_ += xTab + "newGroup = optionList->AddGroup(\"" + categoryInfo->GetCaption() + "\");" + xCrLf;
implCode_ += xTab + "newGroup->SetDescription(\"" + EscapeString(categoryInfo->GetDescription()) + "\");" + xCrLf;
if (categoryInfo->GetSorted())
implCode_ += xTab + "newGroup->SetSorted(true);" + xCrLf;
else
implCode_ += xTab + "newGroup->SetSorted(false);" + xCrLf;
implCode_ += xCrLf;
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
element = classInfo_->GetMember(fieldName);
if (element == NULL)
continue;
member = dynamic_cast<CXmlMemberInfo*>(element);
if (member == NULL || member->IsHidden())
continue;
string caption;
string description;
string memberName;
caption = categoryField->GetCaption();
description = EscapeString(categoryField->GetDescription());
memberName = GetCamelCase(member->GetName()) + "_";
if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
if (member->IsReadOnly()) {
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_Caption);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = newRow->GetValueCell();" + xCrLf;
} else {
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_ComboBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = dynamic_cast<CAsComboBoxCell*>(newRow->GetValueCell());" + xCrLf;
}
} else {
switch (element->GetDataType()) {
case enDataType_String:
if (member->IsReadOnly()) {
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_Caption);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = newRow->GetValueCell();" + xCrLf;
} else {
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_TextBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = dynamic_cast<CAsGenericTextCell*>(newRow->GetValueCell());" + xCrLf;
}
break;
case enDataType_Double:
tmp.Format("%d", dynamic_cast<CXmlMemberInfo*>(element)->GetDecimalPlaces());
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_NumTextBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = dynamic_cast<CAsNumericTextCell*>(newRow->GetValueCell());" + xCrLf;
implCode_ += xTab + memberName + "->SetPrecision(" + (const char*)tmp + ");" + xCrLf;
if (member->IsReadOnly())
implCode_ += xTab + memberName + "->SetReadOnly(true);" + xCrLf;
break;
case enDataType_Long:
switch (member->GetLongMemberGuiInfo()->GetDisplayMode()) {
case enLongMemberDisplayMode_Decimal:
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_NumTextBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = dynamic_cast<CAsNumericTextCell*>(newRow->GetValueCell());" + xCrLf;
implCode_ += xTab + memberName + "->SetPrecision(0);" + xCrLf;
break;
case enLongMemberDisplayMode_Hex:
tmp.Format("%d", member->GetLongMemberGuiInfo()->GetHexBitCount());
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + caption + "\", \"" + caption + "\", enCellType_HexTextBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + description + "\");" + xCrLf;
implCode_ += xTab + memberName + " = dynamic_cast<CAsHexadecimalTextCell*>(newRow->GetValueCell());" + xCrLf;
implCode_ += xTab + memberName + "->SetBitCount(" + string((const char*)tmp) + ");" + xCrLf;
break;
}
if (member->IsReadOnly())
implCode_ += xTab + memberName + "->SetReadOnly(true);" + xCrLf;
break;
case enDataType_Boolean:
implCode_ += xTab + "newRow = newGroup->AddRow(\"" + categoryField->GetCaption() + "\", \"" + categoryField->GetCaption() + "\", enCellType_CheckBox);" + xCrLf;
implCode_ += xTab + "newRow->SetDescription(\"" + EscapeString(categoryField->GetDescription()) + "\");" + xCrLf;
implCode_ += xTab + GetCamelCase(element->GetName()) + "_ = dynamic_cast<CAsCheckBoxCell*>(newRow->GetValueCell());" + xCrLf;
if (member->IsReadOnly())
implCode_ += xTab + memberName + "->SetReadOnly();" + xCrLf;
break;
}
implCode_ += xTab + "newRow->GetValueCell()->SetCellListener(this);" + xCrLf;
implCode_ += xTab + "newRow->GetValueCell()->SetName(\"" + member->GetName() + "\");" + xCrLf;
implCode_ += xCrLf;
}
}
}
implCode_ += xTab + "ShowWindow(SW_SHOW);" + xCrLf;
//implCode_ += xTab + "//" + xCrLf;
//implCode_ += xTab + "DisplayData();" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "return TRUE; // return TRUE unless you set the focus to a control" + xCrLf;
implCode_ += xTab + " // EXCEPTION: OCX Property Pages should return FALSE" + xCrLf;
implCode_ += "}" + xCrLf + xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateProtectedMembers()
{
implCode_ += "void " + GetDlgName() + "::DisplayData()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "USES_CONVERSION;" + xCrLf;
implCode_ += xTab + "if (!GetSafeHwnd() || " + GetCamelCase(classInfo_->GetName()) + "_ == NULL)" + xCrLf;
implCode_ += xTab + xTab + "return;" + xCrLf;
implCode_ += xCrLf;
// display data
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* element;
CXmlMemberInfo* member;
string fieldName;
CString tmp;
string varName;
categoryInfoList = classInfo_->GetCategoryInfoList();
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
implCode_ += xTab + "/////////////////////////////////////////////////////////" + xCrLf;
implCode_ += xTab + "// format field of category \"" + categoryInfo->GetCaption() + "\"" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
implCode_ += xCrLf;
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
element = classInfo_->GetMember(fieldName);
if (element == NULL)
continue;
member = dynamic_cast<CXmlMemberInfo*>(element);
if (member == NULL || member->IsHidden())
continue;
varName = GetCamelCase(member->GetName()) + "Value";
implCode_ += xTab + "// display field \"" + member->GetName() + "\"" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
CXmlMemberValidation_StaticEnum* staticEnum;
CXmlMemberValidation_StaticEnumItem* item;
StaticEnumItemsMap* items;
StaticEnumItemsMap::iterator it;
staticEnum = member->GetValidationInfo()->GetStaticEnum();
items = staticEnum->GetItems();
implCode_ += xTab + "en" + member->GetName() + " " + varName + ";" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->DeleteAllItems();" + xCrLf;
for (it = items->begin(); it != items->end(); it++) {
item = it->second;
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->AddItem(\"" + item->GetItemDescription() + "\", en" + member->GetName() + "_" + item->GetItemName() + ");" + xCrLf;
}
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + varName + ");" + xCrLf;
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->SelectItem(" + varName + ");" + xCrLf;
} else {
switch (element->GetDataType()) {
case enDataType_String:
implCode_ += xTab + "CComBSTR " + varName + ";" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + varName + ");" + xCrLf;
if (member->IsReadOnly())
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->SetText(W2A(" + varName + "));" + xCrLf;
else
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->SetText(W2A(" + varName + "));" + xCrLf;
//implCode_ += xTab + "SysFreeString(" + varName + ");" + xCrLf;
implCode_ += xCrLf;
break;
case enDataType_Boolean:
implCode_ += xTab + OleTypeOf(element->GetDataType()) + " " + varName + ";" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + varName + ");" + xCrLf,
implCode_ += xTab + GetCamelCase(element->GetName()) + "_->SetChecked(" + varName + " == VARIANT_TRUE);" + xCrLf;
implCode_ += xCrLf;
break;
case enDataType_Long:
if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum)
implCode_ += xTab + "en" + element->GetName() + " " + varName + ";" + xCrLf;
else
implCode_ += xTab + OleTypeOf(element->GetDataType()) + " " + varName + ";" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + varName + ");" + xCrLf,
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetValue(" + varName + ");" + xCrLf;
implCode_ += xCrLf;
break;
case enDataType_Double:
implCode_ += xTab + OleTypeOf(element->GetDataType()) + " " + varName + ";" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab +GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + varName + ");" + xCrLf,
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetValue(" + varName + ");" + xCrLf;
implCode_ += xCrLf;
break;
}
}
implCode_ += xCrLf;
}
}
implCode_ += xCrLf;
implCode_ += xTab + "optionList_->RedrawWindow();" + xCrLf;
implCode_ += xTab + "optionList_->GetOptionList()->RedrawWindow();" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
// OnOK()
//
implCode_ += "void " + GetDlgName() + "::OnOK()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += "}" + xCrLf;
// OnCancel()
//
implCode_ += "void " + GetDlgName() + "::OnCancel()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += "}" + xCrLf;
/*** OLD
implCode_ += "void " + GetDlgName() + "::DisplayData()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "USES_CONVERSION;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "if (!GetSafeHwnd() || " + GetCamelCase(classInfo_->GetName()) + "_ == NULL)" + xCrLf;
implCode_ += xTab + xTab + "return;" + xCrLf;
implCode_ += xCrLf;
// display data
//
CXmlGuiCategoryInfoList* categoryInfoList;
CXmlGuiCategoryInfo* categoryInfo;
CXmlGuiCategoryField* categoryField;
CXmlBaseElement* member;
string fieldName;
string tmpName;
CString tmp;
categoryInfoList = classInfo_->GetCategoryInfoList();
for (int i = 0; i < categoryInfoList->GetSize(); i++) {
categoryInfo = categoryInfoList->GetCategory(i);
implCode_ += xTab + "/////////////////////////////////////////////////////////" + xCrLf;
implCode_ += xTab + "// format field of category \"" + categoryInfo->GetCaption() + "\"" + xCrLf;
implCode_ += xTab + "//" + xCrLf;
for (int j = 0; j < categoryInfo->GetFieldCount(); j++) {
categoryField = categoryInfo->GetField(j);
fieldName = categoryField->GetMemberName();
member = classInfo_->GetMember(fieldName);
if (member) {
implCode_ += xTab + "CString " + GetCamelCase(member->GetName()) + "Value;" + xCrLf;
tmpName = GetCamelCase(member->GetName()) + "Tmp";
implCode_ += xTab + OleTypeOf(member->GetDataType()) + " " + tmpName + ";" + xCrLf;
switch (member->GetDataType()) {
case enDataType_String:
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + tmpName + ");" + xCrLf;
implCode_ += xTab + GetCamelCase(member->GetName()) + "Value = W2A(" + tmpName + ");" + xCrLf;
if (categoryField->GetReadOnly())
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetStaticText(" + GetCamelCase(member->GetName()) + "Value);" + xCrLf;
else
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetWindowText(" + GetCamelCase(member->GetName()) + "Value);" + xCrLf;
implCode_ += xTab + "SysFreeString(" + tmpName + ");" + xCrLf;
break;
case enDataType_Boolean:
implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + tmpName + ");" + xCrLf;
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetCheck(" + tmpName + " == VARIANT_TRUE ? TRUE : FALSE);" + xCrLf;
if (categoryField->GetReadOnly())
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetReadOnly(TRUE);" + xCrLf;
break;
case enDataType_Long:
implCode_ += GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + tmpName + ");" + xCrLf;
tmp.Format("Value.Format(\"%%0%dd\"", dynamic_cast<CXmlMemberInfo*>(member)->GetDigitPlaces());
implCode_ += xTab + GetCamelCase(member->GetName()) + (const char*)tmp + ", " + tmpName + ");" + xCrLf;
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetWindowText(" + GetCamelCase(member->GetName()) + "Value);" + xCrLf;
break;
case enDataType_Double:
implCode_ += GetCamelCase(classInfo_->GetName()) + "_->get_" + member->GetName() + "(&" + tmpName + ");" + xCrLf;
tmp.Format("Value.Format(\"%%%d.%df\"", dynamic_cast<CXmlMemberInfo*>(member)->GetDigitPlaces(), dynamic_cast<CXmlMemberInfo*>(member)->GetDecimalPlaces());
implCode_ += xTab + GetCamelCase(member->GetName()) + (const char*)tmp + ", " + tmpName + ");" + xCrLf;
implCode_ += xTab + GetCamelCase(member->GetName()) + "_->SetWindowText(" + GetCamelCase(member->GetName()) + "Value);" + xCrLf;
break;
}
implCode_ += xCrLf;
} else {
TRACE("Warning fieldName not found!!!\n");
}
}
}
//implCode_ += xTab + "RedrawWindow();" + xCrLf;
implCode_ += xTab + "optionTree_.Invalidate();" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
// OnOK()
//
implCode_ += "void " + GetDlgName() + "::OnOK()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += "}" + xCrLf;
// OnCancel()
//
implCode_ += "void " + GetDlgName() + "::OnCancel()" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += "}" + xCrLf;
*/
}
void CAtlCatListDialogGenerator::Head_generateDefineSection()
{
headCode_ += "#ifdef IDD_CFG_TEMPLATE" + xCrLf;
headCode_ += xTab + "#undef IDD_CFG_TEMPLATE" + xCrLf;
headCode_ += "#endif" + xCrLf;
headCode_ += xCrLf;
headCode_ += "#define IDD_CFG_TEMPLATE 1001" + xCrLf;
headCode_ += xCrLf;
}
void CAtlCatListDialogGenerator::Impl_generateOnSize()
{
implCode_ += "void " + GetDlgName() + "::OnSize(UINT nType, int cx, int cy)" + xCrLf;
implCode_ += "{" + xCrLf;
implCode_ += xTab + "CDialog::OnSize(nType, cx, cy);" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + "if (GetSafeHwnd() && optionList_->GetSafeHwnd()) {" + xCrLf;
implCode_ += xTab + xTab + "CRect rc;" + xCrLf;
implCode_ += xCrLf;
implCode_ += xTab + xTab + "GetClientRect(rc);" + xCrLf;
implCode_ += xTab + xTab + "optionList_->SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW);" + xCrLf;
implCode_ += xTab + "}" + xCrLf;
implCode_ += "}" + xCrLf;
implCode_ += xCrLf;
}