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"
42 class LineFiltersList;
48 typedef std::shared_ptr<TempFile> TempFilePtr;
50 // typed lists (homogenous pointer lists)
51 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
52 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
53 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
54 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
57 class CLanguageSelect;
60 * @brief Frame class containing save-routines etc
62 class CMainFrame : public CMDIFrameWnd
64 friend CLanguageSelect;
65 DECLARE_DYNAMIC(CMainFrame)
68 * @brief Frame/View/Document types.
72 FRAME_FOLDER, /**< Folder compare frame. */
73 FRAME_FILE, /**< File compare frame. */
74 FRAME_HEXFILE, /**< Hex file compare frame. */
75 FRAME_IMGFILE, /**< Image file compare frame. */
76 FRAME_OTHER, /**< No frame? */
79 enum { WM_NONINTERACTIVE = 888 }; // timer value
85 BOOL m_bShowErrors; /**< Show folder compare error items? */
86 LOGFONT m_lfDiff; /**< MergeView user-selected font */
87 LOGFONT m_lfDir; /**< DirView user-selected font */
88 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 BOOL DoFileOpen(const PathContext *pFiles = NULL,
102 const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, const String& sReportFile = _T(""), bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
103 bool ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
104 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
105 bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
106 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
107 bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
108 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
109 bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
110 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
112 void UpdateResources();
113 void ClearStatusbarItemCount();
114 void ApplyDiffOptions();
116 void StartFlashing();
117 bool AskCloseConfirmation();
118 BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
119 FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
120 void UpdateDocTitle();
124 virtual void GetMessageString(UINT nID, CString& rMessage) const;
125 // ClassWizard generated virtual function overrides
126 //{{AFX_VIRTUAL(CMainFrame)
128 virtual void ActivateFrame(int nCmdShow = -1);
129 virtual BOOL PreTranslateMessage(MSG* pMsg);
130 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
131 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
134 // Implementation methods
136 virtual ~CMainFrame();
139 // Public implementation data
141 BOOL m_bFirstTime; /**< If first time frame activated, get pos from reg */
142 BOOL m_bFlashing; /**< Window is flashing. */
144 /** @brief Possible toolbar image sizes. */
151 // Implementation data
155 // control bar embedded members
156 CStatusBar m_wndStatusBar;
158 CToolBar m_wndToolBar;
159 CMDITabBar m_wndTabBar;
161 /** @brief Toolbar image table indexes. */
164 TOOLBAR_IMAGES_ENABLED,
165 TOOLBAR_IMAGES_DISABLED,
169 CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
179 MENU_COUNT, // Add new items before this item
182 * Menu frames - for which frame(s) the menu is.
186 MENU_MAINFRM = 0x000001,
187 MENU_FILECMP = 0x000002,
188 MENU_FOLDERCMP = 0x000004,
189 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
193 * A structure attaching a menu item, icon and menu types to apply to.
197 int menuitemID; /**< Menu item's ID. */
198 int iconResID; /**< Icon's resource ID. */
199 int menusToApply; /**< For which menus to apply. */
202 static const MENUITEM_ICON m_MenuIcons[];
204 std::unique_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
205 std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
206 DropHandler *m_pDropHandler;
208 // Generated message map functions
210 //{{AFX_MSG(CMainFrame)
211 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
212 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
213 afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
214 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
215 afx_msg void OnFileOpen();
216 afx_msg void OnHelpGnulicense();
217 afx_msg void OnOptions();
218 afx_msg void OnViewSelectfont();
219 afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
220 afx_msg void OnViewUsedefaultfont();
221 afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
222 afx_msg void OnHelpContents();
223 afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
224 afx_msg void OnClose();
225 afx_msg void OnToolsGeneratePatch();
226 afx_msg void OnDropFiles(const std::vector<String>& files);
227 afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
228 afx_msg void OnPluginUnpackMode(UINT nID);
229 afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
230 afx_msg void OnPluginPrediffMode(UINT nID);
231 afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
232 afx_msg void OnReloadPlugins();
233 afx_msg void OnSaveConfigData();
234 afx_msg void OnFileNew();
235 afx_msg void OnFileNew3();
236 afx_msg void OnToolsFilters();
237 afx_msg void OnViewStatusBar();
238 afx_msg void OnViewToolbar();
239 afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
240 afx_msg void OnViewTabBar();
241 afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
242 afx_msg void OnResizePanes();
243 afx_msg void OnFileOpenproject();
244 afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
245 afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
246 afx_msg void OnTimer(UINT_PTR nIDEvent);
247 afx_msg void OnWindowCloseAll();
248 afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
249 afx_msg void OnSaveProject();
250 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
251 #if _MFC_VER > 0x0600
252 afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
254 afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
256 afx_msg void OnToolbarNone();
257 afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
258 afx_msg void OnToolbarSmall();
259 afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
260 afx_msg void OnToolbarBig();
261 afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
262 afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
263 afx_msg void OnHelpCheckForUpdates();
264 afx_msg void OnFileOpenConflict();
265 afx_msg void OnPluginsList();
266 afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
267 afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
268 afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
269 afx_msg void OnDiffWhitespace(UINT nID);
270 afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
271 afx_msg void OnDiffCaseSensitive();
272 afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
273 afx_msg void OnDiffIgnoreEOL();
274 afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
275 afx_msg void OnIncludeSubfolders();
276 afx_msg void OnUpdateIncludeSubfolders(CCmdUI* pCmdUI);
277 afx_msg void OnCompareMethod(UINT nID);
278 afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
279 afx_msg void OnMRUs(UINT nID);
280 afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
281 afx_msg void OnDestroy();
283 DECLARE_MESSAGE_MAP()
286 void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
287 void FileNew(int nPanes);
288 OpenDocList &GetAllOpenDocs();
289 MergeDocList &GetAllMergeDocs();
290 DirDocList &GetAllDirDocs();
291 HexMergeDocList &GetAllHexMergeDocs();
292 void UpdateFont(FRAMETYPE frame);
293 BOOL CreateToolbar();
294 BOOL CreateComboBoxOnToolbar();
295 CMergeEditView * GetActiveMergeEditView();
296 void LoadToolbarImages();
297 HMENU NewMenu( int view, int ID );
300 CMainFrame * GetMainFrame(); // access to the singleton main frame object
302 /////////////////////////////////////////////////////////////////////////////
304 //{{AFX_INSERT_LOCATION}}
305 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.