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
26 // ID line follows -- this is updated by SVN
27 // $Id: MainFrm.h 6940 2009-08-01 17:29:01Z kimmov $
29 #if !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)
30 #define AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include "ToolBarXPThemes.h"
36 #include "MDITabBar.h"
37 #include "PathContext.h"
48 class LineFiltersList;
52 typedef boost::shared_ptr<TempFile> TempFilePtr;
54 // typed lists (homogenous pointer lists)
55 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
56 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
57 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
58 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
61 class CLanguageSelect;
64 * @brief Frame class containing save-routines etc
66 class CMainFrame : public CMDIFrameWnd
68 friend CLanguageSelect;
69 DECLARE_DYNAMIC(CMainFrame)
72 * @brief Frame/View/Document types.
76 FRAME_FOLDER, /**< Folder compare frame. */
77 FRAME_FILE, /**< File compare frame. */
78 FRAME_IMGFILE, /**< Image file compare frame. */
79 FRAME_OTHER, /**< No frame? */
82 enum { WM_NONINTERACTIVE = 888 }; // timer value
88 BOOL m_bShowErrors; /**< Show folder compare error items? */
89 LOGFONT m_lfDiff; /**< MergeView user-selected font */
90 LOGFONT m_lfDir; /**< DirView user-selected font */
91 static const TCHAR szClassName[];
94 HMENU NewDirViewMenu();
95 HMENU NewMergeViewMenu();
96 HMENU NewHexMergeViewMenu();
97 HMENU NewImgMergeViewMenu();
98 HMENU NewOpenViewMenu();
99 HMENU NewDefaultMenu(int ID = 0);
100 HMENU GetScriptsSubmenu(HMENU mainMenu);
101 HMENU GetPrediffersSubmenu(HMENU mainMenu);
102 void UpdatePrediffersMenu();
104 BOOL DoFileOpen(PathContext *pFiles = NULL,
105 DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), PackingInfo * infoUnpacker = NULL);
106 int ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
107 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
108 int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
109 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
110 void ShowHexMergeDoc(CDirDoc * pDirDoc,
111 const PathContext &paths, bool bRO[]);
112 int ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
113 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
115 void UpdateResources();
116 CString SetStatus(LPCTSTR status);
117 void ClearStatusbarItemCount();
118 void ApplyDiffOptions();
119 void ApplyViewWhitespace();
120 void SetEOLMixed(BOOL bAllow);
122 void StartFlashing();
123 bool AskCloseConfirmation();
124 BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
125 FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
128 virtual void GetMessageString(UINT nID, CString& rMessage) const;
129 // ClassWizard generated virtual function overrides
130 //{{AFX_VIRTUAL(CMainFrame)
132 virtual void ActivateFrame(int nCmdShow = -1);
133 virtual BOOL PreTranslateMessage(MSG* pMsg);
134 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
135 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
138 // Implementation methods
140 virtual ~CMainFrame();
142 // Public implementation data
144 BOOL m_bFirstTime; /**< If first time frame activated, get pos from reg */
145 BOOL m_bFlashing; /**< Window is flashing. */
147 /** @brief Possible toolbar image sizes. */
154 // Implementation data
158 // control bar embedded members
159 CStatusBar m_wndStatusBar;
161 ToolBarXPThemes m_wndToolBar;
162 CMDITabBar m_wndTabBar;
164 /** @brief Toolbar image table indexes. */
167 TOOLBAR_IMAGES_ENABLED,
168 TOOLBAR_IMAGES_DISABLED,
172 CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
182 MENU_COUNT, // Add new items before this item
185 * Menu frames - for which frame(s) the menu is.
189 MENU_MAINFRM = 0x000001,
190 MENU_FILECMP = 0x000002,
191 MENU_FOLDERCMP = 0x000004,
192 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
196 * A structure attaching a menu item, icon and menu types to apply to.
200 int menuitemID; /**< Menu item's ID. */
201 int iconResID; /**< Icon's resource ID. */
202 int menusToApply; /**< For which menus to apply. */
205 static const MENUITEM_ICON m_MenuIcons[];
207 boost::scoped_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
208 std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
210 // Generated message map functions
212 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
213 //{{AFX_MSG(CMainFrame)
214 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
215 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
216 afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
217 afx_msg void OnOptionsShowDifferent();
218 afx_msg void OnOptionsShowIdentical();
219 afx_msg void OnOptionsShowUniqueLeft();
220 afx_msg void OnOptionsShowUniqueRight();
221 afx_msg void OnOptionsShowBinaries();
222 afx_msg void OnOptionsShowSkipped();
223 afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
224 afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
225 afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
226 afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
227 afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
228 afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
229 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
230 afx_msg void OnFileOpen();
231 afx_msg void OnHelpGnulicense();
232 afx_msg void OnOptions();
233 afx_msg void OnViewSelectfont();
234 afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
235 afx_msg void OnViewUsedefaultfont();
236 afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
237 afx_msg void OnHelpContents();
238 afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
239 afx_msg void OnClose();
240 afx_msg void OnViewWhitespace();
241 afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
242 afx_msg void OnToolsGeneratePatch();
243 afx_msg void OnDropFiles(HDROP dropInfo);
244 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
245 afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
246 afx_msg void OnPluginUnpackMode(UINT nID);
247 afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
248 afx_msg void OnPluginPrediffMode(UINT nID);
249 afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
250 afx_msg void OnReloadPlugins();
251 afx_msg void OnSaveConfigData();
252 afx_msg void OnFileNew();
253 afx_msg void OnFileNew3();
254 afx_msg void OnToolsFilters();
255 afx_msg void OnHelpMerge7zmismatch();
256 afx_msg void OnUpdateHelpMerge7zmismatch(CCmdUI* pCmdUI);
257 afx_msg void OnViewStatusBar();
258 afx_msg void OnViewToolbar();
259 afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
260 afx_msg void OnViewTabBar();
261 afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
262 afx_msg void OnResizePanes();
263 afx_msg void OnFileOpenproject();
264 afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
265 afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
266 afx_msg void OnTimer(UINT_PTR nIDEvent);
267 afx_msg void OnWindowCloseAll();
268 afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
269 afx_msg void OnSaveProject();
270 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
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 OnToolbarNone();
277 afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
278 afx_msg void OnToolbarSmall();
279 afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
280 afx_msg void OnToolbarBig();
281 afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
282 afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
283 afx_msg void OnHelpReleasenotes();
284 afx_msg void OnHelpTranslations();
285 afx_msg void OnFileOpenConflict();
286 afx_msg void OnPluginsList();
287 afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
288 afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
289 afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
290 afx_msg void OnDiffWhitespace(UINT nID);
291 afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
292 afx_msg void OnDiffCaseSensitive();
293 afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
294 afx_msg void OnDiffIgnoreEOL();
295 afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
296 afx_msg void OnCompareMethod(UINT nID);
297 afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
298 afx_msg void OnMRUs(UINT nID);
299 afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
301 DECLARE_MESSAGE_MAP()
304 void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
305 void FileNew(int nPanes);
306 const OpenDocList &GetAllOpenDocs();
307 const MergeDocList &GetAllMergeDocs();
308 const DirDocList &GetAllDirDocs();
309 const HexMergeDocList &GetAllHexMergeDocs();
310 void RedisplayAllDirDocs();
311 CMergeDoc * GetMergeDocToShow(int nFiles, CDirDoc * pDirDoc, BOOL * pNew);
312 CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc, BOOL * pNew);
313 CDirDoc * GetDirDocToShow(int nDirs, BOOL * pNew);
314 void UpdateFont(FRAMETYPE frame);
315 BOOL CreateToolbar();
316 BOOL CreateComboBoxOnToolbar();
317 CMergeEditView * GetActiveMergeEditView();
318 void LoadToolbarImages();
319 HMENU NewMenu( int view, int ID );
322 CMainFrame * GetMainFrame(); // access to the singleton main frame object
324 /////////////////////////////////////////////////////////////////////////////
326 //{{AFX_INSERT_LOCATION}}
327 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
329 #endif // !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)