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

📄 resorgsymbolslistctrl.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Core Library
 *
 * (c) Copyright 2000-2004 by Riverblade Limited (UK). All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Description : CResOrgSymbolsListCtrl - list control class for a
 *                resource symbol file
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT/2000/XP
 *
 *  NOTE:
 *
 *    This software is provided "as is". All title and copyrights in and
 *    to the software, including but not limited to any images, text etc.
 *    etc. incorporated into it, are the property of Anna-Jayne Metcalfe
 *    and Riverblade Limited, except where acknowledged otherwise.
 *
 *    Your may freely use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *    For support and updates please visit http://www.riverblade.co.uk/products/resorg
 *    or email support@riverblade.co.uk  
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgCore/ResOrgSymbolsListCtrl.cpp $
 *   $Revision: 18 $
 *       $Date: 13/12/04 3:56 $
 *     $Author: Anna $
 *
 *    $History: ResOrgSymbolsListCtrl.cpp $
 * 
 * *****************  Version 18  *****************
 * User: Anna         Date: 13/12/04   Time: 3:56
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * 1.  Modifications fo compatibility with dynamic splitters
 * 2.  Updated file banners
 * 
 * *****************  Version 17  *****************
 * User: Anna         Date: 11/07/04   Time: 16:16
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added support for detection of out of range symbols
 * 
 * *****************  Version 16  *****************
 * User: Anna         Date: 15/04/03   Time: 20:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * 1.  Removed unnecessary file guards (#pragma once works well enough)
 * 2.  Updated file banners
 * 
 * *****************  Version 15  *****************
 * User: Anna         Date: 3/01/03    Time: 7:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added an option to filter multi-file Symbols Displays by default
 * 
 * *****************  Version 14  *****************
 * User: Anna         Date: 2/01/03    Time: 23:54
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added filtering to the Symbols Display
 * 
 * *****************  Version 13  *****************
 * User: Anna         Date: 2/01/03    Time: 0:07
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Guarded m_pResourceSymbolManager against NULL in
 * CResOrgSymbolsListCtrl::AddSymbols() [for compatibility with multi-file
 * conflict analysis]
 * 
 * *****************  Version 12  *****************
 * User: Anna         Date: 17/12/02   Time: 15:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * CResOrgSymbolsListCtrl::Initialise() now only subclasses the header
 * control if a WinXP theme is not active 
 * 
 * *****************  Version 11  *****************
 * User: Anna         Date: 25/11/02   Time: 15:14
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed website address in banner
 * 
 * *****************  Version 10  *****************
 * User: Anna         Date: 22/10/02   Time: 13:24
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 9  *****************
 * User: Andy         Date: 7/06/02    Time: 17:04
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Renamed the ResOrgUtils module to ResOrgCore. Updated file banners
 * accordingly
 * 
 * *****************  Version 8  *****************
 * User: Andy         Date: 27/05/02   Time: 14:50
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Knock on changes from CResourceSymbolBuffer (now
 * CResourceSymbolManager)
 * 
 * *****************  Version 7  *****************
 * User: Andy         Date: 12/28/01   Time: 4:34p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added a new override of CResOrgSymbolsListCtrl::AddSymbols()
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 12/27/01   Time: 11:20p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Added "Original ID" column
 * 2.  Added CResOrgSymbolsListCtrl::SetSymbolManager(),
 * UpdateAllSymbols() and GetSymbol()
 * 3.  Renamed CResOrgSymbolsListCtrl::LookupSelection() to GetSelection()
 * and added an overload which works with multiple selections
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 2/04/01    Time: 17:39
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Fix a bug introduced in ResOrg 1.3.2: icons were not displaying
 * when the control was used as a child window of a view
 * 2.  Highlight symbols with name (as well as value) conflicts in bold
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 27/03/01   Time: 15:23
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Made the "Status" column optional
 * 2.  Modifications to allow use in the "Symbol Conflicts" property page
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 5/03/01    Time: 19:01
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * CResOrgSymbolsListCtrl::SortList() now calls the base class to set the
 * sort image on the header control
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 2/03/01    Time: 17:07
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Increased the width of the "Status" column
 * 
 * *****************  Version 1  *****************
 * User: Andy         Date: 17/02/01   Time: 6:47
 * Created in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 29/11/00   Time: 18:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

#include "StdAfx.h"
#include "ResOrgCore_Priv.h"

#include "ResourceSymbol.h"
#include "ResourceSymbolManager.h"

#include "ResOrgSymbolsListCtrl.h"


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



// Definitions for List Control column indices and titles
enum
{
	UNKNOWN_COLUMN = -1,
	NAME_COLUMN = 0,
	TYPE_COLUMN,
	ID_COLUMN,
	ORIGINAL_ID_COLUMN,
	FILE_COLUMN,
	STATUS_COLUMN
};



static DATA_TYPE eColumnType[] = 
{
	DT_STRING,		// Name
	DT_STRING,		// Type
	DT_DEC,			// ID
	DT_DEC,			// Original ID
	DT_STRING,		// File
	DT_STRING		// Status
};


const UINT WM_SETSCROLLINFO	= ::RegisterWindowMessage( _T("SetScrollInfo") );



static bool IsViewContainedInSplitterWindow(CWnd* pView)
{
	CWnd* pViewParent = pView->GetParent();
	if (NULL != pViewParent)
	{
		if (pViewParent->IsKindOf(RUNTIME_CLASS(CSplitterWnd) ) )
		{
			return true;
		}
	}
	return false;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListCtrl class

/******************************************************************************
 *	Message Map implementation
 *
 ******************************************************************************/

BEGIN_MESSAGE_MAP(CResOrgSymbolsListCtrl, CResOrgSymbolsListCtrl_BASE)

	ON_WM_CREATE()
	ON_WM_NCCALCSIZE()
	ON_WM_KEYDOWN()
	ON_NOTIFY_REFLECT(	NM_CUSTOMDRAW,							OnCustomDraw)

END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListCtrl construction/destruction

CResOrgSymbolsListCtrl::CResOrgSymbolsListCtrl(void)
{
	m_nSortColumn				= ID_COLUMN;
	m_bSortAscending			= true;
	m_pResourceSymbolManager	= NULL;
	m_bShowStatusColumn			= true;
	m_bShowProblemSymbolsOnly	= false;
}

CResOrgSymbolsListCtrl::~CResOrgSymbolsListCtrl(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListCtrl overrides

void CResOrgSymbolsListCtrl::PreSubclassWindow(void)
{
	if (m_ctrlImages.GetSafeHandle() == NULL)
	{
		m_ctrlImages.Create(SMALL_ICON_CX,
							SMALL_ICON_CY,						// Small icon
							ILC_COLOR | ILC_MASK,				// Colour depth
							0,									// Initial images
							1);									// Growby

		SetImageList(&m_ctrlImages, LVSIL_SMALL);
	}

	CResOrgSymbolsListCtrl_BASE::PreSubclassWindow();
}


/******************************************************************************
 *	Sort the contents of the control by the specified column
 *
 ******************************************************************************/

bool CResOrgSymbolsListCtrl::SortList(int nColumn, bool bAscending)
{
	CResOrgSymbolsListCtrl_BASE::SortList(nColumn, bAscending);

	m_nSortColumn		= nColumn;
	m_bSortAscending	= bAscending;

	// Re-sort contents if sorted before
	if (m_nSortColumn >= 0)
	{
		CResOrgSymbolsListCtrl_BASE::SortList(nColumn, bAscending);

		CCJSortClass sorter(this, nColumn);
		sorter.Sort(bAscending, eColumnType[nColumn]);

		return true;
	}
	return false;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListCtrl implementation

/// Initialise the list control before display.
///
void CResOrgSymbolsListCtrl::Initialise(bool bFlatHeader /*= false*/,
										bool bShowStatusColumn /*= true*/)
{
	m_bShowStatusColumn = bShowStatusColumn;

	// Create the columns in the the List Control
	//
	// For each row the properties specified are:
	//
	//		1.	SubItem field number (0 based)
	//		2.	Text
	//		3.	Justification
	//		4.	Initial width in pixels, size to content (LVSCW_AUTOSIZE) or
	//			size to header (LVSCW_AUTOSIZE_USEHEADER)
	//
	// Change list control style to have:
	//
	//	1.	Flat header (requires CJListCtrl)
	//	2.	Full row selection (requires ComCtl32.dll v4.71)
	//
	if (bFlatHeader)
	{
		CCJThemeHelper theme;
		if (!theme.IsAppThemed() )
		{
			SubclassHeader();
		}
	}

	SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);

	VERIFY (-1 != InsertColumn(NAME_COLUMN,			_T("Name"),			LVCFMT_LEFT, 200,	0) );
	VERIFY (-1 != InsertColumn(TYPE_COLUMN,			_T("Type"),			LVCFMT_LEFT, 100,	0) );
	VERIFY (-1 != InsertColumn(ID_COLUMN,			_T("Value"),		LVCFMT_LEFT, 80,	1));
	VERIFY (-1 != InsertColumn(ORIGINAL_ID_COLUMN,	_T("Orig. Value"),	LVCFMT_LEFT, 80,	1));
	VERIFY (-1 != InsertColumn(FILE_COLUMN,			_T("File"),			LVCFMT_LEFT, 150,	1));
	
	if (m_bShowStatusColumn)
	{
		VERIFY (-1 != InsertColumn(STATUS_COLUMN,	_T("Status"),	LVCFMT_LEFT, 300,	1));
	}
}


bool CResOrgSymbolsListCtrl::SetSymbolManager(CResourceSymbolManager* pResourceSymbolManager)
{
	if (m_pResourceSymbolManager != pResourceSymbolManager)
	{
		if (::IsWindow(m_hWnd) )
		{
			DeleteAllItems();
		}
		m_pResourceSymbolManager = pResourceSymbolManager;
	}
	return (NULL != m_pResourceSymbolManager);
}


bool CResOrgSymbolsListCtrl::ShowProblemSymbolsOnly(bool bShow)
{
	if (bShow != m_bShowProblemSymbolsOnly)
	{
		m_bShowProblemSymbolsOnly = bShow;

		if (NULL != m_pResourceSymbolManager)
		{
			AddSymbols(m_pResourceSymbolManager);
		}

		return true;
	}
	return false;
}


bool CResOrgSymbolsListCtrl::IsVisible(CResourceSymbol* pSymbol) const
{
	ASSERT(NULL != pSymbol);
	if (NULL == m_pResourceSymbolManager)
	{
		ASSERT(FALSE);
		return false;
	}

	bool bShow = false;

	if (NULL != pSymbol)
	{
		if (m_bShowProblemSymbolsOnly)
		{
			if (pSymbol->HasConflicts() || m_pResourceSymbolManager->IsOutOfRange(pSymbol) )
			{
				bShow = true;
			}
		}
		else
		{
			bShow = true;
		}
	}
	return bShow;
}


/// Fill the list control with data
///
void CResOrgSymbolsListCtrl::AddSymbols(CResourceSymbolManager* pResourceSymbolManager)
{
	SetSymbolManager(pResourceSymbolManager);

	SetRedraw(FALSE);

	DeleteAllItems();

	if (NULL != m_pResourceSymbolManager)
	{
		if (m_pResourceSymbolManager->GetSymbolCount() > 0)
		{
			POSITION pos = m_pResourceSymbolManager->GetFirstSymbolPosition();
			while (NULL != pos)
			{
				CResourceSymbol* pSymbol = m_pResourceSymbolManager->GetNextSymbol(pos);

⌨️ 快捷键说明

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