Click here to Skip to main content
15,891,708 members
Articles / Desktop Programming / ATL

CM_ConfigBuilder 1.2g: Visual Studio 6/Visual Studio 2005/Visual Studio 2008 Code Generator for Application Settings Graphic Management

Rate me:
Please Sign up or sign in to vote.
4.94/5 (126 votes)
12 Feb 2008CPOL17 min read 697.4K   9.8K   262  
CM_ConfigBuilder generates and compiles the required files to manage your application's settings/preferences and to store/retrieve them in XML format.
// AsOptionList.h : header file
//

#if !defined(_ASOPTIONLIST_H_)
#define _ASOPTIONLIST_H_

#include <map>
#include "IAsOptionGroupListener.h"
#include "AsFontInfo.h"
#include "cmString.h"

using namespace std;

class CAsOptionGroup;
class CAsBaseCell;
class IAsOptionListListener;

/////////////////////////////////////////////////////////////////////////////
// CAsOptionList window

typedef map<cmString, CAsOptionGroup*> AsOptionGroupMap;

class CAsOptionList : public CWnd,
					  public IAsOptionGroupListener
{
// Construction
public:
	CAsOptionList();

// implementation of IAsOptionGroupListener
//
	void OnGroupSizeChanged(bool redraw = true);
	void OnSelectionInfoChanged(CAsOptionGroup* selectedGroup, bool redraw = true);

	void GetSelectedItemInfo(cmString& title, cmString& description);

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAsOptionList)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CAsOptionList();
	
	BOOL Create(const CRect& rc, CWnd* parentWnd, DWORD style = WS_CHILD | WS_VISIBLE, UINT nID = 0);

	void SetBorderColor(COLORREF borderColor, bool redraw = true );
	COLORREF GetBorderColor() const;

	void SetBkColor(COLORREF bkColor, bool redraw = true);
	COLORREF GetBkColor() const;

	AsOptionGroupMap* GetOptionGroupMap();

	CAsOptionGroup* AddGroup(const cmString& name);
	CAsOptionGroup* GetGroup(const cmString& name);

	void SetVerticalStripWidth(int width);
	int GetVerticalStripWidth() const;

	void SetVerticalSplitterPos(int pos);
	int GetVerticalSplitterPos() const;
		
	void SetFontInfo(const cmString& fontName, int fontSize = 10, bool fontBold = false);
	void SetFontInfo(const CAsFontInfo& fontInfo);

	void RegisterListener(IAsOptionListListener* listener);

	void SetSorted(bool sorted);
	bool GetSorted() const;

	// Generated message map functions
protected:
	//{{AFX_MSG(CAsOptionList)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP();

	void DrawBackground(CDC* pDC);
	void DrawGroups(CDC* pDC);
	void DrawBorder(CDC* pDC);
	long UpdateDrawArea();
	void UpdateWindowSize();
	void EnsureCellVisible(CAsBaseCell* cell);
	bool HitSplitter(const CPoint& point);
	CAsBaseCell* GetFocusedCell();

	CRect GetGlobalDrawArea();

	COLORREF borderColor_;
	COLORREF bkColor_;
	COLORREF verticalSplitBkColor_;

	AsOptionGroupMap groups_;

	int verticalStripWidth_;
	int verticalSplitterPos_;
	long offset_;

	bool draggingSplitter_;
	bool sorted_;

	// font info
	//
	CAsFontInfo fontInfo_;

	IAsOptionListListener* listener_;
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(_ASOPTIONLIST_H_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Italy Italy
For all Stefano's latest code, binaries and tutorials visit www.codemachines.com

Comments and Discussions