Add an option to the TortoiseGitMerge settings dialog to specify the number of contex...
[TortoiseGit.git] / src / TortoiseMerge / FilePatchesDlg.h
blobce415a138057fbf3e3cb40bc376037ad3a1377a3
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006, 2008, 2010-2011, 2013 - 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.
19 #pragma once
20 #include "StandAloneDlg.h"
22 class GitPatch;
24 /**
25 * \ingroup TortoiseMerge
26 * Virtual class providing the callback interface which
27 * is used by CFilePatchesDlg.
29 class CPatchFilesDlgCallBack
31 public:
32 /**
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
37 * \param bContentMods
38 * \param bPropMods
39 * \param sVersion the revision number of the file to patch
40 * \param bAutoPatch
41 * \return TRUE if patching was successful
43 virtual BOOL PatchFile(CString sFilePath, bool bContentMods, bool bPropMods, CString sVersion, BOOL bAutoPatch = FALSE) = 0;
45 /**
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)
63 #define ID_PATCHALL 1
64 #define ID_PATCHSELECTED 2
65 #define ID_PATCHPREVIEW 3
66 /**
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)
75 public:
76 CFilePatchesDlg(CWnd* pParent = NULL); // standard constructor
77 virtual ~CFilePatchesDlg();
79 /**
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
84 * \param pParent
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 };
92 protected:
93 GitPatch * m_pPatch;
94 CPatchFilesDlgCallBack * m_pCallBack;
95 CString m_sPath;
96 CListCtrl m_cFileList;
97 CDWordArray m_arFileStates;
98 CImageList m_ImgList;
99 BOOL m_bMinimized;
100 int m_nWindowHeight;
101 CWnd * m_pMainFrame;
102 int m_ShownIndex;
103 HFONT m_boldFont;
104 protected:
105 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
106 virtual void OnOK();
107 virtual BOOL OnInitDialog();
108 afx_msg void OnSize(UINT nType, int cx, int cy);
109 afx_msg void OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult);
110 afx_msg void OnLvnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
111 afx_msg void OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult);
112 afx_msg void OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult);
113 afx_msg void OnNMRclickFilelist(NMHDR *pNMHDR, LRESULT *pResult);
114 afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
115 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
116 afx_msg void OnBnClickedPatchselectedbutton();
117 afx_msg void OnBnClickedPatchallbutton();
119 DECLARE_MESSAGE_MAP()
121 CString GetFullPath(int nIndex);
122 void SetTitleWithPath(int width);
123 void PatchAll();
124 void PatchSelected();