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;
53 typedef boost::shared_ptr<TempFile> TempFilePtr;
55 // typed lists (homogenous pointer lists)
56 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
57 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
58 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
59 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
62 class CLanguageSelect;
65 * @brief Frame class containing save-routines etc
67 class CMainFrame : public CMDIFrameWnd
69 friend CLanguageSelect;
70 DECLARE_DYNAMIC(CMainFrame)
73 * @brief Frame/View/Document types.
77 FRAME_FOLDER, /**< Folder compare frame. */
78 FRAME_FILE, /**< 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 NewOpenViewMenu();
98 HMENU NewDefaultMenu(int ID = 0);
99 HMENU GetScriptsSubmenu(HMENU mainMenu);
100 HMENU GetPrediffersSubmenu(HMENU mainMenu);
101 void UpdatePrediffersMenu();
103 BOOL DoFileOpen(PathContext *pFiles = NULL,
104 DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), PackingInfo * infoUnpacker = NULL);
105 int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
106 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
107 void ShowHexMergeDoc(CDirDoc * pDirDoc,
108 const PathContext &paths, const bool bRO[]);
109 void UpdateResources();
110 CString SetStatus(LPCTSTR status);
111 void ClearStatusbarItemCount();
112 void ApplyDiffOptions();
113 void ApplyViewWhitespace();
114 void SetEOLMixed(BOOL bAllow);
116 void StartFlashing();
117 bool AskCloseConfirmation();
118 BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
119 FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
122 virtual void GetMessageString(UINT nID, CString& rMessage) const;
123 // ClassWizard generated virtual function overrides
124 //{{AFX_VIRTUAL(CMainFrame)
126 virtual void ActivateFrame(int nCmdShow = -1);
127 virtual BOOL PreTranslateMessage(MSG* pMsg);
128 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
129 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
132 // Implementation methods
134 virtual ~CMainFrame();
137 // Public implementation data
139 BOOL m_bFirstTime; /**< If first time frame activated, get pos from reg */
140 BOOL m_bFlashing; /**< Window is flashing. */
142 /** @brief Possible toolbar image sizes. */
149 // Implementation data
153 // control bar embedded members
154 CStatusBar m_wndStatusBar;
156 ToolBarXPThemes m_wndToolBar;
157 CComboBox m_ctlCompareMethod;
158 CMDITabBar m_wndTabBar;
160 /** @brief Toolbar image table indexes. */
163 TOOLBAR_IMAGES_ENABLED,
164 TOOLBAR_IMAGES_DISABLED,
168 CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
177 MENU_COUNT, // Add new items before this item
180 * Menu frames - for which frame(s) the menu is.
184 MENU_MAINFRM = 0x000001,
185 MENU_FILECMP = 0x000002,
186 MENU_FOLDERCMP = 0x000004,
187 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
191 * A structure attaching a menu item, icon and menu types to apply to.
195 int menuitemID; /**< Menu item's ID. */
196 int iconResID; /**< Icon's resource ID. */
197 int menusToApply; /**< For which menus to apply. */
200 static const MENUITEM_ICON m_MenuIcons[];
202 boost::scoped_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
203 std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
205 // Generated message map functions
207 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
208 //{{AFX_MSG(CMainFrame)
209 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
210 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
211 afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
212 afx_msg void OnOptionsShowDifferent();
213 afx_msg void OnOptionsShowIdentical();
214 afx_msg void OnOptionsShowUniqueLeft();
215 afx_msg void OnOptionsShowUniqueRight();
216 afx_msg void OnOptionsShowBinaries();
217 afx_msg void OnOptionsShowSkipped();
218 afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
219 afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
220 afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
221 afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
222 afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
223 afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
224 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
225 afx_msg void OnFileOpen();
226 afx_msg void OnHelpGnulicense();
227 afx_msg void OnOptions();
228 afx_msg void OnViewSelectfont();
229 afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
230 afx_msg void OnViewUsedefaultfont();
231 afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
232 afx_msg void OnHelpContents();
233 afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
234 afx_msg void OnClose();
235 afx_msg void OnViewWhitespace();
236 afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
237 afx_msg void OnToolsGeneratePatch();
238 afx_msg void OnDropFiles(HDROP dropInfo);
239 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
240 afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
241 afx_msg void OnPluginUnpackMode(UINT nID);
242 afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
243 afx_msg void OnPluginPrediffMode(UINT nID);
244 afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
245 afx_msg void OnReloadPlugins();
246 afx_msg void OnSaveConfigData();
247 afx_msg void OnFileNew();
248 afx_msg void OnFileNew3();
249 afx_msg void OnToolsFilters();
250 afx_msg void OnHelpMerge7zmismatch();
251 afx_msg void OnUpdateHelpMerge7zmismatch(CCmdUI* pCmdUI);
252 afx_msg void OnViewStatusBar();
253 afx_msg void OnViewToolbar();
254 afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
255 afx_msg void OnViewTabBar();
256 afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
257 afx_msg void OnResizePanes();
258 afx_msg void OnFileOpenproject();
259 afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
260 afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
261 afx_msg void OnTimer(UINT_PTR nIDEvent);
262 afx_msg void OnWindowCloseAll();
263 afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
264 afx_msg void OnSaveProject();
265 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
266 #if _MFC_VER > 0x0600
267 afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
269 afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
271 afx_msg void OnToolbarNone();
272 afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
273 afx_msg void OnToolbarSmall();
274 afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
275 afx_msg void OnToolbarBig();
276 afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
277 afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
278 afx_msg void OnHelpReleasenotes();
279 afx_msg void OnHelpTranslations();
280 afx_msg void OnFileOpenConflict();
281 afx_msg void OnPluginsList();
282 afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
283 afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
284 afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
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 OnCompareMethod(UINT nID);
292 afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
293 afx_msg void OnMRUs(UINT nID);
294 afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
296 DECLARE_MESSAGE_MAP()
299 void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
300 void FileNew(int nPanes);
301 const OpenDocList &GetAllOpenDocs();
302 const MergeDocList &GetAllMergeDocs();
303 const DirDocList &GetAllDirDocs();
304 const HexMergeDocList &GetAllHexMergeDocs();
305 void RedisplayAllDirDocs();
306 CMergeDoc * GetMergeDocToShow(int nFiles, CDirDoc * pDirDoc, BOOL * pNew);
307 CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc, BOOL * pNew);
308 CDirDoc * GetDirDocToShow(int nDirs, BOOL * pNew);
309 void UpdateFont(FRAMETYPE frame);
310 BOOL CreateToolbar();
311 BOOL CreateComboBoxOnToolbar();
312 CMergeEditView * GetActiveMergeEditView();
313 void LoadToolbarImages();
314 HMENU NewMenu( int view, int ID );
317 CMainFrame * GetMainFrame(); // access to the singleton main frame object
319 /////////////////////////////////////////////////////////////////////////////
321 //{{AFX_INSERT_LOCATION}}
322 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
324 #endif // !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)