OSDN Git Service

autoit.cpp - Macros >> User 1 ..... Variable >> User 2 (#749) (2)
[winmerge-jp/winmerge-jp.git] / Src / DirView.h
index 63c732f..3b91abf 100644 (file)
@@ -1,21 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //    WinMerge:  an interactive diff/merge utility
 //    Copyright (C) 1997  Dean P. Grimm
-//
-//    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 DirView.h
@@ -27,9 +13,9 @@
 /////////////////////////////////////////////////////////////////////////////
 // CDirView view
 #include <afxcview.h>
-#include <map>
 #include <memory>
-#include "OptionsDiffColors.h"
+#include <optional>
+#include "OptionsDirColors.h"
 #include "SortHeaderCtrl.h"
 #include "UnicodeString.h"
 #include "DirItemIterator.h"
@@ -37,8 +23,6 @@
 
 class FileActionScript;
 
-struct DIFFITEM;
-
 typedef enum { eMain, eContext } eMenuType;
 
 class CDirDoc;
@@ -59,10 +43,10 @@ struct IListCtrl;
 /**
  * @brief Position value for special items (..) in directory compare view.
  */
-const uintptr_t SPECIAL_ITEM_POS = (uintptr_t) - 1L;
+const uintptr_t SPECIAL_ITEM_POS = (uintptr_t)(reinterpret_cast<DIFFITEM *>( - 1L));
 
 /** Default column width in directory compare */
-const UINT DefColumnWidth = 150;
+const UINT DefColumnWidth = 111;
 
 /**
  * @brief Directory compare results view.
@@ -97,13 +81,13 @@ public:
 
        void StartCompare(CompareStats *pCompareStats);
        void Redisplay();
-       void RedisplayChildren(uintptr_t diffpos, int level, UINT &index, int &alldiffs, const DirViewFilterSettings& dirfilter);
+       void RedisplayChildren(DIFFITEM *diffpos, int level, UINT &index, int &alldiffs);
        void UpdateResources();
        void LoadColumnHeaderItems();
-       uintptr_t GetItemKey(int idx) const;
-       int GetItemIndex(uintptr_t key);
+       DIFFITEM *GetItemKey(int idx) const;
+       int GetItemIndex(DIFFITEM *key);
        // for populating list
-       void DeleteItem(int sel);
+       void DeleteItem(int sel, bool removeDIFFITEM = false);
        void DeleteAllDisplayItems();
        void SetFont(const LOGFONT & lf);
 
@@ -114,7 +98,20 @@ public:
        void AddParentFolderItem(bool bEnable);
        void RefreshOptions();
 
-       LRESULT HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lParam);
+       bool HasNextDiff();
+       bool HasPrevDiff();
+       void MoveToNextDiff();
+       void MoveToPrevDiff();
+       void OpenNextDiff();
+       void OpenPrevDiff();
+       void OpenFirstFile();
+       void OpenLastFile();
+       void OpenNextFile();
+       void OpenPrevFile();
+       bool IsFirstFile();
+       bool IsLastFile();
+
+       void SetActivePane(int pane);
 
 // Implementation types
 private:
@@ -124,8 +121,6 @@ private:
        void GetItemFileNames(int sel, String& strLeft, String& strRight) const;
        void GetItemFileNames(int sel, PathContext * paths) const;
        void FormatEncodingDialogDisplays(CLoadSaveCodepageDlg * dlg);
-       bool IsItemLeftOnly(int code);
-       bool IsItemRightOnly(int code);
        DirActions MakeDirActions(DirActions::method_type func) const;
        DirActions MakeDirActions(DirActions::method_type2 func) const;
        Counts Count(DirActions::method_type2 func) const;
@@ -134,7 +129,8 @@ private:
        void DoOpen(SIDE_TYPE stype);
        void DoOpenWith(SIDE_TYPE stype);
        void DoOpenWithEditor(SIDE_TYPE stype);
-       void DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI);
+       void DoOpenParentFolder(SIDE_TYPE stype);
+       void DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI, bool openableForDir = true);
        void ConfirmAndPerformActions(FileActionScript & actions);
        void PerformActionList(FileActionScript & actions);
        void UpdateAfterFileScript(FileActionScript & actionList);
@@ -163,8 +159,8 @@ public:
        void UpdateDiffItemStatus(UINT nIdx);
 private:
        void InitiateSort();
-       void NameColumn(const char* idname, int subitem);
-       int AddNewItem(int i, uintptr_t diffpos, int iImage, int iIndent);
+       void NameColumn(const DirColInfo *col, int subitem);
+       int AddNewItem(int i, DIFFITEM *diffpos, int iImage, int iIndent);
 // End DirViewCols.cpp
 
 private:
@@ -174,10 +170,12 @@ private:
        //{{AFX_VIRTUAL(CDirView)
 public:
        virtual void OnInitialUpdate();
+       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 protected:
        virtual BOOL PreTranslateMessage(MSG* pMsg);
        virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
        virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
+       virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
        //}}AFX_VIRTUAL
 
 // Implementation
@@ -187,32 +185,31 @@ protected:
        int GetFirstDifferentItem();
        int GetLastDifferentItem();
        int AddSpecialItems();
-       void GetCurrentColRegKeys(std::vector<String>& colKeys);
-       void OpenSpecialItems(uintptr_t pos1, uintptr_t pos2, uintptr_t pos3);
+       std::vector<String>     GetCurrentColRegKeys();
+       void OpenSpecialItems(DIFFITEM *pos1, DIFFITEM *pos2, DIFFITEM *pos3);
 
 // Implementation data
 protected:
-       CString GenerateReport();
        CSortHeaderCtrl m_ctlSortHeader;
        CImageList m_imageList;
        CImageList m_imageState;
-       CListCtrl *m_pList;
+       CListCtrlm_pList;
        std::unique_ptr<IListCtrl> m_pIList;
-       bool m_bEscCloses; /**< Cached value for option for ESC closing window */
+       int m_nEscCloses; /**< Cached value for option for ESC closing window */
        bool m_bExpandSubdirs;
        CFont m_font; /**< User-selected font */
        UINT m_nHiddenItems; /**< Count of items we have hidden */
-       bool m_bTreeMode; /**< TRUE if tree mode is on*/
+       bool m_bTreeMode; /**< `true` if tree mode is on*/
+       DirViewFilterSettings m_dirfilter;
        std::unique_ptr<DirCompProgressBar> m_pCmpProgressBar;
        clock_t m_compareStart; /**< Starting process time of the compare */
-       bool m_bUserCancelEdit; /**< TRUE if the user cancels rename */
+       bool m_bUserCancelEdit; /**< `true` if the user cancels rename */
        String m_lastCopyFolder; /**< Last Copy To -target folder. */
 
-       int m_firstDiffItem;
-       int m_lastDiffItem;
-       bool m_bNeedSearchFirstDiffItem;
-       bool m_bNeedSearchLastDiffItem;
-       COLORSETTINGS m_cachedColors; /**< Cached color settings */
+       std::optional<int> m_firstDiffItem;
+       std::optional<int> m_lastDiffItem;
+       DIRCOLORSETTINGS m_cachedColors; /**< Cached color settings */
+       bool m_bUseColors;
 
        std::unique_ptr<CShellContextMenu> m_pShellContextMenuLeft; /**< Shell context menu for group of left files */
        std::unique_ptr<CShellContextMenu> m_pShellContextMenuMiddle; /**< Shell context menu for group of middle files */
@@ -220,17 +217,16 @@ protected:
        HMENU m_hCurrentMenu; /**< Current shell context menu (either left or right) */
        std::unique_ptr<DirViewTreeState> m_pSavedTreeState;
        std::unique_ptr<DirViewColItems> m_pColItems;
+       int m_nActivePane;
 
        // Generated message map functions
        afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
        afx_msg void OnContextMenu(CWnd*, CPoint point);
        //{{AFX_MSG(CDirView)
        afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
-       template<SIDE_TYPE srctype, SIDE_TYPE dsttype>
-       afx_msg void OnDirCopy();
+       afx_msg void OnDirCopy(UINT id);
        template<SIDE_TYPE srctype, SIDE_TYPE dsttype>
        afx_msg void OnCtxtDirCopy();
-       template<SIDE_TYPE srctype, SIDE_TYPE dsttype>
        afx_msg void OnUpdateDirCopy(CCmdUI* pCmdUI);
        template<SIDE_TYPE srctype, SIDE_TYPE dsttype>
        afx_msg void OnUpdateCtxtDirCopy(CCmdUI* pCmdUI);
@@ -253,9 +249,18 @@ protected:
        template<SIDE_TYPE stype>
        afx_msg void OnUpdateCtxtDirOpenWithEditor(CCmdUI* pCmdUI);
        template<SIDE_TYPE stype>
+       afx_msg void OnCtxtDirOpenParentFolder();
+       template<SIDE_TYPE stype>
+       afx_msg void OnUpdateCtxtDirOpenParentFolder(CCmdUI* pCmdUI);
+       template<SIDE_TYPE stype>
        afx_msg void OnCtxtDirCopyTo();
        template<SIDE_TYPE stype>
        afx_msg void OnUpdateCtxtDirCopyTo(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateCtxtDirCopyBothTo(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateCtxtDirCopyBothDiffsOnlyTo(CCmdUI* pCmdUI);
+       template<SIDE_TYPE stype>
+       afx_msg void OnUpdateCtxtDirCopy2(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateCtxtDirCopyBoth2(CCmdUI* pCmdUI);
        afx_msg void OnDestroy();
        afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
        afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
@@ -286,11 +291,12 @@ protected:
        afx_msg void OnCtxtOpenWithUnpacker();
        afx_msg void OnUpdateCtxtOpenWithUnpacker(CCmdUI* pCmdUI);
        afx_msg void OnToolsGenerateReport();
-       afx_msg void OnCtxtDirZipLeft();
-       afx_msg void OnCtxtDirZipRight();
-       afx_msg void OnCtxtDirZipBoth();
-       afx_msg void OnCtxtDirZipBothDiffsOnly();
-       afx_msg void OnUpdateCtxtDir(CCmdUI* pCmdUI);
+       afx_msg LRESULT OnGenerateFileCmpReport(WPARAM wParam, LPARAM lParam);
+       afx_msg void OnToolsGeneratePatch();
+       template<int flag>
+       afx_msg void OnCtxtDirZip();
+       template<SIDE_TYPE stype>
+       afx_msg void OnCtxtDirShellContextMenu();
        afx_msg void OnSelectAll();
        afx_msg void OnUpdateSelectAll(CCmdUI* pCmdUI);
        afx_msg void OnPluginPredifferMode(UINT nID);
@@ -324,17 +330,47 @@ protected:
        afx_msg void OnUpdateViewExpandAllSubdirs(CCmdUI* pCmdUI);
        afx_msg void OnViewCollapseAllSubdirs();
        afx_msg void OnUpdateViewCollapseAllSubdirs(CCmdUI* pCmdUI);
+       template <int pane1, int pane2>
+       afx_msg void OnViewSwapPanes();
+       template <int pane1, int pane2>
+       afx_msg void OnUpdateViewSwapPanes(CCmdUI* pCmdUI);
+       afx_msg void OnOptionsShowDifferent();
+       afx_msg void OnOptionsShowIdentical();
+       afx_msg void OnOptionsShowUniqueLeft();
+       afx_msg void OnOptionsShowUniqueMiddle();
+       afx_msg void OnOptionsShowUniqueRight();
+       afx_msg void OnOptionsShowBinaries();
+       afx_msg void OnOptionsShowSkipped();
+       afx_msg void OnOptionsShowDifferentLeftOnly();
+       afx_msg void OnOptionsShowDifferentMiddleOnly();
+       afx_msg void OnOptionsShowDifferentRightOnly();
+       afx_msg void OnOptionsShowMissingLeftOnly();
+       afx_msg void OnOptionsShowMissingMiddleOnly();
+       afx_msg void OnOptionsShowMissingRightOnly();
+       afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowuniquemiddle(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowDifferentLeftOnly(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowDifferentMiddleOnly(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowDifferentRightOnly(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowMissingLeftOnly(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowMissingMiddleOnly(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateOptionsShowMissingRightOnly(CCmdUI* pCmdUI);
        afx_msg void OnMergeCompare();
        template<SELECTIONTYPE seltype>
        afx_msg void OnMergeCompare2();
+       afx_msg void OnMergeCompareNonHorizontally();
        afx_msg void OnMergeCompareXML();
-       afx_msg void OnMergeCompareHex();
+       afx_msg void OnMergeCompareAs(UINT nID);
        afx_msg void OnUpdateMergeCompare(CCmdUI *pCmdUI);
        template<SELECTIONTYPE seltype>
        afx_msg void OnUpdateMergeCompare2(CCmdUI *pCmdUI);
        afx_msg void OnViewCompareStatistics();
        afx_msg void OnFileEncoding();
-       afx_msg void OnUpdateFileEncoding(CCmdUI* pCmdUI);
        afx_msg void OnHelp();
        afx_msg void OnEditCopy();
        afx_msg void OnEditCut();
@@ -346,24 +382,25 @@ protected:
        afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
        afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
        afx_msg void OnSearch();
-       afx_msg void OnExpandFolder();
-       afx_msg void OnCollapseFolder();
        afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
        afx_msg void OnBnClickedComparisonStop();
+       afx_msg void OnBnClickedComparisonPause();
+       afx_msg void OnBnClickedComparisonContinue();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
-       BOOL OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult);
-       BOOL OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult);
+       bool OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult);
+       bool OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult);
 
 private:
-       void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = NULL);
-       void OpenSelectionHex();
+       void Open(const PathContext& paths, DWORD dwFlags[3], FileTextEncoding encoding[3], PackingInfo * infoUnpacker = nullptr);
+       void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = nullptr, bool openableForDir = true);
+       void OpenSelectionAs(UINT id);
        bool GetSelectedItems(int * sel1, int * sel2, int * sel3);
        void OpenParentDirectory();
        template<SIDE_TYPE srctype, SIDE_TYPE dsttype>
        void DoUpdateDirCopy(CCmdUI* pCmdUI, eMenuType menuType);
-       const DIFFITEM & GetDiffItem(int sel) const;
-       DIFFITEM & GetDiffItem(int sel);
+       const DIFFITEM &GetDiffItem(int sel) const;
+       DIFFITEM &GetDiffItem(int sel);
        int GetSingleSelectedItem() const;
        void MoveFocus(int currentInd, int i, int selCount);
 
@@ -371,12 +408,15 @@ private:
        void HeaderContextMenu(CPoint point, int i);
        void ListContextMenu(CPoint point, int i);
        bool ListShellContextMenu(SIDE_TYPE side);
+       void ShowShellContextMenu(SIDE_TYPE side);
        CShellContextMenu* GetCorrespondingShellContextMenu(HMENU hMenu) const;
        void ReloadColumns();
        bool IsLabelEdit() const;
        void CollapseSubdir(int sel);
        void ExpandSubdir(int sel, bool bRecursive = false);
        void GetColors(int nRow, int nCol, COLORREF& clrBk, COLORREF& clrText) const;
+       int GetDefColumnWidth() const { return MulDiv(DefColumnWidth, CClientDC(const_cast<CDirView *>(this)).GetDeviceCaps(LOGPIXELSX), 72); };
+
 public:
        DirItemIterator Begin() const { return DirItemIterator(m_pIList.get()); }
        DirItemIterator End() const { return DirItemIterator(); }
@@ -390,11 +430,5 @@ public:
 
 #ifndef _DEBUG  // debug version in DirView.cpp
 inline CDirDoc* CDirView::GetDocument()
-{ return (CDirDoc*)m_pDocument; }
+{ return reinterpret_cast<CDirDoc*>(m_pDocument); }
 #endif
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.