OSDN Git Service

0b432d3c453450e889636b4bf0bef1abac93ba35
[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 SourceControl;
46 class DropHandler;
47
48 typedef std::shared_ptr<TempFile> TempFilePtr;
49
50 // typed lists (homogenous pointer lists)
51 typedef CTypedPtrList<CPtrList, COpenDoc *> OpenDocList;
52 typedef CTypedPtrList<CPtrList, CMergeDoc *> MergeDocList;
53 typedef CTypedPtrList<CPtrList, CDirDoc *> DirDocList;
54 typedef CTypedPtrList<CPtrList, CHexMergeDoc *> HexMergeDocList;
55
56 class PackingInfo;
57 class CLanguageSelect;
58
59 /**
60  * @brief Frame class containing save-routines etc
61  */
62 class CMainFrame : public CMDIFrameWnd
63 {
64         friend CLanguageSelect;
65         DECLARE_DYNAMIC(CMainFrame)
66 public:
67         /**
68          * @brief Frame/View/Document types.
69          */
70         enum FRAMETYPE
71         {
72                 FRAME_FOLDER, /**< Folder compare frame. */
73                 FRAME_FILE, /**< File compare frame. */
74                 FRAME_HEXFILE, /**< Hex file compare frame. */
75                 FRAME_IMGFILE, /**< Image file compare frame. */
76                 FRAME_OTHER, /**< No frame? */
77         };
78
79         CMainFrame();
80
81 // Attributes
82 public: 
83         BOOL m_bShowErrors; /**< Show folder compare error items? */
84         LOGFONT m_lfDiff; /**< MergeView user-selected font */
85         LOGFONT m_lfDir; /**< DirView user-selected font */
86         static const TCHAR szClassName[];
87 // Operations
88 public:
89         HMENU NewDirViewMenu();
90         HMENU NewMergeViewMenu();
91         HMENU NewHexMergeViewMenu();
92         HMENU NewImgMergeViewMenu();
93         HMENU NewOpenViewMenu();
94         HMENU NewDefaultMenu(int ID = 0);
95         HMENU GetScriptsSubmenu(HMENU mainMenu);
96         HMENU GetPrediffersSubmenu(HMENU mainMenu);
97         void UpdatePrediffersMenu();
98
99         BOOL DoFileOpen(const PathContext *pFiles = NULL,
100                 const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, const String& sReportFile = _T(""), bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
101         bool ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
102                 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
103         bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
104                 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
105         bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
106                 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
107         bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
108                 const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
109
110         void UpdateResources();
111         void ClearStatusbarItemCount();
112         void ApplyDiffOptions();
113         void SelectFilter();
114         void StartFlashing();
115         bool AskCloseConfirmation();
116         BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
117         FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
118         void UpdateDocTitle();
119         void ReloadMenu();
120         DropHandler *GetDropHandler() const { return m_pDropHandler; }
121
122 // Overrides
123         virtual void GetMessageString(UINT nID, CString& rMessage) const;
124         // ClassWizard generated virtual function overrides
125         //{{AFX_VIRTUAL(CMainFrame)
126 public:
127         virtual void ActivateFrame(int nCmdShow = -1);
128         virtual BOOL PreTranslateMessage(MSG* pMsg);
129         virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
130         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
131         //}}AFX_VIRTUAL
132
133 // Implementation methods
134 protected:
135         virtual ~CMainFrame();
136
137
138 // Public implementation data
139 public:
140         BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
141
142 // Implementation data
143 protected:
144
145
146         // control bar embedded members
147         CStatusBar  m_wndStatusBar;
148         CReBar m_wndReBar;
149         CToolBar m_wndToolBar;
150         CMDITabBar m_wndTabBar;
151
152         /** @brief Toolbar image table indexes. */
153         enum TOOLBAR_IMAGES
154         {
155                 TOOLBAR_IMAGES_ENABLED,
156                 TOOLBAR_IMAGES_DISABLED,
157                 TOOLBAR_IMAGES_COUNT
158         };
159
160         CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
161
162         enum
163         {
164                 MENU_DEFAULT,
165                 MENU_MERGEVIEW,
166                 MENU_DIRVIEW,
167                 MENU_HEXMERGEVIEW,
168                 MENU_IMGMERGEVIEW,
169                 MENU_OPENVIEW,
170                 MENU_COUNT, // Add new items before this item
171         };
172         /**
173          * Menu frames - for which frame(s) the menu is.
174          */
175         enum
176         {
177                 MENU_MAINFRM = 0x000001,
178                 MENU_FILECMP = 0x000002,
179                 MENU_FOLDERCMP = 0x000004,
180                 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
181         };
182
183         /**
184          * A structure attaching a menu item, icon and menu types to apply to.
185          */
186         struct MENUITEM_ICON
187         {
188                 int menuitemID;   /**< Menu item's ID. */
189                 int iconResID;    /**< Icon's resource ID. */
190                 int menusToApply; /**< For which menus to apply. */
191         };
192
193         static const MENUITEM_ICON m_MenuIcons[];
194
195         std::unique_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
196         std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
197         DropHandler *m_pDropHandler;
198
199 // Generated message map functions
200 protected:
201         //{{AFX_MSG(CMainFrame)
202         afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
203         afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
204         afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
205         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
206         afx_msg void OnFileOpen();
207         afx_msg void OnHelpGnulicense();
208         afx_msg void OnOptions();
209         afx_msg void OnViewSelectfont();
210         afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
211         afx_msg void OnViewUsedefaultfont();
212         afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
213         afx_msg void OnHelpContents();
214         afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
215         afx_msg void OnClose();
216         afx_msg void OnToolsGeneratePatch();
217         afx_msg void OnDropFiles(const std::vector<String>& files);
218         afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
219         afx_msg void OnPluginUnpackMode(UINT nID);
220         afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
221         afx_msg void OnPluginPrediffMode(UINT nID);
222         afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
223         afx_msg void OnReloadPlugins();
224         afx_msg void OnSaveConfigData();
225         afx_msg void OnFileNew();
226         afx_msg void OnFileNew3();
227         afx_msg void OnToolsFilters();
228         afx_msg void OnViewStatusBar();
229         afx_msg void OnViewToolbar();
230         afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
231         afx_msg void OnViewTabBar();
232         afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
233         afx_msg void OnResizePanes();
234         afx_msg void OnFileOpenproject();
235         afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
236         afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
237         afx_msg void OnWindowCloseAll();
238         afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
239         afx_msg void OnSaveProject();
240 #if _MFC_VER > 0x0600
241         afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
242 #else
243         afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
244 #endif
245         afx_msg void OnToolbarSize(UINT id);
246         afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI);
247         afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
248         afx_msg void OnHelpCheckForUpdates();
249         afx_msg void OnUpdateHelpCheckForUpdates(CCmdUI* pCmdUI);
250         afx_msg void OnFileOpenConflict();
251         afx_msg void OnPluginsList();
252         afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
253         afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
254         afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
255         afx_msg void OnDiffWhitespace(UINT nID);
256         afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
257         afx_msg void OnDiffCaseSensitive();
258         afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
259         afx_msg void OnDiffIgnoreEOL();
260         afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
261         afx_msg void OnIncludeSubfolders();
262         afx_msg void OnUpdateIncludeSubfolders(CCmdUI* pCmdUI);
263         afx_msg void OnCompareMethod(UINT nID);
264         afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
265         afx_msg void OnMRUs(UINT nID);
266         afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
267         afx_msg void OnDestroy();
268         //}}AFX_MSG
269         DECLARE_MESSAGE_MAP()
270
271 private:
272         void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
273         void FileNew(int nPanes);
274         OpenDocList &GetAllOpenDocs();
275         MergeDocList &GetAllMergeDocs();
276         DirDocList &GetAllDirDocs();
277         HexMergeDocList &GetAllHexMergeDocs();
278         void UpdateFont(FRAMETYPE frame);
279         BOOL CreateToolbar();
280         BOOL CreateComboBoxOnToolbar();
281         CMergeEditView * GetActiveMergeEditView();
282         void LoadToolbarImages();
283         HMENU NewMenu( int view, int ID );
284 };
285
286 CMainFrame * GetMainFrame(); // access to the singleton main frame object
287
288 /////////////////////////////////////////////////////////////////////////////
289
290 //{{AFX_INSERT_LOCATION}}
291 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.