OSDN Git Service

Use __super
[winmerge-jp/winmerge-jp.git] / Src / EditorFilepathBar.cpp
index 8633bef..7700e63 100644 (file)
@@ -21,6 +21,8 @@
 BEGIN_MESSAGE_MAP(CEditorFilePathBar, CDialogBar)
        ON_NOTIFY_EX (TTN_NEEDTEXT, 0, OnToolTipNotify)
        ON_CONTROL_RANGE (EN_SETFOCUS, IDC_STATIC_TITLE_PANE0, IDC_STATIC_TITLE_PANE2, OnSetFocusEdit)
+       ON_CONTROL_RANGE (EN_USER_CAPTION_CHANGED, IDC_STATIC_TITLE_PANE0, IDC_STATIC_TITLE_PANE2, OnChangeEdit)
+       ON_CONTROL_RANGE (EN_USER_FILE_SELECTED, IDC_STATIC_TITLE_PANE0, IDC_STATIC_TITLE_PANE2, OnSelectEdit)
 END_MESSAGE_MAP()
 
 
@@ -47,7 +49,7 @@ CEditorFilePathBar::~CEditorFilePathBar()
  */
 BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
 {
-       if (! CDialogBar::Create(pParentWnd, CEditorFilePathBar::IDD, 
+       if (! __super::Create(pParentWnd, CEditorFilePathBar::IDD, 
                        CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, CEditorFilePathBar::IDD))
                return FALSE;
 
@@ -56,11 +58,13 @@ BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
                m_font.CreateFontIndirect(&ncm.lfStatusFont);
 
        // subclass the two custom edit boxes
+       const int nLogPixelsY = CClientDC(this).GetDeviceCaps(LOGPIXELSY);
+       int cx = -MulDiv(ncm.lfStatusFont.lfHeight, nLogPixelsY, 72);
        for (int pane = 0; pane < static_cast<int>(std::size(m_Edit)); pane++)
        {
                m_Edit[pane].SubClassEdit(IDC_STATIC_TITLE_PANE0 + pane, this);
                m_Edit[pane].SetFont(&m_font);
-               m_Edit[pane].SetMargins(4, 4);
+               m_Edit[pane].SetMargins(4, 4 + cx);
        }
        return TRUE;
 };
@@ -83,12 +87,12 @@ void CEditorFilePathBar::Resize()
        if (m_hWnd == nullptr)
                return;
 
-       WINDOWPLACEMENT infoBar;
+       WINDOWPLACEMENT infoBar = {};
        GetWindowPlacement(&infoBar);
 
-       int widths[3];
+       int widths[3] = {};
        for (int pane = 0; pane < m_nPanes; pane++)
-               widths[pane] = (infoBar.rcNormalPosition.right / m_nPanes);
+               widths[pane] = (infoBar.rcNormalPosition.right / m_nPanes) - ((pane == 0) ? 7 : 5);
        Resize(widths);
 }
 
@@ -173,8 +177,29 @@ BOOL CEditorFilePathBar::OnToolTipNotify(UINT id, NMHDR * pTTTStruct, LRESULT *
 
 void CEditorFilePathBar::OnSetFocusEdit(UINT id)
 {
-       if (m_callbackfunc)
-               m_callbackfunc(id - IDC_STATIC_TITLE_PANE0);
+       if (m_setFocusCallbackfunc)
+               m_setFocusCallbackfunc(id - IDC_STATIC_TITLE_PANE0);
+}
+
+void CEditorFilePathBar::OnChangeEdit(UINT id)
+{
+       const int pane = id - IDC_STATIC_TITLE_PANE0;
+       if (m_captionChangedCallbackfunc)
+       {
+               CString text;
+               m_Edit[pane].GetWindowText(text);
+               m_captionChangedCallbackfunc(pane, (LPCTSTR)text);
+       }
+}
+
+void CEditorFilePathBar::OnSelectEdit(UINT id)
+{
+       const int pane = id - IDC_STATIC_TITLE_PANE0;
+       if (m_fileSelectedCallbackfunc)
+       {
+               String filename = m_Edit[pane].GetSelectedFile();
+               m_fileSelectedCallbackfunc(pane, filename);
+       }
 }
 
 /**