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 #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         enum { WM_NONINTERACTIVE = 888 }; // timer value
80
81         CMainFrame();
82
83 // Attributes
84 public: 
85         BOOL m_bShowErrors; /**< Show folder compare error items? */
86         LOGFONT m_lfDiff; /**< MergeView user-selected font */
87         LOGFONT m_lfDir; /**< DirView user-selected font */
88         static const TCHAR szClassName[];
89 // Operations
90 public:
91         HMENU NewDirViewMenu();
92         HMENU NewMergeViewMenu();
93         HMENU NewHexMergeViewMenu();
94         HMENU NewImgMergeViewMenu();
95         HMENU NewOpenViewMenu();
96         HMENU NewDefaultMenu(int ID = 0);
97         HMENU GetScriptsSubmenu(HMENU mainMenu);
98         HMENU GetPrediffersSubmenu(HMENU mainMenu);
99         void UpdatePrediffersMenu();
100
101         BOOL DoFileOpen(const PathContext *pFiles = NULL,
102                 const DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
103         int ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
104                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
105         int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
106                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
107         void ShowHexMergeDoc(CDirDoc * pDirDoc,
108                 const PathContext &paths, const bool bRO[]);
109         int ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
110                 const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
111
112         void UpdateResources();
113         CString SetStatus(LPCTSTR status);
114         void ClearStatusbarItemCount();
115         void ApplyDiffOptions();
116         void ApplyViewWhitespace();
117         void SetEOLMixed(BOOL bAllow);
118         void SelectFilter();
119         void StartFlashing();
120         bool AskCloseConfirmation();
121         BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
122         FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
123         void UpdateDocTitle();
124         void ReloadMenu();
125
126 // Overrides
127         virtual void GetMessageString(UINT nID, CString& rMessage) const;
128         // ClassWizard generated virtual function overrides
129         //{{AFX_VIRTUAL(CMainFrame)
130 public:
131         virtual void ActivateFrame(int nCmdShow = -1);
132         virtual BOOL PreTranslateMessage(MSG* pMsg);
133         virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
134         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
135         //}}AFX_VIRTUAL
136
137 // Implementation methods
138 protected:
139         virtual ~CMainFrame();
140
141
142 // Public implementation data
143 public:
144         BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
145         BOOL m_bFlashing; /**< Window is flashing. */
146
147         /** @brief Possible toolbar image sizes. */
148         enum TOOLBAR_SIZE
149         {
150                 TOOLBAR_SIZE_16x16,
151                 TOOLBAR_SIZE_32x32,
152         };
153
154 // Implementation data
155 protected:
156
157
158         // control bar embedded members
159         CStatusBar  m_wndStatusBar;
160         CReBar m_wndReBar;
161         CToolBar m_wndToolBar;
162         CMDITabBar m_wndTabBar;
163
164         /** @brief Toolbar image table indexes. */
165         enum TOOLBAR_IMAGES
166         {
167                 TOOLBAR_IMAGES_ENABLED,
168                 TOOLBAR_IMAGES_DISABLED,
169                 TOOLBAR_IMAGES_COUNT
170         };
171
172         CImageList m_ToolbarImages[TOOLBAR_IMAGES_COUNT]; /**< Images for toolbar */
173
174         enum
175         {
176                 MENU_DEFAULT,
177                 MENU_MERGEVIEW,
178                 MENU_DIRVIEW,
179                 MENU_HEXMERGEVIEW,
180                 MENU_IMGMERGEVIEW,
181                 MENU_OPENVIEW,
182                 MENU_COUNT, // Add new items before this item
183         };
184         /**
185          * Menu frames - for which frame(s) the menu is.
186          */
187         enum
188         {
189                 MENU_MAINFRM = 0x000001,
190                 MENU_FILECMP = 0x000002,
191                 MENU_FOLDERCMP = 0x000004,
192                 MENU_ALL = MENU_MAINFRM | MENU_FILECMP | MENU_FOLDERCMP
193         };
194
195         /**
196          * A structure attaching a menu item, icon and menu types to apply to.
197          */
198         struct MENUITEM_ICON
199         {
200                 int menuitemID;   /**< Menu item's ID. */
201                 int iconResID;    /**< Icon's resource ID. */
202                 int menusToApply; /**< For which menus to apply. */
203         };
204
205         static const MENUITEM_ICON m_MenuIcons[];
206
207         std::unique_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
208         std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
209         DropHandler *m_pDropHandler;
210
211 // Generated message map functions
212 protected:
213         //{{AFX_MSG(CMainFrame)
214         afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
215         afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) ;
216         afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
217         afx_msg void OnOptionsShowDifferent();
218         afx_msg void OnOptionsShowIdentical();
219         afx_msg void OnOptionsShowUniqueLeft();
220         afx_msg void OnOptionsShowUniqueRight();
221         afx_msg void OnOptionsShowBinaries();
222         afx_msg void OnOptionsShowSkipped();
223         afx_msg void OnUpdateOptionsShowdifferent(CCmdUI* pCmdUI);
224         afx_msg void OnUpdateOptionsShowidentical(CCmdUI* pCmdUI);
225         afx_msg void OnUpdateOptionsShowuniqueleft(CCmdUI* pCmdUI);
226         afx_msg void OnUpdateOptionsShowuniqueright(CCmdUI* pCmdUI);
227         afx_msg void OnUpdateOptionsShowBinaries(CCmdUI* pCmdUI);
228         afx_msg void OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI);
229         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
230         afx_msg void OnFileOpen();
231         afx_msg void OnHelpGnulicense();
232         afx_msg void OnOptions();
233         afx_msg void OnViewSelectfont();
234         afx_msg void OnUpdateViewSelectfont(CCmdUI* pCmdUI);
235         afx_msg void OnViewUsedefaultfont();
236         afx_msg void OnUpdateViewUsedefaultfont(CCmdUI* pCmdUI);
237         afx_msg void OnHelpContents();
238         afx_msg void OnUpdateHelpContents(CCmdUI* pCmdUI);
239         afx_msg void OnClose();
240         afx_msg void OnViewWhitespace();
241         afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
242         afx_msg void OnToolsGeneratePatch();
243         afx_msg void OnDropFiles(const std::vector<String>& files);
244         afx_msg void OnUpdatePluginUnpackMode(CCmdUI* pCmdUI);
245         afx_msg void OnPluginUnpackMode(UINT nID);
246         afx_msg void OnUpdatePluginPrediffMode(CCmdUI* pCmdUI);
247         afx_msg void OnPluginPrediffMode(UINT nID);
248         afx_msg void OnUpdateReloadPlugins(CCmdUI* pCmdUI);
249         afx_msg void OnReloadPlugins();
250         afx_msg void OnSaveConfigData();
251         afx_msg void OnFileNew();
252         afx_msg void OnFileNew3();
253         afx_msg void OnToolsFilters();
254         afx_msg void OnViewStatusBar();
255         afx_msg void OnViewToolbar();
256         afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI);
257         afx_msg void OnViewTabBar();
258         afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI);
259         afx_msg void OnResizePanes();
260         afx_msg void OnFileOpenproject();
261         afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
262         afx_msg LRESULT OnUser1(WPARAM wParam, LPARAM lParam);
263         afx_msg void OnTimer(UINT_PTR nIDEvent);
264         afx_msg void OnWindowCloseAll();
265         afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI);
266         afx_msg void OnSaveProject();
267         afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
268 #if _MFC_VER > 0x0600
269         afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
270 #else
271         afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
272 #endif
273         afx_msg void OnToolbarNone();
274         afx_msg void OnUpdateToolbarNone(CCmdUI* pCmdUI);
275         afx_msg void OnToolbarSmall();
276         afx_msg void OnUpdateToolbarSmall(CCmdUI* pCmdUI);
277         afx_msg void OnToolbarBig();
278         afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI);
279         afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
280         afx_msg void OnHelpCheckForUpdates();
281         afx_msg void OnFileOpenConflict();
282         afx_msg void OnPluginsList();
283         afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI);
284         afx_msg void OnDiffOptionsDropDown(NMHDR* pNMHDR, LRESULT* pResult);
285         afx_msg void OnUpdateDiffOptions(CCmdUI* pCmdUI);
286         afx_msg void OnDiffWhitespace(UINT nID);
287         afx_msg void OnUpdateDiffWhitespace(CCmdUI* pCmdUI);
288         afx_msg void OnDiffCaseSensitive();
289         afx_msg void OnUpdateDiffCaseSensitive(CCmdUI* pCmdUI);
290         afx_msg void OnDiffIgnoreEOL();
291         afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
292         afx_msg void OnCompareMethod(UINT nID);
293         afx_msg void OnUpdateCompareMethod(CCmdUI* pCmdUI);
294         afx_msg void OnMRUs(UINT nID);
295         afx_msg void OnUpdateNoMRUs(CCmdUI* pCmdUI);
296         afx_msg void OnDestroy();
297         //}}AFX_MSG
298         DECLARE_MESSAGE_MAP()
299
300 private:
301         void addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems = 20);
302         void FileNew(int nPanes);
303         const OpenDocList &GetAllOpenDocs();
304         const MergeDocList &GetAllMergeDocs();
305         const DirDocList &GetAllDirDocs();
306         const HexMergeDocList &GetAllHexMergeDocs();
307         void RedisplayAllDirDocs();
308         void UpdateFont(FRAMETYPE frame);
309         BOOL CreateToolbar();
310         BOOL CreateComboBoxOnToolbar();
311         CMergeEditView * GetActiveMergeEditView();
312         void LoadToolbarImages();
313         HMENU NewMenu( int view, int ID );
314 };
315
316 CMainFrame * GetMainFrame(); // access to the singleton main frame object
317
318 /////////////////////////////////////////////////////////////////////////////
319
320 //{{AFX_INSERT_LOCATION}}
321 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.