// WinMerge: an interactive diff/merge utility
// Copyright (C) 1997-2000 Thingamahoochie Software
// Author: Dean Grimm
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
+// SPDX-License-Identifier: GPL-2.0-or-later
/////////////////////////////////////////////////////////////////////////////
/**
* @file FilePathEdit.cpp
ON_WM_CONTEXTMENU()
ON_WM_CTLCOLOR_REFLECT()
ON_WM_NCPAINT()
+ ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
END_MESSAGE_MAP()
size_t iBegin = 0;
int nLines = 1;
- while (1)
+ while (true)
{
String line;
CFilepathEdit::CFilepathEdit()
: m_crBackGnd(RGB(255, 255, 255))
, m_crText(RGB(0,0,0))
- , m_bActive(FALSE)
+ , m_bActive(false)
{
}
* @brief Subclass the control.
* @param [in] nID ID of the control to subclass.
* @param [in] pParent Parent control of the control to subclass.
- * @return TRUE if succeeded, FALSE otherwise.
+ * @return `true` if succeeded, `false` otherwise.
*/
-BOOL CFilepathEdit::SubClassEdit(UINT nID, CWnd* pParent)
+bool CFilepathEdit::SubClassEdit(UINT nID, CWnd* pParent)
{
- m_bActive = FALSE;
+ m_bActive = false;
return SubclassDlgItem(nID, pParent);
};
/**
- * @brief Return the control's original text.
- * @return Control's original text.
- */
-void CFilepathEdit::GetOriginalText(String& rString) const
-{
- rString = m_sOriginalText;
-}
-
-/**
* @brief Set the text to show in the control.
* This function sets the text (original text) to show in the control.
* The control may modify the text for displaying in the GUI.
theApp.TranslateMenu(menu.m_hMenu);
BCMenu* pPopup = static_cast<BCMenu *>(menu.GetSubMenu(0));
- ASSERT(pPopup != NULL);
+ ASSERT(pPopup != nullptr);
DWORD sel = GetSel();
if (HIWORD(sel) == LOWORD(sel))
GetWindowRect(rect);
rect.OffsetRect(-rect.TopLeft());
dc.FillSolidRect(CRect(rect.left, rect.top, rect.left + margin, rect.bottom), GetDarkenColor(m_crBackGnd, 0.98));
- dc.FillSolidRect(CRect(rect.left, rect.top, rect.left + 1, rect.bottom), GetDarkenColor(m_crBackGnd, 0.90));
+ dc.FillSolidRect(CRect(rect.left, rect.top, rect.left + 1, rect.bottom), GetDarkenColor(m_crBackGnd, 0.96));
dc.FillSolidRect(CRect(rect.right - margin, rect.top, rect.right, rect.bottom), m_crBackGnd);
dc.FillSolidRect(CRect(rect.left + 1, rect.top, rect.right, rect.top + margin), GetDarkenColor(m_crBackGnd, 0.98));
- dc.FillSolidRect(CRect(rect.left, rect.top, rect.right, rect.top + 1), GetDarkenColor(m_crBackGnd, 0.90));
+ dc.FillSolidRect(CRect(rect.left, rect.top, rect.right, rect.top + 1), GetDarkenColor(m_crBackGnd, 0.96));
dc.FillSolidRect(CRect(rect.left + margin, rect.bottom - margin, rect.right, rect.bottom), m_crBackGnd);
}
+void CFilepathEdit::OnEditCopy()
+{
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
+ if (nStartChar == nEndChar)
+ SetSel(0, -1);
+ Copy();
+ if (nStartChar == nEndChar)
+ SetSel(nStartChar, nEndChar);
+}
+
+BOOL CFilepathEdit::PreTranslateMessage(MSG *pMsg)
+{
+ if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+ {
+ if (::TranslateAccelerator (m_hWnd, static_cast<CFrameWnd *>(AfxGetMainWnd())->GetDefaultAccelerator(), pMsg))
+ return TRUE;
+ }
+ return CEdit::PreTranslateMessage(pMsg);
+}
+
/**
* @brief Set the control to look active/inactive.
* This function sets control to look like an active control. We don't
* have real focus on this control, but editor pane below it. However
* for user this active look informs which editor pane is active.
- * @param [in] bActive If TRUE set control look like active control.
+ * @param [in] bActive If `true` set control look like active control.
*/
void CFilepathEdit::SetActive(bool bActive)
{
m_bActive = bActive;
- if (m_hWnd == NULL)
+ if (m_hWnd == nullptr)
return;
CRect rcWnd;
SetTextColor(::GetSysColor(COLOR_INACTIVECAPTIONTEXT));
SetBackColor(::GetSysColor(COLOR_INACTIVECAPTION));
}
- RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
+ RedrawWindow(nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE);
}
/**
HBRUSH CFilepathEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
UNUSED_ALWAYS(nCtlColor);
- // Return a non-NULL brush if the parent's
+ // Return a non-`nullptr` brush if the parent's
//handler should not be called
//set text color