OSDN Git Service

Shell Extension for Windows 11 or later (5)
[winmerge-jp/winmerge-jp.git] / Src / EditorFilepathBar.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    WinMerge:  an interactive diff/merge utility
3 //    Copyright (C) 1997  Dean P. Grimm
4 //    SPDX-License-Identifier: GPL-2.0-or-later
5 /////////////////////////////////////////////////////////////////////////////
6 /** 
7  * @file  EditorFilePathBar.h
8  *
9  * @brief Interface of the CEditorFilePathBar class.
10  *
11  */
12 #pragma once
13
14 #include "FilepathEdit.h"
15 #include <functional>
16
17 /**
18  * Interface to update the header data.
19  */
20 class IHeaderBar
21 {
22 public:
23         virtual String GetText(int pane) const = 0;
24         virtual void SetText(int pane, const String& sString) = 0;
25         virtual void SetActive(int pane, bool bActive) = 0;
26         virtual void SetPaneCount(int nPanes) = 0;
27         virtual void Resize() = 0;
28         virtual void SetOnSetFocusCallback(const std::function<void(int)> callbackfunc) = 0;
29 };
30
31
32 /**
33  * @brief A dialog bar with two controls for left/right path.
34  * This class is a dialog bar for the both files path in the editor. 
35  * The bar looks like a statusBar (font, height). The control
36  * displays a tip for each path (as a tooltip). 
37  */
38 class CEditorFilePathBar : public CDialogBar, public IHeaderBar
39 {
40 public : 
41         CEditorFilePathBar();
42         ~CEditorFilePathBar();
43
44         BOOL Create( CWnd* pParentWnd);
45         virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
46
47 // Dialog Data
48         enum { IDD = IDD_EDITOR_HEADERBAR };
49         
50         void Resize() override;
51         void Resize(int widths[]);
52         void SetOnSetFocusCallback(const std::function<void(int)> callbackfunc) override;
53
54         // Implement IFilepathHeaders
55         void SetText(int pane, const String& sString) override;
56         String GetText(int pane) const override;
57         void SetActive(int pane, bool bActive) override;
58         void SetPaneCount(int nPanes) override;
59
60 protected:
61         //{{AFX_MSG(CEditorFilePathBar)
62         afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pTTTStruct, LRESULT * pResult );
63         afx_msg void OnSetFocusEdit(UINT id);
64         //}}AFX_MSG
65         DECLARE_MESSAGE_MAP();
66
67 private:
68         // this dialog uses custom edit boxes
69         CFilepathEdit m_Edit[3]; /**< Edit controls. */
70         CFont m_font; /**< Font for editcontrols */
71         int m_nPanes;
72         std::function<void(int)> m_callbackfunc;
73 };
74
75 inline void CEditorFilePathBar::SetPaneCount(int nPanes)
76 {
77         m_nPanes = nPanes;
78 }
79
80 /** 
81  * @brief Set callback function on EN_SETFOCUS notification
82  */
83 inline void CEditorFilePathBar::SetOnSetFocusCallback(const std::function<void(int)> callbackfunc)
84 {
85         m_callbackfunc = callbackfunc;
86 }
87