1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006-2012 - 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.
22 #include "LocatorBar.h"
23 #include "LineDiffBar.h"
24 #include "FilePatchesDlg.h"
26 #include "XSplitter.h"
32 #define MOVESTOIGNORE 3
35 * \ingroup TortoiseMerge
36 * The main frame of TortoiseMerge. Handles all the menu and toolbar commands.
38 class CMainFrame
: public CFrameWndEx
, public CPatchFilesDlgCallBack
//CFrameWndEx
43 virtual ~CMainFrame();
45 void ShowDiffBar(bool bShow
);
47 virtual void AssertValid() const;
48 virtual void Dump(CDumpContext
& dc
) const;
51 DECLARE_DYNCREATE(CMainFrame
)
53 virtual BOOL
PreCreateWindow(CREATESTRUCT
& cs
);
54 virtual BOOL
OnCreateClient(LPCREATESTRUCT lpcs
, CCreateContext
* pContext
);
55 virtual void ActivateFrame(int nCmdShow
= -1);
56 /// line = -1 means keep the current position,
57 /// line >= 0 means scroll to that line,
58 /// and line == -2 means do nothing or scroll to first diff depending on registry setting
59 bool LoadViews(int line
= -2);
60 void ClearViewNamesAndPaths();
61 void SetWindowTitle();
63 afx_msg LRESULT
OnTaskbarButtonCreated(WPARAM wParam
, LPARAM lParam
);
64 afx_msg
void OnApplicationLook(UINT id
);
65 afx_msg
void OnUpdateApplicationLook(CCmdUI
* pCmdUI
);
67 afx_msg
void OnFileSave();
68 afx_msg
void OnFileSaveAs();
69 afx_msg
void OnFileOpen();
70 afx_msg
void OnFileReload();
71 afx_msg
void OnClose();
72 afx_msg
void OnActivate(UINT
, CWnd
*, BOOL
);
73 afx_msg
void OnViewWhitespaces();
74 afx_msg
int OnCreate(LPCREATESTRUCT lpCreateStruct
);
75 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
76 afx_msg
void OnUpdateFileSave(CCmdUI
*pCmdUI
);
77 afx_msg
void OnUpdateFileSaveAs(CCmdUI
*pCmdUI
);
78 afx_msg
void OnViewOnewaydiff();
79 afx_msg
void OnUpdateViewOnewaydiff(CCmdUI
*pCmdUI
);
80 afx_msg
void OnUpdateViewWhitespaces(CCmdUI
*pCmdUI
);
81 afx_msg
void OnViewOptions();
82 afx_msg
void OnViewLinedown();
83 afx_msg
void OnViewLineup();
84 afx_msg
void OnViewLineleft();
85 afx_msg
void OnViewLineright();
86 afx_msg
void OnEditUseTheirs();
87 afx_msg
void OnEditUseMine();
88 afx_msg
void OnEditUseTheirsThenMine();
89 afx_msg
void OnEditUseMineThenTheirs();
90 afx_msg
void OnUpdateEditUseminethentheirblock(CCmdUI
*pCmdUI
);
91 afx_msg
void OnUpdateEditUsemyblock(CCmdUI
*pCmdUI
);
92 afx_msg
void OnUpdateEditUsetheirblock(CCmdUI
*pCmdUI
);
93 afx_msg
void OnUpdateEditUsetheirthenmyblock(CCmdUI
*pCmdUI
);
94 afx_msg
void OnUpdateMergeMarkasresolved(CCmdUI
*pCmdUI
);
95 afx_msg
void OnMergeMarkasresolved();
96 afx_msg
void OnUpdateMergeNextconflict(CCmdUI
*pCmdUI
);
97 afx_msg
void OnUpdateMergePreviousconflict(CCmdUI
*pCmdUI
);
98 afx_msg
void OnUpdateEditCopy(CCmdUI
*pCmdUI
);
99 afx_msg
void OnUpdateEditPaste(CCmdUI
*pCmdUI
);
100 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
101 afx_msg
void OnViewSwitchleft();
102 afx_msg
void OnUpdateViewSwitchleft(CCmdUI
*pCmdUI
);
103 afx_msg
void OnUpdateViewShowfilelist(CCmdUI
*pCmdUI
);
104 afx_msg
void OnViewShowfilelist();
105 afx_msg
void OnEditUndo();
106 afx_msg
void OnUpdateEditUndo(CCmdUI
*pCmdUI
);
107 afx_msg
void OnViewInlinediffword();
108 afx_msg
void OnUpdateViewInlinediffword(CCmdUI
*pCmdUI
);
109 afx_msg
void OnViewInlinediff();
110 afx_msg
void OnUpdateViewInlinediff(CCmdUI
*pCmdUI
);
111 afx_msg
void OnUpdateEditCreateunifieddifffile(CCmdUI
*pCmdUI
);
112 afx_msg
void OnEditCreateunifieddifffile();
113 afx_msg
void OnUpdateViewLinediffbar(CCmdUI
*pCmdUI
);
114 afx_msg
void OnViewLinediffbar();
115 afx_msg
void OnUpdateViewLocatorbar(CCmdUI
*pCmdUI
);
116 afx_msg
void OnViewLocatorbar();
117 afx_msg
void OnEditUseleftblock();
118 afx_msg
void OnUpdateUseBlock(CCmdUI
*pCmdUI
);
119 afx_msg
void OnUpdateEditUseleftblock(CCmdUI
*pCmdUI
);
120 afx_msg
void OnEditUseleftfile();
121 afx_msg
void OnUpdateEditUseleftfile(CCmdUI
*pCmdUI
);
122 afx_msg
void OnEditUseblockfromleftbeforeright();
123 afx_msg
void OnUpdateEditUseblockfromleftbeforeright(CCmdUI
*pCmdUI
);
124 afx_msg
void OnEditUseblockfromrightbeforeleft();
125 afx_msg
void OnUpdateEditUseblockfromrightbeforeleft(CCmdUI
*pCmdUI
);
126 afx_msg
void OnUpdateNavigateNextdifference(CCmdUI
*pCmdUI
);
127 afx_msg
void OnUpdateNavigatePreviousdifference(CCmdUI
*pCmdUI
);
128 afx_msg
void OnViewCollapsed();
129 afx_msg
void OnUpdateViewCollapsed(CCmdUI
*pCmdUI
);
130 afx_msg
void OnViewComparewhitespaces();
131 afx_msg
void OnUpdateViewComparewhitespaces(CCmdUI
*pCmdUI
);
132 afx_msg
void OnViewIgnorewhitespacechanges();
133 afx_msg
void OnUpdateViewIgnorewhitespacechanges(CCmdUI
*pCmdUI
);
134 afx_msg
void OnViewIgnoreallwhitespacechanges();
135 afx_msg
void OnUpdateViewIgnoreallwhitespacechanges(CCmdUI
*pCmdUI
);
136 afx_msg
void OnUpdateNavigateNextinlinediff(CCmdUI
*pCmdUI
);
137 afx_msg
void OnUpdateNavigatePrevinlinediff(CCmdUI
*pCmdUI
);
138 afx_msg
void OnViewMovedBlocks();
139 afx_msg
void OnUpdateViewMovedBlocks(CCmdUI
*pCmdUI
);
140 afx_msg
void OnViewWraplonglines();
141 afx_msg
void OnUpdateViewWraplonglines(CCmdUI
*pCmdUI
);
143 DECLARE_MESSAGE_MAP()
146 virtual BOOL
PatchFile(CString sFilePath
, bool bContentMods
, bool bPropMods
, CString sVersion
, BOOL bAutoPatch
) override
;
147 virtual BOOL
DiffFiles(CString sURL1
, CString sRev1
, CString sURL2
, CString sRev2
) override
;
149 BOOL
MarkAsResolved();
150 int SaveFile(const CString
& sFilePath
);
151 void WriteWindowPlacement(WINDOWPLACEMENT
* pwp
);
152 BOOL
ReadWindowPlacement(WINDOWPLACEMENT
* pwp
);
153 bool FileSave(bool bCheckResolved
=true);
155 bool FileSaveAs(bool bCheckResolved
=true);
156 /// checks if there are modifications and asks the user to save them first
157 /// IDCANCEL is returned if the user wants to cancel.
158 /// If the user wanted to save the modifications, this method does the saving
160 int CheckForReload();
162 void OnViewLineUpDown(int direction
);
163 void OnViewLineLeftRight(int direction
);
164 bool HasConflictsWontKeep();
165 bool TryGetFileName(CString
& result
);
166 CBaseView
* GetActiveBaseView() const;
167 void OnViewTextFoldUnfold();
168 void OnViewTextFoldUnfold(CBaseView
* view
);
169 bool HasUnsavedEdits() const;
170 static bool HasUnsavedEdits(const CBaseView
* view
);
171 static bool IsViewGood(const CBaseView
* view
);
172 static bool HasPrevConflict(CBaseView
* view
);
173 static bool HasNextConflict(CBaseView
* view
);
174 static bool HasPrevInlineDiff(CBaseView
* view
);
175 static bool HasNextInlineDiff(CBaseView
* view
);
178 CMFCStatusBar m_wndStatusBar
;
179 CLocatorBar m_wndLocatorBar
;
180 CLineDiffBar m_wndLineDiffBar
;
181 CXSplitter m_wndSplitter
;
182 CXSplitter m_wndSplitter2
;
183 CFilePatchesDlg m_dlgFilePatches
;
186 BOOL m_bInitSplitter
;
189 bool m_bHasConflicts
;
191 bool m_bInlineWordDiff
;
196 CMFCRibbonBar m_wndRibbonBar
;
197 CMFCRibbonApplicationButton m_MainButton
;
199 CRegDWORD m_regWrapLines
;
200 CRegDWORD m_regViewModedBlocks
;
201 CRegDWORD m_regOneWay
;
202 CRegDWORD m_regCollapsed
;
203 CRegDWORD m_regInlineDiff
;
205 CLeftView
* m_pwndLeftView
;
206 CRightView
* m_pwndRightView
;
207 CBottomView
* m_pwndBottomView
;
209 BOOL m_bReversedPatch
;
213 int m_nMoveMovesToIgnore
;
215 bool m_bViewMovedBlocks
;
217 bool m_bSaveRequired
;
219 WPARAM resolveMsgWParam
;
220 LPARAM resolveMsgLParam
;