www.pudn.com > TidyWin32-src.zip > ConfigPage.h


#ifndef CONFIG_PAGE_H 
#define CONFIG_PAGE_H 
 
#include "resource.h" 
 
class CTidyProxy; 
 
//------------------------------------------------------------------- 
class IConfigPage { 
public: 
	virtual void Initialize(HWND, const RECT&, CTidyProxy*) = 0; 
	virtual void Terminate() = 0; 
	virtual void Update() = 0; 
	virtual void Validate() = 0; 
	virtual CWindow* GetWindow() = 0; 
}; 
 
//------------------------------------------------------------------- 
template  
class CConfigPage : public CDialogImpl, 
					public IConfigPage 
{ 
public: 
	virtual void Initialize(HWND hParentWnd, const RECT& rc, CTidyProxy* ptp) 
	{	m_pTidyProxy = ptp; 
		Create(hParentWnd); 
		ShowWindow(TRUE); 
		MoveWindow(&rc); 
	} 
	virtual void Terminate() { DestroyWindow(); delete this; } 
	virtual CWindow* GetWindow() { return this; } 
 
	// Update() helper for bool values 
	void SetCheckBox(bool b, unsigned int checkId) 
		{ CheckDlgButton(checkId, b ? BST_CHECKED : BST_UNCHECKED); } 
	// Validate() helper for bool values 
	bool GetCheckBox(unsigned int checkId) 
		{ return (IsDlgButtonChecked(checkId) == TRUE) ? true : false; } 
 
protected: 
	CTidyProxy* m_pTidyProxy; 
}; 
 
//------------------------------------------------------------------- 
class CMarkupConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_MARKUP }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(CMarkupConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
class CCleanupConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_CLEANUP }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(CCleanupConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
class CXMLConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_XML }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(CXMLConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
class CEncodingConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_ENCODING }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(CEncodingConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
class CLayoutConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_LAYOUT }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(CLayoutConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
class COperationConfig : public CConfigPage 
{ 
public: 
	enum { IDD = IDD_CONF_OPERATION }; 
 
	// IConfigPage interface 
	virtual void Update(); 
	virtual void Validate(); 
 
public: 
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 
 
BEGIN_MSG_MAP(COperationConfig) 
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 
END_MSG_MAP() 
}; 
 
//------------------------------------------------------------------- 
#endif	// CONFIG_PAGE_H