Statistics graphs do not show up any more
[TortoiseGit.git] / src / TortoiseMerge / MainFrm.h
blobf63dd639990803da4c5f7e350ae63ebd86b75dfe
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2013 - TortoiseGit
4 // Copyright (C) 2006-2013 - 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
22 #include "DiffData.h"
23 #include "LocatorBar.h"
24 #include "LineDiffBar.h"
25 #include "FilePatchesDlg.h"
26 #include "TempFile.h"
27 #include "XSplitter.h"
28 #include "GitPatch.h"
29 #include "SimpleIni.h"
31 #include <tuple>
33 class CLeftView;
34 class CRightView;
35 class CBottomView;
36 #define MOVESTOIGNORE 3
38 #define TABMODE_NONE 0x00
39 #define TABMODE_USESPACES 0x01
40 #define TABMODE_SMARTINDENT 0x02
43 /**
44 * \ingroup TortoiseMerge
45 * The main frame of TortoiseMerge. Handles all the menu and toolbar commands.
47 class CMainFrame : public CFrameWndEx, public CPatchFilesDlgCallBack //CFrameWndEx
49 public:
50 CMainFrame();
51 virtual ~CMainFrame();
53 void ShowDiffBar(bool bShow);
54 #ifdef _DEBUG
55 virtual void AssertValid() const;
56 virtual void Dump(CDumpContext& dc) const;
57 #endif
58 protected:
59 DECLARE_DYNCREATE(CMainFrame)
61 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
62 virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
63 virtual void ActivateFrame(int nCmdShow = -1);
64 /// line = -1 means keep the current position,
65 /// line >= 0 means scroll to that line,
66 /// and line == -2 means do nothing or scroll to first diff depending on registry setting
67 bool LoadViews(int line = -2);
68 void ClearViewNamesAndPaths();
69 void SetWindowTitle();
71 afx_msg LRESULT OnTaskbarButtonCreated(WPARAM wParam, LPARAM lParam);
72 afx_msg void OnApplicationLook(UINT id);
73 afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI);
75 afx_msg void OnFileSave();
76 afx_msg void OnFileSaveAs();
77 afx_msg void OnFileOpen();
78 afx_msg void OnFileReload();
79 afx_msg void OnClose();
80 afx_msg void OnActivate(UINT, CWnd*, BOOL);
81 afx_msg void OnViewWhitespaces();
82 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
83 afx_msg void OnSize(UINT nType, int cx, int cy);
84 afx_msg void OnUpdateFileSave(CCmdUI *pCmdUI);
85 afx_msg void OnUpdateFileSaveAs(CCmdUI *pCmdUI);
86 afx_msg void OnViewOnewaydiff();
87 afx_msg void OnUpdateViewOnewaydiff(CCmdUI *pCmdUI);
88 afx_msg void OnUpdateViewWhitespaces(CCmdUI *pCmdUI);
89 afx_msg void OnViewOptions();
90 afx_msg void OnViewLinedown();
91 afx_msg void OnViewLineup();
92 afx_msg void OnViewLineleft();
93 afx_msg void OnViewLineright();
94 afx_msg void OnEditUseTheirs();
95 afx_msg void OnEditUseMine();
96 afx_msg void OnEditUseTheirsThenMine();
97 afx_msg void OnEditUseMineThenTheirs();
98 afx_msg void OnUpdateEditUseminethentheirblock(CCmdUI *pCmdUI);
99 afx_msg void OnUpdateEditUsemyblock(CCmdUI *pCmdUI);
100 afx_msg void OnUpdateEditUsetheirblock(CCmdUI *pCmdUI);
101 afx_msg void OnUpdateEditUsetheirthenmyblock(CCmdUI *pCmdUI);
102 afx_msg void OnUpdateMergeMarkasresolved(CCmdUI *pCmdUI);
103 afx_msg void OnMergeMarkasresolved();
104 afx_msg void OnUpdateMergeNextconflict(CCmdUI *pCmdUI);
105 afx_msg void OnUpdateMergePreviousconflict(CCmdUI *pCmdUI);
106 afx_msg void OnUpdateEditCopy(CCmdUI *pCmdUI);
107 afx_msg void OnUpdateEditPaste(CCmdUI *pCmdUI);
108 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
109 afx_msg void OnViewSwitchleft();
110 afx_msg void OnUpdateViewSwitchleft(CCmdUI *pCmdUI);
111 afx_msg void OnUpdateViewShowfilelist(CCmdUI *pCmdUI);
112 afx_msg void OnViewShowfilelist();
113 afx_msg void OnEditUndo();
114 afx_msg void OnUpdateEditUndo(CCmdUI *pCmdUI);
115 afx_msg void OnEditEnable();
116 afx_msg void OnUpdateEditEnable(CCmdUI *pCmdUI);
117 afx_msg void OnViewInlinediffword();
118 afx_msg void OnUpdateViewInlinediffword(CCmdUI *pCmdUI);
119 afx_msg void OnViewInlinediff();
120 afx_msg void OnUpdateViewInlinediff(CCmdUI *pCmdUI);
121 afx_msg void OnUpdateEditCreateunifieddifffile(CCmdUI *pCmdUI);
122 afx_msg void OnEditCreateunifieddifffile();
123 afx_msg void OnUpdateEditTabspace(CCmdUI *pCmdUI);
124 afx_msg void OnEditTabspace();
125 afx_msg void OnUpdateEditSmartTab(CCmdUI *pCmdUI);
126 afx_msg void OnEditSmartTab();
127 afx_msg void OnUpdateViewLinediffbar(CCmdUI *pCmdUI);
128 afx_msg void OnViewLinediffbar();
129 afx_msg void OnUpdateViewLocatorbar(CCmdUI *pCmdUI);
130 afx_msg void OnViewLocatorbar();
131 afx_msg void OnEditUseleftblock();
132 afx_msg void OnUpdateUseBlock(CCmdUI *pCmdUI);
133 afx_msg void OnUpdateEditUseleftblock(CCmdUI *pCmdUI);
134 afx_msg void OnEditUseleftfile();
135 afx_msg void OnUpdateEditUseleftfile(CCmdUI *pCmdUI);
136 afx_msg void OnEditUseblockfromleftbeforeright();
137 afx_msg void OnUpdateEditUseblockfromleftbeforeright(CCmdUI *pCmdUI);
138 afx_msg void OnEditUseblockfromrightbeforeleft();
139 afx_msg void OnUpdateEditUseblockfromrightbeforeleft(CCmdUI *pCmdUI);
140 afx_msg void OnUpdateNavigateNextdifference(CCmdUI *pCmdUI);
141 afx_msg void OnUpdateNavigatePreviousdifference(CCmdUI *pCmdUI);
142 afx_msg void OnViewCollapsed();
143 afx_msg void OnUpdateViewCollapsed(CCmdUI *pCmdUI);
144 afx_msg void OnViewComparewhitespaces();
145 afx_msg void OnUpdateViewComparewhitespaces(CCmdUI *pCmdUI);
146 afx_msg void OnViewIgnorewhitespacechanges();
147 afx_msg void OnUpdateViewIgnorewhitespacechanges(CCmdUI *pCmdUI);
148 afx_msg void OnViewIgnoreallwhitespacechanges();
149 afx_msg void OnUpdateViewIgnoreallwhitespacechanges(CCmdUI *pCmdUI);
150 afx_msg void OnUpdateNavigateNextinlinediff(CCmdUI *pCmdUI);
151 afx_msg void OnUpdateNavigatePrevinlinediff(CCmdUI *pCmdUI);
152 afx_msg void OnViewMovedBlocks();
153 afx_msg void OnUpdateViewMovedBlocks(CCmdUI *pCmdUI);
154 afx_msg void OnViewWraplonglines();
155 afx_msg void OnUpdateViewWraplonglines(CCmdUI *pCmdUI);
156 afx_msg void OnIndicatorLeftview();
157 afx_msg void OnIndicatorRightview();
158 afx_msg void OnIndicatorBottomview();
159 afx_msg void OnTimer(UINT_PTR nIDEvent);
160 afx_msg void OnViewIgnorecomments();
161 afx_msg void OnUpdateViewIgnorecomments(CCmdUI *pCmdUI);
162 afx_msg void OnUpdateViewRegexFilter(CCmdUI *pCmdUI);
163 afx_msg void OnRegexfilter(UINT cmd);
164 afx_msg void OnDummyEnabled() {};
165 afx_msg void OnEncodingLeft(UINT cmd);
166 afx_msg void OnEncodingRight(UINT cmd);
167 afx_msg void OnEncodingBottom(UINT cmd);
168 afx_msg void OnEOLLeft(UINT cmd);
169 afx_msg void OnEOLRight(UINT cmd);
170 afx_msg void OnEOLBottom(UINT cmd);
171 afx_msg void OnUpdateEncodingLeft(CCmdUI *pCmdUI);
172 afx_msg void OnUpdateEncodingRight(CCmdUI *pCmdUI);
173 afx_msg void OnUpdateEncodingBottom(CCmdUI *pCmdUI);
174 afx_msg void OnUpdateEOLLeft(CCmdUI *pCmdUI);
175 afx_msg void OnUpdateEOLRight(CCmdUI *pCmdUI);
176 afx_msg void OnUpdateEOLBottom(CCmdUI *pCmdUI);
178 DECLARE_MESSAGE_MAP()
179 protected:
180 void UpdateLayout();
181 virtual BOOL PatchFile(CString sFilePath, bool bContentMods, bool bPropMods, CString sVersion, BOOL bAutoPatch) override;
182 virtual BOOL DiffFiles(CString sURL1, CString sRev1, CString sURL2, CString sRev2) override;
183 int CheckResolved();
184 BOOL MarkAsResolved();
185 int SaveFile(const CString& sFilePath);
186 void WriteWindowPlacement(WINDOWPLACEMENT * pwp);
187 BOOL ReadWindowPlacement(WINDOWPLACEMENT * pwp);
188 bool FileSave(bool bCheckResolved=true);
189 void PatchSave();
190 bool FileSaveAs(bool bCheckResolved=true);
191 void LoadIgnoreCommentData();
192 /// checks if there are modifications and asks the user to save them first
193 /// IDCANCEL is returned if the user wants to cancel.
194 /// If the user wanted to save the modifications, this method does the saving
195 /// itself.
196 int CheckForReload();
197 enum ECheckForSaveReason {
198 CHFSR_CLOSE, ///< closing apps
199 CHFSR_SWITCH, ///< switching views
200 CHFSR_RELOAD, ///< reload views also switching between 1 and 2 way diff
201 CHFSR_OPTIONS, ///< white space change, options
202 CHFSR_OPEN, ///< open open dialog
204 /// checks if there are modifications and asks the user to save them first
205 /// IDCANCEL is returned if the user wants to cancel.
206 /// If the user wanted to save the modifications, this method does the saving
207 /// itself.
208 int CheckForSave(ECheckForSaveReason eReason/* = CHFSR_SWITCH*/);
209 void OnViewLineUpDown(int direction);
210 void OnViewLineLeftRight(int direction);
211 bool HasConflictsWontKeep();
212 bool TryGetFileName(CString& result);
213 CBaseView* GetActiveBaseView() const;
214 void OnViewTextFoldUnfold();
215 void OnViewTextFoldUnfold(CBaseView* view);
216 bool HasUnsavedEdits() const;
217 static bool HasUnsavedEdits(const CBaseView* view);
218 static bool IsViewGood(const CBaseView* view);
219 static bool HasPrevConflict(CBaseView* view);
220 static bool HasNextConflict(CBaseView* view);
221 static bool HasPrevInlineDiff(CBaseView* view);
222 static bool HasNextInlineDiff(CBaseView* view);
223 void BuildRegexSubitems();
225 protected:
226 CMFCStatusBar m_wndStatusBar;
227 CMFCRibbonStatusBar m_wndRibbonStatusBar;
228 CLocatorBar m_wndLocatorBar;
229 CLineDiffBar m_wndLineDiffBar;
230 CXSplitter m_wndSplitter;
231 CXSplitter m_wndSplitter2;
232 CFilePatchesDlg m_dlgFilePatches;
234 GitPatch m_Patch;
235 BOOL m_bInitSplitter;
236 bool m_bCheckReload;
238 bool m_bHasConflicts;
240 bool m_bInlineWordDiff;
241 bool m_bInlineDiff;
242 bool m_bLineDiff;
243 bool m_bLocatorBar;
244 bool m_bUseRibbons;
245 bool m_bUseTaskDialog;
247 CMFCRibbonBar m_wndRibbonBar;
248 CMFCRibbonApplicationButton m_MainButton;
250 CRegDWORD m_regWrapLines;
251 CRegDWORD m_regViewModedBlocks;
252 CRegDWORD m_regOneWay;
253 CRegDWORD m_regCollapsed;
254 CRegDWORD m_regInlineDiff;
255 CRegDWORD m_regUseRibbons;
256 CRegDWORD m_regUseTaskDialog;
257 CRegDWORD m_regIgnoreComments;
259 std::map<CString, std::tuple<CString, CString, CString>> m_IgnoreCommentsMap;
260 CSimpleIni m_regexIni;
261 int m_regexIndex;
262 CRegDWORD m_regTabMode;
263 public:
264 CLeftView * m_pwndLeftView;
265 CRightView * m_pwndRightView;
266 CBottomView * m_pwndBottomView;
267 BOOL m_bOneWay;
268 BOOL m_bReversedPatch;
269 CDiffData m_Data;
270 bool m_bReadOnly;
271 bool m_bBlame;
272 int m_nMoveMovesToIgnore;
273 bool m_bCollapsed;
274 bool m_bViewMovedBlocks;
275 bool m_bWrapLines;
276 bool m_bSaveRequired;
277 bool m_bSaveRequiredOnConflicts;
278 HWND resolveMsgWnd;
279 WPARAM resolveMsgWParam;
280 LPARAM resolveMsgLParam;
282 const CMFCToolBar * GetToolbar() const { return &m_wndToolBar; }
283 void FillEncodingButton( CMFCRibbonButton * pButton, int start );
284 void FillEOLButton( CMFCRibbonButton * pButton, int start );
285 CMFCMenuBar m_wndMenuBar;
286 CMFCToolBar m_wndToolBar;