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