Commits

jtuc  committed 1ac7b6a
  • Participants
  • Parent commits 31b7b95

Comments (0)

Files changed (8)

File Src/CompareStats.cpp

  * @brief Constructor, initializes critical section.
  */
 CompareStats::CompareStats()
+	: m_hEvent(CreateEvent(NULL, TRUE, FALSE, NULL))
 {
 	Reset();
 }
  */
 CompareStats::~CompareStats()
 {
+	CloseHandle(m_hEvent);
 }
 
 /** 
 	m_nComparedItems = 0;
 	ZeroMemory(m_counts, sizeof m_counts);
 	m_pCurDiffItem = NULL;
+	Continue();
 }
 
 /**

File Src/CompareStats.h

 	String GetRightPath(CDiffContext *) const;
 	void Reset();
 	static RESULT GetColImage(const DIFFITEM *);
-
+	void Wait() const
+	{
+		// WaitForSingleObject() is expensive so avoid it if possible
+		if (paused)
+			WaitForSingleObject(m_hEvent, INFINITE);
+	}
+	void Pause()
+	{
+		paused = true;
+		ResetEvent(m_hEvent);
+	}
+	void Continue()
+	{
+		paused = false;
+		SetEvent(m_hEvent);
+	}
 private:
 
+	HANDLE m_hEvent;
+	bool paused;
 	long m_counts[N_DIFFIMG]; /**< Table storing result counts */
 	long m_nTotalItems; /**< Total items found to compare */
 	long m_nComparedItems; /**< Compared items so far */

File Src/DiffContext.cpp

 			::DispatchMessage(&msg);
 		}
 	}
+	m_pCompareStats->Wait();
 	return m_bAborting;
 }
 

File Src/DirCompProgressDlg.cpp

  *
  * @brief Implementation file for Directory compare state dialog
  */
-// ID line follows -- this is updated by SVN
-// $Id$
-
 #include "StdAfx.h"
 #include "Merge.h"
 #include "LanguageSelect.h"
 : ODialog(IDD_DIRCOMP_PROGRESS)
 , m_pDirDoc(pDirDoc)
 , m_pStatsDlg(new CompareStatisticsDlg(pDirDoc->GetCompareStats()))
+, m_rotPauseContinue(0)
 {
 	LanguageSelect.Create(*this, theApp.m_pMainWnd->GetLastActivePopup()->m_hWnd);
 }
 		{
 		case IDCANCEL:
 			m_pDirDoc->AbortCurrentScan();
+			m_pDirDoc->GetCompareStats()->Continue();
+			break;
+		case IDC_PAUSE_CONTINUE:
+			switch (m_rotPauseContinue)
+			{
+			case 0:
+				m_pDirDoc->GetCompareStats()->Pause();
+				break;
+			case 1:
+				m_pDirDoc->GetCompareStats()->Continue();
+				break;
+			}
+			stl::rotate(m_strPauseContinue.begin(),
+				m_strPauseContinue.begin() + m_strPauseContinue.find('\t') + 1,
+				m_strPauseContinue.end());
+			SetDlgItemText(IDC_PAUSE_CONTINUE,
+				m_strPauseContinue.substr(0, m_strPauseContinue.find('\t')).c_str());
+			m_rotPauseContinue = (m_rotPauseContinue + 1) % 2;
 			break;
 		}
 		break;
 		break;
 	case WM_SETCURSOR:
 		return GetParent()->SendMessage(message, wParam, lParam);
+	case WM_CTLCOLORBTN:
+		reinterpret_cast<HSurface *>(wParam)->SetBkColor(RGB(255,0,0));
+		break;
 	}
 	return ODialog::WindowProc(message, wParam, lParam);
 }
 	SetDlgItemInt(IDC_ITEMSCOMPARED, 0);
 	SetDlgItemInt(IDC_ITEMSTOTAL, 0);
 
+	GetDlgItemText(IDC_PAUSE_CONTINUE, m_strPauseContinue);
+	SetDlgItemText(IDC_PAUSE_CONTINUE, m_strPauseContinue.substr(0, m_strPauseContinue.find('\t')).c_str());
+
 	SetTimer(IDT_UPDATE, UPDATE_INTERVAL);
 	return TRUE;
 }

File Src/DirCompProgressDlg.h

 private:
 	CDirFrame *const m_pDirDoc; /**< Pointer to dirdoc we are comparing */
 	CompareStatisticsDlg *const m_pStatsDlg;
+	String m_strPauseContinue;
+	int m_rotPauseContinue;
 };
 
 //{{AFX_INSERT_LOCATION}}

File Src/DirFrame.h

 	AllowUpwardDirectory::ReturnCode AllowUpwardDirectory(String &leftParent, String &rightParent);
 	void SetItemViewFlag(DIFFITEM *, UINT flag, UINT mask);
 	void SetItemViewFlag(UINT flag, UINT mask);
-	const CompareStats *GetCompareStats() const { return m_pCompareStats; };
+	CompareStats *GetCompareStats() const { return m_pCompareStats; };
 
 private:
 	bool InitContext(LPCTSTR pszLeft, LPCTSTR pszRight, int nRecursive, DWORD dwContext);

File Src/Merge.rc

     GROUPBOX        "Different", IDC_STATIC, 7, 15, 186, 37
     RTEXT           "Text:", IDC_STATIC, 11, 25, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_INOTEQUAL, 71, 23, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_DIFFFILE, 86, 24, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_DIFFFILE, 86, 24, 38, 10, SS_RIGHT | SS_SUNKEN
     RTEXT           "Binary:", IDC_STATIC, 11, 39, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_IDIFFBINFILE, 71, 36, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_DIFFBINARY, 86, 37, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_DIFFBINARY, 86, 37, 38, 10, SS_RIGHT | SS_SUNKEN
     GROUPBOX        "Unique", IDC_STATIC, 7, 55, 186, 37
     RTEXT           "Left:", IDC_STATIC, 11, 65, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_ILUNIQFOLDER, 132, 63, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_LUNIQFOLDER, 146, 64, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_LUNIQFOLDER, 146, 64, 38, 10, SS_RIGHT | SS_SUNKEN
     ICON            "", IDC_STAT_ILUNIQFILE, 71, 63, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_LUNIQFILE, 86, 64, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_LUNIQFILE, 86, 64, 38, 10, SS_RIGHT | SS_SUNKEN
     RTEXT           "Right:", IDC_STATIC, 11, 78, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_IRUNIQFOLDER, 132, 76, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_RUNIQFOLDER, 146, 77, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_RUNIQFOLDER, 146, 77, 38, 10, SS_RIGHT | SS_SUNKEN
     ICON            "", IDC_STAT_IRUNIQFILE, 71, 76, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_RUNIQFILE, 86, 77, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_RUNIQFILE, 86, 77, 38, 10, SS_RIGHT | SS_SUNKEN
     GROUPBOX        "Identical", IDC_STATIC, 7, 95, 186, 37
     ICON            "", IDC_STAT_IIDENTICFOLDER, 132, 103, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_IDENTICFOLDER, 146, 104, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_IDENTICFOLDER, 146, 104, 38, 10, SS_RIGHT | SS_SUNKEN
     RTEXT           "Text:", IDC_STATIC, 11, 105, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_IEQUALFILE, 71, 103, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_IDENTICFILE, 86, 104, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_IDENTICFILE, 86, 104, 38, 10, SS_RIGHT | SS_SUNKEN
     RTEXT           "Binary:", IDC_STATIC, 11, 118, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_IEQUALBINFILE, 71, 116, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_IDENTICBINARY, 86, 117, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_IDENTICBINARY, 86, 117, 38, 10, SS_RIGHT | SS_SUNKEN
     CONTROL         "", IDC_STATIC, WC_STATIC, SS_ETCHEDHORZ, 7, 136, 183, 1
     RTEXT           "Total:", IDC_STATIC, 11, 142, 56, 8, SS_RIGHT
     ICON            "", IDC_STAT_ITOTALFOLDERS, 132, 140, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_TOTALFOLDER, 146, 141, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_TOTALFOLDER, 146, 141, 38, 10, SS_RIGHT | SS_SUNKEN
     ICON            "", IDC_STAT_ITOTALFILES, 71, 140, 21, 20, SS_ICON
-    RTEXT           "Static", IDC_STAT_TOTALFILE, 86, 141, 38, 10, SS_RIGHT | SS_SUNKEN
+    RTEXT           "", IDC_STAT_TOTALFILE, 86, 141, 38, 10, SS_RIGHT | SS_SUNKEN
     DEFPUSHBUTTON   "Close", IDOK, 200, 140, 50, 14
 }
 
 CAPTION " Folder Compare Progress"
 FONT 8, "MS Shell Dlg", 0, 0, 1
 {
-    DEFPUSHBUTTON   "Stop", IDCANCEL, 166, 15, 83, 14
+    DEFPUSHBUTTON   "Stop", IDCANCEL, 166, 7, 83, 14
+    PUSHBUTTON      "Pause\tContinue\t", IDC_PAUSE_CONTINUE, 166, 23, 83, 14
     CONTROL         "", IDC_PROGRESSCOMPARE, PROGRESS_CLASS, WS_BORDER, 7, 68, 242, 9
     RTEXT           "0", IDC_ITEMSCOMPARED, 95, 29, 30, 8, SS_RIGHT
     RTEXT           "0", IDC_ITEMSTOTAL, 95, 19, 30, 8, SS_RIGHT
     IDR_MERGEDOCTYPE              "\nFileCompare\n\n\n\nWinMerge.FileCompare\nWinMerge File Compare"
     IDR_DIRDOCTYPE                "\nFolderCompare\n\n\n\nWinMerge.FolderCompare\nWinMerge Folder Compare"
     IDC_MIXED_EOL                 "Preserve original EOL chars"
-    IDC_COMPARISON_STOP           "Stop"
-    IDC_COMPARISON_CLOSE          "Press any key"
     IDC_STATIC_TITLE_LEFT         "Right click on the path to copy"
     IDC_STATIC_TITLE_RIGHT        "Right click on the path to copy"
     IDS_SPLASH_DEVELOPERS         "Developers:\nDean Grimm, Christian List, Kimmo Varis, Jochen Tucht, Tim Gerundt, Takashi Sawanaki, Gal Hammer, Alexander Skinner"

File Src/resource.h

 #define IDC_EXT_EDITOR_PATH                     1092
 #define IDC_DIFF_SWAPFILES                      1093
 #define IDC_DIFF_OPENTOEDITOR                   1094
-#define IDC_COMPARISON_STOP                     1106
-#define IDC_COMPARISON_CLOSE                    1107
-#define IDC_DIFF_INCLCMDLINE                    1108
+#define IDC_DIFF_INCLCMDLINE                    1095
+#define IDC_PAUSE_CONTINUE                      1100
+#define IDC_PROGRESSCOMPARE                     1101
+#define IDC_ITEMSCOMPARED                       1102
+#define IDC_ITEMSTOTAL                          1103
 #define IDC_WMGOTO_FILELEFT                     1109
 #define IDC_WMGOTO_FILERIGHT                    1110
 #define IDC_WMGOTO_TOLINE                       1111
 #define IDC_SAVECLOSING_DISCARDALL              1188
 #define IDC_MULTIDOC_FILECMP                    1189
 #define IDC_MULTIDOC_DIRCMP                     1190
-#define IDC_PROGRESSCOMPARE                     1191
-#define IDC_ITEMSCOMPARED                       1192
-#define IDC_ITEMSTOTAL                          1193
 #define IDC_REPORT_STYLECOMBO                   1194
 #define IDC_REPORT_BROWSEFILE                   1195
 #define IDC_REPORT_FILE                         1196