-/////////////////////////////////////////////////////////////////////////////
-// License (GPLv2+):
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-/////////////////////////////////////////////////////////////////////////////
+// SPDX-License-Identifier: GPL-2.0-or-later
/**
* @file CompareStatisticsDlg.cpp
*
#include "stdafx.h"
#include "CompareStatisticsDlg.h"
#include "CompareStats.h"
-#include "Merge.h"
#ifdef _DEBUG
#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
#endif
-
-/** @brief Icon size in the dialog. */
-static const CSize IconSize(16, 16);
-
/////////////////////////////////////////////////////////////////////////////
// SaveClosingDlg dialog
-IMPLEMENT_DYNAMIC(CompareStatisticsDlg, CDialog)
+IMPLEMENT_DYNAMIC(CompareStatisticsDlg, CTrDialog)
-CompareStatisticsDlg::CompareStatisticsDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CompareStatisticsDlg::IDD, pParent)
-, m_pCompareStats(NULL)
+CompareStatisticsDlg::CompareStatisticsDlg(const CompareStats* pStats, CWnd* pParent /*= nullptr*/) :
+ m_pCompareStats(pStats),
+ CTrDialog(pStats->GetCompareDirs() < 3 ? IDD_COMPARE_STATISTICS : IDD_COMPARE_STATISTICS3, pParent)
{
//{{AFX_DATA_INIT(CompareStatisticsDlg)
//}}AFX_DATA_INIT
}
-BEGIN_MESSAGE_MAP(CompareStatisticsDlg, CDialog)
+BEGIN_MESSAGE_MAP(CompareStatisticsDlg, CTrDialog)
//{{AFX_MSG_MAP(SaveClosingDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
*/
BOOL CompareStatisticsDlg::OnInitDialog()
{
- theApp.TranslateDialog(m_hWnd);
- CDialog::OnInitDialog();
+ CTrDialog::OnInitDialog();
int totalFiles = 0;
int totalFolders = 0;
-
- // Identicals
- int count = m_pCompareStats->GetCount(CompareStats::RESULT_DIR);
- totalFolders += count;
- SetDlgItemInt(IDC_STAT_IDENTICFOLDER, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_SAME);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_IDENTICFILE, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_BINSAME);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_IDENTICBINARY, count);
-
- // Different
- count = m_pCompareStats->GetCount(CompareStats::RESULT_DIFF);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_DIFFFILE, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_BINDIFF);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_DIFFBINARY, count);
-
- // Unique
- count = m_pCompareStats->GetCount(CompareStats::RESULT_LDIRUNIQUE);
- totalFolders += count;
- SetDlgItemInt(IDC_STAT_LUNIQFOLDER, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_LUNIQUE);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_LUNIQFILE, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_MDIRUNIQUE);
- totalFolders += count;
- SetDlgItemInt(IDC_STAT_MUNIQFOLDER, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_MUNIQUE);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_MUNIQFILE, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_RDIRUNIQUE);
- totalFolders += count;
- SetDlgItemInt(IDC_STAT_RUNIQFOLDER, count);
- count = m_pCompareStats->GetCount(CompareStats::RESULT_RUNIQUE);
- totalFiles += count;
- SetDlgItemInt(IDC_STAT_RUNIQFILE, count);
+ const int iconCX = []() {
+ const int cx = GetSystemMetrics(SM_CXSMICON);
+ if (cx < 24)
+ return 16;
+ if (cx < 32)
+ return 24;
+ if (cx < 48)
+ return 32;
+ return 48;
+ }();
+ const int iconCY = iconCX;
+
+ static const struct { int ctlID; CompareStats::RESULT resultType; bool isDir; } ctlResultTypeMap[] =
+ {
+ { IDC_STAT_IDENTICFOLDER, CompareStats::RESULT_DIRSAME, true },
+ { IDC_STAT_IDENTICFILE, CompareStats::RESULT_SAME, false },
+ { IDC_STAT_IDENTICBINARY, CompareStats::RESULT_BINSAME, false },
+ { IDC_STAT_DIFFFOLDER, CompareStats::RESULT_DIRDIFF, true },
+ { IDC_STAT_DIFFFILE, CompareStats::RESULT_DIFF, false },
+ { IDC_STAT_DIFFBINARY, CompareStats::RESULT_BINDIFF, false },
+ { IDC_STAT_LUNIQFOLDER, CompareStats::RESULT_LDIRUNIQUE, true },
+ { IDC_STAT_LUNIQFILE, CompareStats::RESULT_LUNIQUE, false },
+ { IDC_STAT_MUNIQFOLDER, CompareStats::RESULT_MDIRUNIQUE, true },
+ { IDC_STAT_MUNIQFILE, CompareStats::RESULT_MUNIQUE, false },
+ { IDC_STAT_RUNIQFOLDER, CompareStats::RESULT_RDIRUNIQUE, true },
+ { IDC_STAT_RUNIQFILE, CompareStats::RESULT_RUNIQUE, false },
+ { IDC_STAT_LMISSINGFOLDER, CompareStats::RESULT_LDIRMISSING, true },
+ { IDC_STAT_LMISSINGFILE, CompareStats::RESULT_LMISSING, false },
+ { IDC_STAT_MMISSINGFOLDER, CompareStats::RESULT_MDIRMISSING, true },
+ { IDC_STAT_MMISSINGFILE, CompareStats::RESULT_MMISSING, false },
+ { IDC_STAT_RMISSINGFOLDER, CompareStats::RESULT_RDIRMISSING, true },
+ { IDC_STAT_RMISSINGFILE, CompareStats::RESULT_RMISSING, false },
+ };
+ for (auto&& map : ctlResultTypeMap)
+ {
+ int count = m_pCompareStats->GetCount(map.resultType);
+ if (!map.isDir)
+ totalFiles += count;
+ else
+ totalFolders += count;
+ SetDlgItemInt(map.ctlID, count);
+ }
// Total
SetDlgItemInt(IDC_STAT_TOTALFOLDER, totalFolders);
SetDlgItemInt(IDC_STAT_TOTALFILE, totalFiles);
// Load small folder icons
- CStatic * pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_ILUNIQFOLDER);
- HICON hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_LFOLDER), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IMUNIQFOLDER);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_MFOLDER), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IRUNIQFOLDER);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_RFOLDER), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
+ static const struct { int ctlID; int iconID; } ctlIconMap[] =
+ {
+ { IDC_STAT_ILUNIQFOLDER, IDI_LFOLDER },
+ { IDC_STAT_IMUNIQFOLDER, IDI_MFOLDER },
+ { IDC_STAT_IRUNIQFOLDER, IDI_RFOLDER },
+ { IDC_STAT_ILMISSINGFOLDER, IDI_MRFOLDER },
+ { IDC_STAT_IMMISSINGFOLDER, IDI_LRFOLDER },
+ { IDC_STAT_IRMISSINGFOLDER, IDI_LMFOLDER },
+ { IDC_STAT_INOTEQUALFOLDER, IDI_NOTEQUALFOLDER },
+ { IDC_STAT_INOTEQUAL, IDI_NOTEQUALFILE },
+ { IDC_STAT_IDIFFBINFILE, IDI_BINARYDIFF },
+ { IDC_STAT_ILUNIQFILE, IDI_LFILE },
+ { IDC_STAT_IMUNIQFILE, IDI_MFILE },
+ { IDC_STAT_IRUNIQFILE, IDI_RFILE },
+ { IDC_STAT_ILMISSINGFILE, IDI_MRFILE },
+ { IDC_STAT_IMMISSINGFILE, IDI_LRFILE },
+ { IDC_STAT_IRMISSINGFILE, IDI_LMFILE },
+ { IDC_STAT_IEQUALFILE, IDI_EQUALFILE },
+ { IDC_STAT_IEQUALBINFILE, IDI_EQUALBINARY },
+ { IDC_STAT_IIDENTICFOLDER, IDI_EQUALFOLDER },
+ };
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IIDENTICFOLDER);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_FOLDER), IMAGE_ICON, IconSize.cy, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_INOTEQUAL);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_NOTEQUALFILE), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IDIFFBINFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_BINARYDIFF), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_ILUNIQFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_LFILE), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IMUNIQFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_MFILE), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IRUNIQFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_RFILE), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IEQUALFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_EQUALFILE), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_IEQUALBINFILE);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_EQUALBINARY), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_ITOTALFOLDERS);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_SIGMA), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
-
- pBitmapCtrl = (CStatic *) GetDlgItem(IDC_STAT_ITOTALFILES);
- hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_SIGMA), IMAGE_ICON, IconSize.cx, IconSize.cy, LR_SHARED);
- pBitmapCtrl->SetIcon(hIcon);
+ for (auto&& map : ctlIconMap)
+ {
+ if (GetDlgItem(map.ctlID))
+ {
+ HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
+ MAKEINTRESOURCE(map.iconID), IMAGE_ICON, iconCX, iconCY, LR_SHARED);
+ SendDlgItemMessage(map.ctlID, STM_SETICON, (WPARAM)hIcon, 0L);
+ }
+ }
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
-
-/**
- * @brief Set compare stats for the dialog.
- * @param [in] pStats Pointer to the structure containing compare stats.
- */
-void CompareStatisticsDlg::SetCompareStats(const CompareStats * pStats)
-{
- m_pCompareStats = pStats;
-}