OSDN Git Service

Remove [Help/Release Notes] and [Help/Translations] menu item
[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 #pragma once
27
28 #include <vector>
29 #include <memory>
30 #include "MDITabBar.h"
31 #include "PathContext.h"
32
33 class BCMenu;
34 class CDiffView;
35 class CDirView;
36 class COpenDoc;
37 class CDirDoc;
38 class CMergeDoc;
39 class CHexMergeDoc;
40 class CMergeEditView;
41 class SyntaxColors;
42 class LineFiltersList;
43 class TempFile;
44 struct FileLocation;
45 class DropHandler;
46
47 typedef std::shared_ptr<TempFile> TempFilePtr;
48
49 // typed lists (homogenous pointer lists)
50 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
51 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
52 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
53 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
54
55 class PackingInfo;
56 class CLanguageSelect;
57
58 /**
59  * @brief Frame class containing save-routines etc
60  */
61 class CMainFrame : public CMDIFrameWnd
62 {
63         friend CLanguageSelect;
64         DECLARE_DYNAMIC(CMainFrame)
65 public:
66         /**
67          * @brief Frame/View/Document types.
68          */
69         enum FRAMETYPE
70         {
71                 FRAME_FOLDER, /**< Folder compare frame. */
72                 FRAME_FILE, /**< File compare frame. */
73                 FRAME_HEXFILE, /**< Hex file compare frame. */
74                 FRAME_IMGFILE, /**< Image file compare frame. */
75                 FRAME_OTHER, /**< No frame? */
76         };
77
78         enum { WM_NONINTERACTIVE = 888 }; // timer value
79
80         CMainFrame();
81
82 // Attributes
83 public: 
84         BOOL m_bShowErrors; /**< Show folder compare error items? */
85         LOGFONT m_lfDiff; /**< MergeView user-selected font */
86         LOGFONT m_lfDir; /**< DirView user-selected font */
87         static const TCHAR szClassName[];
88 // Operations
89 public:
90         HMENU NewDirViewMenu();
91         HMENU NewMergeViewMenu();
92         HMENU NewHexMergeViewMenu();
93         HMENU NewImgMergeViewMenu();
94         HMENU NewOpenViewMenu();
95         HMENU NewDefaultMenu(int ID = 0);
96         HMENU GetScriptsSubmenu(HMENU mainMenu);
97         HMENU GetPrediffersSubmenu(HMENU mainMenu);
98         void UpdatePrediffersMenu();
99
100         BOOL DoFileOpen(const PathContext *pFiles = NULL,
101                 const DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
102         int ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
103                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
104         int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
105                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
106         void ShowHexMergeDoc(CDirDoc * pDirDoc,
107                 const PathContext &paths, const bool bRO[]);
108         int ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
109                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
110
111         void UpdateResources();
112         CString SetStatus(LPCTSTR status);
113         void ClearStatusbarItemCount();
114         void ApplyDiffOptions();
115         void ApplyViewWhitespace();
116         void SetEOLMixed(BOOL bAllow);
117         void SelectFilter();
118         void StartFlashing();
119         bool AskCloseConfirmation();
120         BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
121         FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
122         void UpdateDocTitle();
123         void ReloadMenu();
124
125 // Overrides
126         // ClassWizard generated virtual function overrides
127         //{{AFX_VIRTUAL(CMainFrame)
128 public:
129         virtual void ActivateFrame(int nCmdShow = -1);
130         virtual BOOL PreTranslateMessage(MSG* pMsg);
131         virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
132         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
133         //}}AFX_VIRTUAL
134
135 // Implementation methods
136 protected:
137         virtual ~CMainFrame();
138
139 // Public implementation data
140 public:
141         BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
142         BOOL m_bFlashing; /**< Window is flashing. */
143
144         /** @brief Possible toolbar image sizes. */
145         enum TOOLBAR_SIZE
146         {
147                 TOOLBAR_SIZE_16x16,
148                 TOOLBAR_SIZE_32x32,
149         };
150
151 // Implementation data
152 protected:
153
154
155         // control bar embedded members
156         CStatusBar  m_wndStatusBar;
157         CReBar m_wndReBar;
158         CToolBar m_wndToolBar;
159         CMDITabBar m_wndTabBar;
160
161         /** @brief Toolbar image table indexes. */
162         enum TOOLBAR_IMAGES
163         {
164                 TOOLBAR_IMAGES_ENABLED,
165                 TOOLBAR_IMAGES_DISABLED,
166                 TOOLBAR_IMAGES_COUNT
167         };
168
169         CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
170
171         enum
172         {
173                 MENU_DEFAULT,
174                 MENU_MERGEVIEW,
175                 MENU_DIRVIEW,
176                 MENU_HEXMERGEVIEW,
177                 MENU_IMGMERGEVIEW,
178                 MENU_OPENVIEW,
179                 MENU_COUNT, // Add new items before this item
180         };
181         /**
182          * Menu frames - for which frame(s) the menu is.
183          */
184         enum
185         {
186                 MENU_MAINFRM = 0x000001,
187                 MENU_FILECMP = 0x000002,
188                 MENU_FOLDERCMP = 0x000004,
189                 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
190         };
191
192         /**
193          * A structure attaching a menu item, icon and menu types to apply to.
194          */
195         struct MENUITEM_ICON
196         {
197                 int menuitemID;   /**< Menu item's ID. */
198                 int iconResID;    /**< Icon's resource ID. */
199                 int menusToApply; /**< For which menus to apply. */
200         };
201
202         static const MENUITEM_ICON m_MenuIcons[];
203
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;
207
208 // Generated message map functions
209 protected:
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 void OnOptionsShowDifferent();
215         afx_msg void OnOptionsShowIdentical();
216         afx_msg void OnOptionsShowUniqueLeft();
217         afx_msg void OnOptionsShowUniqueRight();
218         afx_msg void OnOptionsShowBinaries();
219         afx_msg void OnOptionsShowSkipped();
220         afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
221         afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
222         afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
223         afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
224         afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
225         afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
226         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
227         afx_msg void OnFileOpen();
228         afx_msg void OnHelpGnulicense();
229         afx_msg void OnOptions();
230         afx_msg void OnViewSelectfont();
231         afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
232         afx_msg void OnViewUsedefaultfont();
233         afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
234         afx_msg void OnHelpContents();
235         afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
236         afx_msg void OnClose();
237         afx_msg void OnViewWhitespace();
238         afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
239         afx_msg void OnToolsGeneratePatch();
240         afx_msg void OnDropFiles(const std::vector<String>& files);
241         afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
242         afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
243         afx_msg void OnPluginUnpackMode(UINT nID);
244         afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
245         afx_msg void OnPluginPrediffMode(UINT nID);
246         afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
247         afx_msg void OnReloadPlugins();
248         afx_msg void OnSaveConfigData();
249         afx_msg void OnFileNew();
250         afx_msg void OnFileNew3();
251         afx_msg void OnToolsFilters();
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);
268 #else
269         afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
270 #endif
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 OnHelpCheckForUpdates();
279         afx_msg void OnFileOpenConflict();
280         afx_msg void OnPluginsList();
281         afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
282         afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
283         afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
284         afx_msg void OnDiffWhitespace(UINT nID);
285         afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
286         afx_msg void OnDiffCaseSensitive();
287         afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
288         afx_msg void OnDiffIgnoreEOL();
289         afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
290         afx_msg void OnCompareMethod(UINT nID);
291         afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
292         afx_msg void OnMRUs(UINT nID);
293         afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
294         afx_msg void OnDestroy();
295         //}}AFX_MSG
296         DECLARE_MESSAGE_MAP()
297
298 private:
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);
307         CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc);
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 );
315 };
316
317 CMainFrame * GetMainFrame(); // access to the singleton main frame object
318
319 /////////////////////////////////////////////////////////////////////////////
320
321 //{{AFX_INSERT_LOCATION}}
322 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.