/************************************************************************
*
* Resource ID Organiser Core Library
*
* (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : ResOrgMDIFrameWnd.cpp
*
* Description : CResOrgMDIFrameWnd - MDI main frame window class
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or later
* Microsoft Visual C++ .NET 2002
*
* Target
* Environment : Windows 98/NT/2000/XP
*
* 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 Anna-Jayne 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.annasplace.me.uk/resorg 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/ResOrgCore/ResOrgMDIFrameWnd.cpp $
* $Revision: 10 $
* $Date: 11/07/04 16:23 $
* $Author: Anna $
*
* $History: ResOrgMDIFrameWnd.cpp $
*
* ***************** Version 10 *****************
* User: Anna Date: 11/07/04 Time: 16:23
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Added support for detection of out of range symbols
* 2. Double clicking Status Bar panes now does something vaguely
* sensible...
*
* ***************** Version 9 *****************
* User: Anna Date: 3/03/03 Time: 23:33
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Removed CResOrgMDIFrameWnd::OnUpdateFileSaveEtc() - it's no longer
* needed as CResOrgHtmlDoc is a bit cleverer
*
* ***************** Version 8 *****************
* User: Anna Date: 25/11/02 Time: 15:13
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed website address in banner
*
* ***************** Version 7 *****************
* User: Anna Date: 22/10/02 Time: 13:24
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed name/mail address (at last!)
*
* ***************** Version 6 *****************
* 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 5 *****************
* User: Andy Date: 10/05/02 Time: 16:00
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added "Use Office XP style menus" option
*
* ***************** Version 4 *****************
* User: Andy Date: 12/27/01 Time: 10:31p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added the ability to show text on toolbars
*
* ***************** Version 3 *****************
* User: Andy Date: 11/10/01 Time: 12:15p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added a new pane to the status bar & removed the duff ones
*
* ***************** Version 2 *****************
* User: Andy Date: 2/06/01 Time: 19:51
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Comment changes only
*
* ***************** Version 1 *****************
* User: Andy Date: 2/06/01 Time: 16:49
* Created in $/Projects/AddIns/ResOrg/ResOrgUtils
*
*
* $Nokeywords: $
*
************************************************************************/
#include "StdAfx.h"
#include "ResOrgCore_Priv.h"
#include "ResOrgSymbolsDoc.h"
#include "ResOrgMDIFrameWnd.h"
#include ".\resorgmdiframewnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd
IMPLEMENT_DYNCREATE(CResOrgMDIFrameWnd, CResOrgMDIFrameWnd_BASE)
static const UINT uToolBarTextMsg = ::RegisterWindowMessage(OPTION_DISPLAY_TOOLBAR_TEXT);
static const UINT uXpMenuStyleMsg = ::RegisterWindowMessage(OPTION_DISPLAY_XP_MENUS);
BEGIN_MESSAGE_MAP(CResOrgMDIFrameWnd, CResOrgMDIFrameWnd_BASE)
ON_WM_CREATE()
ON_WM_DROPFILES()
ON_WM_CLOSE()
ON_WM_LBUTTONDBLCLK()
ON_UPDATE_COMMAND_UI( ID_FILE_CLOSE, OnUpdateFileClose)
ON_UPDATE_COMMAND_UI( ID_INDICATOR_NEXT_SYMBOLS, OnUpdateNextSymbolIndicator)
ON_UPDATE_COMMAND_UI( ID_INDICATOR_SYM_COUNT, OnUpdateSymbolCount)
ON_UPDATE_COMMAND_UI( ID_INDICATOR_SYM_PROBLEMS, OnUpdateProblemSymbolCount)
ON_REGISTERED_MESSAGE( uToolBarTextMsg, OnMsgToolBarTextOptionChanged)
ON_REGISTERED_MESSAGE( uXpMenuStyleMsg, OnMsgXpStyleMenuOptionChanged)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_SYM_COUNT,
ID_INDICATOR_SYM_PROBLEMS,
ID_INDICATOR_NEXT_SYMBOLS
};
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd construction/destruction
CResOrgMDIFrameWnd::CResOrgMDIFrameWnd(void)
{
}
CResOrgMDIFrameWnd::~CResOrgMDIFrameWnd(void)
{
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd virtual overrides
BOOL CResOrgMDIFrameWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (Options.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo) )
{
return TRUE;
}
return CResOrgMDIFrameWnd_BASE::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd diagnostics
#ifdef _DEBUG
void CResOrgMDIFrameWnd::AssertValid(void) const
{
CResOrgMDIFrameWnd_BASE::AssertValid();
}
void CResOrgMDIFrameWnd::Dump(CDumpContext& dc) const
{
CResOrgMDIFrameWnd_BASE::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd operations
CDocument* CResOrgMDIFrameWnd::MDIGetActiveDocument(void) const
{
CDocument* pDoc = NULL;
CMDIChildWnd * pwndChild = MDIGetActive();
if (NULL != pwndChild)
{
pDoc = pwndChild->GetActiveDocument();
}
return pDoc;
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd implementation
// (none)
/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd message handlers
int CResOrgMDIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CResOrgMDIFrameWnd_BASE::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this, Options.ShowTextOnToolbars() ) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// RecalcLayout();
if (!m_wndStatusBar.CreateStatusBar(this,
indicators,
sizeof(indicators)/sizeof(UINT) ) )
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// Resize the status bar panes
UINT uID = 0;
UINT eStyle = 0;
int nWidth = 0;
m_wndStatusBar.GetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
uID,
eStyle,
nWidth);
m_wndStatusBar.SetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
uID,
eStyle,
nWidth * 2);
m_wndStatusBar.GetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_PROBLEMS),
uID,
eStyle,
nWidth);
m_wndStatusBar.SetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_PROBLEMS),
uID,
eStyle,
nWidth * 2);
m_wndStatusBar.GetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_NEXT_SYMBOLS),
uID,
eStyle,
nWidth);
m_wndStatusBar.SetPaneInfo( m_wndStatusBar.CommandToIndex(ID_INDICATOR_NEXT_SYMBOLS),
uID,
eStyle,
nWidth * 2);
// The "Symbol Count" pane shows as white on a blue background, unless it's disabled
m_wndStatusBar.SetFgColor( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
RGB(255, 255, 255), // White
::GetSysColor(COLOR_GRAYTEXT) ); // Dark Grey (usually)
m_wndStatusBar.SetBkColor( m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
RGB(0, 0, 128), // Dark blue
::GetSysColor(COLOR_3DFACE) ); // Grey (usually)
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
// The only line of code you need to support
// TabbedMDI interface automatically
//
VERIFY(m_MTIClientWnd.Attach(this));
return 0;
}
/******************************************************************************
* The framework calls this override as a signal that files have been dropped
* within the window
*
******************************************************************************/
void CResOrgMDIFrameWnd::OnDropFiles(HDROP hDropInfo)
{
SetActiveWindow(); // Activate us first
UINT uFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
CStringArray arrayUnsuitableFiles;
CWinApp* pApp = AfxGetApp();
ASSERT(NULL != pApp);
if (NULL != pApp)
{
for (UINT n = 0; n < uFiles; n++)
{
// Extract the name of the file
TCHAR szFileName[_MAX_PATH];
::DragQueryFile(hDropInfo, n, szFileName, _MAX_PATH);
// Check to see if we can open it; if so proceed
CNGSplitPath split(szFileName);
if (0 == split.GetExtension().CompareNoCase( _T(".h") ) )
{
pApp->OpenDocumentFile(szFileName);
}
else
{
arrayUnsuitableFiles.Add(split.GetFileName() + split.GetExtension() );
}
}
}
if (arrayUnsuitableFiles.GetSize() > 0)
{
CString sMsg;
sMsg.LoadString(IDP_RESORG_FILE_BAD_TYPE);
for (int n = 0; n < arrayUnsuitableFiles.GetSize(); n++)
{
sMsg += _T("\t") + arrayUnsuitableFiles[n] + _T("\n");
}
AfxMessageBox(sMsg, MB_OK | MB_ICONSTOP);
}
::DragFinish(hDropInfo);
}
void CResOrgMDIFrameWnd::OnUpdateFileClose(CCmdUI* pCmdUI)
{
CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
pCmdUI->Enable(NULL != pDoc);
}
void CResOrgMDIFrameWnd::OnUpdateSymbolCount(CCmdUI* pCmdUI)
{
int nPane = m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT);
ASSERT(nPane >= 0);
CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
if (pDoc != NULL)
{
CString sText;
sText.Format(pCmdUI->m_nID, pDoc->GetSymbolBuffer()->GetSymbolCount() );
m_wndStatusBar.SetMode(nPane, XSB_ICON_AND_TEXT);
m_wndStatusBar.SetIconAndText(nPane, IDI_SYM_RESOURCE, sText);
pCmdUI->Enable(TRUE);
}
else
{
m_wndStatusBar.SetMode(nPane, XSB_TEXT);
m_wndStatusBar.SetText(nPane, _T(""), _T("") );
pCmdUI->SetText( _T("") );
pCmdUI->Enable(FALSE);
}
}
void CResOrgMDIFrameWnd::OnUpdateProblemSymbolCount(CCmdUI* pCmdUI)
{
int nPane = m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_PROBLEMS);
ASSERT(nPane >= 0);
CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
if (pDoc != NULL)
{
int nProblemSymbols = pDoc->GetSymbolBuffer()->GetProblemSymbolCount();
CString sText;
sText.Format(pCmdUI->m_nID, nProblemSymbols);
UINT uIconID = 0;
if (nProblemSymbols > 0)
{
uIconID = IDI_SYM_WARNING;
m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 0) ); // Yellow
m_wndStatusBar.SetBkColor(nPane, RGB(255, 0, 0) ); // Red
}
else
{
uIconID = IDI_SYM_INFORMATION;
m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 255) ); // White
m_wndStatusBar.SetBkColor(nPane, RGB(0, 128, 0) ); // Dark Green
}
m_wndStatusBar.SetMode(nPane, XSB_ICON_AND_TEXT);
m_wndStatusBar.SetIconAndText(nPane, uIconID, sText);
pCmdUI->Enable(TRUE);
}
else
{
m_wndStatusBar.SetMode(nPane, XSB_TEXT);
m_wndStatusBar.SetText(nPane, _T(""), _T("") );
m_wndStatusBar.SetFgColor(nPane, ::GetSysColor(COLOR_GRAYTEXT) ); // Dark Grey (usually)
m_wndStatusBar.SetBkColor(nPane, GetSysColor(COLOR_3DFACE) );
pCmdUI->SetText( _T("") );
pCmdUI->Enable(FALSE);
}
}
void CResOrgMDIFrameWnd::OnUpdateNextSymbolIndicator(CCmdUI* pCmdUI)
{
int nPane = m_wndStatusBar.CommandToIndex(ID_INDICATOR_NEXT_SYMBOLS);
ASSERT(nPane >= 0);
CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
if (pDoc != NULL)
{
CString sText;
// sText.Format(pCmdUI->m_nIDs);
UINT uIconID = 0;
if (pDoc->CheckNextSymbolValues(FALSE) )
{
uIconID = IDI_SYM_WARNING;
sText = _T("Next Symbol values in use");
m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 0) ); // Yellow
m_wndStatusBar.SetBkColor(nPane, RGB(255, 0, 0) ); // Red
}
else
{
uIconID = IDI_SYM_INFORMATION;
sText = _T("Next Symbol Values OK");
m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 255) ); // White
m_wndStatusBar.SetBkColor(nPane, RGB(0, 128, 0) ); // Dark Green
}
m_wndStatusBar.SetMode(nPane, XSB_ICON_AND_TEXT);
m_wndStatusBar.SetIconAndText(nPane, uIconID, sText);
pCmdUI->Enable(TRUE);
}
else
{
m_wndStatusBar.SetMode(nPane, XSB_TEXT);
m_wndStatusBar.SetText(nPane, _T(""), _T("") );
m_wndStatusBar.SetFgColor(nPane, ::GetSysColor(COLOR_GRAYTEXT) ); // Dark Grey (usually)
m_wndStatusBar.SetBkColor(nPane, GetSysColor(COLOR_3DFACE) );
pCmdUI->SetText( _T("") );
pCmdUI->Enable(FALSE);
}
}
LRESULT CResOrgMDIFrameWnd::OnMsgToolBarTextOptionChanged(WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
m_wndToolBar.ShowLabels( Options.ShowTextOnToolbars() );
RecalcLayout();
return LRESULT(0);
}
LRESULT CResOrgMDIFrameWnd::OnMsgXpStyleMenuOptionChanged(WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
CCJMenu::SetMenuDrawMode(Options.UseXpStyleMenus() ? CCJMenu_DRAWMODE_XP : CCJMenu_DRAWMODE_ORIGINAL);
return LRESULT(0);
}
void CResOrgMDIFrameWnd::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CDocument* pDoc = MDIGetActiveDocument();
if (NULL != pDoc)
{
int nPane = m_wndStatusBar.GetPaneAtPosition(point);
if (nPane > 0)
{
UINT uID = 0;
UINT uStyle = 0;
int nWidth = 0;
m_wndStatusBar.GetPaneInfo(nPane, uID, uStyle, nWidth);
switch (uID)
{
case ID_INDICATOR_SYM_COUNT:
PostMessage(WM_COMMAND, ID_FILE_PROPERTIES_STATISTICS);
break;
case ID_INDICATOR_SYM_PROBLEMS:
PostMessage(WM_COMMAND, ID_SYM_PROBLEM_NEXT);
break;
case ID_INDICATOR_NEXT_SYMBOLS:
PostMessage(WM_COMMAND, ID_FILE_PROPERTIES_NEXT_SYMBOLS);
break;
default:
break;
}
}
}
CResOrgMDIFrameWnd_BASE::OnLButtonDblClk(nFlags, point);
}