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 ApplyViewWhitespace();
113 void SetEOLMixed(BOOL bAllow);
115 void StartFlashing();
116 bool AskCloseConfirmation();
117 BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
118 FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
121 virtual void GetMessageString(UINT nID, CString& rMessage) const;
122 // ClassWizard generated virtual function overrides
123 //{{AFX_VIRTUAL(CMainFrame)
125 virtual void ActivateFrame(int nCmdShow = -1);
126 virtual BOOL PreTranslateMessage(MSG* pMsg);
127 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
128 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
131 // Implementation methods
133 virtual ~CMainFrame();
136 // Public implementation data
138 BOOL m_bFirstTime; /**< If first time frame activated, get pos from reg */
139 BOOL m_bFlashing; /**< Window is flashing. */
141 /** @brief Possible toolbar image sizes. */
148 // Implementation data
152 // control bar embedded members
153 CStatusBar m_wndStatusBar;
155 ToolBarXPThemes m_wndToolBar;
156 CMDITabBar m_wndTabBar;
158 /** @brief Toolbar image table indexes. */
161 TOOLBAR_IMAGES_ENABLED,
162 TOOLBAR_IMAGES_DISABLED,
166 CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
175 MENU_COUNT, // Add new items before this item
178 * Menu frames - for which frame(s) the menu is.
182 MENU_MAINFRM = 0x000001,
183 MENU_FILECMP = 0x000002,
184 MENU_FOLDERCMP = 0x000004,
185 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
189 * A structure attaching a menu item, icon and menu types to apply to.
193 int menuitemID; /**< Menu item's ID. */
194 int iconResID; /**< Icon's resource ID. */
195 int menusToApply; /**< For which menus to apply. */
198 static const MENUITEM_ICON m_MenuIcons[];
200 boost::scoped_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
201 std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
203 // Generated message map functions
205 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
206 //{{AFX_MSG(CMainFrame)
207 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
208 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
209 afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
210 afx_msg void OnOptionsShowDifferent();
211 afx_msg void OnOptionsShowIdentical();
212 afx_msg void OnOptionsShowUniqueLeft();
213 afx_msg void OnOptionsShowUniqueRight();
214 afx_msg void OnOptionsShowBinaries();
215 afx_msg void OnOptionsShowSkipped();
216 afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
217 afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
218 afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
219 afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
220 afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
221 afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
222 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
223 afx_msg void OnFileOpen();
224 afx_msg void OnHelpGnulicense();
225 afx_msg void OnOptions();
226 afx_msg void OnViewSelectfont();
227 afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
228 afx_msg void OnViewUsedefaultfont();
229 afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
230 afx_msg void OnHelpContents();
231 afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
232 afx_msg void OnClose();
233 afx_msg void OnViewWhitespace();
234 afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
235 afx_msg void OnToolsGeneratePatch();
236 afx_msg void OnDropFiles(HDROP dropInfo);
237 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
238 afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
239 afx_msg void OnPluginUnpackMode(UINT nID);
240 afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
241 afx_msg void OnPluginPrediffMode(UINT nID);
242 afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
243 afx_msg void OnReloadPlugins();
244 afx_msg void OnSaveConfigData();
245 afx_msg void OnFileNew();
246 afx_msg void OnFileNew3();
247 afx_msg void OnToolsFilters();
248 afx_msg void OnHelpMerge7zmismatch();
249 afx_msg void OnUpdateHelpMerge7zmismatch(CCmdUI* pCmdUI);
250 afx_msg void OnViewStatusBar();
251 afx_msg void OnViewToolbar();
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 OnTimer(UINT_PTR nIDEvent);
260 afx_msg void OnWindowCloseAll();
261 afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
262 afx_msg void OnSaveProject();
263 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
264 #if _MFC_VER > 0x0600
265 afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
267 afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
269 afx_msg void OnToolbarNone();
270 afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
271 afx_msg void OnToolbarSmall();
272 afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
273 afx_msg void OnToolbarBig();
274 afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
275 afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
276 afx_msg void OnHelpReleasenotes();
277 afx_msg void OnHelpTranslations();
278 afx_msg void OnFileOpenConflict();
279 afx_msg void OnPluginsList();
280 afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
282 DECLARE_MESSAGE_MAP()
285 void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
286 void FileNew(int nPanes);
287 const OpenDocList &GetAllOpenDocs();
288 const MergeDocList &GetAllMergeDocs();
289 const DirDocList &GetAllDirDocs();
290 const HexMergeDocList &GetAllHexMergeDocs();
291 void RedisplayAllDirDocs();
292 CMergeDoc * GetMergeDocToShow(int nFiles, CDirDoc * pDirDoc, BOOL * pNew);
293 CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc, BOOL * pNew);
294 CDirDoc * GetDirDocToShow(int nDirs, BOOL * pNew);
295 void UpdateFont(FRAMETYPE frame);
297 CMergeEditView * GetActiveMergeEditView();
298 void LoadToolbarImages();
299 HMENU NewMenu( int view, int ID );
302 CMainFrame * GetMainFrame(); // access to the singleton main frame object
304 /////////////////////////////////////////////////////////////////////////////
306 //{{AFX_INSERT_LOCATION}}
307 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
309 #endif // !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)