RebaseDlg: Correctly remember commits for rewriting on Squash after (Edit|Squash...
[TortoiseGit.git] / src / TortoiseMerge / FilePatchesDlg.h
blobc13c3923c7613c0b35f1ea5797d965d7b580e2dd
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2022-2023 - TortoiseGit
4 // Copyright (C) 2006, 2008, 2010-2011, 2013, 2015 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "StandAloneDlg.h"
23 class GitPatch;
25 /**
26 * \ingroup TortoiseMerge
27 * Virtual class providing the callback interface which
28 * is used by CFilePatchesDlg.
30 class CPatchFilesDlgCallBack
32 public:
33 /**
34 * Callback function. Called when the user double clicks on a
35 * specific file to patch. The framework then has to process
36 * the patching/viewing.
37 * \param sFilePath the full path to the file to patch
38 * \param bContentMods
39 * \param bPropMods
40 * \param sVersion the revision number of the file to patch
41 * \param bAutoPatch
42 * \return TRUE if patching was successful
44 virtual BOOL PatchFile(CString sFilePath, bool bContentMods, bool bPropMods, CString sVersion, BOOL bAutoPatch = FALSE) = 0;
46 /**
47 * Callback function. Called when the user double clicks on a
48 * specific file to diff. The framework then has to fetch the two
49 * files from the URL's and revisions specified in the callback function and
50 * show them in the diff viewer.
51 * \param sURL1 the URL of the first file to diff
52 * \param sURL2 the URL of the second file to diff
53 * \param sRev1 the revision of the first file
54 * \param sRev2 the revision of the second file
56 virtual BOOL DiffFiles(CString sURL1, CString sRev1, CString sURL2, CString sRev2) = 0;
59 #define FPDLG_FILESTATE_GOOD 0
60 #define FPDLG_FILESTATE_ERROR (-1)
61 #define FPDLG_FILESTATE_PATCHED (-2)
62 #define FPDLG_FILESTATE_CONFLICT (-3)
64 #define ID_PATCHALL 1
65 #define ID_PATCHSELECTED 2
66 #define ID_PATCHPREVIEW 3
67 /**
68 * \ingroup TortoiseMerge
70 * Dialog class, showing all files to patch from a unified diff file.
72 class CFilePatchesDlg : public CResizableStandAloneDialog
74 DECLARE_DYNAMIC(CFilePatchesDlg)
76 public:
77 CFilePatchesDlg(CWnd* pParent = nullptr); // standard constructor
78 virtual ~CFilePatchesDlg();
80 void ParentOnMoving(HWND parentHWND, LPRECT pRect);
82 /**
83 * Call this method to initialize the dialog.
84 * \param pPatch The CPatch object used to get the filenames from the unified diff file
85 * \param pCallBack The Object providing the callback interface (CPatchFilesDlgCallBack)
86 * \param sPath The path to the "parent" folder where the patch gets applied to
87 * \param pParent
88 * \return TRUE if successful
90 BOOL Init(GitPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, CString sPath, CWnd * pParent);
92 BOOL SetFileStatusAsPatched(CString sPath);
93 bool HasFiles() const { return m_cFileList.GetItemCount() > 0; }
94 enum { IDD = IDD_FILEPATCHES };
95 protected:
96 GitPatch* m_pPatch = nullptr;
97 CPatchFilesDlgCallBack* m_pCallBack = nullptr;
98 CString m_sPath;
99 CListCtrl m_cFileList;
100 CDWordArray m_arFileStates;
101 BOOL m_bMinimized = FALSE;
102 int m_nWindowHeight = -1;
103 CWnd* m_pMainFrame = nullptr;
104 int m_ShownIndex = -1;
105 CFont m_boldFont;
106 protected:
107 void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
108 void OnOK() override;
109 BOOL OnInitDialog() override;
110 afx_msg void OnSize(UINT nType, int cx, int cy);
111 afx_msg void OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult);
112 afx_msg void OnLvnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
113 afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult);
114 afx_msg void OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult);
115 afx_msg void OnNMRclickFilelist(NMHDR *pNMHDR, LRESULT *pResult);
116 afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
117 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
118 afx_msg void OnBnClickedPatchselectedbutton();
119 afx_msg void OnBnClickedPatchallbutton();
121 DECLARE_MESSAGE_MAP()
123 CString GetFullPath(int nIndex);
124 void SetTitleWithPath(int width);
125 void PatchAll();
126 void PatchSelected();
127 void SetStateText(int i, int state);