OSDN Git Service

Apply also the patch "RFE: [ 1646407 ] Use "equal" or "not equal" as file compare...
authorsdottaka <sdottaka@sourceforge.net>
Sat, 8 Mar 2014 07:00:09 +0000 (16:00 +0900)
committersdottaka <sdottaka@sourceforge.net>
Sat, 8 Mar 2014 07:00:09 +0000 (16:00 +0900)
--HG--
branch : stable

Src/DirFrame.cpp
Src/DirFrame.h
Src/DirView.cpp

index d9ba458..d113dcf 100644 (file)
@@ -76,6 +76,8 @@ static UINT RO_PANEL_WIDTH = 40;
 IMPLEMENT_DYNCREATE(CDirFrame, CMDIChildWnd)
 
 CDirFrame::CDirFrame()
+: m_hIdentical(NULL)
+, m_hDifferent(NULL)
 {
 }
 
@@ -130,6 +132,10 @@ int CDirFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        m_wndStatusBar.SetPaneText(PANE_LEFT_RO, sText.c_str(), TRUE); 
        m_wndStatusBar.SetPaneText(PANE_MIDDLE_RO, sText.c_str(), TRUE); 
        m_wndStatusBar.SetPaneText(PANE_RIGHT_RO, sText.c_str(), TRUE);
+
+       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALFOLDER);
+       m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALFOLDER);
+
        return 0;
 }
 
@@ -201,6 +207,33 @@ void CDirFrame::UpdateResources()
 {
 }
 
+/**
+* @brief Reflect comparison result in window's icon.
+* @param nResult [in] Last comparison result which the application returns.
+*/
+void CDirFrame::SetLastCompareResult(int nResult)
+{
+       HICON hCurrent = GetIcon(FALSE);
+       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
+
+       if (hCurrent != hReplace)
+       {
+               SetIcon(hReplace, TRUE);
+
+               BOOL bMaximized;
+               GetMDIFrame()->MDIGetActive(&bMaximized);
+
+               // When MDI maximized the window icon is drawn on the menu bar, so we
+               // need to notify it that our icon has changed.
+               if (bMaximized)
+               {
+                       GetMDIFrame()->DrawMenuBar();
+               }
+       }
+
+       theApp.SetLastCompareResult(nResult);
+}
+
 void CDirFrame::OnClose() 
 {      
        CMDIChildWnd::OnClose();
@@ -220,6 +253,19 @@ BOOL CDirFrame::DestroyWindow()
                GetWindowPlacement(&wp);
                theApp.WriteProfileInt(_T("Settings"), _T("ActiveFrameMax"), (wp.showCmd == SW_MAXIMIZE));
        }
+
+       if (m_hIdentical != NULL)
+       {
+               DestroyIcon(m_hIdentical);
+               m_hIdentical = NULL;
+       }
+
+       if (m_hDifferent != NULL)
+       {
+               DestroyIcon(m_hDifferent);
+               m_hDifferent = NULL;
+       }
+
        return CMDIChildWnd::DestroyWindow();
 }
 
index a541356..443a409 100644 (file)
@@ -46,6 +46,10 @@ protected:
 // Attributes
 public:
 
+private:
+       HICON m_hIdentical;
+       HICON m_hDifferent;
+
 // Operations
 public:
        void SetStatus(LPCTSTR szStatus);
@@ -54,6 +58,7 @@ public:
        IHeaderBar * GetHeaderInterface();
        void UpdateResources();
        void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
+       void SetLastCompareResult(int nResult);
 
 // Overrides
        virtual void GetMessageString(UINT nID, CString& rMessage) const;
index 930f3fd..c858f41 100644 (file)
@@ -603,7 +603,8 @@ void CDirView::Redisplay()
        int alldiffs = 0;
        UIntPtr diffpos = ctxt.GetFirstDiffPosition();
        RedisplayChildren(diffpos, 0, cnt, alldiffs);
-       theApp.SetLastCompareResult(alldiffs);
+       if (pDoc->m_diffThread.GetThreadState() == CDiffThread::THREAD_COMPLETED)
+               GetParentFrame()->SetLastCompareResult(alldiffs);
        SortColumnsAppropriately();
        SetRedraw(TRUE);
 }