⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlclassdocdlg.cpp

📁 文档生成工具 XML例子
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// XMLClassDocDlg.cpp : implementation file
//

#include "stdafx.h"
#include "XMLClassDoc.h"
#include "XMLClassDocDlg.h"
#include "HFileToDoc.h"
#include "DocManage.h"
#include "AddClassDlg.h"
#include "AddFunctionDlg.h"
#include "AddPropertyDlg.h"
#include "FModifyDlg.h"
#include "PModifyDlg.h"
#include "printDocDlg.h"
#include "StringDefine.h"
#include "resource.h"
#include "DirDialog.h"
#include "ConfigDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern CXMLClassDocApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXMLClassDocDlg dialog

CXMLClassDocDlg::CXMLClassDocDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CXMLClassDocDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXMLClassDocDlg)
	m_bFunction = true;
	m_bPrivate = true;
	m_bProperty = true;
	m_bProtected = true;
	m_bPublic = true;
	m_strClassDesc = _T("");
	m_strPath = _T("");
	m_strPrivateF = _T("");
	m_strPrivateP = _T("");
	m_strProtectedF = _T("");
	m_strProtectedP = _T("");
	m_strPublicF = _T("");
	m_strPublicP = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_nNetRootFolderID = -1;
}

void CXMLClassDocDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXMLClassDocDlg)
	DDX_Control(pDX, IDC_LISTLOC, m_ListLoc);
	DDX_Control(pDX, IDC_LIST_CLASSINFO, m_ListCtrl);
	DDX_Check(pDX, IDC_CHECKFUNCTION, m_bFunction);
	DDX_Check(pDX, IDC_CHECKPRIVATE, m_bPrivate);
	DDX_Check(pDX, IDC_CHECKPROPERTY, m_bProperty);
	DDX_Check(pDX, IDC_CHECKPROTECTED, m_bProtected);
	DDX_Check(pDX, IDC_CHECKPUBLIC, m_bPublic);
	DDX_Text(pDX, IDC_CLASSDESC, m_strClassDesc);
	DDX_Text(pDX, IDC_PATH, m_strPath);
	DDX_Text(pDX, IDC_PRIVATEFUNCTION, m_strPrivateF);
	DDX_Text(pDX, IDC_PRIVATEPROPERTY, m_strPrivateP);
	DDX_Text(pDX, IDC_PROTECTEDFUNCTION, m_strProtectedF);
	DDX_Text(pDX, IDC_PROTECTEDPROPERTY, m_strProtectedP);
	DDX_Text(pDX, IDC_PUBLICFUNCTION, m_strPublicF);
	DDX_Text(pDX, IDC_PUBLICPROPERTY, m_strPublicP);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CXMLClassDocDlg, CDialog)
	//{{AFX_MSG_MAP(CXMLClassDocDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_NEW_DOC, OnNewDoc)
	ON_EN_KILLFOCUS(IDC_CLASSDESC, OnKillfocusClassdesc)
	ON_BN_CLICKED(IDC_CHECKFUNCTION, OnCheckChange)
	ON_BN_CLICKED(IDC_NEW_CLASSDOC, OnNewClassdoc)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_CLASSINFO, OnDblclkListClassinfo)
	ON_BN_CLICKED(IDC_ADD_FUNCTION, OnAddFunction)
	ON_BN_CLICKED(IDC_ADD_PROPERTY, OnAddProperty)
	ON_BN_CLICKED(IDC_PRINT, OnPrint)
	ON_COMMAND(ID_POP_DELETEDOC, OnDeletedoc)
	ON_COMMAND(ID_POP_DELETEMEMBER, OnDeletemember)
	ON_NOTIFY(NM_RCLICK, IDC_LIST_CLASSINFO, OnRclickListClassinfo)
	ON_NOTIFY(NM_CLICK, IDC_LISTLOC, OnClickListloc)
	ON_NOTIFY(NM_RCLICK, IDC_LISTLOC, OnRclickListloc)
	ON_BN_CLICKED(IDC_CHECKPRIVATE, OnCheckChange)
	ON_BN_CLICKED(IDC_CHECKPROPERTY, OnCheckChange)
	ON_BN_CLICKED(IDC_CHECKPROTECTED, OnCheckChange)
	ON_BN_CLICKED(IDC_CHECKPUBLIC, OnCheckChange)
	ON_COMMAND(ID_POP_ADDFUNCTION, OnAddFunction)
	ON_COMMAND(ID_POP_ADDPROPERTY, OnAddProperty)
	ON_COMMAND(ID_POP_PRINT, OnPrint)
	ON_BN_CLICKED(IDC_DELETEDOC, OnDeletedoc)
	ON_BN_CLICKED(IDC_DELETE_MEMBER, OnDeletemember)
	ON_BN_CLICKED(IDC_NEW_PATH, OnNewPath)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXMLClassDocDlg message handlers

BOOL CXMLClassDocDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_ilSmall.Create (IDB_SMALLDOC, 16, 1, RGB (255, 0, 255));
	m_ilSmallLoc.Create (IDB_SMALLLOC, 16, 1, RGB (255, 0, 255));
	m_strPath = theApp.m_strLocPath;
	m_ListLoc.SetImageList (&m_ilSmallLoc, LVSIL_SMALL);
	m_ListLoc.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	
	m_ListLoc.InsertColumn (0, _T ("类名"), LVCFMT_LEFT, 325);
    //m_ListLoc.InsertColumn (2, _T ("最后修改日期"), LVCFMT_CENTER, 128);
	
	InitData();
	ReadClassList();
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	UpdateData(FALSE);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CXMLClassDocDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CXMLClassDocDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CXMLClassDocDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CXMLClassDocDlg::OnOK() 
{
	
}

void CXMLClassDocDlg::OnNewDoc() 
{
	CFileDialog* fileInDlg = new CFileDialog(true);
	fileInDlg->m_ofn.lpstrFilter = "头文件 (*.h)\0*.h\0";
	if(fileInDlg->DoModal() == 1)
	{
		char pszInFilePath[200];
		memset(pszInFilePath, 0, sizeof(pszInFilePath));
		sprintf(pszInFilePath, "%s", fileInDlg->GetPathName());
	
		if (pszInFilePath != NULL)
		{
			CHFileToDoc *pFTOD = new CHFileToDoc();
			pFTOD->OpenFile(pszInFilePath);
			delete pFTOD;
		}
	}
	ReadClassList();
//	m_ListLoc.SetSelectionMark(-1);
	//m_ListClass.SetCurSel(-1);
	m_ListCtrl.DeleteAllItems();
	m_strClassDesc.Empty();
	m_strClassName.Empty();
	UpdateData(false);
	delete fileInDlg;	
}

BOOL CXMLClassDocDlg::InitData()
{
	CDC*  pDC;
	pDC = m_ListCtrl.GetDC();
	CSize sz;
	char sName[][32]=
	{
		"成员名",
		"属性",
		"说明"
	};
	int x[3] = {80,40,420};
	for(int i=0;i<sizeof(sName)/32;i++)
	{
		sz=pDC->GetTextExtent(CString(sName[i]));
		sz.cx+=x[i];
		m_ListCtrl.InsertColumn(i,sName[i],LVCFMT_LEFT,sz.cx);
	}
	m_ListCtrl.ReleaseDC(pDC);
	m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	return TRUE;

}

BOOL CXMLClassDocDlg::ReadClassList()
{
	m_ListLoc.DeleteAllItems();
	CDocManage* pDocManage = new CDocManage();
	if(!pDocManage->ReadClassList(m_ListLoc,theApp.m_strLocPath))
	{
		MessageBox("读取类列表失败!", "错误");
	}
	delete pDocManage;
	return true;
}

void CXMLClassDocDlg::OnKillfocusClassdesc() 
{
	UpdateData(true);
	if(!m_strClassName.IsEmpty())
	{
		CDocManage* pDocManage = new CDocManage();
		pDocManage->WriteClassDesc(m_strClassName, m_strClassDesc);
		delete pDocManage;
	}
}

void CXMLClassDocDlg::OnCheckChange() 
{
	UpdateData(true);
	if(!m_strClassName.IsEmpty())
	{
		ReadClassInfo();
	}
}

BOOL CXMLClassDocDlg::ReadClassInfo()
{
	POSITION pos =m_ListLoc.GetFirstSelectedItemPosition();
	if(pos!=NULL)
	{	
		int nIdex = m_ListLoc.GetNextSelectedItem(pos);
		m_strClassName = m_ListLoc.GetItemText(nIdex,0);
	}
	if(m_strClassName.IsEmpty())
	{
		return false;
	}
	m_ListCtrl.DeleteAllItems();
	CDocManage* pDocManage = new CDocManage();
	m_strClassDesc = pDocManage->ReadClassDesc(m_strClassName);
	m_strClassDesc.Replace("\n", "\r\n");

	CString strQuery;
	long length = 0;
	strQuery.Format("Classes/class/Functions/function[@visit='%s']", PUBLICFUNCTION);
	length = pDocManage->GetMemberNum(m_strClassName,strQuery);
	m_strPublicF.Format("%s:%d个", PUBLICFUNCTION, length);
	
	strQuery.Format("Classes/class/Functions/function[@visit='%s']", PROTECTEDFUNCTION);
	length = pDocManage->GetMemberNum(m_strClassName,strQuery);
	m_strProtectedF.Format("%s:%d个", PROTECTEDFUNCTION, length);

	strQuery.Format("Classes/class/Functions/function[@visit='%s']", PRIVATEFUNCTION);
	length = pDocManage->GetMemberNum(m_strClassName,strQuery);
	m_strPrivateF.Format("%s:%d个", PRIVATEFUNCTION, length);

	strQuery.Format("Classes/class/Propertys/property[@visit='%s']", PUBLICPROPERTY);
	length = pDocManage->GetMemberNum(m_strClassName,strQuery);
	m_strPublicP.Format("%s:%d个", PUBLICPROPERTY, length);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -