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 Declaration file for CMainFrame
16 #include "MDITabBar.h"
17 #include "PathContext.h"
18 #include "OptionsDef.h"
19 #include "OptionsMgr.h"
29 class LineFiltersList;
36 typedef std::shared_ptr<TempFile> TempFilePtr;
38 // typed lists (homogenous pointer lists)
39 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
40 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
41 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
42 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
45 class CLanguageSelect;
47 CMainFrame * GetMainFrame(); // access to the singleton main frame object
50 * @brief Frame class containing save-routines etc
52 class CMainFrame : public CMDIFrameWnd
54 friend CLanguageSelect;
55 DECLARE_DYNAMIC(CMainFrame)
58 * @brief Frame/View/Document types.
62 FRAME_FOLDER, /**< Folder compare frame. */
63 FRAME_FILE, /**< File compare frame. */
64 FRAME_HEXFILE, /**< Hex file compare frame. */
65 FRAME_IMGFILE, /**< Image file compare frame. */
66 FRAME_OTHER, /**< No frame? */
73 bool m_bShowErrors; /**< Show folder compare error items? */
74 LOGFONT m_lfDiff; /**< MergeView user-selected font */
75 LOGFONT m_lfDir; /**< DirView user-selected font */
76 static const TCHAR szClassName[];
80 HMENU NewDirViewMenu();
81 HMENU NewMergeViewMenu();
82 HMENU NewHexMergeViewMenu();
83 HMENU NewImgMergeViewMenu();
84 HMENU NewOpenViewMenu();
85 HMENU NewDefaultMenu(int ID = 0);
86 HMENU GetScriptsSubmenu(HMENU mainMenu);
87 HMENU GetPrediffersSubmenu(HMENU mainMenu);
88 void UpdatePrediffersMenu();
90 void FileNew(int nPanes);
91 bool DoFileOpen(const PathContext *pFiles = nullptr,
92 const DWORD dwFlags[] = nullptr, const String strDesc[] = nullptr, const String& sReportFile = _T(""), bool bRecurse = false, CDirDoc *pDirDoc = nullptr, String prediffer = _T(""), const PackingInfo * infoUnpacker = nullptr);
93 bool ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
94 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr);
95 bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
96 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr);
97 bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
98 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr);
99 bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
100 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr);
102 void UpdateResources();
103 void ClearStatusbarItemCount();
104 void ApplyDiffOptions();
106 void StartFlashing();
107 bool AskCloseConfirmation();
108 bool DoOpenConflict(const String& conflictFile, const String strDesc[] = nullptr, bool checked = false);
109 FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
110 void UpdateDocTitle();
112 DropHandler *GetDropHandler() const { return m_pDropHandler; }
113 const CTypedPtrArray<CPtrArray, CMDIChildWnd*>* GetChildArray() const { return &m_arrChild; }
116 virtual void GetMessageString(UINT nID, CString& rMessage) const;
117 // ClassWizard generated virtual function overrides
118 //{{AFX_VIRTUAL(CMainFrame)
120 virtual void ActivateFrame(int nCmdShow = -1);
121 virtual BOOL PreTranslateMessage(MSG* pMsg);
122 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
123 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
126 // Implementation methods
128 virtual ~CMainFrame();
130 // Public implementation data
132 bool m_bFirstTime; /**< If first time frame activated, get pos from reg */
134 // Implementation data
136 // control bar embedded members
137 CStatusBar m_wndStatusBar;
139 CToolBar m_wndToolBar;
140 CMDITabBar m_wndTabBar;
141 CTypedPtrArray<CPtrArray, CMDIChildWnd*> m_arrChild;
143 // Tweak MDI client window behavior
144 class CMDIClient : public CWnd
146 static UINT_PTR const m_nRedrawTimer = 1612;
147 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
154 // To reduce flicker in maximized state, disable drawing while messing with MDI child frames
156 HWND hwndActive = reinterpret_cast<HWND>(SendMessage(WM_MDIGETACTIVE, 0, reinterpret_cast<LPARAM>(&bMaximized)));
157 if ((bMaximized || (message == WM_MDICREATE && !hwndActive)) &&
158 SetTimer(m_nRedrawTimer, USER_TIMER_MINIMUM, nullptr))
165 if (wParam == m_nRedrawTimer)
167 KillTimer(m_nRedrawTimer);
169 RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE);
173 return CWnd::WindowProc(message, wParam, lParam);
177 /** @brief Toolbar image table indexes. */
180 TOOLBAR_IMAGES_ENABLED,
181 TOOLBAR_IMAGES_DISABLED,
185 CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
195 MENU_COUNT, // Add new items before this item
198 * Menu frames - for which frame(s) the menu is.
202 MENU_MAINFRM = 0x000001,
203 MENU_FILECMP = 0x000002,
204 MENU_FOLDERCMP = 0x000004,
205 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
209 * A structure attaching a menu item, icon and menu types to apply to.
213 int menuitemID; /**< Menu item's ID. */
214 int iconResID; /**< Icon's resource ID. */
215 int menusToApply; /**< For which menus to apply. */
218 static const MENUITEM_ICON m_MenuIcons[];
220 std::unique_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
221 std::unique_ptr<BCMenu> m_pImageMenu;
222 std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
223 DropHandler *m_pDropHandler;
225 // Generated message map functions
227 //{{AFX_MSG(CMainFrame)
228 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
229 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
230 afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
231 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
232 afx_msg void OnFileOpen();
233 afx_msg void OnHelpGnulicense();
234 afx_msg void OnOptions();
235 afx_msg void OnViewSelectfont();
236 afx_msg void OnViewUsedefaultfont();
237 afx_msg void OnHelpContents();
238 afx_msg void OnClose();
239 afx_msg void OnToolsGeneratePatch();
240 afx_msg void OnDropFiles(const std::vector<String>& files);
241 afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
242 afx_msg void OnPluginUnpackMode(UINT nID);
243 afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
244 afx_msg void OnPluginPrediffMode(UINT nID);
245 afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
246 afx_msg void OnReloadPlugins();
247 afx_msg void OnSaveConfigData();
248 afx_msg void OnFileNew();
249 afx_msg void OnFileNew3();
250 afx_msg void OnToolsFilters();
251 afx_msg void OnViewStatusBar();
252 afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
253 afx_msg void OnViewTabBar();
254 afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
255 afx_msg void OnResizePanes();
256 afx_msg void OnFileOpenProject();
257 afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
258 afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
259 afx_msg void OnWindowCloseAll();
260 afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
261 afx_msg void OnSaveProject();
262 #if _MFC_VER > 0x0600
263 afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
265 afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
267 afx_msg void OnToolbarSize(UINT id);
268 afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI);
269 afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
270 afx_msg void OnHelpReleasenotes();
271 afx_msg void OnHelpTranslations();
272 afx_msg void OnFileOpenConflict();
273 afx_msg void OnPluginsList();
274 afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
275 afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
276 afx_msg void OnDiffWhitespace(UINT nID);
277 afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
278 afx_msg void OnDiffCaseSensitive();
279 afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
280 afx_msg void OnDiffIgnoreEOL();
281 afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
282 afx_msg void OnDiffIgnoreCP();
283 afx_msg void OnUpdateDiffIgnoreCP(CCmdUI* pCmdUI);
284 afx_msg void OnIncludeSubfolders();
285 afx_msg void OnUpdateIncludeSubfolders(CCmdUI* pCmdUI);
286 afx_msg void OnCompareMethod(UINT nID);
287 afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
288 afx_msg void OnMRUs(UINT nID);
289 afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
290 afx_msg void OnTimer(UINT_PTR nIDEvent);
291 afx_msg void OnDestroy();
292 afx_msg void OnAccelQuit();
294 afx_msg LRESULT OnChildFrameAdded(WPARAM wParam, LPARAM lParam);
295 afx_msg LRESULT OnChildFrameRemoved(WPARAM wParam, LPARAM lParam);
296 afx_msg LRESULT OnChildFrameActivate(WPARAM wParam, LPARAM lParam);
297 afx_msg LRESULT OnChildFrameActivated(WPARAM wParam, LPARAM lParam);
298 DECLARE_MESSAGE_MAP()
301 void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
302 OpenDocList &GetAllOpenDocs();
303 MergeDocList &GetAllMergeDocs();
304 DirDocList &GetAllDirDocs();
305 HexMergeDocList &GetAllHexMergeDocs();
306 std::list<CImgMergeFrame *> GetAllImgMergeFrames();
307 void UpdateFont(FRAMETYPE frame);
308 BOOL CreateToolbar();
309 CMergeEditView * GetActiveMergeEditView();
310 void LoadToolbarImages();
311 HMENU NewMenu( int view, int ID );