Click here to Skip to main content
13,733,945 members
Click here to Skip to main content

Stats

2M views
55.9K downloads
446 bookmarked
Posted 3 Sep 2008
Licenced CPOL

CGridListCtrlEx - Grid Control Based on CListCtrl

, 16 Mar 2015
A custom draw CListCtrl with subitem editing and formatting
CGridListCtrlEx
DemoApplication
res
CGridListCtrlEx.ico
FLGDEN.ICO
FLGFRAN.ICO
FLGGERM.ICO
FLGGREEC.ico
FLGSPAIN.ICO
FLGSWED.ICO
Documentation
CGridListCtrlEx
screenshot.png
vs2003
CGridListCtrlEx.vcproj
vs2005
CGridListCtrlEx.vcproj
vs2008
CGridListCtrlEx.vcproj
vs6
CGridListCtrlEx.dsp
CGridListCtrlEx.dsw
Release
CGridListCtrlEx.exe
msvcp120.dll
msvcr120.dll
CGridListCtrlEx.ico
FLGDEN.ICO
FLGFRAN.ICO
FLGGERM.ICO
FLGGREEC.ico
FLGSPAIN.ICO
FLGSWED.ICO
screenshot.png
Doxygen
Doxyfile
html
arrowdown.png
arrowright.png
bc_s.png
bdwn.png
class_c_grid_column_trait.png
class_c_grid_column_trait_combo.png
class_c_grid_column_trait_date_time.png
class_c_grid_column_trait_edit.png
class_c_grid_column_trait_hyper_link.png
class_c_grid_column_trait_image.png
class_c_grid_column_trait_multiline_edit.png
class_c_grid_column_trait_text.png
class_c_grid_editor_combo_box.png
class_c_grid_editor_combo_box_edit.png
class_c_grid_editor_date_time_ctrl.png
class_c_grid_editor_text.png
class_c_grid_list_ctrl_ex.png
class_c_grid_list_ctrl_groups.png
class_c_grid_multiline_editor_text.png
class_c_grid_row_trait.png
class_c_grid_row_trait_text.png
class_c_grid_row_trait_x_p.png
class_c_view_config_section.png
class_c_view_config_section_default.png
class_c_view_config_section_default_1_1_c_view_config_section_local.png
class_c_view_config_section_profiles.png
class_c_view_config_section_win_app.png
closed.png
doc.png
doxygen.png
folderclosed.png
folderopen.png
ftv2blank.png
ftv2cl.png
ftv2doc.png
ftv2folderclosed.png
ftv2folderopen.png
ftv2lastnode.png
ftv2link.png
ftv2mlastnode.png
ftv2mnode.png
ftv2mo.png
ftv2node.png
ftv2ns.png
ftv2plastnode.png
ftv2pnode.png
ftv2splitbar.png
ftv2vertline.png
nav_f.png
nav_g.png
nav_h.png
open.png
search
close.png
mag_sel.png
search_l.png
search_m.png
search_r.png
splitbar.png
sync_off.png
sync_on.png
tab_a.png
tab_b.png
tab_h.png
tab_s.png
CGridListCtrlEx.vcproj
CGridListCtrlEx.vcproj
CGridListCtrlEx.vcproj
CGridListCtrlEx.dsp
CGridListCtrlEx.dsw
#pragma once

//------------------------------------------------------------------------
// Author:  Rolf Kristensen	
// Source:  http://www.codeproject.com/KB/list/CGridListCtrlEx.aspx
// License: Free to use for all (New BSD License)
//------------------------------------------------------------------------

//------------------------------------------------------------------------
//! Abstract interface for persisting view configuration
//------------------------------------------------------------------------
class CViewConfigSection
{
protected:
	CString m_ViewName;		//!< Configuration name used when persisting the state (Translates into a section name)

	//! Pure virtual interface for reading setting from persisting layer
	virtual CString ReadSetting(const CString& strSection, const CString& strSetting, const CString& strDefval) const = 0;
	//! Pure virtual interface for writing setting to persisting layer
	virtual void WriteSetting(const CString& strSection, const CString& strSetting, const CString& strValue) = 0;
	//! Pure virtual interface for removing setting section from persisting layer
	virtual void RemoveSection(const CString& strSection) = 0;

	// Converters
	virtual CString ConvertBoolSetting(bool bValue) const;
	virtual CString ConvertIntSetting(int nValue) const;
	virtual CString ConvertFloatSetting(double nValue, int nDecimals = 6) const;
	virtual CString ConvertArraySetting(const CSimpleArray<CString>& values, const CString& strDelimiter = _T(", ")) const;
	virtual CString ConvertArraySetting(const CSimpleArray<int>& values, const CString& strDelimiter = _T(", ")) const;
	virtual CString ConvertLogFontSetting(const LOGFONT& font) const;
	virtual CString ConvertRectSetting(const RECT& rect) const;
	virtual CString ConvertColorSetting(COLORREF color) const;
	virtual void	SplitArraySetting(const CString& strArray, CSimpleArray<CString>& values, const CString& strDelimiter = _T(", ")) const;

	virtual const CString& GetSectionName() const;

public:
	explicit CViewConfigSection(const CString& strViewName);
	virtual ~CViewConfigSection();

	// Getters
	virtual CString GetSetting(const CString& strName, const CString& strDefval = _T("")) const;
	virtual bool GetBoolSetting(const CString& strName, bool bDefval = false) const;
	virtual int GetIntSetting(const CString& strName, int nDefval = 0) const;
	virtual double GetFloatSetting(const CString& strName, double nDefval = 0.0) const;
	virtual LOGFONT GetLogFontSetting(const CString& strName) const;
	virtual CRect GetRectSetting(const CString& strName, const CRect& rectDefval = CRect(0,0,0,0)) const;
	virtual COLORREF GetColorSetting(const CString& strName, const COLORREF colorDefval = RGB(0,0,0)) const;
	virtual void GetArraySetting(const CString& strName, CSimpleArray<CString>& values, const CString& strDelimiter = _T(", ")) const;
	virtual void GetArraySetting(const CString& strName, CSimpleArray<int>& values, const CString& strDelimiter = _T(", ")) const;

	// Setters
	virtual void SetSetting(const CString& strName, const CString& strValue);
	virtual void SetBoolSetting(const CString& strName, bool bValue);
	virtual void SetIntSetting(const CString& strName, int nValue);
	virtual void SetFloatSetting(const CString& strName, double nValue, int nDecimals = 6);
	virtual void SetArraySetting(const CString& strName, const CSimpleArray<CString>& values, const CString& strDelimiter = _T(", "));
	virtual void SetArraySetting(const CString& strName, const CSimpleArray<int>& values, const CString& strDelimiter = _T(", "));
	virtual void SetLogFontSetting(const CString& strName, const LOGFONT& font);
	virtual void SetRectSetting(const CString& strName, const RECT& rect);
	virtual void SetColorSetting(const CString& strName, COLORREF color);

	virtual void RemoveCurrentConfig();
};

//------------------------------------------------------------------------
//! Abstract interface for persisting view configuration, that can use
//! an in-memory default-configuration.
//!
//! It will use the values in the default-config if nothing else can be found
//------------------------------------------------------------------------
class CViewConfigSectionDefault : public CViewConfigSection
{
protected:
	//! Inner class that stores the default configuration in memory
	class CViewConfigSectionLocal : public CViewConfigSection
	{
	protected:
		CSimpleMap<CString,CString> m_LocalSettings;	//!< Default configuration

		// Persistence of settings
		virtual CString ReadSetting(const CString& strSection, const CString& strName, const CString& strDefval) const;
		virtual void WriteSetting(const CString& strSection, const CString& strName, const CString& strValue);
		virtual void RemoveSection(const CString& strSection);

	public:
		explicit CViewConfigSectionLocal(const CString& strViewName);
		CViewConfigSectionLocal(const CViewConfigSectionLocal& other);
		CViewConfigSectionLocal& operator=(const CViewConfigSectionLocal& other);

		bool HasSettings() const;
		void CopySettings(CViewConfigSection& destination) const;
	};
	CViewConfigSectionLocal m_DefaultConfig;	//!< Default configuration stored in memory

public:
	explicit CViewConfigSectionDefault(const CString& strViewName);

	virtual CViewConfigSection& GetDefaultConfig();
	virtual bool HasDefaultConfig() const;
	virtual void ResetConfigDefault();

	virtual CString GetSetting(const CString& strName, const CString& strDefval = _T("")) const;
};

//------------------------------------------------------------------------
//! Abstract interface for persisting view configuration, that can switch
//! between different view configuration profiles.
//------------------------------------------------------------------------
class CViewConfigSectionProfiles : public CViewConfigSectionDefault
{
protected:
	mutable CString m_CurrentSection;	//!< Section name combined from the viewname and the current profile name
	virtual const CString& GetSectionName() const;

	virtual void SplitSectionName(const CString& strSection, CString& strViewName, CString& strProfile);
	virtual CString JoinSectionName(const CString& strViewName, const CString& strProfile) const;

public:
	explicit CViewConfigSectionProfiles(const CString& strViewName);

	virtual void RemoveCurrentConfig();

	virtual void GetProfiles(CSimpleArray<CString>& profiles) const;
	virtual CString GetActiveProfile();
	virtual void SetActiveProfile(const CString& strProfile);
	virtual void AddProfile(const CString& strProfile);
	virtual void DeleteProfile(const CString& strProfile);
};

//------------------------------------------------------------------------
//! Can persist the column configuration using CWinApp::WriteProfile()
//------------------------------------------------------------------------
class CViewConfigSectionWinApp : public CViewConfigSectionProfiles
{
protected:
	virtual CString ReadSetting(const CString& strSection, const CString& strSetting, const CString& strDefval) const;
	virtual void WriteSetting(const CString& strSection, const CString& strSetting, const CString& strValue);
	virtual void RemoveSection(const CString& strSection);

public:
	CViewConfigSectionWinApp(const CString& strViewName);
};

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)

Share

About the Author

Rolf Kristensen
Software Developer
Denmark Denmark
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05-2016 | 2.8.180920.1 | Last Updated 16 Mar 2015
Article Copyright 2008 by Rolf Kristensen
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid