Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

The SBJ MVC Framework - The Model, from Abstraction to Realization

, 20 Mar 2009
A Model-View-Controller Framework that integrates with the MFC Doc/View architecture
SbjDevBin201.zip
XmlMvc2090.dll
Shapes.exe
SbjCore2090.dll
SbjDevSrc201.zip
Shapes
Data
res
buttons.bmp
filelarge.bmp
filesmall.bmp
filesmall.png
main.bmp
Shapes.ico
ShapesDoc.ico
Toolbar.bmp
Toolbar256.bmp
treeimages.bmp
vssver.scc
Write - Copy.png
Write.png
Write1.png
writelarge.bmp
writesmall - Copy.bmp
writesmall - Copy.png
writesmall.bmp
writesmall.png
XmlMvc
res
vssver.scc
SbjCore
res
bigcat.ico
main.bmp
properties.bmp
properties_hc.bmp
properties_wnd_hc.ico
vssver.scc
CommonSettings.vsprops
CommonAppDebugSettings.vsprops
CommonAppReleaseSettings.vsprops
CommonDLLDebugSettings.vsprops
CommonDLLReleaseSettings.vsprops
//------------------------------------------------------------------------------
// $Workfile: ItemDisplayModel.cpp $
// $Header: /SbjDev/SbjCore/ItemDisplayModel.cpp 2     11/12/08 2:22p Steve $
//
//	Copyright � 2008 SbjCat
// All rights reserved.
//
//
// *** Authors ***
//	 Steve Johnson
//
// $Revision: 2 $
//
//-----------------------------------------------------------------------------

#include "StdAfx.h"
#include "ItemDisplayModel.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

namespace SbjCore
{
	namespace Mvc
	{
		namespace TreeView
		{
			struct ItemDisplayModelImpl
			{
				CString		sItemText;
				LPLOGFONT	pLF;
				LPLOGFONT	pLFSelected;
				COLORREF	rgbText;
				COLORREF	rgbBack;
				COLORREF	rgbTextSelected;
				COLORREF	rgbBackSelected;
				int			nImageResID;
				int			nImageResIDSelected;

				ItemDisplayModelImpl() :
				pLF(NULL),                
					pLFSelected(NULL),        
					rgbText(GetSysColor(COLOR_WINDOWTEXT)),           
					rgbBack(GetSysColor(COLOR_WINDOW)),           
					rgbTextSelected(GetSysColor(COLOR_WINDOWTEXT)),   
					rgbBackSelected(GetSysColor(COLOR_WINDOW)),   
					nImageResID(-1),       
					nImageResIDSelected(-1)	
				{
				}

				ItemDisplayModelImpl(LPCTSTR lpszText,
					int nImgResID,
					int nImgResIDSelected,
					LPLOGFONT plogfont,
					LPLOGFONT plogfontSelected,
					COLORREF rgbTxt,
					COLORREF rgbBck,
					COLORREF rgbTxtSelected,
					COLORREF rgbBckSelected) :
				sItemText(lpszText),      
					pLF(plogfont),                
					pLFSelected(plogfontSelected),        
					rgbText(rgbTxt),           
					rgbBack(rgbBck),           
					rgbTextSelected(rgbTxtSelected),   
					rgbBackSelected(rgbBckSelected),   
					nImageResID(nImgResID),       
					nImageResIDSelected(nImgResIDSelected)	
				{
					if (-1 == nImageResIDSelected)
					{
						nImageResIDSelected = nImageResID;
					}
				}

				virtual ~ItemDisplayModelImpl()
				{
				}

			};



			ItemDisplayModel::ItemDisplayModel() :
			m_pImpl(new ItemDisplayModelImpl)
			{
			}

			ItemDisplayModel::ItemDisplayModel(LPCTSTR lpszText,
				int nImgResID /*= -1*/,
				int nImgResIDSelected /*= -1*/,
				LPLOGFONT plf /*= NULL*/,
				LPLOGFONT plfSelected /*= NULL*/,
				COLORREF rgbTxt /*= GetSysColor(COLOR_WINDOWTEXT)*/,
				COLORREF rgbBck /*= GetSysColor(COLOR_WINDOW)*/,
				COLORREF rgbTxtSelected /*= GetSysColor(COLOR_WINDOWTEXT)*/,
				COLORREF rgbBckSelected /*= GetSysColor(COLOR_WINDOW)*/) :
				m_pImpl(new ItemDisplayModelImpl(lpszText, nImgResID, nImgResIDSelected, plf, plfSelected,
				rgbTxt, rgbBck, rgbTxtSelected, rgbBckSelected))
			{
			}

			ItemDisplayModel::~ItemDisplayModel()
			{
				try 
				{
					delete m_pImpl;
				}
				catch (...)
				{
					ASSERT(FALSE);
				}

			}


			LPCTSTR ItemDisplayModel::GetItemText() const
			{
				return m_pImpl->sItemText;
			}

			LPLOGFONT ItemDisplayModel::GetFont() const
			{
				return m_pImpl->pLF;	
			}

			LPLOGFONT ItemDisplayModel::GetSelectedFont() const
			{
				return m_pImpl->pLFSelected;	
			}

			COLORREF ItemDisplayModel::GetTextColor() const
			{
				return m_pImpl->rgbText;	
			}

			COLORREF ItemDisplayModel::GetBackColor() const
			{
				return m_pImpl->rgbBack;
			}

			COLORREF ItemDisplayModel::GetSelectedTextColor() const
			{
				return m_pImpl->rgbTextSelected;	
			}

			COLORREF ItemDisplayModel::GetSelectedBackColor() const
			{
				return m_pImpl->rgbBackSelected;
			}

			int ItemDisplayModel::GetImageResID() const
			{
				return m_pImpl->nImageResID;	
			}

			int ItemDisplayModel::GetSelectedImageResID() const
			{
				return m_pImpl->nImageResIDSelected;	
			}

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

			void ItemDisplayModel::SetItemText(const LPCTSTR lpsz)
			{
				m_pImpl->sItemText = lpsz;
			}

			void ItemDisplayModel::SetFont(const LPLOGFONT plf)
			{
				m_pImpl->pLF = plf;	
			}

			void ItemDisplayModel::SetSelectedFont(const LPLOGFONT plf)
			{
				m_pImpl->pLFSelected = plf;	
			}

			void ItemDisplayModel::SetTextColor(const COLORREF rgb)
			{
				m_pImpl->rgbText = rgb;	
			}

			void ItemDisplayModel::SetBackColor(const COLORREF rgb)
			{
				m_pImpl->rgbBack = rgb;
			}

			void ItemDisplayModel::SetSelectedTextColor(const COLORREF rgb)
			{
				m_pImpl->rgbTextSelected = rgb;	
			}

			void ItemDisplayModel::SetSelectedBackColor(const COLORREF rgb)
			{
				m_pImpl->rgbBackSelected = rgb;
			}

			void ItemDisplayModel::SetImageResID(const int n)
			{
				m_pImpl->nImageResID = n;	
				if (m_pImpl->nImageResIDSelected < 0)
				{
					m_pImpl->nImageResIDSelected = n;
				}
			}

			void ItemDisplayModel::SetSelectedImageResID(const int n)
			{
				m_pImpl->nImageResIDSelected = n;	
			}
		}


	}
}


//*** Modification History ***
// $Log: /SbjDev/SbjCore/ItemDisplayModel.cpp $
// 
// 2     11/12/08 2:22p Steve
// Finished Generalization of Model  v2.0.1

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

SBJ

United States United States
Real name is Steve Johnson. Programming since 1979. Started on a Heathkit Micro with a DEC LSI-11 and UCSD Pascal. Moved to PCs & DOS as soon as Turbo Pascal became available. Did some Assembly, ISR, TSR etc. All this while working for a Manufacturing Co. for 8 years. Had my own solo Co. doing barcode labeling software for 4 years (terrible business man, all I wanted to do was code). Since then working for various software companies. Moved to Windows around the time of 3.1 with Borland C then C++. Then on to VC++ and MFC, and just about anything I could get my hands on or had to learn for my job, and been at it ever since. Of course recently I've been playing with .NET, ASP, C#, WPF etc.

| Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 20 Mar 2009
Article Copyright 2008 by SBJ
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid