📄 resorgsymbolslistview.cpp
字号:
/************************************************************************
*
* Resource ID Organiser Utility Library
*
* (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
* All rights reserved.
*
************************************************************************
*
* Filename : ResOrgSymbolsListView.cpp
*
* Description : CResOrgSymbolsListView - list view class for a resource
* symbol file
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or 4
*
* Target
* Environment : Windows 98/NT
*
* NOTE:
*
* This software is provided "as is" free for personal use. All
* title and copyrights in and to the software, including but not
* limited to any images, text, etc. incorporated into it, are
* owned by Andy Metcalfe, except where acknowledged otherwise.
*
* Your may freely to use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
*
* Visit http://www.resorg.co.uk for latest updates
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgUtils/ResOrgSymbolsListView.cpp $
* $Revision: 14 $
* $Date: 24/07/01 11:24 $
* $Author: Andy $
*
* $History: ResOrgSymbolsListView.cpp $
*
* ***************** Version 14 *****************
* User: Andy Date: 24/07/01 Time: 11:24
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* The Symbols Display list control is now created with the
* LVS_SHOWSELALWAYS style so that the selection is retained when it loses
* the focus
*
* ***************** Version 13 *****************
* User: Andy Date: 26/05/01 Time: 15:23
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added OnHelpHitTest() override
*
* ***************** Version 12 *****************
* User: Andy Date: 5/05/01 Time: 20:50
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Optimised OnInitialUpdate()
*
* ***************** Version 11 *****************
* User: Andy Date: 23/04/01 Time: 21:17
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added icons to context menus
*
* ***************** Version 10 *****************
* User: Andy Date: 2/04/01 Time: 17:40
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added "Autosize Columns" context menu entry
*
* ***************** Version 9 *****************
* User: Andy Date: 27/03/01 Time: 15:23
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Modifications to integrate the "Conflicts" tab to Resource Symbol
* properties
*
* ***************** Version 8 *****************
* User: Andy Date: 9/03/01 Time: 12:37
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Remove "Apply" button from Symbol Properties
*
* ***************** Version 7 *****************
* User: Andy Date: 9/03/01 Time: 7:07
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Interfacing changes to symbol properties sheet
*
* ***************** Version 6 *****************
* User: Andy Date: 5/03/01 Time: 19:02
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Set default item on context menu
*
* ***************** Version 5 *****************
* User: Andy Date: 2/03/01 Time: 17:10
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added accelerator keys to message boxes
* 2. Context Menu handler now displays a context menu even if the mouse
* position is not over an item in the list control
* 3. Implemented CResOrgSymbolsListView::OnCmdAddSymbol()
*
* ***************** Version 4 *****************
* User: Andy Date: 17/02/01 Time: 7:00
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Moved generic list control code into a new class
* (CResOrgSymbolsListCtrl)
* 2. Class renamed for consistancy
* 3. Added a "Status" column
* 4. Show modified symbols in blue, and read-only symbols in grey
* [handled by CResOrgSymbolsListCtrl]
* 5. Use new wrapper methods in the document to manipulate its
* CResourceSymbolBuffer object rather than accessing it directly. This
* allows most of the view hints to be moved to the document
*
* ***************** Version 3 *****************
* User: Andy Date: 29/11/00 Time: 18:38
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added file banners
*
* $Nokeywords: $
*
************************************************************************/
// ResOrgSymbolsListView.cpp : implementation of the CResOrgSymbolsListView class
//
#include "StdAfx.h"
#include <AfxPriv.h>
#include "ResOrgUtils_Priv.h"
#include "ResourceSymbol.h"
#include "ResourceSymbolBuffer.h"
#include "SymbolPropertySheet.h"
#include "SymbolPropertiesGeneralPage.h"
#include "SymbolPropertiesConflictsPage.h"
#include "ResOrgSymbolsDoc.h"
#include "ResOrgSymbolsListView.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
};
/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListView
IMPLEMENT_DYNCREATE(CResOrgSymbolsListView, CResOrgSymbolsListView_BASE)
/******************************************************************************
* Message Map implementation
*
******************************************************************************/
BEGIN_MESSAGE_MAP(CResOrgSymbolsListView, CResOrgSymbolsListView_BASE)
//{{AFX_MSG_MAP(CResOrgSymbolsListView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_CONTEXTMENU()
ON_COMMAND( ID_SYM_AUTOSIZE_COLS, OnCmdAutosizeColumns)
ON_COMMAND( ID_EDIT_SELECT_ALL, OnCmdEditSelectAll)
ON_UPDATE_COMMAND_UI( ID_EDIT_SELECT_ALL, OnUpdateEditSelectAll)
ON_COMMAND( ID_SYM_PROPERTIES, OnCmdSymbolProperties)
ON_UPDATE_COMMAND_UI( ID_SYM_PROPERTIES, OnUpdateSymbolProperties)
ON_COMMAND( ID_SYM_ADD, OnCmdAddSymbol)
ON_COMMAND( ID_EDIT_CLEAR, OnCmdDeleteSymbol)
ON_UPDATE_COMMAND_UI( ID_EDIT_CLEAR, OnUpdateDeleteSymbol)
//}}AFX_MSG_MAP
// The following are outside of ClassWizard's reach as it can't understand
// them....
ON_MESSAGE( WM_HELPHITTEST, OnHelpHitTest)
ON_NOTIFY( LVN_ITEMCHANGED, IDC_RESORG_SYMBOLS, OnItemChangedListCtrl)
ON_NOTIFY( NM_DBLCLK, IDC_RESORG_SYMBOLS, OnDblClickListCtrl)
// Standard printing commands
ON_COMMAND( ID_FILE_PRINT, CResOrgSymbolsListView_BASE::OnFilePrint)
ON_COMMAND( ID_FILE_PRINT_DIRECT, CResOrgSymbolsListView_BASE::OnFilePrint)
ON_COMMAND( ID_FILE_PRINT_PREVIEW, CResOrgSymbolsListView_BASE::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListView construction/destruction
CResOrgSymbolsListView::CResOrgSymbolsListView(void)
{
m_bInitialised = FALSE;
}
CResOrgSymbolsListView::~CResOrgSymbolsListView(void)
{
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListView overrides
/******************************************************************************
* This method is called by the framework before the creation of the
* window attached to this CWnd object.
*
* This override is used to modify the window styles here to set the List
* control style to report view.
*
* This is achieved by masking out the view style using LVS_TYPEMASK
* and setting the LVS_REPORT style. LVS_SINGLESEL is also set to allow
* only single selections.
*
* Note that we DON'T want the LVS_SORTASCENDING style as this sorts items
* by item text and in this case we cannot have a comparison function.
*
******************************************************************************/
BOOL CResOrgSymbolsListView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style = (cs.style & ~LVS_TYPEMASK) | LVS_REPORT;
return CResOrgSymbolsListView_BASE::PreCreateWindow(cs);
}
/******************************************************************************
* Called by the framework to render an image of the document.
*
* The framework calls this function to perform screen display, printing,
* and print preview, and it passes a different device context in each case.
*
* As the list control does everything for us, this override is not currently
* used.
*
* It will however be required if printing and print preview is to be
* implemented
*
******************************************************************************/
void CResOrgSymbolsListView::OnDraw(CDC* /*pDC*/)
{
// CResOrgSymbolsDoc* pDoc = GetDocument();
// ASSERT_VALID(pDoc);
// CListCtrl& refCtrl = GetListCtrl();
}
/******************************************************************************
* Called by the framework after the view is first attached to the document,
* but before the view is initially displayed.
*
* This override is used to configure the list control before display.
*
******************************************************************************/
void CResOrgSymbolsListView::OnInitialUpdate(void)
{
// Initialise the List Control
if (!m_bInitialised)
{
Initialise();
}
// m_ctrlSymbols.AddSymbols( GetDocument()->GetSymbolBuffer() );
// m_ctrlSymbols.AutoSizeColumn();
// Call the base class to fill in the list view and invalidate the entire area
// so that it will be painted
CResOrgSymbolsListView_BASE::OnInitialUpdate();
m_ctrlSymbols.AutoSizeColumn();
}
/******************************************************************************
* Called by the framework after the view抯 document has been modified.
*
* This override is used to update the data in the list control
*
******************************************************************************/
void CResOrgSymbolsListView::OnUpdate(CView* pSender,
LPARAM lHint,
CObject* pHint)
{
UNREFERENCED_PARAMETER(pSender);
if (!m_bInitialised)
{
Initialise();
}
switch (lHint)
{
case SYM_REFRESH:
{
CWaitCursor wait;
m_ctrlSymbols.AddSymbols( GetDocument()->GetSymbolBuffer() ); // Sledgehammer approach - slow but effective
}
break;
case SYM_ADDED:
m_ctrlSymbols.AddSymbol( (CResourceSymbol*)pHint );
m_ctrlSymbols.Sort();
break;
case SYM_CHANGED:
m_ctrlSymbols.UpdateSymbol( (CResourceSymbol*)pHint );
m_ctrlSymbols.Sort();
break;
case SYM_DELETED:
m_ctrlSymbols.RemoveSymbol( (CResourceSymbol*)pHint );
break;
default:
break;
}
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgSymbolsListView printing
BOOL CResOrgSymbolsListView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CResOrgSymbolsListView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -