1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006, 2008, 2010-2011, 2013, 2015 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "StandAloneDlg.h"
25 * \ingroup TortoiseMerge
26 * Virtual class providing the callback interface which
27 * is used by CFilePatchesDlg.
29 class CPatchFilesDlgCallBack
33 * Callback function. Called when the user double clicks on a
34 * specific file to patch. The framework then has to process
35 * the patching/viewing.
36 * \param sFilePath the full path to the file to patch
39 * \param sVersion the revision number of the file to patch
41 * \return TRUE if patching was successful
43 virtual BOOL
PatchFile(CString sFilePath
, bool bContentMods
, bool bPropMods
, CString sVersion
, BOOL bAutoPatch
= FALSE
) = 0;
46 * Callback function. Called when the user double clicks on a
47 * specific file to diff. The framework then has to fetch the two
48 * files from the URL's and revisions specified in the callback function and
49 * show them in the diff viewer.
50 * \param sURL1 the URL of the first file to diff
51 * \param sURL2 the URL of the second file to diff
52 * \param sRev1 the revision of the first file
53 * \param sRev2 the revision of the second file
55 virtual BOOL
DiffFiles(CString sURL1
, CString sRev1
, CString sURL2
, CString sRev2
) = 0;
58 #define FPDLG_FILESTATE_GOOD 0
59 #define FPDLG_FILESTATE_ERROR (-1)
60 #define FPDLG_FILESTATE_PATCHED (-2)
61 #define FPDLG_FILESTATE_CONFLICT (-3)
64 #define ID_PATCHSELECTED 2
65 #define ID_PATCHPREVIEW 3
67 * \ingroup TortoiseMerge
69 * Dialog class, showing all files to patch from a unified diff file.
71 class CFilePatchesDlg
: public CResizableStandAloneDialog
73 DECLARE_DYNAMIC(CFilePatchesDlg
)
76 CFilePatchesDlg(CWnd
* pParent
= nullptr); // standard constructor
77 virtual ~CFilePatchesDlg();
80 * Call this method to initialize the dialog.
81 * \param pPatch The CPatch object used to get the filenames from the unified diff file
82 * \param pCallBack The Object providing the callback interface (CPatchFilesDlgCallBack)
83 * \param sPath The path to the "parent" folder where the patch gets applied to
85 * \return TRUE if successful
87 BOOL
Init(GitPatch
* pPatch
, CPatchFilesDlgCallBack
* pCallBack
, CString sPath
, CWnd
* pParent
);
89 BOOL
SetFileStatusAsPatched(CString sPath
);
90 bool HasFiles() {return m_cFileList
.GetItemCount()>0;}
91 enum { IDD
= IDD_FILEPATCHES
};
94 CPatchFilesDlgCallBack
* m_pCallBack
;
96 CListCtrl m_cFileList
;
97 CDWordArray m_arFileStates
;
104 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
106 virtual BOOL
OnInitDialog();
107 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
108 afx_msg
void OnLvnGetInfoTipFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
109 afx_msg
void OnLvnItemchangedFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
110 afx_msg
void OnNMDblclkFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
111 afx_msg
void OnNMCustomdrawFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
112 afx_msg
void OnNMRclickFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
113 afx_msg
void OnNcLButtonDblClk(UINT nHitTest
, CPoint point
);
114 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
115 afx_msg
void OnBnClickedPatchselectedbutton();
116 afx_msg
void OnBnClickedPatchallbutton();
118 DECLARE_MESSAGE_MAP()
120 CString
GetFullPath(int nIndex
);
121 void SetTitleWithPath(int width
);
123 void PatchSelected();
124 void SetStateText(int i
, int state
);