1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997 Dean P. Grimm
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (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
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /////////////////////////////////////////////////////////////////////////////
23 * @brief interface of the CImgMergeFrame class
28 #include "EditorFilepathBar.h"
29 #include "PathContext.h"
30 #include "DiffFileInfo.h"
31 #include "IMergeDoc.h"
32 #include "WinIMergeLib.h"
33 #include "LocationBar.h"
34 #include "FileLocation.h"
35 #include "MergeFrameCommon.h"
40 * @brief Frame class for file compare, handles panes, statusbar etc.
42 class CImgMergeFrame : public CMergeFrameCommon,public IMergeDoc
47 BUFFER_NORMAL = 0, /**< Normal, file loaded from disk */
48 BUFFER_NORMAL_NAMED, /**< Normal, description given */
49 BUFFER_UNNAMED, /**< Empty, created buffer */
50 BUFFER_UNNAMED_SAVED, /**< Empty buffer saved with filename */
53 using CMDIChildWnd::Create;
55 DECLARE_DYNCREATE(CImgMergeFrame)
62 bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], CMDIFrameWnd *pParent);
63 void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
64 void ChangeFile(int pane, const String& path);
65 void SetDirDoc(CDirDoc * pDirDoc) override;
66 void UpdateResources();
67 bool CloseNow() override;
68 void DirDocClosing(CDirDoc * pDirDoc) override { m_pDirDoc = nullptr; }
69 void UpdateLastCompareResult();
70 void UpdateAutoPaneResize();
71 void UpdateSplitter();
72 bool GenerateReport(const String& sFileName) const override;
73 void DoAutoMerge(int dstPane);
74 bool IsModified() const;
75 bool IsFileChangedOnDisk(int pane) const;
76 void CheckFileChanged(void) override;
77 String GetDescription(int pane) const { return m_strDesc[pane]; }
78 static bool IsLoadable();
82 CEditorFilePathBar m_wndFilePathBar;
83 CStatusBar m_wndStatusBar[3];
86 // ClassWizard generated virtual function overrides
87 //{{AFX_VIRTUAL(CImgMergeFrame)
89 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
90 virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
91 virtual BOOL DestroyWindow();
92 virtual BOOL PreTranslateMessage(MSG *);
100 bool EnsureValidDockState(CDockState& state);
104 virtual ~CImgMergeFrame();
105 void CreateImgWndStatusBar(CStatusBar &, CWnd *);
106 // Generated message map functions
108 int UpdateDiffItem(CDirDoc * pDirDoc);
109 void UpdateHeaderSizes();
110 void UpdateHeaderPath(int pane);
111 void SetTitle(LPCTSTR lpszTitle);
112 bool DoFileSave(int pane);
113 bool DoFileSaveAs(int pane);
114 bool PromptAndSaveIfNeeded(bool bAllowCancel);
115 bool MergeModeKeyDown(MSG* pMsg);
116 static void OnChildPaneEvent(const IImgMergeWindow::Event& evt);
117 void OnDropFiles(int pane, const std::vector<String>& files);
118 CLocationBar m_wndLocationBar;
119 IImgMergeWindow *m_pImgMergeWindow;
120 IImgToolWindow *m_pImgToolWindow;
121 PathContext m_filePaths;
123 BUFFERTYPE m_nBufferType[3];
124 DiffFileInfo m_fileInfo[3];
129 //{{AFX_MSG(CImgMergeFrame)
130 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
131 afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
132 afx_msg void OnClose();
133 afx_msg void OnFileSave();
134 afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
135 afx_msg void OnFileSaveLeft();
136 afx_msg void OnFileSaveMiddle();
137 afx_msg void OnUpdateFileSaveMiddle(CCmdUI* pCmdUI);
138 afx_msg void OnFileSaveRight();
139 afx_msg void OnFileSaveAsLeft();
140 afx_msg void OnFileSaveAsMiddle();
141 afx_msg void OnUpdateFileSaveAsMiddle(CCmdUI* pCmdUI);
142 afx_msg void OnFileSaveAsRight();
143 afx_msg void OnLeftReadOnly();
144 afx_msg void OnUpdateLeftReadOnly(CCmdUI* pCmdUI);
145 afx_msg void OnMiddleReadOnly();
146 afx_msg void OnUpdateMiddleReadOnly(CCmdUI* pCmdUI);
147 afx_msg void OnRightReadOnly();
148 afx_msg void OnUpdateRightReadOnly(CCmdUI* pCmdUI);
149 afx_msg void OnFileReload();
150 afx_msg void OnFileClose();
151 afx_msg void OnFileRecompareAs(UINT nId);
152 afx_msg void OnUpdateFileRecompareAs(CCmdUI* pCmdUI);
153 afx_msg void OnWindowChangePane();
154 afx_msg void OnSize(UINT nType, int cx, int cy);
155 afx_msg void OnIdleUpdateCmdUI();
156 afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
157 afx_msg LRESULT OnStorePaneSizes(WPARAM wParam, LPARAM lParam);
158 afx_msg void OnEditUndo();
159 afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
160 afx_msg void OnEditRedo();
161 afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
162 afx_msg void OnViewZoomIn();
163 afx_msg void OnViewZoomOut();
164 afx_msg void OnViewZoomNormal();
165 afx_msg void OnViewSplitVertically();
166 afx_msg void OnUpdateViewSplitVertically(CCmdUI* pCmdUI);
167 afx_msg void OnFirstdiff();
168 afx_msg void OnUpdateFirstdiff(CCmdUI* pCmdUI);
169 afx_msg void OnLastdiff();
170 afx_msg void OnUpdateLastdiff(CCmdUI* pCmdUI);
171 afx_msg void OnNextdiff();
172 afx_msg void OnUpdateNextdiff(CCmdUI* pCmdUI);
173 afx_msg void OnPrevdiff();
174 afx_msg void OnUpdatePrevdiff(CCmdUI* pCmdUI);
175 afx_msg void OnNextConflict();
176 afx_msg void OnUpdateNextConflict(CCmdUI* pCmdUI);
177 afx_msg void OnPrevConflict();
178 afx_msg void OnUpdatePrevConflict(CCmdUI* pCmdUI);
179 afx_msg void OnX2Y(int srcPane, int dstPane);
180 afx_msg void OnUpdateX2Y(CCmdUI* pCmdUI, int srcPane, int dstPane);
181 afx_msg void OnL2r();
182 afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
183 afx_msg void OnR2l();
184 afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
185 afx_msg void OnCopyFromLeft();
186 afx_msg void OnUpdateCopyFromLeft(CCmdUI* pCmdUI);
187 afx_msg void OnCopyFromRight();
188 afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
189 afx_msg void OnAllLeft();
190 afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
191 afx_msg void OnAllRight();
192 afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
193 afx_msg void OnAutoMerge();
194 afx_msg void OnUpdateAutoMerge(CCmdUI* pCmdUI);
195 afx_msg void OnImgViewDifferences();
196 afx_msg void OnUpdateImgViewDifferences(CCmdUI* pCmdUI);
197 afx_msg void OnImgZoom(UINT nId);
198 afx_msg void OnUpdateImgZoom(CCmdUI* pCmdUI);
199 afx_msg void OnImgOverlayMode(UINT nId);
200 afx_msg void OnUpdateImgOverlayMode(CCmdUI* pCmdUI);
201 afx_msg void OnImgDraggingMode(UINT nId);
202 afx_msg void OnUpdateImgDraggingMode(CCmdUI* pCmdUI);
203 afx_msg void OnImgDiffBlockSize(UINT nId);
204 afx_msg void OnUpdateImgDiffBlockSize(CCmdUI* pCmdUI);
205 afx_msg void OnImgThreshold(UINT nId);
206 afx_msg void OnUpdateImgThreshold(CCmdUI* pCmdUI);
207 afx_msg void OnImgInsertionDeletionDetectionMode(UINT nId);
208 afx_msg void OnUpdateImgInsertionDeletionDetectionMode(CCmdUI* pCmdUI);
209 afx_msg void OnImgPrevPage();
210 afx_msg void OnUpdateImgPrevPage(CCmdUI* pCmdUI);
211 afx_msg void OnImgNextPage();
212 afx_msg void OnUpdateImgNextPage(CCmdUI* pCmdUI);
213 afx_msg void OnImgCurPanePrevPage();
214 afx_msg void OnUpdateImgCurPanePrevPage(CCmdUI* pCmdUI);
215 afx_msg void OnImgCurPaneNextPage();
216 afx_msg void OnUpdateImgCurPaneNextPage(CCmdUI* pCmdUI);
217 afx_msg void OnImgUseBackColor();
218 afx_msg void OnUpdateImgUseBackColor(CCmdUI* pCmdUI);
219 afx_msg void OnToolsGenerateReport();
220 afx_msg void OnRefresh();
222 DECLARE_MESSAGE_MAP()