OSDN Git Service

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