1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997 Dean P. Grimm
4 // SPDX-License-Identifier: GPL-2.0-or-later
5 /////////////////////////////////////////////////////////////////////////////
9 * @brief interface of the CImgMergeFrame class
14 #include "EditorFilepathBar.h"
15 #include "PathContext.h"
16 #include "DiffFileInfo.h"
17 #include "IMergeDoc.h"
18 #include "WinIMergeLib.h"
19 #include "LocationBar.h"
20 #include "FileLocation.h"
21 #include "MergeFrameCommon.h"
22 #include "FileTransform.h"
27 * @brief Frame class for file compare, handles panes, statusbar etc.
29 class CImgMergeFrame : public CMergeFrameCommon,public IMergeDoc
34 NORMAL = 0, /**< Normal, file loaded from disk */
35 NORMAL_NAMED, /**< Normal, description given */
36 UNNAMED, /**< Empty, created buffer */
37 UNNAMED_SAVED, /**< Empty buffer saved with filename */
40 using CMDIChildWnd::Create;
42 DECLARE_DYNCREATE(CImgMergeFrame)
49 bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], CMDIFrameWnd *pParent);
50 void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
51 void ChangeFile(int pane, const String& path);
52 CDirDoc* GetDirDoc() const override { return m_pDirDoc; };
53 void SetDirDoc(CDirDoc * pDirDoc) override;
54 void UpdateResources();
55 bool CloseNow() override;
56 void DirDocClosing(CDirDoc * pDirDoc) override { m_pDirDoc = nullptr; }
57 void UpdateLastCompareResult();
58 void UpdateAutoPaneResize();
59 void UpdateSplitter();
60 bool GenerateReport(const String& sFileName) const override;
61 const PackingInfo* GetUnpacker() const override { return &m_infoUnpacker; };
62 void SetUnpacker(const PackingInfo* infoUnpacker) override { if (infoUnpacker) m_infoUnpacker = *infoUnpacker; };
63 const PrediffingInfo* GetPrediffer() const override { return nullptr; };
64 int GetFileCount() const override { return m_filePaths.GetSize(); }
65 String GetPath(int pane) const override { return m_filePaths[pane]; }
66 bool GetReadOnly(int pane) const override { return m_bRO[pane]; }
67 void DoAutoMerge(int dstPane);
68 bool IsModified() const;
69 IMergeDoc::FileChange IsFileChangedOnDisk(int pane) const;
70 void CheckFileChanged(void) override;
71 String GetDescription(int pane) const { return m_strDesc[pane]; }
72 static bool IsLoadable();
76 CEditorFilePathBar m_wndFilePathBar;
77 CStatusBar m_wndStatusBar[3];
80 // ClassWizard generated virtual function overrides
81 //{{AFX_VIRTUAL(CImgMergeFrame)
83 virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
84 virtual BOOL DestroyWindow();
85 virtual BOOL PreTranslateMessage(MSG *);
93 bool EnsureValidDockState(CDockState& state);
97 void SaveActivePane();
98 virtual ~CImgMergeFrame();
99 void CreateImgWndStatusBar(CStatusBar &, CWnd *);
100 // Generated message map functions
103 int UpdateDiffItem(CDirDoc * pDirDoc);
104 void UpdateHeaderSizes();
105 void UpdateHeaderPath(int pane);
106 void SetTitle(LPCTSTR lpszTitle);
107 bool DoFileSave(int pane);
108 bool DoFileSaveAs(int pane, bool packing = true);
109 bool PromptAndSaveIfNeeded(bool bAllowCancel);
110 bool MergeModeKeyDown(MSG* pMsg);
111 static void OnChildPaneEvent(const IImgMergeWindow::Event& evt);
112 void OnDropFiles(int pane, const std::vector<String>& files);
113 static void TranslateLocationPane(int id, const wchar_t *org, size_t dstbufsize, wchar_t *dst);
114 CLocationBar m_wndLocationBar;
115 IImgMergeWindow *m_pImgMergeWindow;
116 IImgToolWindow *m_pImgToolWindow;
117 PathContext m_filePaths;
119 BUFFERTYPE m_nBufferType[3];
120 DiffFileInfo m_fileInfo[3];
125 PackingInfo m_infoUnpacker;
126 std::vector<int> m_unpackerSubcodes[3];
128 //{{AFX_MSG(CImgMergeFrame)
129 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
130 afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
131 afx_msg void OnClose();
132 afx_msg void OnDestroy();
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 OnOpenWithUnpacker();
154 afx_msg void OnWindowChangePane();
155 afx_msg void OnSize(UINT nType, int cx, int cy);
156 afx_msg void OnIdleUpdateCmdUI();
157 afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
158 afx_msg LRESULT OnStorePaneSizes(WPARAM wParam, LPARAM lParam);
159 afx_msg void OnEditUndo();
160 afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
161 afx_msg void OnEditRedo();
162 afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
163 afx_msg void OnEditCut();
164 afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
165 afx_msg void OnEditCopy();
166 afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
167 afx_msg void OnEditPaste();
168 afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
169 afx_msg void OnEditSelectAll();
170 afx_msg void OnViewZoomIn();
171 afx_msg void OnViewZoomOut();
172 afx_msg void OnViewZoomNormal();
173 afx_msg void OnViewSplitVertically();
174 afx_msg void OnUpdateViewSplitVertically(CCmdUI* pCmdUI);
175 afx_msg void OnFirstdiff();
176 afx_msg void OnUpdateFirstdiff(CCmdUI* pCmdUI);
177 afx_msg void OnLastdiff();
178 afx_msg void OnUpdateLastdiff(CCmdUI* pCmdUI);
179 afx_msg void OnNextdiff();
180 afx_msg void OnUpdateNextdiff(CCmdUI* pCmdUI);
181 afx_msg void OnPrevdiff();
182 afx_msg void OnUpdatePrevdiff(CCmdUI* pCmdUI);
183 afx_msg void OnNextConflict();
184 afx_msg void OnUpdateNextConflict(CCmdUI* pCmdUI);
185 afx_msg void OnPrevConflict();
186 afx_msg void OnUpdatePrevConflict(CCmdUI* pCmdUI);
187 afx_msg void OnX2Y(int srcPane, int dstPane);
188 afx_msg void OnUpdateX2Y(CCmdUI* pCmdUI, int srcPane, int dstPane);
189 afx_msg void OnL2r();
190 afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
191 afx_msg void OnR2l();
192 afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
193 afx_msg void OnCopyFromLeft();
194 afx_msg void OnUpdateCopyFromLeft(CCmdUI* pCmdUI);
195 afx_msg void OnCopyFromRight();
196 afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
197 afx_msg void OnAllLeft();
198 afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
199 afx_msg void OnAllRight();
200 afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
201 afx_msg void OnAutoMerge();
202 afx_msg void OnUpdateAutoMerge(CCmdUI* pCmdUI);
203 afx_msg void OnImgViewDifferences();
204 afx_msg void OnUpdateImgViewDifferences(CCmdUI* pCmdUI);
205 afx_msg void OnImgZoom(UINT nId);
206 afx_msg void OnUpdateImgZoom(CCmdUI* pCmdUI);
207 afx_msg void OnImgOverlayMode(UINT nId);
208 afx_msg void OnUpdateImgOverlayMode(CCmdUI* pCmdUI);
209 afx_msg void OnImgDraggingMode(UINT nId);
210 afx_msg void OnUpdateImgDraggingMode(CCmdUI* pCmdUI);
211 afx_msg void OnImgDiffBlockSize(UINT nId);
212 afx_msg void OnUpdateImgDiffBlockSize(CCmdUI* pCmdUI);
213 afx_msg void OnImgThreshold(UINT nId);
214 afx_msg void OnUpdateImgThreshold(CCmdUI* pCmdUI);
215 afx_msg void OnImgInsertionDeletionDetectionMode(UINT nId);
216 afx_msg void OnUpdateImgInsertionDeletionDetectionMode(CCmdUI* pCmdUI);
217 afx_msg void OnImgPrevPage();
218 afx_msg void OnUpdateImgPrevPage(CCmdUI* pCmdUI);
219 afx_msg void OnImgNextPage();
220 afx_msg void OnUpdateImgNextPage(CCmdUI* pCmdUI);
221 afx_msg void OnImgCurPanePrevPage();
222 afx_msg void OnUpdateImgCurPanePrevPage(CCmdUI* pCmdUI);
223 afx_msg void OnImgCurPaneNextPage();
224 afx_msg void OnUpdateImgCurPaneNextPage(CCmdUI* pCmdUI);
225 afx_msg void OnImgUseBackColor();
226 afx_msg void OnImgVectorImageScaling(UINT nId);
227 afx_msg void OnUpdateImgVectorImageScaling(CCmdUI* pCmdUI);
228 afx_msg void OnUpdateImgUseBackColor(CCmdUI* pCmdUI);
229 afx_msg void OnImgCompareExtractedText();
230 afx_msg void OnToolsGenerateReport();
231 afx_msg void OnRefresh();
232 afx_msg void OnSetFocus(CWnd *pNewWnd);
233 afx_msg void OnHelp();
235 DECLARE_MESSAGE_MAP()