OSDN Git Service

Remove unused resource IDs
[winmerge-jp/winmerge-jp.git] / Src / ImgMergeFrm.cpp
index bcaff8e..082198e 100644 (file)
@@ -38,9 +38,6 @@
 #define new DEBUG_NEW
 #endif
 
-/** @brief Location for image compare specific help to open. */
-static const TCHAR ImgMergeFrameHelpLocation[] = _T("::/htmlhelp/Compare_images.html");
-
 /////////////////////////////////////////////////////////////////////////////
 // CImgMergeFrame
 
@@ -194,6 +191,8 @@ CImgMergeFrame::CImgMergeFrame()
 
 CImgMergeFrame::~CImgMergeFrame()
 {
+       GetMainFrame()->UnwatchDocuments(this);
+
        if (m_pDirDoc != nullptr)
        {
                m_pDirDoc->MergeDocClosing(this);
@@ -260,6 +259,8 @@ bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bo
        if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
                m_pImgMergeWindow->FirstDiff();
 
+       GetMainFrame()->WatchDocuments(this);
+
        return true;
 }
 
@@ -267,7 +268,7 @@ void CImgMergeFrame::MoveOnLoad(int nPane, int)
 {
        if (nPane < 0)
        {
-               nPane = GetOptionsMgr()->GetInt(OPT_ACTIVE_PANE);
+               nPane = (m_nBufferType[0] != BUFFERTYPE::UNNAMED) ? GetOptionsMgr()->GetInt(OPT_ACTIVE_PANE) : 0;
                if (nPane < 0 || nPane >= m_pImgMergeWindow->GetPaneCount())
                        nPane = 0;
        }
@@ -408,7 +409,6 @@ void CImgMergeFrame::OnChildPaneEvent(const IImgMergeWindow::Event& evt)
        }
        else if (evt.eventType == IImgMergeWindow::CONTEXTMENU)
        {
-               CImgMergeFrame *pFrame = reinterpret_cast<CImgMergeFrame *>(evt.userdata);
                BCMenu menuPopup;
                menuPopup.LoadMenu(MAKEINTRESOURCE(IDR_POPUP_IMG_CTXT));
                theApp.TranslateMenu(menuPopup.m_hMenu);
@@ -461,6 +461,7 @@ BOOL CImgMergeFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
        bool bResult;
        if (std::count(m_nBufferType, m_nBufferType + m_filePaths.GetSize(), BUFFERTYPE::UNNAMED) == m_filePaths.GetSize())
        {
+               m_infoUnpacker.Initialize(false);
                bResult = m_pImgMergeWindow->NewImages(m_filePaths.GetSize(), 1, 256, 256);
        }
        else
@@ -526,7 +527,17 @@ int CImgMergeFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        }
 
        m_wndFilePathBar.SetPaneCount(m_pImgMergeWindow->GetPaneCount());
-       m_wndFilePathBar.SetOnSetFocusCallback([&](int pane) { m_pImgMergeWindow->SetActivePane(pane); });
+       m_wndFilePathBar.SetOnSetFocusCallback([&](int pane) {
+               if (m_nActivePane != pane)
+                       m_pImgMergeWindow->SetActivePane(pane);
+       });
+       m_wndFilePathBar.SetOnCaptionChangedCallback([&](int pane, const String& sText) {
+               m_strDesc[pane] = sText;
+               UpdateHeaderPath(pane);
+       });
+       m_wndFilePathBar.SetOnFileSelectedCallback([&](int pane, const String& sFilepath) {
+               ChangeFile(pane, sFilepath);
+       });
 
        // Merge frame also has a dockable bar at the very left
        // created in OnCreateClient 
@@ -968,8 +979,6 @@ void CImgMergeFrame::OnFileRecompareAs(UINT nID)
        DWORD dwFlags[3];
        String strDesc[3];
        int nBuffers = m_filePaths.GetSize();
-       CDirDoc *pDirDoc = m_pDirDoc->GetMainView() ? m_pDirDoc :
-               static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
        PackingInfo infoUnpacker(m_infoUnpacker.GetPluginPipeline());
 
        for (int nBuffer = 0; nBuffer < nBuffers; ++nBuffer)
@@ -1051,6 +1060,7 @@ void CImgMergeFrame::UpdateHeaderSizes()
 {
        if (m_pImgMergeWindow != nullptr)
        {
+               const int scrollbarWidth = GetSystemMetrics(SM_CXVSCROLL);
                int w[3];
                CRect rc, rcMergeWindow;
                int nPaneCount = m_pImgMergeWindow->GetPaneCount();
@@ -1063,13 +1073,15 @@ void CImgMergeFrame::UpdateHeaderSizes()
                        {
                                RECT rc1 = m_pImgMergeWindow->GetPaneWindowRect(pane);
                                w[pane] = rc1.right - rc1.left - 4;
+                               if (pane == nPaneCount - 1)
+                                       w[pane] -= scrollbarWidth;
                                if (w[pane]<1) w[pane]=1; // Perry 2003-01-22 (I don't know why this happens)
                        }
                }
                else
                {
                        for (int pane = 0; pane < nPaneCount; pane++)
-                               w[pane] = rcMergeWindow.Width() / nPaneCount - 4;
+                               w[pane] = (rcMergeWindow.Width() - scrollbarWidth) / nPaneCount - 6;
                }
 
                if (!std::equal(m_nLastSplitPos, m_nLastSplitPos + nPaneCount - 1, w))
@@ -1144,10 +1156,10 @@ int CImgMergeFrame::UpdateDiffItem(CDirDoc *pDirDoc)
        // If directory compare has results
        if (pDirDoc && pDirDoc->HasDiffs())
        {
-               const String &pathLeft = m_filePaths.GetLeft();
-               const String &pathRight = m_filePaths.GetRight();
-               CDiffContext &ctxt = const_cast<CDiffContext &>(pDirDoc->GetDiffContext());
 // FIXME:
+//             const String &pathLeft = m_filePaths.GetLeft();
+//             const String &pathRight = m_filePaths.GetRight();
+//             CDiffContext &ctxt = const_cast<CDiffContext &>(pDirDoc->GetDiffContext());
 //             if (UINT_PTR pos = pDirDoc->FindItemFromPaths(pathLeft, pathRight))
 //             {
 //                     DIFFITEM &di = pDirDoc->GetDiffRefByKey(pos);