/************************************************************************
*
* Resource ID Organiser Core Library
*
* (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : ResOrgReportStyleSheetDlg.cpp
*
* Description : CResOrgReportStyleSheetDlg - dialog class for selecting
* a stylesheet for an HTML report
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or later
* Microsoft Visual C++ .NET 2003
*
* 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/ResOrgReportStyleSheetDlg.cpp $
* $Revision: 6 $
* $Date: 29/08/04 10:47 $
* $Author: Anna $
*
* $History: ResOrgReportStyleSheetDlg.cpp $
*
* ***************** Version 6 *****************
* User: Anna Date: 29/08/04 Time: 10:47
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* The Symbol Conflict Report is now a "Problem Symbol Report"
*
* ***************** Version 5 *****************
* User: Anna Date: 11/07/04 Time: 16:18
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Removed the unnecessary handler
* CResOrgReportStyleSheetDlg::OnKillFocusStyleSheetPathName()
*
* ***************** Version 4 *****************
* User: Anna Date: 10/05/04 Time: 23:52
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* The stylesheet pathname control is now a recent file combo box
*
* ***************** Version 3 *****************
* User: Anna Date: 3/11/03 Time: 13:07
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Converted the "pathname" edit control to a recent items combo box
* 2. Made the dialog resizeable
*
* ***************** Version 2 *****************
* User: Anna Date: 21/07/03 Time: 13:04
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added Symbol Conflict Report
*
* ***************** Version 1 *****************
* User: Anna Date: 1/03/03 Time: 18:20
* Created in $/Projects/AddIns/ResOrg/ResOrgCore
*
* $Nokeywords: $
*
************************************************************************/
#include "StdAfx.h"
#include "ResOrgCore_Priv.h"
#include "ResOrgReportStyleSheetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResOrgReportStyleSheetDlg dialog
CResOrgReportStyleSheetDlg::CResOrgReportStyleSheetDlg(CWnd* pParent /*=NULL*/)
: CResOrgReportStyleSheetDlg_BASE(CResOrgReportStyleSheetDlg::IDD, pParent)
{
m_sStyleSheetPathName = _T("");
m_eStyleSheetSelect = REPORT_TYPE_SYMBOLS;
}
void CResOrgReportStyleSheetDlg::DoDataExchange(CDataExchange* pDX)
{
CResOrgReportStyleSheetDlg_BASE::DoDataExchange(pDX);
DDX_Control(pDX, IDC_REPORT_INFO, m_ctrlInfoText);
DDX_Control(pDX, IDC_REPORT_STYLESHEET_PATHNAME, m_ctrlStyleSheetPathName);
DDX_Radio(pDX, IDC_REPORT_STYLESHEET_SELECT, m_eStyleSheetSelect);
DDX_CBStringExact(pDX, IDC_REPORT_STYLESHEET_PATHNAME, m_sStyleSheetPathName);
}
BEGIN_MESSAGE_MAP(CResOrgReportStyleSheetDlg, CResOrgReportStyleSheetDlg_BASE)
ON_CBN_SELCHANGE( IDC_REPORT_STYLESHEET_PATHNAME, OnSelChangeStyleSheetPathName)
ON_COMMAND( IDC_REPORT_STYLESHEET_SELECT, OnCmdStyleSheetSelect)
ON_BN_CLICKED( IDC_REPORT_STYLESHEET_BROWSE, OnClickedBrowse)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResOrgReportStyleSheetDlg virtual overrides
int CResOrgReportStyleSheetDlg::GetStyleSheetID(void) const
{
int nSyleSheetID = -1;
switch (m_eStyleSheetSelect)
{
case REPORT_TYPE_SYMBOLS:
nSyleSheetID = IDR_SYM_REPORT_HTML;
break;
case REPORT_TYPE_PROBLEM_SYMBOLS:
nSyleSheetID = IDR_SYM_PROBLEM_REPORT_HTML;
break;
case REPORT_TYPE_USER_DEFINED:
break;
default:
ASSERT(FALSE);
break;
}
return nSyleSheetID;
}
CString CResOrgReportStyleSheetDlg::GetStyleSheetPathName(void) const
{
if (REPORT_TYPE_USER_DEFINED == m_eStyleSheetSelect)
{
return m_sStyleSheetPathName;
}
return _T("");
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgReportStyleSheetDlg virtual overrides
BOOL CResOrgReportStyleSheetDlg::OnInitDialog(void)
{
BOOL bResult = CResOrgReportStyleSheetDlg_BASE::OnInitDialog();
m_Resizer.Create(this);
m_Resizer.SetGripEnabled(TRUE);
m_Resizer.SetMinimumTrackingSize();
m_Resizer.Add(IDC_REPORT_STYLESHEET_SELECT, 0, 20, 0, 0);
m_Resizer.Add(IDC_REPORT_STYLESHEET_PROBLEMS, 0, 30, 0, 0);
m_Resizer.Add(IDC_REPORT_STYLESHEET_FILE, 0, 40, 0, 0);
m_Resizer.Add(IDC_REPORT_STYLESHEET_PATHNAME, 0, 50, 100, 0);
m_Resizer.Add(IDC_REPORT_STYLESHEET_BROWSE, 100, 50, 0, 0);
m_Resizer.Add(IDC_REPORT_INFO, 0, 60, 100, 0);
m_Resizer.Add(IDOK, 100, 80, 0, 0);
m_Resizer.Add(IDCANCEL, 100, 80, 0, 0);
m_Resizer.Add(ID_HELP, 100, 80, 0, 0);
CenterWindow();
CString sInfo;
sInfo.LoadString(IDS_REPORT_INFO);
m_ctrlInfoText.SetWindowText(sInfo);
m_ctrlStyleSheetPathName.SetMRURegKey ( _T("Reports") );
m_ctrlStyleSheetPathName.SetMRUValueFormat ( _T("Stylesheet #%d") );
m_ctrlStyleSheetPathName.SetAutoRefreshAfterAdd(TRUE);
m_ctrlStyleSheetPathName.SetAutoSaveAfterAdd(TRUE);
m_ctrlStyleSheetPathName.LoadMRU();
m_ctrlStyleSheetPathName.RefreshCtrl();
// Set the initial selection...skipping any dead files
for (int nItem = 0; nItem < m_ctrlStyleSheetPathName.GetCount(); nItem++)
{
CString sPathName;
m_ctrlStyleSheetPathName.GetLBText(nItem, sPathName);
if (::FileExists(sPathName) )
{
m_sStyleSheetPathName = sPathName;
UpdateData(FALSE);
break;
}
}
SetAvailableControls();
return bResult;
}
void CResOrgReportStyleSheetDlg::OnOK(void)
{
if (REPORT_TYPE_USER_DEFINED == m_eStyleSheetSelect)
{
if (!::FileExists(m_sStyleSheetPathName) )
{
int nSel = m_ctrlStyleSheetPathName.GetCurSel();
if (nSel >= 0)
{
::AfxMessageBox(IDP_REPORT_NO_LONGER_EXISTS, MB_OK | MB_ICONSTOP);
if (nSel >= 0)
{
m_ctrlStyleSheetPathName.RemoveFromMRU(nSel);
}
}
m_sStyleSheetPathName = _T("");
UpdateData(FALSE);
SetAvailableControls();
return; // Don't allow exit
}
}
CResOrgReportStyleSheetDlg_BASE::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgReportStyleSheetDlg implementation
void CResOrgReportStyleSheetDlg::SetAvailableControls(void)
{
switch (m_eStyleSheetSelect)
{
case REPORT_TYPE_SYMBOLS:
case REPORT_TYPE_PROBLEM_SYMBOLS:
EnableDlgControl(IDC_REPORT_STYLESHEET_BROWSE, FALSE);
EnableDlgControl(IDC_REPORT_STYLESHEET_PATHNAME, FALSE);
EnableDlgControl(IDOK, TRUE);
break;
case REPORT_TYPE_USER_DEFINED:
EnableDlgControl(IDC_REPORT_STYLESHEET_BROWSE, TRUE);
EnableDlgControl(IDC_REPORT_STYLESHEET_PATHNAME, TRUE);
EnableDlgControl(IDOK, !m_sStyleSheetPathName.IsEmpty() && ::FileExists(m_sStyleSheetPathName) );
break;
default:
ASSERT(FALSE);
break;
}
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgReportStyleSheetDlg message handlers
void CResOrgReportStyleSheetDlg::OnCmdStyleSheetSelect(void)
{
SetAvailableControls();
}
void CResOrgReportStyleSheetDlg::OnSelChangeStyleSheetPathName(void)
{
CString sOldPathName = m_sStyleSheetPathName;
int nSel = m_ctrlStyleSheetPathName.GetCurSel();
if (nSel >= 0)
{
m_ctrlStyleSheetPathName.GetLBText(nSel, m_sStyleSheetPathName);
}
if (!::FileExists(m_sStyleSheetPathName) )
{
::AfxMessageBox(IDP_REPORT_NO_LONGER_EXISTS, MB_OK | MB_ICONWARNING);
m_ctrlStyleSheetPathName.RemoveFromMRU(nSel);
m_sStyleSheetPathName = sOldPathName;
}
UpdateData(FALSE);
SetAvailableControls();
}
/// Browse for stylesheet (.xsl) files
void CResOrgReportStyleSheetDlg::OnClickedBrowse(void)
{
#if _MSC_VER < 1300 // BXFileDialog doesn't work with VC7 yet
BXFileDialog dlg( TRUE, // Open
FALSE, // No preview
TRUE, // Resizeable
CString( (LPCTSTR)IDS_FILE_FILTER_STYLESHEETS_EXT), // Default extension
NULL, // Default filename
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST, // Flags
CString( (LPCTSTR)IDS_FILE_FILTER_STYLESHEETS), // File filter
::AfxGetMainWnd() ); // Parent window
DWORD dwVersion = LOWORD(::GetVersion() );
DWORD dwMajor = LOBYTE(dwVersion);
DWORD dwMinor = HIBYTE(dwVersion);
DWORD dwUseableVer = (dwMajor << 8) + dwMinor;
if (dwUseableVer >= 0x501)
{
// Use the VS.NET visual style on WinXP and later
dlg.SetAppearance(BXFileDialog::APPEARANCE_VSDOTNET);
}
#else
CFileDialog dlg( TRUE, // Open
CString( (LPCTSTR)IDS_FILE_FILTER_STYLESHEETS_EXT), // Default extension
NULL, // Default filename
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ENABLESIZING,
// Flags
CString( (LPCTSTR)IDS_FILE_FILTER_STYLESHEETS), // File filter
::AfxGetMainWnd() ); // Parent window
#endif
if (IDOK == dlg.DoModal() )
{
// Open and parse it (via the document)
m_sStyleSheetPathName = dlg.GetPathName();
m_ctrlStyleSheetPathName.AddToMRU(m_sStyleSheetPathName);
SetAvailableControls();
}
}