OSDN Git Service

RFE: [ 1646407 ] Use "equal" or "not equal" as file compare icon
authorGal Hammer <galh@users.sourceforge.net>
Wed, 21 Mar 2007 19:33:10 +0000 (19:33 +0000)
committerGal Hammer <galh@users.sourceforge.net>
Wed, 21 Mar 2007 19:33:10 +0000 (19:33 +0000)
Src/Changes.txt
Src/ChildFrm.cpp
Src/ChildFrm.h
Src/MergeDoc.cpp

index 29b9916..3a3173e 100644 (file)
@@ -3,6 +3,10 @@ Add new items to top.
 (This summarizes all changes to all files under Src, including Src\Languages.)
 
 2007-03-21 Gal
+ RFE: [ 1646407 ] Use "equal" or "not equal" as file compare icon
+  Src: ChildFrm.cpp ChildFrm.h MergeDoc.cpp
+
+2007-03-21 Gal
  BUG: [ 1491334 ] thinly highlighted position is wrong
   Src: stringdiffs.cpp stringdiffsi.h
 
index 5045c79..dedb9bf 100644 (file)
@@ -100,6 +100,8 @@ CChildFrame::CChildFrame()
 #pragma warning(disable:4355) // 'this' : used in base member initializer list
 : m_leftStatus(this, PANE_LEFT_INFO)
 , m_rightStatus(this, PANE_RIGHT_INFO)
+, m_hIdentical(NULL)
+, m_hDifferent(NULL)
 #pragma warning(default:4355)
 {
        m_bActivated = FALSE;
@@ -294,6 +296,9 @@ int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        m_wndStatusBar.SetPaneText(PANE_LEFT_RO, sText, TRUE); 
        m_wndStatusBar.SetPaneText(PANE_RIGHT_RO, sText, TRUE);
 
+       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALFILE);
+       m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALFILE);
+
        SetTimer(0, 250, NULL); // used to update the title headers
        return 0;
 }
@@ -459,6 +464,19 @@ BOOL CChildFrame::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();
 }
 
@@ -557,6 +575,33 @@ IHeaderBar * CChildFrame::GetHeaderInterface()
        return &m_wndFilePathBar;
 }
 
+/**
+* @brief Reflect comparison result in window's icon.
+* @param nResult [in] Last comparison result which the application returns.
+*/
+void CChildFrame::SetLastCompareResult(int nResult)
+{
+       HICON hCurrent = GetIcon(FALSE);
+       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
+
+       if (hCurrent != hReplace)
+       {
+               SetIcon(hReplace, FALSE);
+
+               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 CChildFrame::OnTimer(UINT_PTR nIDEvent) 
 {
        if (IsWindowVisible())
index ffb55b7..0887489 100644 (file)
@@ -53,6 +53,7 @@ public:
        IHeaderBar * GetHeaderInterface();
        void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
        CMergeDoc * GetMergeDoc() { return m_pMergeDoc; }
+       void SetLastCompareResult(int nResult);
 
 // Attributes
 protected:
@@ -114,6 +115,8 @@ private:
        void UpdateHeaderSizes();
        BOOL m_bActivated;
        CMergeDoc * m_pMergeDoc;
+       HICON m_hIdentical;
+       HICON m_hDifferent;
 
        //{{AFX_MSG(CChildFrame)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
index d7baa07..8ee8c69 100644 (file)
@@ -525,7 +525,7 @@ int CMergeDoc::Rescan(BOOL &bBinary, BOOL &bIdentical,
                m_bEditAfterRescan[1] = FALSE;
        }
 
-       theApp.SetLastCompareResult(m_diffList.GetSignificantDiffs());
+       GetParentFrame()->SetLastCompareResult(m_diffList.GetSignificantDiffs());
 
        m_pRescanFileInfo[0]->Update(m_filePaths.GetLeft());
        m_pRescanFileInfo[1]->Update(m_filePaths.GetRight());