OSDN Git Service

Merge with stable
[winmerge-jp/winmerge-jp.git] / Src / MainFrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    WinMerge:  an interactive diff/merge utility
3 //    Copyright (C) 1997  Dean P. Grimm
4 //
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.
9 //
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.
14 //
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.
18 //
19 /////////////////////////////////////////////////////////////////////////////
20 /** 
21  * @file  MainFrm.h
22  *
23  * @brief Declaration file for CMainFrame
24  *
25  */
26 // ID line follows -- this is updated by SVN
27 // $Id: MainFrm.h 6940 2009-08-01 17:29:01Z kimmov $
28
29 #if !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)
30 #define AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_
31
32 #include <vector>
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include "ToolBarXPThemes.h"
36 #include "MDITabBar.h"
37 #include "PathContext.h"
38
39 class BCMenu;
40 class CDiffView;
41 class CDirView;
42 class COpenDoc;
43 class CDirDoc;
44 class CMergeDoc;
45 class CHexMergeDoc;
46 class CMergeEditView;
47 class SyntaxColors;
48 class LineFiltersList;
49 class TempFile;
50 struct FileLocation;
51 class SourceControl;
52
53 typedef boost::shared_ptr<TempFile> TempFilePtr;
54
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;
60
61 class PackingInfo;
62 class CLanguageSelect;
63
64 /**
65  * @brief Frame class containing save-routines etc
66  */
67 class CMainFrame : public CMDIFrameWnd
68 {
69         friend CLanguageSelect;
70         DECLARE_DYNAMIC(CMainFrame)
71 public:
72         /**
73          * @brief Frame/View/Document types.
74          */
75         enum FRAMETYPE
76         {
77                 FRAME_FOLDER, /**< Folder compare frame. */
78                 FRAME_FILE, /**< File compare frame. */
79                 FRAME_HEXFILE, /**< Hex file compare frame. */
80                 FRAME_IMGFILE, /**< Image file compare frame. */
81                 FRAME_OTHER, /**< No frame? */
82         };
83
84         enum { WM_NONINTERACTIVE = 888 }; // timer value
85
86         CMainFrame();
87
88 // Attributes
89 public: 
90         BOOL m_bShowErrors; /**< Show folder compare error items? */
91         LOGFONT m_lfDiff; /**< MergeView user-selected font */
92         LOGFONT m_lfDir; /**< DirView user-selected font */
93         static const TCHAR szClassName[];
94 // Operations
95 public:
96         HMENU NewDirViewMenu();
97         HMENU NewMergeViewMenu();
98         HMENU NewHexMergeViewMenu();
99         HMENU NewImgMergeViewMenu();
100         HMENU NewOpenViewMenu();
101         HMENU NewDefaultMenu(int ID = 0);
102         HMENU GetScriptsSubmenu(HMENU mainMenu);
103         HMENU GetPrediffersSubmenu(HMENU mainMenu);
104         void UpdatePrediffersMenu();
105
106         BOOL DoFileOpen(PathContext *pFiles = NULL,
107                 DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), PackingInfo * infoUnpacker = NULL);
108         int ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
109                 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
110         int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
111                 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
112         void ShowHexMergeDoc(CDirDoc * pDirDoc,
113                 const PathContext &paths, const bool bRO[]);
114         int ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
115                 DWORD dwFlags[], PackingInfo * infoUnpacker = NULL);
116
117         void UpdateResources();
118         CString SetStatus(LPCTSTR status);
119         void ClearStatusbarItemCount();
120         void ApplyDiffOptions();
121         void ApplyViewWhitespace();
122         void SetEOLMixed(BOOL bAllow);
123         void SelectFilter();
124         void StartFlashing();
125         bool AskCloseConfirmation();
126         BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
127         FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
128
129 // Overrides
130         virtual void GetMessageString(UINT nID, CString& rMessage) const;
131         // ClassWizard generated virtual function overrides
132         //{{AFX_VIRTUAL(CMainFrame)
133 public:
134         virtual void ActivateFrame(int nCmdShow = -1);
135         virtual BOOL PreTranslateMessage(MSG* pMsg);
136         virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
137         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
138         //}}AFX_VIRTUAL
139
140 // Implementation methods
141 protected:
142         virtual ~CMainFrame();
143
144
145 // Public implementation data
146 public:
147         BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
148         BOOL m_bFlashing; /**< Window is flashing. */
149
150         /** @brief Possible toolbar image sizes. */
151         enum TOOLBAR_SIZE
152         {
153                 TOOLBAR_SIZE_16x16,
154                 TOOLBAR_SIZE_32x32,
155         };
156
157 // Implementation data
158 protected:
159
160
161         // control bar embedded members
162         CStatusBar  m_wndStatusBar;
163         CReBar m_wndReBar;
164         ToolBarXPThemes m_wndToolBar;
165         CMDITabBar m_wndTabBar;
166
167         /** @brief Toolbar image table indexes. */
168         enum TOOLBAR_IMAGES
169         {
170                 TOOLBAR_IMAGES_ENABLED,
171                 TOOLBAR_IMAGES_DISABLED,
172                 TOOLBAR_IMAGES_COUNT
173         };
174
175         CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
176
177         enum
178         {
179                 MENU_DEFAULT,
180                 MENU_MERGEVIEW,
181                 MENU_DIRVIEW,
182                 MENU_HEXMERGEVIEW,
183                 MENU_IMGMERGEVIEW,
184                 MENU_OPENVIEW,
185                 MENU_COUNT, // Add new items before this item
186         };
187         /**
188          * Menu frames - for which frame(s) the menu is.
189          */
190         enum
191         {
192                 MENU_MAINFRM = 0x000001,
193                 MENU_FILECMP = 0x000002,
194                 MENU_FOLDERCMP = 0x000004,
195                 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
196         };
197
198         /**
199          * A structure attaching a menu item, icon and menu types to apply to.
200          */
201         struct MENUITEM_ICON
202         {
203                 int menuitemID;   /**< Menu item's ID. */
204                 int iconResID;    /**< Icon's resource ID. */
205                 int menusToApply; /**< For which menus to apply. */
206         };
207
208         static const MENUITEM_ICON m_MenuIcons[];
209
210         boost::scoped_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
211         std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
212
213 // Generated message map functions
214 protected:
215         virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
216         //{{AFX_MSG(CMainFrame)
217         afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
218         afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
219         afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
220         afx_msg void OnOptionsShowDifferent();
221         afx_msg void OnOptionsShowIdentical();
222         afx_msg void OnOptionsShowUniqueLeft();
223         afx_msg void OnOptionsShowUniqueRight();
224         afx_msg void OnOptionsShowBinaries();
225         afx_msg void OnOptionsShowSkipped();
226         afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
227         afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
228         afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
229         afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
230         afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
231         afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
232         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
233         afx_msg void OnFileOpen();
234         afx_msg void OnHelpGnulicense();
235         afx_msg void OnOptions();
236         afx_msg void OnViewSelectfont();
237         afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
238         afx_msg void OnViewUsedefaultfont();
239         afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
240         afx_msg void OnHelpContents();
241         afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
242         afx_msg void OnClose();
243         afx_msg void OnViewWhitespace();
244         afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
245         afx_msg void OnToolsGeneratePatch();
246         afx_msg void OnDropFiles(HDROP dropInfo);
247         afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
248         afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
249         afx_msg void OnPluginUnpackMode(UINT nID);
250         afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
251         afx_msg void OnPluginPrediffMode(UINT nID);
252         afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
253         afx_msg void OnReloadPlugins();
254         afx_msg void OnSaveConfigData();
255         afx_msg void OnFileNew();
256         afx_msg void OnFileNew3();
257         afx_msg void OnToolsFilters();
258         afx_msg void OnHelpMerge7zmismatch();
259         afx_msg void OnUpdateHelpMerge7zmismatch(CCmdUI* pCmdUI);
260         afx_msg void OnViewStatusBar();
261         afx_msg void OnViewToolbar();
262         afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
263         afx_msg void OnViewTabBar();
264         afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
265         afx_msg void OnResizePanes();
266         afx_msg void OnFileOpenproject();
267         afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
268         afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
269         afx_msg void OnTimer(UINT_PTR nIDEvent);
270         afx_msg void OnWindowCloseAll();
271         afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
272         afx_msg void OnSaveProject();
273         afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
274 #if _MFC_VER > 0x0600
275         afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
276 #else
277         afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
278 #endif
279         afx_msg void OnToolbarNone();
280         afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
281         afx_msg void OnToolbarSmall();
282         afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
283         afx_msg void OnToolbarBig();
284         afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
285         afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
286         afx_msg void OnHelpReleasenotes();
287         afx_msg void OnHelpTranslations();
288         afx_msg void OnFileOpenConflict();
289         afx_msg void OnPluginsList();
290         afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
291         afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
292         afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
293         afx_msg void OnDiffWhitespace(UINT nID);
294         afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
295         afx_msg void OnDiffCaseSensitive();
296         afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
297         afx_msg void OnDiffIgnoreEOL();
298         afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
299         afx_msg void OnCompareMethod(UINT nID);
300         afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
301         afx_msg void OnMRUs(UINT nID);
302         afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
303         //}}AFX_MSG
304         DECLARE_MESSAGE_MAP()
305
306 private:
307         void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
308         void FileNew(int nPanes);
309         const OpenDocList &GetAllOpenDocs();
310         const MergeDocList &GetAllMergeDocs();
311         const DirDocList &GetAllDirDocs();
312         const HexMergeDocList &GetAllHexMergeDocs();
313         void RedisplayAllDirDocs();
314         CMergeDoc * GetMergeDocToShow(int nFiles, CDirDoc * pDirDoc, BOOL * pNew);
315         CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc, BOOL * pNew);
316         CDirDoc * GetDirDocToShow(int nDirs, BOOL * pNew);
317         void UpdateFont(FRAMETYPE frame);
318         BOOL CreateToolbar();
319         BOOL CreateComboBoxOnToolbar();
320         CMergeEditView * GetActiveMergeEditView();
321         void LoadToolbarImages();
322         HMENU NewMenu( int view, int ID );
323 };
324
325 CMainFrame * GetMainFrame(); // access to the singleton main frame object
326
327 /////////////////////////////////////////////////////////////////////////////
328
329 //{{AFX_INSERT_LOCATION}}
330 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
331
332 #endif // !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_)