// CppCatListDialogGenerator.cpp: implementation of the CCppCatListDialogGenerator class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CppCatListDialogGenerator.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
//////////////////////////////////////////////////////////////////////

CCppCatListDialogGenerator::CCppCatListDialogGenerator()
{

}

CCppCatListDialogGenerator::~CCppCatListDialogGenerator()
{

}

void CCppCatListDialogGenerator::Generate()
{
	GenerateHeader();
	GenerateImplementation();
}

void CCppCatListDialogGenerator::GenerateHeader()
{
	cmString fileName;
	cmString pathName;

	// header file generation
	//
	headCode_ = _T("");
	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() + _T("\\include\\");
	fileName = GetDlgName() + _T(".h");
	SaveFile(pathName + fileName, headCode_);

	hGeneratedFiles_[fileName] = pathName + fileName;
}

void CCppCatListDialogGenerator::GenerateImplementation()
{
	cmString fileName;
	cmString pathName;

	// generate implementation file
	//
	implCode_ = _T("");
	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() + _T("\\src\\");
	fileName = GetDlgName() + _T(".cpp");
	SaveFile(pathName + fileName, implCode_);

	cppGeneratedFiles_[fileName] = pathName + fileName;
}

void CCppCatListDialogGenerator::Head_generateHeader()
{
	headCode_ += _T("// ") + GetDlgName() + _T(".h : header file") + xCrLf;
	headCode_ += _T("//") + xCrLf + xCrLf;
	headCode_ += GetGenerationTimeStamp();
}

void CCppCatListDialogGenerator::Head_generateIfDefBegin()
{
	headCode_ += _T("#if !defined(") + DefineOf(GetDlgName()) + _T(")") + xCrLf;
	headCode_ += _T("#define ") + DefineOf(GetDlgName()) + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateIncludeSection()
{
	headCode_ += _T("#include \"stdafx.h\"") + xCrLf;
	headCode_ += _T("#include \"resource.h\"") + xCrLf;
	headCode_ += _T("#include \"") + GetResourceFileName() + _T(".h\"") + xCrLf;
	headCode_ += _T("#include \"ICmCellListener.h\"") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateForwardDeclarations()
{
	headCode_ += _T("// forward declarations") + xCrLf;
	headCode_ += _T("//") + xCrLf;
	headCode_ += _T("class ") + GetClassName() + _T(";") + xCrLf;
	headCode_ += _T("class cmOptionListWnd;") + xCrLf;
	headCode_ += _T("class cmBaseCell;") + xCrLf;
	headCode_ += _T("class cmGenericTextCell;") + xCrLf;
	headCode_ += _T("class cmCheckBoxCell;") + xCrLf;
	headCode_ += _T("class cmNumericTextCell;") + xCrLf;
	headCode_ += _T("class cmComboBoxCell;") + xCrLf;
	headCode_ += _T("class cmHexadecimalTextCell;") + xCrLf;
	headCode_ += _T("class cmSmartNumericTextCell;") + xCrLf;
	headCode_ += xCrLf;
	if (classInfo_->GetCardinalityInfo()->GetCardinality() != enCardinality_SingleInstance)
		headCode_ += _T("class ") + GetClassName() + GetCardinalityPostfix(classInfo_) + _T(";") + xCrLf;
	headCode_ += _T("class ") + GetClassName() + _T(";") + xCrLf;
	headCode_ += _T("class ") + GetMainDlgName() + _T(";") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateClassBegin()
{
	headCode_ += _T("/////////////////////////////////////////////////////////////////////////////") + xCrLf;
	headCode_ += _T("// ") + GetDlgName() + _T(" dialog") + xCrLf + xCrLf;

	headCode_ += _T("class ") + GetDlgName() + _T(" : public CDialog,") + xCrLf;
	headCode_ += xTab + xTab + xTab + _T("public ICmCellListener") + xCrLf;
	headCode_ += _T("{")  + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateConstructor()
{
	headCode_ += _T("public:") + xCrLf;
	headCode_ += xTab + GetDlgName() + _T("(CWnd* pParent = NULL);") + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateDestructor()
{
	headCode_ += xTab + _T("virtual ~") + GetDlgName() + _T("();") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Head_generatePublicMethods()
{
	enCardinality c;

	c = classInfo_->GetCardinalityInfo()->GetCardinality();

	headCode_ += xTab + _T("public:") + xCrLf;
	if (c == enCardinality_Map) {
		cmString mapDecl;
		cmString mapName;

		mapDecl = GetClassName() + GetCardinalityPostfix(classInfo_) + _T("* ");
		mapName = GetCamelCase(GetClassName()) + GetCardinalityPostfix(classInfo_);
		headCode_ += xTab + _T("virtual void SetData(") + mapDecl + mapName + _T(", ") + GetClassName() + _T("* ") + GetCamelCase(classInfo_->GetName()) + _T(", HTREEITEM parentItem, ") + GetMainDlgName() + _T("* mainDialog);") + xCrLf;
	} else {
		headCode_ += xTab + _T("virtual void SetData(") + GetClassName() + _T("* ") + GetCamelCase(classInfo_->GetName()) + _T(");") + xCrLf;
	}
	headCode_ += xTab + _T("virtual void StoreData();") + xCrLf;
	headCode_ += xCrLf;
	headCode_ += xTab + _T("// implementation of ICmCellListener") + xCrLf;
	headCode_ += xTab + _T("//") + xCrLf;
	headCode_ += _T("public:") + xCrLf;	
	headCode_ += xTab + _T("bool OnValueChanged(const cmString& fieldName, double oldValue, double newValue);") + xCrLf;
	headCode_ += xTab + _T("bool OnValueChanged(const cmString& fieldName, long oldValue, long newValue);") + xCrLf;
	headCode_ += xTab + _T("bool OnValueChanged(const cmString& fieldName, bool oldValue, bool newValue);") + xCrLf;
	headCode_ += xTab + _T("bool OnValueChanged(const cmString& fieldName, cmString oldValue, cmString newValue);") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateDialogData()
{
	// dialog data section
	//
	headCode_ += _T("// Dialog Data") + xCrLf;
	headCode_ += xTab + _T("//{{AFX_DATA(") +  GetDlgName() + _T(")") + xCrLf;
	headCode_ += _T("enum { IDD = IDD_CFG_TEMPLATE };")  + xCrLf;
	headCode_ += xTab + xTab + _T("// NOTE: the ClassWizard will add data members here") + xCrLf;
	headCode_ += xTab + _T("//}}AFX_DATA")  + xCrLf + xCrLf;
	
	// declaration of option tree items
	//
	CXmlGuiCategoryInfoList* categoryInfoList;
	CXmlGuiCategoryInfo* categoryInfo;
	CXmlGuiCategoryField* categoryField;
	CXmlBaseElement* element;
	CXmlMemberInfo* member;
	cmString fieldName;
	cmString fieldMemberId;
	cmString 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()) + _T("_");
			if (member->IsHidden()) {
				headCode_ += xTab + _T("// --- HIDDEN --- ") + memberVariableName + xCrLf;
				continue;
			}

			if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
				headCode_ += xTab + _T("cmComboBoxCell* ") + GetCamelCase(member->GetName()) + _T("_;") + xCrLf;
				continue;
			}

			if (member->GetDataType() == enDataType_String) {
				switch (member->GetStringMemberGuiInfo()->GetDisplayMode()) {
					case enDoubleMemberDisplayMode_GenericNumber:
						if(member->IsReadOnly())
							headCode_ += xTab + _T("cmBaseCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						else
							headCode_ += xTab + _T("cmGenericTextCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						break;
				}
				continue;
			}
		
			if (member->GetDataType() == enDataType_Double) {
				switch (member->GetDoubleMemberGuiInfo()->GetDisplayMode()) {
					case enDoubleMemberDisplayMode_GenericNumber:
						headCode_ += xTab + _T("cmNumericTextCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						break;
				}			
			
				continue;
			}
			
			if (member->GetDataType() == enDataType_Long) {
				switch (member->GetLongMemberGuiInfo()->GetDisplayMode()) {
					case enLongMemberDisplayMode_Decimal:
						headCode_ += xTab + _T("cmNumericTextCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						break;

					case enLongMemberDisplayMode_Hex:
						headCode_ += xTab + _T("cmHexadecimalTextCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						break;

					case enLongMemberDisplayMode_Smart:
						headCode_ += xTab + _T("cmSmartNumericTextCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;
						break;
				}
				continue;
			}

			if (member->GetDataType() == enDataType_Boolean) {
							
				switch (member->GetBooleanMemberGuiInfo()->GetDisplayMode()) {
					case enBooleanMemberDisplayMode_None:
						headCode_ += xTab + _T("// -- NOT VISIBLE -- cmCheckBoxCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;			
						break;

					case enBooleanMemberDisplayMode_CheckBox:
						headCode_ += xTab + _T("cmCheckBoxCell* ") + GetCamelCase(element->GetName()) + _T("_;") + xCrLf;			
						break;
				}
				continue;
			}
		}
	}
}

void CCppCatListDialogGenerator::Head_generateOverrides()
{
	headCode_ += _T("// Overrides") + xCrLf;
	headCode_ += xTab + _T("// ClassWizard generated virtual function overrides") + xCrLf;
	headCode_ += xTab + _T("//{{AFX_VIRTUAL(") + GetDlgName() + _T(")") + xCrLf;
	headCode_ += xTab + _T("protected:") + xCrLf;
	headCode_ += xTab + _T("//virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support") + xCrLf;
	headCode_ += xTab + _T("//}}AFX_VIRTUAL") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateMessageMap()
{
	headCode_ += _T("// Implementation") + xCrLf;
	headCode_ += _T("//") + xCrLf;
	headCode_ += _T("protected:") + xCrLf;
	headCode_ += xCrLf;
	headCode_ += xTab + _T("// Generated message map functions") + xCrLf;
	headCode_ += xTab + _T("//{{AFX_MSG(") + GetDlgName() + _T(")") + xCrLf;
	headCode_ += xTab + _T("virtual BOOL OnInitDialog();") + xCrLf;
	headCode_ += xTab + _T("afx_msg void OnSize(UINT nType, int cx, int cy);") + xCrLf;
	headCode_ += xTab + _T("//}}AFX_MSG") + xCrLf;
	headCode_ += xTab + _T("DECLARE_MESSAGE_MAP()") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateProtectedMembers()
{
	headCode_ += xTab + _T("// Implementation") + xCrLf;
	headCode_ += xTab + _T("//") + xCrLf;
	headCode_ += xTab + _T("protected:") + xCrLf;
	headCode_ += xTab + xTab +_T("DECLARE_DYNCREATE(") + GetDlgName() + _T(");") + xCrLf;
	headCode_ += xCrLf;
	headCode_ += xTab + xTab + _T("virtual void DisplayData();") + xCrLf;
	headCode_ += xTab + xTab + _T("virtual void OnOK();") + xCrLf;
	headCode_ += xTab + xTab + _T("virtual void OnCancel();") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateDataMembers()
{
	headCode_ += xTab + _T("// data members") + xCrLf;
	headCode_ += xTab + _T("//") + xCrLf;
	headCode_ += xTab + _T("protected:") + xCrLf;
	headCode_ += xTab + GetClassName() + _T("* ") + GetCamelCase(classInfo_->GetName()) + _T("_;") + xCrLf;
	headCode_ += xTab + _T("cmOptionListWnd* optionList_;")  + xCrLf;
	headCode_ += xTab + _T("bool initialized_;") + xCrLf;
	
	enCardinality c;

	c = classInfo_->GetCardinalityInfo()->GetCardinality();
	if (c == enCardinality_Map) {
		headCode_ += xTab + _T("HTREEITEM parentItem_;") + xCrLf;
		headCode_ += xTab + GetMainDlgName() + _T("* mainDialog_;") + xCrLf;
		headCode_ += xTab + GetClassName() + GetCardinalityPostfix(classInfo_) + _T("* map_;") + xCrLf;
	}

	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Head_generateClassEnd()
{
	headCode_ += _T("};") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateIfDefEnd()
{
	headCode_ += _T("#endif // !defined(") + DefineOf(GetDlgName()) + _T(")") + xCrLf + xCrLf;
}

///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION FILE GENERATORS
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

void CCppCatListDialogGenerator::Impl_generateHeader()
{
	implCode_ += _T("// ") + GetDlgName() + _T(".cpp : implementation file") + xCrLf;
	implCode_ += _T("//") + xCrLf;
	implCode_ += GetGenerationTimeStamp();
	implCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateIncludeSection()
{
	implCode_ += _T("#include \"stdafx.h\"") + xCrLf;
	implCode_ += _T("#include \"") + GetDlgName() + _T(".h\"") + xCrLf;
	implCode_ += _T("#include \"") + GetClassName() + _T(".h\"") + xCrLf;
	if (classInfo_->GetCardinalityInfo()->GetCardinality() != enCardinality_SingleInstance)
		implCode_ += _T("#include \"") + GetClassName() + GetCardinalityPostfix(classInfo_) + _T(".h\"") + xCrLf;
	implCode_ += _T("#include \"") + GetMainDlgName() + _T(".h\"") + xCrLf;
	implCode_ += _T("#include \"resource.h\"") + xCrLf;
	implCode_ += _T("#include \"cmBaseCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmGenericTextCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmCheckBoxCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmComboBoxCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmNumericTextCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmHexadecimalTextCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmSmartNumericTextCell.h\"") + xCrLf;
	implCode_ += _T("#include \"cmOptionListWnd.h\"") + xCrLf;
	implCode_ += _T("#include \"cmOptionList.h\"") + xCrLf;
	implCode_ += _T("#include \"cmOptionGroup.h\"") + xCrLf;
	implCode_ += _T("#include \"cmOptionRow.h\"") + xCrLf;
	implCode_ += _T("#include \"cmCellEnum.h\"") + xCrLf;
	implCode_ += xCrLf;
}

void CCppCatListDialogGenerator::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 CCppCatListDialogGenerator::Impl_generateMainTitle()
{
	implCode_ += _T("/////////////////////////////////////////////////////////////////////////////") + xCrLf;
	implCode_ += _T("// ") + GetClassName() + _T(" dialog") + xCrLf + xCrLf;

	implCode_ += _T("IMPLEMENT_DYNCREATE(") + GetDlgName() + _T(", CDialog)") + xCrLf;
	implCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateConstructor()
{
	implCode_ += GetDlgName() + _T("::") + GetDlgName() + _T("(CWnd* pParent /*=NULL*/):") + xCrLf;
	implCode_ += xTab + _T("CDialog(") + GetDlgName() + _T("::IDD, pParent),") + xCrLf;
	implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + _T("_(NULL),") + xCrLf;
	implCode_ += xTab + _T("initialized_(false),") + xCrLf;
	implCode_ += xTab + _T("optionList_(NULL)");
	// initialization of option tree items
	//
	CXmlGuiCategoryInfoList* categoryInfoList;
	CXmlGuiCategoryInfo* categoryInfo;
	CXmlGuiCategoryField* categoryField;
	CXmlBaseElement* element;
	CXmlMemberInfo* member;
	cmString 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_ += _T(",") + xCrLf;
					implCode_ += xTab + GetCamelCase(member->GetName()) + _T("_(NULL)");
					if (i == (categoryInfoList->GetSize() - 1) && j == (categoryInfo->GetFieldCount() - 1))
						break;
				}
			}
		}
	}
	implCode_ += xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("//{{AFX_DATA_INIT(") + GetDlgName() + _T(")") + xCrLf;
	implCode_ += xTab + xTab + _T("// NOTE: the ClassWizard will add member initialization here") + xCrLf;
	implCode_ += xTab + _T("//}}AFX_DATA_INIT") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateDestructor()
{
	implCode_ += GetDlgName() + _T("::~") + GetDlgName() + _T("()") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("if (optionList_)") + xCrLf;
	implCode_ += xTab + xTab + _T("delete optionList_;") + xCrLf;
	implCode_ += _T("}") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Impl_generatePublicMethods()
{
	// SetData
	//
	enCardinality c;
	cmString mapDecl;
	cmString mapName;

	c = classInfo_->GetCardinalityInfo()->GetCardinality();
	if (c == enCardinality_Map) {
		mapDecl = GetClassName() + GetCardinalityPostfix(classInfo_) + _T("* ");
		mapName = GetCamelCase(GetClassName()) + GetCardinalityPostfix(classInfo_);
		implCode_ += _T("void ") + GetDlgName() + _T("::SetData(") + mapDecl + mapName + _T(", ") + GetClassName() + _T("* ") + GetCamelCase(classInfo_->GetName()) + _T(", HTREEITEM parentItem, ") + GetMainDlgName() + _T("* mainDialog)") + xCrLf;
	} else {
		implCode_ += _T("void ") + GetDlgName() + _T("::SetData(") + GetClassName() + _T("* ") + GetCamelCase(classInfo_->GetName()) + _T(")") + xCrLf;
	}
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("if (!initialized_)") + xCrLf;
	implCode_ += xTab + xTab + _T("OnInitDialog();") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + _T("_ = ") + GetCamelCase(classInfo_->GetName()) + _T(";") + xCrLf;
	if (c == enCardinality_Map) {
		implCode_ += xTab + _T("parentItem_ = parentItem;") + xCrLf;
		implCode_ += xTab + _T("mainDialog_ = mainDialog;") + xCrLf;
		implCode_ += xTab + _T("map_ = ") + mapName + _T(";") + xCrLf;
	}
	implCode_ += xCrLf;
	implCode_ += xTab + _T("// display data") + xCrLf;
	implCode_ += xTab + _T("//") + xCrLf;
	implCode_ += xTab + _T("DisplayData();") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	// StoreData
	//
	implCode_ += _T("void ") + GetDlgName() + _T("::StoreData()") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	
	implCode_ += xTab + _T("if (!GetSafeHwnd() || ") + GetCamelCase(classInfo_->GetName()) + _T("_ == NULL)") + xCrLf;
	implCode_ += xTab + xTab + _T("return;") + xCrLf;
	implCode_ += xCrLf;

	// store data
	//
	CXmlGuiCategoryInfoList* categoryInfoList;
	CXmlGuiCategoryInfo* categoryInfo;
	CXmlGuiCategoryField* categoryField;
	CXmlBaseElement* element;
	CXmlMemberInfo* member;
	cmString fieldName;
	CString tmp;

	categoryInfoList = classInfo_->GetCategoryInfoList();

	for (int i = 0; i < categoryInfoList->GetSize(); i++) {
		categoryInfo = categoryInfoList->GetCategory(i);
		
		implCode_ += xTab + _T("/////////////////////////////////////////////////////////") + xCrLf;
		implCode_ += xTab + _T("// get fields from category \"") + categoryInfo->GetCaption() + _T("\"") + xCrLf;
		implCode_ += xTab + _T("//") + 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 &&
				!member->IsHidden()) {
				implCode_ += xTab + GetCamelCase(classInfo_->GetName()) + _T("_->Set") + element->GetName() + _T("((") + GetClassName(classInfo_->GetName()) + _T("::en") + member->GetName() + _T(")") + GetCamelCase(member->GetName()) + _T("_->GetSelectedItemKey());") + xCrLf;
				continue;
			} 
			
			// store only members that are not readonly (read-only members did not change)
			//
			if (!member->IsReadOnly() && !member->IsHidden()) {
				cmString cName;
				cmString mName;

				cName = classInfo_->GetName();
				mName = member->GetName();

				switch (element->GetDataType()) {
					case enDataType_String:
						implCode_ += xTab + GetCamelCase(cName) + _T("_->Set") + mName + _T("(") + GetCamelCase(mName) + _T("_->GetText());") + xCrLf;
						break;

					case enDataType_Boolean:
						implCode_ += xTab + GetCamelCase(cName) + _T("_->Set") + mName + _T("(") + GetCamelCase(mName) + _T("_->GetChecked());") + xCrLf;
						break;

					case enDataType_Long:
						implCode_ += xTab + GetCamelCase(cName) + _T("_->Set") + mName + _T("(") + GetCamelCase(mName) + _T("_->GetValue());") + xCrLf;
						if (IsSmartLong(member))
							implCode_ += xTab + GetCamelCase(cName) + _T("_->__SetHexDisplay_") + mName + _T("(") + GetCamelCase(mName) + _T("_->GetHexDisplayMode());") + xCrLf;
						break;

					case enDataType_Double:
						implCode_ += xTab + GetCamelCase(cName) + _T("_->Set") + mName + _T("(") + GetCamelCase(mName) + _T("_->GetValue());") + xCrLf;
						break;
				}
			}
		}
	}

	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	// generate implementation of ICmCellListener
	//
	cmString n;
	cmString p;
	cmString parentPath;

	parentPath = GetParentPath(NULL, parentStack_);
	n = classInfo_->GetName();
	
	implCode_ += _T("bool ") + GetDlgName() + _T("::OnValueChanged(const cmString& fieldName, double oldValue, double newValue)") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("return true;") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	implCode_ += _T("bool ") + GetDlgName() + _T("::OnValueChanged(const cmString& fieldName, long oldValue, long newValue)") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("return true;") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	implCode_ += _T("bool ") + GetDlgName() + _T("::OnValueChanged(const cmString& fieldName, bool oldValue, bool newValue)") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("return true;") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	implCode_ += _T("bool ") + GetDlgName() + _T("::OnValueChanged(const cmString& fieldName, cmString oldValue, cmString newValue)") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	if (c == enCardinality_Map) {
		p = GetCardinalityPostfix(classInfo_);
		implCode_ += xTab + _T("if (fieldName == _T(\"") + classInfo_->GetCardinalityInfo()->GetMapSortKey() + _T("\")) {") + xCrLf;
		implCode_ += xTab + xTab + _T("bool ret;") + xCrLf;
		implCode_ += xTab + xTab + _T("string key;") + xCrLf;
		implCode_ += xTab + xTab + GetClassName() + _T("* item;") + xCrLf;
		implCode_ += xCrLf;
		implCode_ += xTab + xTab + _T("if (map_->Find(newValue, &item)) {") + xCrLf;
		implCode_ += xTab + xTab + xTab + _T("MessageBox(_T(\"Key already exists\"), _T(\"Error\"));") + xCrLf;
		implCode_ += xTab + xTab + xTab + _T("return false;") + xCrLf;
		implCode_ += xTab + xTab + _T("}") + xCrLf;
		implCode_ += xTab + xTab + _T("map_->ReplaceKey(oldValue, newValue);") + xCrLf;
		implCode_ += xTab + xTab + _T("map_->Find(newValue, &item);") + xCrLf;
		implCode_ += xTab + xTab + GetCamelCase(classInfo_->GetName()) + _T("_ = item;") + xCrLf;
		implCode_ += xTab + xTab + _T("ret = mainDialog_->ReplaceMapKey") + parentPath + _T("_") + n + p + _T("_") + n + _T("(parentItem_, oldValue, newValue);") + xCrLf;
		implCode_ += xTab + xTab + _T("return ret;") + xCrLf;
		implCode_ += xTab + _T("}") + xCrLf;
	}
	implCode_ += xCrLf;
	implCode_ += xTab + _T("return true;") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateMessageMap()
{
	implCode_ += _T("BEGIN_MESSAGE_MAP(") + GetDlgName() + _T(", CDialog)") + xCrLf;
	implCode_ += xTab + _T("//{{AFX_MSG_MAP(getDlgName())") + xCrLf;
	implCode_ += xTab + _T("ON_WM_CREATE()") + xCrLf;
	implCode_ += xTab + _T("ON_WM_SIZE()") + xCrLf;
	implCode_ += xTab + _T("//}}AFX_MSG_MAP") + xCrLf;
	implCode_ += _T("END_MESSAGE_MAP()") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateOnInitDialog()
{
	implCode_ += _T("/////////////////////////////////////////////////////////////////////////////") + xCrLf;
	implCode_ += _T("// ") + GetDlgName() + _T(" message handlers") + xCrLf + xCrLf;

	implCode_ += _T("BOOL ") + GetDlgName() + _T("::OnInitDialog()") + xCrLf ;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("initialized_ = true;") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("CDialog::OnInitDialog();") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("ModifyStyle(WS_POPUP, WS_CHILD | WS_CLIPCHILDREN);") + xCrLf;
	implCode_ += xTab + _T("ShowWindow(SW_HIDE);") + xCrLf;
	implCode_ += xCrLf;

	// create optiontree
	//
	implCode_ += xTab + _T("// create optionList_") + xCrLf;
	implCode_ += xTab + _T("//") + xCrLf;
	implCode_ += xTab + _T("CRect rc;") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("GetClientRect(rc);") + xCrLf;
	implCode_ += xTab + _T("optionList_ = new cmOptionListWnd;") + xCrLf;
	implCode_ += xTab + _T("if (!optionList_->Create(rc, this)) {") + xCrLf;
	implCode_ += xTab + xTab + _T("TRACE0(\"Failed to create options control.\\r\\n\");") + xCrLf;
	implCode_ += xTab + xTab + _T("return FALSE;") + xCrLf;
	implCode_ += xTab + _T("}") + xCrLf;
	implCode_ += xTab +	_T("optionList_->SetFontInfo(_T(\"tahoma\"), 11, false);") + xCrLf;
	implCode_ += xCrLf;

	// optiontree population
	//
	CXmlGuiCategoryInfoList* categoryInfoList;
	CXmlGuiCategoryInfo* categoryInfo;
	CXmlGuiCategoryField* categoryField;
	CXmlBaseElement* element;
	CXmlMemberInfo* member;
	cmString fieldName;
	CString tmp;

	categoryInfoList = classInfo_->GetCategoryInfoList();

	implCode_ += xTab + _T("cmOptionList* optionList = NULL;") + xCrLf;
	implCode_ += xTab + _T("cmOptionGroup* newGroup = NULL;") + xCrLf;
	implCode_ += xTab + _T("cmOptionRow* newRow = NULL;") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("optionList = optionList_->GetOptionList();") + xCrLf;
	if (categoryInfoList->GetSorted())
		implCode_ += xTab + _T("optionList->SetSorted(true);") + xCrLf;
	else
		implCode_ += xTab + _T("optionList->SetSorted(false);") + xCrLf;
	
	implCode_ += xCrLf;
	for (int i = 0; i < categoryInfoList->GetSize(); i++) {
		categoryInfo = categoryInfoList->GetCategory(i);
		
		implCode_ += xTab + _T("// category \"") + categoryInfo->GetCaption() + _T("\"") + xCrLf;
		implCode_ += xTab + _T("//") + xCrLf;
		implCode_ += xTab + _T("newGroup = optionList->AddGroup(_T(\"") + categoryInfo->GetCaption() + _T("\"));") + xCrLf;
		implCode_ += xTab + _T("newGroup->SetDescription(_T(\"") + EscapeString(categoryInfo->GetDescription()) + _T("\"));") + xCrLf;
		if (categoryInfo->GetSorted())
			implCode_ += xTab + _T("newGroup->SetSorted(true);") + xCrLf;
		else
			implCode_ += xTab + _T("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;

			cmString caption;
			cmString description;
			cmString memberName;

			caption = categoryField->GetCaption();
			description = EscapeString(categoryField->GetDescription());
			memberName = GetCamelCase(member->GetName()) + _T("_");

			if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
				if (member->IsReadOnly()) {
					implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_Caption);") + xCrLf;
					implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
					implCode_ += xTab + memberName + _T(" = newRow->GetValueCell();") + xCrLf;							
				} else {
					implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_ComboBox);") + xCrLf;
					implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
					implCode_ += xTab + memberName + _T(" = dynamic_cast<cmComboBoxCell*>(newRow->GetValueCell());") + xCrLf;							
				}
			} else {
				switch (element->GetDataType()) {
					case enDataType_String:
						if (member->IsReadOnly()) {
							implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_Caption);") + xCrLf;
							implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
							implCode_ += xTab + memberName + _T(" = newRow->GetValueCell();") + xCrLf;							
						} else {
							implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_TextBox);") + xCrLf;
							implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
							implCode_ += xTab + memberName + _T(" = dynamic_cast<cmGenericTextCell*>(newRow->GetValueCell());") + xCrLf;							
						}
						break;

					case enDataType_Double:
						tmp.Format(_T("%d"), dynamic_cast<CXmlMemberInfo*>(element)->GetDecimalPlaces());
						implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_NumTextBox);") + xCrLf;
						implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
						implCode_ += xTab + memberName + _T(" = dynamic_cast<cmNumericTextCell*>(newRow->GetValueCell());") + xCrLf;							
						implCode_ += xTab + memberName + _T("->SetPrecision(") + tmp + _T(");") + xCrLf;
						if (member->IsReadOnly())
							implCode_ += xTab + memberName + _T("->SetReadOnly(true);") + xCrLf;
						break;

					case enDataType_Long:
						switch (member->GetLongMemberGuiInfo()->GetDisplayMode()) {
							case enLongMemberDisplayMode_Decimal:
								implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_NumTextBox);") + xCrLf;
								implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
								implCode_ += xTab + memberName + _T(" = dynamic_cast<cmNumericTextCell*>(newRow->GetValueCell());") + xCrLf;							
								implCode_ += xTab + memberName + _T("->SetPrecision(0);") + xCrLf;
								break;

							case enLongMemberDisplayMode_Hex:
								tmp.Format(_T("%d"), member->GetLongMemberGuiInfo()->GetHexBitCount());
								implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_HexTextBox);") + xCrLf;
								implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
								implCode_ += xTab + memberName + _T(" = dynamic_cast<cmHexadecimalTextCell*>(newRow->GetValueCell());") + xCrLf;							
								implCode_ += xTab + memberName + _T("->SetBitCount(") + tmp + _T(");") + xCrLf;
								break;

							case enLongMemberDisplayMode_Smart:
								tmp.Format(_T("%d"), member->GetLongMemberGuiInfo()->GetHexBitCount());
								implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + caption + _T("\"), _T(\"") + caption + _T("\"), enCmCellType_SmartNumTextBox);") + xCrLf;
								implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + description + _T("\"));") + xCrLf;
								implCode_ += xTab + memberName + _T(" = dynamic_cast<cmSmartNumericTextCell*>(newRow->GetValueCell());") + xCrLf;							
								//implCode_ += xTab + memberName + _T("->SetBitCount(") + tmp + _T(");") + xCrLf;
								break;

						}
						
						if (member->IsReadOnly())
							implCode_ += xTab + memberName + _T("->SetReadOnly(true);") + xCrLf;
						break;

					case enDataType_Boolean:
						implCode_ += xTab + _T("newRow = newGroup->AddRow(_T(\"") + categoryField->GetCaption() + _T("\"), _T(\"") + categoryField->GetCaption() + _T("\"), enCmCellType_CheckBox);") + xCrLf;
						implCode_ += xTab + _T("newRow->SetDescription(_T(\"") + EscapeString(categoryField->GetDescription()) + _T("\"));") + xCrLf;
						implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_ = dynamic_cast<cmCheckBoxCell*>(newRow->GetValueCell());") + xCrLf;							
						if (member->IsReadOnly())
							implCode_ += xTab + memberName + _T("->SetReadOnly(true);") + xCrLf;
						break;
				}
				implCode_ += xTab + _T("newRow->GetValueCell()->SetCellListener(this);") + xCrLf;
				implCode_ += xTab + _T("newRow->GetValueCell()->SetName(_T(\"") + member->GetName() + _T("\"));") + xCrLf;
				implCode_ += xCrLf;
			}
		}
	}

	implCode_ += xTab + _T("ShowWindow(SW_SHOW);") + xCrLf;
		
	//implCode_ += xTab + "//" + xCrLf;
	//implCode_ += xTab + "DisplayData();" + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("return TRUE;  // return TRUE unless you set the focus to a control") + xCrLf;
	implCode_ += xTab + _T("			   // EXCEPTION: OCX Property Pages should return FALSE")  + xCrLf;
	implCode_ += _T("}") + xCrLf + xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateProtectedMembers()
{
	implCode_ += _T("void ") + GetDlgName() + _T("::DisplayData()") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("if (!GetSafeHwnd() || ") + GetCamelCase(classInfo_->GetName()) + _T("_ == NULL)") + xCrLf;
	implCode_ += xTab + xTab + _T("return;") + xCrLf;
	implCode_ += xCrLf;

	// display data
	//
	CXmlGuiCategoryInfoList* categoryInfoList;
	CXmlGuiCategoryInfo* categoryInfo;
	CXmlGuiCategoryField* categoryField;
	CXmlBaseElement* element;
	CXmlMemberInfo* member;
	cmString fieldName;
	cmString tmp;

	categoryInfoList = classInfo_->GetCategoryInfoList();

	for (int i = 0; i < categoryInfoList->GetSize(); i++) {
		categoryInfo = categoryInfoList->GetCategory(i);
		
		implCode_ += xTab + _T("/////////////////////////////////////////////////////////") + xCrLf;
		implCode_ += xTab + _T("// format field of category \"") + categoryInfo->GetCaption() + _T("\"") + xCrLf;
		implCode_ += xTab + _T("//") + 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;

			if (member->GetValidationInfo()->GetValidationMode() == enValidationMode_StaticEnum) {
				CXmlMemberValidation_StaticEnum* staticEnum;
				CXmlMemberValidation_StaticEnumItem* item;
				StaticEnumItems* items;
								
				staticEnum = member->GetValidationInfo()->GetStaticEnum();
				items = staticEnum->GetItems();
				
				implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->DeleteAllItems();") + xCrLf;
				
				for (int i = 0; i < items->size(); i++) {
					item = (*items)[i];

					implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->AddItem(_T(\"") + item->GetItemDescription() + _T("\"), ") + GetClassName(classInfo_->GetName()) + _T("::en") + member->GetName() + _T("_") + item->GetItemName() + _T(");") + xCrLf;
				}

				implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->SelectItem(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
			} else {
				switch (element->GetDataType()) {
					case enDataType_String:
						if (member->IsReadOnly())
							implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->SetText(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
						else
							implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->SetText(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
						break;

					case enDataType_Boolean:
						implCode_ += xTab + GetCamelCase(element->GetName()) + _T("_->SetChecked(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
						break;

					case enDataType_Long:
						if (IsSmartLong(member)) 
							implCode_ += xTab + GetCamelCase(member->GetName()) + _T("_->SetHexDisplayMode(") + GetCamelCase(classInfo_->GetName()) + _T("_->__GetHexDisplay_") + member->GetName() + _T("());") + xCrLf;
						implCode_ += xTab + GetCamelCase(member->GetName()) + _T("_->SetValue(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
						break;

					case enDataType_Double:
						implCode_ += xTab + GetCamelCase(member->GetName()) + _T("_->SetValue(") + GetCamelCase(classInfo_->GetName()) + _T("_->Get") + member->GetName() + _T("());") + xCrLf;
						break;

				}
			}
		}
	}
	implCode_ += xCrLf;
	implCode_ += xTab + _T("optionList_->RedrawWindow();") + xCrLf;
	implCode_ += xTab + _T("optionList_->GetOptionList()->RedrawWindow();") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;

	// OnOK()
	//
	implCode_ += _T("void ") + GetDlgName() + _T("::OnOK()") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += _T("}") + xCrLf;

	// OnCancel()
	//
	implCode_ += _T("void ") + GetDlgName() + _T("::OnCancel()") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += _T("}") + xCrLf;
}

void CCppCatListDialogGenerator::Head_generateDefineSection()
{
	headCode_ += _T("#ifdef IDD_CFG_TEMPLATE") + xCrLf;
	headCode_ += xTab + _T("#undef IDD_CFG_TEMPLATE") + xCrLf;
	headCode_ += _T("#endif") + xCrLf;
	headCode_ += xCrLf;
	headCode_ += _T("#define IDD_CFG_TEMPLATE                1001") + xCrLf;
	headCode_ += xCrLf;
}

void CCppCatListDialogGenerator::Impl_generateOnSize()
{
	implCode_ += _T("void ") + GetDlgName() + _T("::OnSize(UINT nType, int cx, int cy)") + xCrLf;
	implCode_ += _T("{") + xCrLf;
	implCode_ += xTab + _T("CDialog::OnSize(nType, cx, cy);") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + _T("if (GetSafeHwnd() && optionList_->GetSafeHwnd()) {") + xCrLf;
	implCode_ += xTab + xTab + _T("CRect rc;") + xCrLf;
	implCode_ += xCrLf;
	implCode_ += xTab + xTab + _T("GetClientRect(rc);") + xCrLf;
	implCode_ += xTab + xTab + _T("optionList_->SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW);") + xCrLf;
	implCode_ += xTab + _T("}") + xCrLf;
	implCode_ += _T("}") + xCrLf;
	implCode_ += xCrLf;
}

