From 7e2f5ff74a20107a75ff766ba5a9b2197ee0738e Mon Sep 17 00:00:00 2001 From: sdottaka Date: Thu, 22 Aug 2024 22:04:10 +0900 Subject: [PATCH 01/22] WIP --- Src/Common/MDITabBar.cpp | 12 ++++++++++ Src/Common/MDITabBar.h | 1 + Src/MainFrm.cpp | 48 +++++++++++++++++++++++++++++++++++----- Src/MainFrm.h | 3 +++ Src/MenuBar.cpp | 5 +++++ 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index eed049a5cee..57b4dd77ccd 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -34,6 +34,7 @@ BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) ON_WM_MOUSELEAVE() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() + ON_MESSAGE(WM_SIZEPARENT, OnSizeParent) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -488,6 +489,17 @@ void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point) CWnd::OnLButtonUp(nFlags, point); } +LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam) +{ + AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; +// lpLayout->rect.left += 24; +// lpLayout->rect.right -= 24 * 3; + LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast(lpLayout)); +// lpLayout->rect.left -= 24; +// lpLayout->rect.right += 24 * 3; + return result; +} + CRect CMDITabBar::GetCloseButtonRect(int nItem) { CClientDC dc(this); diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index 231e730282e..da3449d46be 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -71,6 +71,7 @@ class CMDITabBar : public CControlBar afx_msg void OnMouseLeave(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam); //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 9264fb3b4cf..9713bf57440 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -69,6 +69,7 @@ #include "ClipboardHistory.h" #include "locality.h" #include "DirWatcher.h" +#include using std::vector; using boost::begin; @@ -220,6 +221,9 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_MESSAGE(WM_COPYDATA, OnCopyData) ON_MESSAGE(WM_USER+1, OnUser1) ON_WM_ACTIVATEAPP() + ON_WM_ACTIVATE() + ON_WM_NCCALCSIZE() + ON_WM_NCHITTEST() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>)) @@ -404,12 +408,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.SubclassWindow(m_hWndMDIClient); - if (!CreateToolbar()) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - if (!m_wndTabBar.Create(this)) { TRACE0("Failed to create tab bar\n"); @@ -420,6 +418,12 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) if (!GetOptionsMgr()->GetBool(OPT_SHOW_TABBAR)) __super::ShowControlBar(&m_wndTabBar, false, 0); + if (!CreateToolbar()) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); @@ -2481,6 +2485,38 @@ void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID) } } +void CMainFrame::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) +{ + MARGINS margins; + + margins.cxLeftWidth = 0; + margins.cxRightWidth = 0; + margins.cyBottomHeight = 0; + margins.cyTopHeight = 0; + + //HRESULT hr = _AfxDwmExtendFrameIntoClientArea(m_hWnd, &margins); + + __super::OnActivate(nState, pWndOther, bMinimized); +} + +void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) +{ + RECT rcWindow = lpncsp->rgrc[0]; + __super::OnNcCalcSize(bCalcValidRects, lpncsp); + lpncsp->rgrc[0].top = rcWindow.top + 0; +} + +LRESULT CMainFrame::OnNcHitTest(CPoint point) +{ + LRESULT res = 0; + //_AfxDwmDefWindowProc(GetSafeHwnd(), WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y), &res); + //return (UINT)res; + return HTMAXBUTTON; + return HTMINBUTTON; + return HTCAPTION; + return __super::OnNcHitTest(point); +} + BOOL CMainFrame::CreateToolbar() { if (!m_wndMenuBar.Create(this)) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index c1b4046959a..9df289b6d2b 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -381,6 +381,9 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI); afx_msg void OnSaveProject(); afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); + afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); + afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnToolbarSize(UINT id); afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); diff --git a/Src/MenuBar.cpp b/Src/MenuBar.cpp index 1f2b9b3b97b..2db2cc521ff 100644 --- a/Src/MenuBar.cpp +++ b/Src/MenuBar.cpp @@ -78,6 +78,9 @@ BOOL CMenuBar::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID) bool CMenuBar::AttachMenu(CMenu* pMenu) { + if (!m_hWnd) + return false; + CToolBarCtrl& toolbar = GetToolBarCtrl(); toolbar.SetRedraw(false); @@ -334,6 +337,8 @@ LRESULT CMenuBar::OnShowPopupMenu(WPARAM wParam, LPARAM lParam) BOOL CMenuBar::PreTranslateMessage(MSG* pMsg) { + if (!m_hWnd) + return FALSE; if (pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP) { if (pMsg->wParam == VK_F10 || pMsg->wParam == VK_MENU) From 00d9c2b16386083ac46ca3c9e8a1d1594cd43a35 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Fri, 23 Aug 2024 21:42:06 +0900 Subject: [PATCH 02/22] WIP --- Src/MainFrm.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 9713bf57440..cb23457bea2 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -2511,9 +2511,46 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point) LRESULT res = 0; //_AfxDwmDefWindowProc(GetSafeHwnd(), WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y), &res); //return (UINT)res; - return HTMAXBUTTON; - return HTMINBUTTON; - return HTCAPTION; + CRect rc; + GetWindowRect(&rc); + if (point.y < rc.top + 32) + { + const int bw = 32; + const int m = 4; + if (point.y < rc.top + 4) + { + if (point.x < rc.left + m) + return HTTOPLEFT; + else if (rc.right - m <= point.x) + return HTTOPRIGHT; + return HTTOP; + } + if (rc.bottom - m <= point.y) + { + if (point.x < rc.left + m) + return HTBOTTOMLEFT; + else if (rc.right - m <= point.x) + return HTBOTTOMRIGHT; + return HTBOTTOM; + } + if (point.x < rc.left + m) + return HTLEFT; + if (rc.right - m <= point.x) + return HTRIGHT; + if (rc.right - bw * 3 <= point.x && point.x < rc.right - bw * 2) + { + return HTMINBUTTON; + } + else if (rc.right - bw * 2 <= point.x && point.x < rc.right - bw) + { + return HTMAXBUTTON; + } + else if (rc.right - bw <= point.x && point.x < rc.right) + { + return HTCLOSE; + } + return HTCAPTION; + } return __super::OnNcHitTest(point); } From d0bf09aa20ab72a8e83b5b46a2e3895dd36d1af0 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 25 Aug 2024 18:59:08 +0900 Subject: [PATCH 03/22] WIP --- Src/MainFrm.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index cb23457bea2..8ed1de0b30b 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -449,6 +449,9 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.ModifyStyleEx(WS_EX_CLIENTEDGE, 0); +// const DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED; // false ? DWMNCRP_USEWINDOWSTYLE : DWMNCRP_DISABLED; +// _AfxDwmSetWindowAttribute(m_hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp)); + return 0; } From 4bee9e2f3b4effb8ce7ac9ce4044d1e1ff2191b4 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sun, 1 Sep 2024 09:39:14 +0900 Subject: [PATCH 04/22] WIP --- Src/Common/MDITabBar.cpp | 11 +++++++---- Src/MainFrm.cpp | 39 +++++++++++++++++++++++++++++++++++++-- Src/MainFrm.h | 1 + Src/Merge.vcxproj | 2 ++ Src/Merge.vcxproj.filters | 6 ++++++ Src/TitleBarHelper.cpp | 37 +++++++++++++++++++++++++++++++++++++ Src/TitleBarHelper.h | 26 ++++++++++++++++++++++++++ 7 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 Src/TitleBarHelper.cpp create mode 100644 Src/TitleBarHelper.h diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 57b4dd77ccd..154a4a1c9e0 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -491,12 +491,15 @@ void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point) LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam) { + CClientDC dc(this); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; -// lpLayout->rect.left += 24; -// lpLayout->rect.right -= 24 * 3; + lpLayout->rect.left += pointToPixel(18); + lpLayout->rect.right -= pointToPixel(18) * 3; LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast(lpLayout)); -// lpLayout->rect.left -= 24; -// lpLayout->rect.right += 24 * 3; + lpLayout->rect.left -= pointToPixel(18);; + lpLayout->rect.right += pointToPixel(18) * 3; return result; } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 8ed1de0b30b..7b11d071aeb 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -224,6 +224,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_WM_ACTIVATE() ON_WM_NCCALCSIZE() ON_WM_NCHITTEST() + ON_WM_PAINT() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>)) @@ -2516,9 +2517,14 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point) //return (UINT)res; CRect rc; GetWindowRect(&rc); - if (point.y < rc.top + 32) + CClientDC dc(this); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; + const int height = pointToPixel(24); + const int buttonWidth = pointToPixel(24); + if (point.y < rc.top + height) { - const int bw = 32; + const int bw = buttonWidth; const int m = 4; if (point.y < rc.top + 4) { @@ -2557,6 +2563,35 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point) return __super::OnNcHitTest(point); } +void CMainFrame::OnPaint() +{ + __super::OnPaint(); + CRect rcClient; + GetClientRect(&rcClient); + CClientDC dc(this); + dc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE)); + dc.DrawIcon(CPoint{ 0, 0 }, GetIcon(true)); + const int bw = 64; + CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw }; + CRect rc2{ rcClient.right - bw * 2, 0, rcClient.right - bw * 1, bw }; + CRect rc3{ rcClient.right - bw * 3, 0, rcClient.right - bw * 2, bw }; + HTHEME hTheme = OpenThemeData(m_hWnd, L"WINDOW"); + if (hTheme) + { + int state = CBS_NORMAL; + DrawThemeBackground(hTheme, dc.m_hDC, WP_CLOSEBUTTON, state, &rc1, nullptr); + DrawThemeBackground(hTheme, dc.m_hDC, WP_RESTOREBUTTON, state, &rc2, nullptr); + DrawThemeBackground(hTheme, dc.m_hDC, WP_MINBUTTON, state, &rc3, nullptr); + CloseThemeData(hTheme); + } + else + { + DrawFrameControl(dc.m_hDC, &rc1, DFC_CAPTION, DFCS_CAPTIONCLOSE); + DrawFrameControl(dc.m_hDC, &rc2, DFC_CAPTION, DFCS_CAPTIONMAX); + DrawFrameControl(dc.m_hDC, &rc3, DFC_CAPTION, DFCS_CAPTIONMIN); + } +} + BOOL CMainFrame::CreateToolbar() { if (!m_wndMenuBar.Create(this)) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 9df289b6d2b..5f0404d687c 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -383,6 +383,7 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnPaint(); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnToolbarSize(UINT id); afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI); diff --git a/Src/Merge.vcxproj b/Src/Merge.vcxproj index 17dc1c6a1bb..b8b16e8d6d3 100644 --- a/Src/Merge.vcxproj +++ b/Src/Merge.vcxproj @@ -1404,6 +1404,7 @@ $(IntDir)$(TargetName)2.pch + Use @@ -1647,6 +1648,7 @@ + diff --git a/Src/Merge.vcxproj.filters b/Src/Merge.vcxproj.filters index 7d185baf24c..74c14d6d5f3 100644 --- a/Src/Merge.vcxproj.filters +++ b/Src/Merge.vcxproj.filters @@ -735,6 +735,9 @@ MFCGui\Common\Source Files + + MFCGui\Common\Source Files + @@ -1406,6 +1409,9 @@ MFCGui\Common\Header Files + + MFCGui\Common\Header Files + diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp new file mode 100644 index 00000000000..92e1af647b1 --- /dev/null +++ b/Src/TitleBarHelper.cpp @@ -0,0 +1,37 @@ +// Copyright (c) 2024 Takashi Sawanaka +// SPDX-License-Identifier: BSL-1.0 +/** + * @file TitleBarHelper.cpp + * + * @brief Implementation of the CTitleBarHelper class + */ + +#include "StdAfx.h" +#include "TitleBarHelper.h" + +void CTitleBarHelper::DrawIcon(CDC& dc) +{ +} + +void CTitleBarHelper::DrawButtons(CDC& dc) +{ +} + +CRect CTitleBarHelper::GetIconRect() +{ + return CRect{}; +} + +CRect CTitleBarHelper::GetButtonsRect() +{ + return CRect{}; +} + +void CTitleBarHelper::Update(CSize size, bool maxmized) +{ +} + +int CTitleBarHelper::HitTest(CPoint pt) +{ + return HTTOP; +} diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h new file mode 100644 index 00000000000..4f0ff86cd79 --- /dev/null +++ b/Src/TitleBarHelper.h @@ -0,0 +1,26 @@ +/** + * @file TitleBarHelper.h + * + * @brief Declaration file for CTitleBarHelper + * + */ +#pragma once + +#include +#include +#include + +class CTitleBarHelper { +public: + CTitleBarHelper() {} + void DrawIcon(CDC& dc); + void DrawButtons(CDC& dc); + CRect GetIconRect(); + CRect GetButtonsRect(); + void Update(CSize size, bool maxmized); + int HitTest(CPoint pt); + +private: + CSize m_size; + int m_iconSize; +}; From 8b3cd59e8b069f662d65884f4f773411c9484c5c Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 1 Sep 2024 23:13:33 +0900 Subject: [PATCH 05/22] WIP --- Src/Common/MDITabBar.cpp | 24 +++++++--- Src/Common/MDITabBar.h | 16 ++++++- Src/MainFrm.cpp | 99 +++++++--------------------------------- Src/MainFrm.h | 4 +- Src/TitleBarHelper.cpp | 56 ++++++++++++++++++++++- Src/TitleBarHelper.h | 4 +- 6 files changed, 110 insertions(+), 93 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 154a4a1c9e0..047eb673e4d 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -43,6 +43,14 @@ static int determineIconSize() return GetSystemMetrics(SM_CXSMICON); } +BOOL CMDITabBar::Init(bool bOnTitleBar, float leftMarginPoint, float rightMarginPoint) +{ + m_bOnTitleBar = bOnTitleBar; + m_leftMarginPoint = leftMarginPoint; + m_rightMarginPoint = rightMarginPoint; + return true; +} + /** * @brief Create tab bar. * @param pParentWnd [in] main frame window pointer @@ -93,7 +101,7 @@ BOOL CMDITabBar::PreTranslateMessage(MSG* pMsg) */ CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { - if (GetItemCount() == 0) + if (!m_bOnTitleBar && GetItemCount() == 0) return CSize(SHRT_MAX, 0); TEXTMETRIC tm; @@ -463,7 +471,7 @@ void CMDITabBar::OnLButtonDown(UINT nFlags, CPoint point) InvalidateRect(m_rcCurrentCloseButtom); if (!m_bCloseButtonDown) { - if (DragDetect(point)) + if (DragDetect(point)) { m_nDraggingTabItemIndex = GetItemIndexFromPoint(point); SetCapture(); @@ -495,11 +503,13 @@ LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam) const int lpx = dc.GetDeviceCaps(LOGPIXELSX); auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; - lpLayout->rect.left += pointToPixel(18); - lpLayout->rect.right -= pointToPixel(18) * 3; + const int leftMargin = pointToPixel(m_leftMarginPoint); + const int rightMargin = pointToPixel(m_rightMarginPoint); + lpLayout->rect.left += leftMargin; + lpLayout->rect.right -= rightMargin; LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast(lpLayout)); - lpLayout->rect.left -= pointToPixel(18);; - lpLayout->rect.right += pointToPixel(18) * 3; + lpLayout->rect.left -= leftMargin; + lpLayout->rect.right += rightMargin; return result; } @@ -587,6 +597,7 @@ void CMDITabBar::UpdateToolTips(int nTabItemIndex) return; for (CWnd* pFrame = pParentWnd->GetTopWindow(); pFrame; pFrame = pFrame->GetNextWindow()) + { if (reinterpret_cast(tci.lParam) == pFrame->m_hWnd) { HWND hFrameWnd = pFrame->m_hWnd; @@ -620,4 +631,5 @@ void CMDITabBar::UpdateToolTips(int nTabItemIndex) m_nTooltipTabItemIndex = nTabItemIndex; return; } + } } diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index da3449d46be..78530fd0cda 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -16,6 +16,9 @@ class CMDITabBar : public CControlBar private: enum {MDITABBAR_MINTITLELENGTH = 8, MDITABBAR_MAXTITLELENGTH = 64}; + bool m_bOnTitleBar; + float m_leftMarginPoint; + float m_rightMarginPoint; bool m_bInSelchange; CMDIFrameWnd *m_pMainFrame; bool m_bMouseTracking; @@ -28,8 +31,19 @@ class CMDITabBar : public CControlBar int m_nTooltipTabItemIndex; /**< Index of the tab displaying tooltip */ public: - CMDITabBar() : m_bInSelchange(false), m_pMainFrame(nullptr), m_bMouseTracking(false), m_bCloseButtonDown(false), m_bAutoMaxWidth(true), m_nDraggingTabItemIndex(-1), m_nTooltipTabItemIndex(-1){} + CMDITabBar() + : m_bOnTitleBar(true) + , m_leftMarginPoint(0) + , m_rightMarginPoint(0) + , m_bInSelchange(false) + , m_pMainFrame(nullptr) + , m_bMouseTracking(false) + , m_bCloseButtonDown(false) + , m_bAutoMaxWidth(true) + , m_nDraggingTabItemIndex(-1) + , m_nTooltipTabItemIndex(-1) {} virtual ~CMDITabBar() {} + BOOL Init(bool bOnTitleBar, float iconWidthPoint, float buttonsWidthPoint); BOOL Create(CMDIFrameWnd* pParentWnd); void UpdateTabs(); bool GetAutoMaxWidth() const { return m_bAutoMaxWidth; } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 7b11d071aeb..903756f60dd 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -221,9 +221,9 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_MESSAGE(WM_COPYDATA, OnCopyData) ON_MESSAGE(WM_USER+1, OnUser1) ON_WM_ACTIVATEAPP() - ON_WM_ACTIVATE() ON_WM_NCCALCSIZE() ON_WM_NCHITTEST() + ON_WM_SIZE() ON_WM_PAINT() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu @@ -409,6 +409,8 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.SubclassWindow(m_hWndMDIClient); + m_wndTabBar.Init(true, 18.f, 18.f * 3); + if (!m_wndTabBar.Create(this)) { TRACE0("Failed to create tab bar\n"); @@ -450,9 +452,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.ModifyStyleEx(WS_EX_CLIENTEDGE, 0); -// const DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED; // false ? DWMNCRP_USEWINDOWSTYLE : DWMNCRP_DISABLED; -// _AfxDwmSetWindowAttribute(m_hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp)); - return 0; } @@ -2489,20 +2488,6 @@ void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID) } } -void CMainFrame::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) -{ - MARGINS margins; - - margins.cxLeftWidth = 0; - margins.cxRightWidth = 0; - margins.cyBottomHeight = 0; - margins.cyTopHeight = 0; - - //HRESULT hr = _AfxDwmExtendFrameIntoClientArea(m_hWnd, &margins); - - __super::OnActivate(nState, pWndOther, bMinimized); -} - void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { RECT rcWindow = lpncsp->rgrc[0]; @@ -2510,56 +2495,17 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs lpncsp->rgrc[0].top = rcWindow.top + 0; } +void CMainFrame::OnSize(UINT nType, int cx, int cy) +{ + m_titleBar.Update(this, nType, cx, cy); + __super::OnSize(nType, cx, cy); +} + LRESULT CMainFrame::OnNcHitTest(CPoint point) { - LRESULT res = 0; - //_AfxDwmDefWindowProc(GetSafeHwnd(), WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y), &res); - //return (UINT)res; - CRect rc; - GetWindowRect(&rc); - CClientDC dc(this); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; - const int height = pointToPixel(24); - const int buttonWidth = pointToPixel(24); - if (point.y < rc.top + height) - { - const int bw = buttonWidth; - const int m = 4; - if (point.y < rc.top + 4) - { - if (point.x < rc.left + m) - return HTTOPLEFT; - else if (rc.right - m <= point.x) - return HTTOPRIGHT; - return HTTOP; - } - if (rc.bottom - m <= point.y) - { - if (point.x < rc.left + m) - return HTBOTTOMLEFT; - else if (rc.right - m <= point.x) - return HTBOTTOMRIGHT; - return HTBOTTOM; - } - if (point.x < rc.left + m) - return HTLEFT; - if (rc.right - m <= point.x) - return HTRIGHT; - if (rc.right - bw * 3 <= point.x && point.x < rc.right - bw * 2) - { - return HTMINBUTTON; - } - else if (rc.right - bw * 2 <= point.x && point.x < rc.right - bw) - { - return HTMAXBUTTON; - } - else if (rc.right - bw <= point.x && point.x < rc.right) - { - return HTCLOSE; - } - return HTCAPTION; - } + LRESULT res = m_titleBar.HitTest(point); + if (res > HTNOWHERE) + return res; return __super::OnNcHitTest(point); } @@ -2570,26 +2516,15 @@ void CMainFrame::OnPaint() GetClientRect(&rcClient); CClientDC dc(this); dc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE)); - dc.DrawIcon(CPoint{ 0, 0 }, GetIcon(true)); + HICON hIcon = (HICON)SendMessage(WM_GETICON, ICON_SMALL2, 0); + if (hIcon == nullptr) + hIcon = (HICON)GetClassLongPtr(m_hWnd, GCLP_HICONSM); + if (hIcon != nullptr) + DrawIconEx(dc.m_hDC, 8, 8, hIcon, 16, 16, 0, nullptr, DI_NORMAL); const int bw = 64; CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw }; CRect rc2{ rcClient.right - bw * 2, 0, rcClient.right - bw * 1, bw }; CRect rc3{ rcClient.right - bw * 3, 0, rcClient.right - bw * 2, bw }; - HTHEME hTheme = OpenThemeData(m_hWnd, L"WINDOW"); - if (hTheme) - { - int state = CBS_NORMAL; - DrawThemeBackground(hTheme, dc.m_hDC, WP_CLOSEBUTTON, state, &rc1, nullptr); - DrawThemeBackground(hTheme, dc.m_hDC, WP_RESTOREBUTTON, state, &rc2, nullptr); - DrawThemeBackground(hTheme, dc.m_hDC, WP_MINBUTTON, state, &rc3, nullptr); - CloseThemeData(hTheme); - } - else - { - DrawFrameControl(dc.m_hDC, &rc1, DFC_CAPTION, DFCS_CAPTIONCLOSE); - DrawFrameControl(dc.m_hDC, &rc2, DFC_CAPTION, DFCS_CAPTIONMAX); - DrawFrameControl(dc.m_hDC, &rc3, DFC_CAPTION, DFCS_CAPTIONMIN); - } } BOOL CMainFrame::CreateToolbar() diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 5f0404d687c..b0d517e47f7 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -22,6 +22,7 @@ #include "OptionsDef.h" #include "OptionsMgr.h" #include "FileOpenFlags.h" +#include "TitleBarHelper.h" class BCMenu; class CDirView; @@ -342,6 +343,7 @@ class CMainFrame : public CMDIFrameWnd std::vector m_tempFiles; /**< List of possibly needed temp files. */ DropHandler *m_pDropHandler; std::unique_ptr m_pDirWatcher; + CTitleBarHelper m_titleBar; // Generated message map functions protected: @@ -381,10 +383,10 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI); afx_msg void OnSaveProject(); afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); - afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg void OnPaint(); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); + afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnToolbarSize(UINT id); afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index 92e1af647b1..76b4f48527b 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -27,11 +27,63 @@ CRect CTitleBarHelper::GetButtonsRect() return CRect{}; } -void CTitleBarHelper::Update(CSize size, bool maxmized) +void CTitleBarHelper::Update(CWnd* pWnd, UINT nType, int cx, int cy) { + m_size = CSize(cx, cy); + m_nType = nType; + m_pWnd = pWnd; } int CTitleBarHelper::HitTest(CPoint pt) { - return HTTOP; + if (!m_pWnd) + return HTNOWHERE; + CClientDC dc(m_pWnd); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; + const int height = pointToPixel(24); + const int buttonWidth = pointToPixel(24); + CRect rc; + m_pWnd->GetWindowRect(&rc); + if (pt.y < rc.top + height) + { + const int bw = buttonWidth; + const int m = 4; + if (pt.y < rc.top + 4) + { + if (pt.x < rc.left + m) + return HTTOPLEFT; + else if (rc.right - m <= pt.x) + return HTTOPRIGHT; + return HTTOP; + } + if (rc.bottom - m <= pt.y) + { + if (pt.x < rc.left + m) + return HTBOTTOMLEFT; + else if (rc.right - m <= pt.x) + return HTBOTTOMRIGHT; + return HTBOTTOM; + } + if (pt.x < rc.left + m) + return HTLEFT; + if (rc.right - m <= pt.x) + return HTRIGHT; + if (pt.x < rc.left + bw) + return HTSYSMENU; + if (rc.right - bw * 3 <= pt.x && pt.x < rc.right - bw * 2) + { + return HTMINBUTTON; + } + else if (rc.right - bw * 2 <= pt.x && pt.x < rc.right - bw) + { + return HTMAXBUTTON; + } + else if (rc.right - bw <= pt.x && pt.x < rc.right) + { + return HTCLOSE; + } + return HTCAPTION; + } + return HTCLIENT; } diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 4f0ff86cd79..a4662172941 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -17,10 +17,12 @@ class CTitleBarHelper { void DrawButtons(CDC& dc); CRect GetIconRect(); CRect GetButtonsRect(); - void Update(CSize size, bool maxmized); + void Update(CWnd* pWnd, UINT nType, int cx, int cy); int HitTest(CPoint pt); private: + CWnd* m_pWnd; CSize m_size; + int m_nType; int m_iconSize; }; From 6110e8f28f1b5399d7ef0221cf38f7107a0c466a Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sat, 7 Sep 2024 21:05:05 +0900 Subject: [PATCH 06/22] WIP --- Src/Common/MDITabBar.cpp | 33 +++++++++++++++++++++++++++------ Src/Common/MDITabBar.h | 6 +++++- Src/MainFrm.cpp | 14 ++++++-------- Src/TitleBarHelper.cpp | 12 ++++++++++-- Src/TitleBarHelper.h | 4 ++-- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 047eb673e4d..61b9eeaf48b 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -43,9 +43,10 @@ static int determineIconSize() return GetSystemMetrics(SM_CXSMICON); } -BOOL CMDITabBar::Init(bool bOnTitleBar, float leftMarginPoint, float rightMarginPoint) +BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized, float leftMarginPoint, float rightMarginPoint) { m_bOnTitleBar = bOnTitleBar; + m_bMaximized = bMaximized; m_leftMarginPoint = leftMarginPoint; m_rightMarginPoint = rightMarginPoint; return true; @@ -115,7 +116,10 @@ CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) const int r = pointToPixel(RR_RADIUS); const int sw = pointToPixel(RR_SHADOWWIDTH); - return CSize(SHRT_MAX, tm.tmHeight + (sw + r) * 2); + int my = m_bOnTitleBar ? (m_bMaximized ? (8 + 6) : 6) : 0; + CSize size(SHRT_MAX, my + tm.tmHeight + (sw + r) * 2); + SetItemSize(0, size.cy); + return size; } void CMDITabBar::OnPaint() @@ -368,18 +372,23 @@ void CMDITabBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) const int sw = pointToPixel(RR_SHADOWWIDTH); CRect rc = lpDraw->rcItem; + if (m_bOnTitleBar) + { + rc.top += 2 + (m_bMaximized ? 8 : 0); + rc.bottom -= 1; + } if (lpDraw->itemState & ODS_SELECTED) { const COLORREF clrShadow = CEColor::GetIntermediateColor(GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DFACE), 0.5f); if (GetSysColor(COLOR_3DFACE) == GetSysColor(COLOR_WINDOW)) { - DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, sw - 1, rc.Width() - sw * 2, rc.top - sw * 2 + 2, r, sw, + DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, rc.top + sw - 1, rc.Width() - sw * 2, rc.top - sw * 2 + 2, r, sw, GetSysColor(COLOR_HIGHLIGHT), clrShadow, GetSysColor(COLOR_3DFACE)); SetTextColor(lpDraw->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { - DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, sw - 1, rc.Width() - sw * 2, rc.Height() - sw * 2 + 2, r, sw, + DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, rc.top + sw - 1, rc.Width() - sw * 2, rc.Height() - sw * 2 + 2, r, sw, GetSysColor(COLOR_WINDOW), clrShadow, GetSysColor(COLOR_3DFACE)); SetTextColor(lpDraw->hDC, GetSysColor(COLOR_WINDOWTEXT)); } @@ -499,15 +508,27 @@ void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point) LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam) { + if (!m_bOnTitleBar) + return __super::OnSizeParent(wParam, lParam); CClientDC dc(this); const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; + auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; const int leftMargin = pointToPixel(m_leftMarginPoint); const int rightMargin = pointToPixel(m_rightMarginPoint); + if (m_bMaximized) + { +// lpLayout->rect.top += 8; +// lpLayout->rect.bottom -= 8; + } lpLayout->rect.left += leftMargin; lpLayout->rect.right -= rightMargin; LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast(lpLayout)); + if (m_bMaximized) + { +// lpLayout->rect.top -= 8; +// lpLayout->rect.bottom += 8; + } lpLayout->rect.left -= leftMargin; lpLayout->rect.right += rightMargin; return result; @@ -527,7 +548,7 @@ CRect CMDITabBar::GetCloseButtonRect(int nItem) rc.left = rc.right - size.cx - sw - r; rc.right = rc.left + size.cx; int y = (rcClient.top + rcClient.bottom) / 2; - rc.top = y - size.cy / 2 + 1; + rc.top = y - size.cy / 2 + 1 + ((m_bOnTitleBar && m_bMaximized) ? 8 / 2 : 0); rc.bottom = rc.top + size.cy; return rc; } diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index 78530fd0cda..163de4fb6c5 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -17,6 +17,7 @@ class CMDITabBar : public CControlBar enum {MDITABBAR_MINTITLELENGTH = 8, MDITABBAR_MAXTITLELENGTH = 64}; bool m_bOnTitleBar; + bool m_bMaximized; float m_leftMarginPoint; float m_rightMarginPoint; bool m_bInSelchange; @@ -33,6 +34,7 @@ class CMDITabBar : public CControlBar public: CMDITabBar() : m_bOnTitleBar(true) + , m_bMaximized(false) , m_leftMarginPoint(0) , m_rightMarginPoint(0) , m_bInSelchange(false) @@ -43,7 +45,7 @@ class CMDITabBar : public CControlBar , m_nDraggingTabItemIndex(-1) , m_nTooltipTabItemIndex(-1) {} virtual ~CMDITabBar() {} - BOOL Init(bool bOnTitleBar, float iconWidthPoint, float buttonsWidthPoint); + BOOL Update(bool bOnTitleBar, bool bMaxmized, float iconWidthPoint, float buttonsWidthPoint); BOOL Create(CMDIFrameWnd* pParentWnd); void UpdateTabs(); bool GetAutoMaxWidth() const { return m_bAutoMaxWidth; } @@ -70,6 +72,8 @@ class CMDITabBar : public CControlBar { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM) pHitTestInfo); } BOOL GetItemRect(int nItem, LPRECT lpRect) const { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); } + BOOL SetItemSize(int x, int y) const + { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_SETITEMSIZE, (WPARAM)0, (LPARAM)MAKELONG(x, y)); } protected: virtual BOOL PreTranslateMessage(MSG* pMsg); diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 903756f60dd..84619f60155 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -409,7 +409,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.SubclassWindow(m_hWndMDIClient); - m_wndTabBar.Init(true, 18.f, 18.f * 3); + m_wndTabBar.Update(true, false, 32.f, 18.f * 3); if (!m_wndTabBar.Create(this)) { @@ -2497,7 +2497,8 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs void CMainFrame::OnSize(UINT nType, int cx, int cy) { - m_titleBar.Update(this, nType, cx, cy); + m_titleBar.OnSize(this, nType, cx, cy); + m_wndTabBar.Update(true, (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); __super::OnSize(nType, cx, cy); } @@ -2515,12 +2516,9 @@ void CMainFrame::OnPaint() CRect rcClient; GetClientRect(&rcClient); CClientDC dc(this); - dc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE)); - HICON hIcon = (HICON)SendMessage(WM_GETICON, ICON_SMALL2, 0); - if (hIcon == nullptr) - hIcon = (HICON)GetClassLongPtr(m_hWnd, GCLP_HICONSM); - if (hIcon != nullptr) - DrawIconEx(dc.m_hDC, 8, 8, hIcon, 16, 16, 0, nullptr, DI_NORMAL); + CRect rc = { rcClient.left, rcClient.top, rcClient.right, rcClient.top + 32 }; + dc.FillSolidRect(&rc, GetSysColor(COLOR_3DFACE)); + m_titleBar.DrawIcon(this, dc); const int bw = 64; CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw }; CRect rc2{ rcClient.right - bw * 2, 0, rcClient.right - bw * 1, bw }; diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index 76b4f48527b..d8a11d6ab0b 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -8,9 +8,17 @@ #include "StdAfx.h" #include "TitleBarHelper.h" +#include "RoundedRectWithShadow.h" -void CTitleBarHelper::DrawIcon(CDC& dc) +void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) { + HICON hIcon = (HICON)pWnd->SendMessage(WM_GETICON, ICON_SMALL2, 0); + if (hIcon == nullptr) + hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM); + if (hIcon != nullptr) + { + DrawIconEx(dc.m_hDC, 8, 8 + (m_nType == SIZE_MAXIMIZED ? 8 : 0), hIcon, 16, 16, 0, nullptr, DI_NORMAL); + } } void CTitleBarHelper::DrawButtons(CDC& dc) @@ -27,7 +35,7 @@ CRect CTitleBarHelper::GetButtonsRect() return CRect{}; } -void CTitleBarHelper::Update(CWnd* pWnd, UINT nType, int cx, int cy) +void CTitleBarHelper::OnSize(CWnd* pWnd, UINT nType, int cx, int cy) { m_size = CSize(cx, cy); m_nType = nType; diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index a4662172941..41b94359dd2 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -13,11 +13,11 @@ class CTitleBarHelper { public: CTitleBarHelper() {} - void DrawIcon(CDC& dc); + void DrawIcon(CWnd* pWnd, CDC& dc); void DrawButtons(CDC& dc); CRect GetIconRect(); CRect GetButtonsRect(); - void Update(CWnd* pWnd, UINT nType, int cx, int cy); + void OnSize(CWnd* pWnd, UINT nType, int cx, int cy); int HitTest(CPoint pt); private: From e867c0df853fb684f862eb81903ed01f71ad1e7f Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 8 Sep 2024 20:31:51 +0900 Subject: [PATCH 07/22] crystaledit/editlib/parses/*: refactor --- .../crystaledit/editlib/parsers/abap.cpp | 38 ++-- .../crystaledit/editlib/parsers/batch.cpp | 73 +++---- .../crystaledit/editlib/parsers/cplusplus.cpp | 104 ++++------ Externals/crystaledit/editlib/parsers/dcl.cpp | 157 ++++++--------- .../crystaledit/editlib/parsers/dlang.cpp | 103 ++++------ .../crystaledit/editlib/parsers/fortran.cpp | 31 ++- .../crystaledit/editlib/parsers/fsharp.cpp | 105 ++++------- Externals/crystaledit/editlib/parsers/go.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/ini.cpp | 19 +- .../crystaledit/editlib/parsers/innosetup.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/is.cpp | 115 +++++------ .../crystaledit/editlib/parsers/lisp.cpp | 154 ++++++--------- Externals/crystaledit/editlib/parsers/lua.cpp | 91 ++++----- .../crystaledit/editlib/parsers/matlab.cpp | 91 ++++----- .../crystaledit/editlib/parsers/nsis.cpp | 103 ++++------ .../crystaledit/editlib/parsers/pascal.cpp | 91 ++++----- .../crystaledit/editlib/parsers/perl.cpp | 91 ++++----- Externals/crystaledit/editlib/parsers/php.cpp | 127 +++++-------- Externals/crystaledit/editlib/parsers/po.cpp | 91 ++++----- .../editlib/parsers/powershell.cpp | 43 ++--- .../crystaledit/editlib/parsers/python.cpp | 115 +++++------ .../crystaledit/editlib/parsers/rexx.cpp | 103 ++++------ .../crystaledit/editlib/parsers/rsrc.cpp | 103 ++++------ .../crystaledit/editlib/parsers/ruby.cpp | 103 ++++------ .../crystaledit/editlib/parsers/rust.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/sh.cpp | 103 ++++------ .../crystaledit/editlib/parsers/siod.cpp | 178 +++++++----------- .../crystaledit/editlib/parsers/smarty.cpp | 135 +++++-------- Externals/crystaledit/editlib/parsers/sql.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/tcl.cpp | 91 ++++----- .../crystaledit/editlib/parsers/verilog.cpp | 43 ++--- .../crystaledit/editlib/parsers/vhdl.cpp | 95 ++++------ 32 files changed, 1185 insertions(+), 1923 deletions(-) diff --git a/Externals/crystaledit/editlib/parsers/abap.cpp b/Externals/crystaledit/editlib/parsers/abap.cpp index 4da5cd5c92f..3283960aefd 100644 --- a/Externals/crystaledit/editlib/parsers/abap.cpp +++ b/Externals/crystaledit/editlib/parsers/abap.cpp @@ -1051,6 +1051,19 @@ static bool IsNumber(const tchar_t* pszChars, int nLength) return result; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -1210,14 +1223,7 @@ CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int { if (nIdentBegin >= 0) { - if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; @@ -1227,23 +1233,9 @@ CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int } if (nIdentBegin >= 0) - { - if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) dwCookie &= COOKIE_EXT_COMMENT; return dwCookie; } - - - - - diff --git a/Externals/crystaledit/editlib/parsers/batch.cpp b/Externals/crystaledit/editlib/parsers/batch.cpp index b88e694a3d3..d27ff45ba3f 100644 --- a/Externals/crystaledit/editlib/parsers/batch.cpp +++ b/Externals/crystaledit/editlib/parsers/batch.cpp @@ -686,6 +686,33 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, unsigned &dwCookie) +{ + if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || + (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) + ) + { + dwCookie=COOKIE_PREPROCESSOR; + } + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -846,28 +873,7 @@ CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, i } else { - if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || - (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) - ) - { - dwCookie=COOKIE_PREPROCESSOR; - } - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } bRedefineBlock = true; bDecIndex = true; @@ -878,28 +884,7 @@ CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || - (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) - ) - { - dwCookie=COOKIE_PREPROCESSOR; - } - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie = 0; diff --git a/Externals/crystaledit/editlib/parsers/cplusplus.cpp b/Externals/crystaledit/editlib/parsers/cplusplus.cpp index 0c9aaf58c89..88482f66b02 100644 --- a/Externals/crystaledit/editlib/parsers/cplusplus.cpp +++ b/Externals/crystaledit/editlib/parsers/cplusplus.cpp @@ -260,6 +260,44 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, + bool (*IsKeyword)(const tchar_t *pszChars, int nLength), + bool (*IsUser1Keyword)(const tchar_t *pszChars, int nLength)) +{ + if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} unsigned CrystalLineParser::ParseLineC (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -441,38 +479,7 @@ CrystalLineParser::ParseLineCJava (unsigned dwCookie, const tchar_t *pszChars, i { if (nIdentBegin >= 0) { - if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, IsKeyword, IsUser1Keyword); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -482,38 +489,7 @@ CrystalLineParser::ParseLineCJava (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, IsKeyword, IsUser1Keyword); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/dcl.cpp b/Externals/crystaledit/editlib/parsers/dcl.cpp index 6651d32a774..e22d8e621bf 100644 --- a/Externals/crystaledit/editlib/parsers/dcl.cpp +++ b/Externals/crystaledit/editlib/parsers/dcl.cpp @@ -123,6 +123,61 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '{' || pszChars[j] == ':') + { + bFunction = true; + } + break; + } + } + if (!bFunction) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == ':') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -268,56 +323,7 @@ CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '{' || pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - if (!bFunction) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -327,56 +333,7 @@ CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '{' || pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - if (!bFunction) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/dlang.cpp b/Externals/crystaledit/editlib/parsers/dlang.cpp index c274ede58ef..924ed633f1f 100644 --- a/Externals/crystaledit/editlib/parsers/dlang.cpp +++ b/Externals/crystaledit/editlib/parsers/dlang.cpp @@ -162,6 +162,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -457,38 +494,7 @@ CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, i { if (nIdentBegin >= 0) { - if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -498,38 +504,7 @@ CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | COOKIE_STRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/fortran.cpp b/Externals/crystaledit/editlib/parsers/fortran.cpp index 9f9265482b3..20ce2531493 100644 --- a/Externals/crystaledit/editlib/parsers/fortran.cpp +++ b/Externals/crystaledit/editlib/parsers/fortran.cpp @@ -239,6 +239,19 @@ IsFortranKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszFortranKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -363,14 +376,7 @@ CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -380,14 +386,7 @@ CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/fsharp.cpp b/Externals/crystaledit/editlib/parsers/fsharp.cpp index cf9746e3cfd..a1d7198055b 100644 --- a/Externals/crystaledit/editlib/parsers/fsharp.cpp +++ b/Externals/crystaledit/editlib/parsers/fsharp.cpp @@ -194,6 +194,44 @@ IsUserKeyword(const tchar_t* pszChars, int nLength) return ISXKEYWORD(s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); + } + else + { + // Todo: F# parenthesis are often optional, so functions are not usually this easy to detect! + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace(pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -403,39 +441,7 @@ CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - else - { - // Todo: F# parenthesis are often optional, so functions are not usually this easy to detect! - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace(pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -445,38 +451,7 @@ CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace(pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/go.cpp b/Externals/crystaledit/editlib/parsers/go.cpp index 258f00f95da..79780429dd7 100644 --- a/Externals/crystaledit/editlib/parsers/go.cpp +++ b/Externals/crystaledit/editlib/parsers/go.cpp @@ -108,6 +108,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -270,38 +307,7 @@ CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -311,38 +317,7 @@ CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING; diff --git a/Externals/crystaledit/editlib/parsers/ini.cpp b/Externals/crystaledit/editlib/parsers/ini.cpp index 0bf08df1070..e18d3ae95ee 100644 --- a/Externals/crystaledit/editlib/parsers/ini.cpp +++ b/Externals/crystaledit/editlib/parsers/ini.cpp @@ -24,6 +24,15 @@ #define new DEBUG_NEW #endif +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -195,10 +204,7 @@ CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -208,10 +214,7 @@ CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/innosetup.cpp b/Externals/crystaledit/editlib/parsers/innosetup.cpp index d7147909b49..8cfd9141079 100644 --- a/Externals/crystaledit/editlib/parsers/innosetup.cpp +++ b/Externals/crystaledit/editlib/parsers/innosetup.cpp @@ -297,6 +297,43 @@ IsLineSection(const tchar_t *pszChars, int nLength, bool& bCodeSection) return true; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -487,38 +524,7 @@ CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChar { if (nIdentBegin >= 0) { - if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -528,38 +534,7 @@ CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChar if (nIdentBegin >= 0) { - if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/is.cpp b/Externals/crystaledit/editlib/parsers/is.cpp index b991278fce0..29934c27078 100644 --- a/Externals/crystaledit/editlib/parsers/is.cpp +++ b/Externals/crystaledit/editlib/parsers/is.cpp @@ -429,6 +429,47 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -602,42 +643,7 @@ CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -647,42 +653,7 @@ CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/lisp.cpp b/Externals/crystaledit/editlib/parsers/lisp.cpp index 99f23166bae..34b4a39e03e 100644 --- a/Externals/crystaledit/editlib/parsers/lisp.cpp +++ b/Externals/crystaledit/editlib/parsers/lisp.cpp @@ -260,6 +260,60 @@ IsLispKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszLispKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, bool &bDefun) +{ + if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) + { + bDefun = true; + } + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + if (!bDefun) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (!bFunction) + { + for (int j = I; j >= 0; j--) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -407,55 +461,7 @@ CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -465,55 +471,7 @@ CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/lua.cpp b/Externals/crystaledit/editlib/parsers/lua.cpp index 0d44f315882..d163afe4648 100644 --- a/Externals/crystaledit/editlib/parsers/lua.cpp +++ b/Externals/crystaledit/editlib/parsers/lua.cpp @@ -56,6 +56,39 @@ IsLuaKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszLuaKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -236,34 +269,7 @@ CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -273,34 +279,7 @@ CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/matlab.cpp b/Externals/crystaledit/editlib/parsers/matlab.cpp index e1d66a2d8fd..9358631f4ee 100644 --- a/Externals/crystaledit/editlib/parsers/matlab.cpp +++ b/Externals/crystaledit/editlib/parsers/matlab.cpp @@ -92,6 +92,39 @@ IsMatlabKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszMatlabKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -263,34 +296,7 @@ CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -300,34 +306,7 @@ CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/nsis.cpp b/Externals/crystaledit/editlib/parsers/nsis.cpp index bec2854c00e..42bb1b0275c 100644 --- a/Externals/crystaledit/editlib/parsers/nsis.cpp +++ b/Externals/crystaledit/editlib/parsers/nsis.cpp @@ -434,6 +434,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -607,38 +644,7 @@ CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -648,38 +654,7 @@ CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/pascal.cpp b/Externals/crystaledit/editlib/parsers/pascal.cpp index 129beab830f..27e5b1d3466 100644 --- a/Externals/crystaledit/editlib/parsers/pascal.cpp +++ b/Externals/crystaledit/editlib/parsers/pascal.cpp @@ -112,6 +112,39 @@ IsPascalKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszPascalKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -272,34 +305,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -309,34 +315,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/perl.cpp b/Externals/crystaledit/editlib/parsers/perl.cpp index 6dbf348c2e2..bf8f8ee5322 100644 --- a/Externals/crystaledit/editlib/parsers/perl.cpp +++ b/Externals/crystaledit/editlib/parsers/perl.cpp @@ -256,6 +256,39 @@ IsPerlKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszPerlKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -380,34 +413,7 @@ CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -417,34 +423,7 @@ CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/php.cpp b/Externals/crystaledit/editlib/parsers/php.cpp index 61f64ef238c..2d264df0fa7 100644 --- a/Externals/crystaledit/editlib/parsers/php.cpp +++ b/Externals/crystaledit/editlib/parsers/php.cpp @@ -253,6 +253,51 @@ IsPhp2Keyword (const tchar_t *pszChars, int nLength) ISXKEYWORDI (s_apszPredefinedConstantList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, DWORD dwCookie) +{ + if (dwCookie & COOKIE_USER2) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); + } + else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePhp(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -417,46 +462,7 @@ CrystalLineParser::ParseLinePhpLanguage (unsigned dwCookie, const tchar_t *pszCh { if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -485,46 +491,7 @@ CrystalLineParser::ParseLinePhpLanguage (unsigned dwCookie, const tchar_t *pszCh if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_CHAR); diff --git a/Externals/crystaledit/editlib/parsers/po.cpp b/Externals/crystaledit/editlib/parsers/po.cpp index c3268b87502..15a3c57811a 100644 --- a/Externals/crystaledit/editlib/parsers/po.cpp +++ b/Externals/crystaledit/editlib/parsers/po.cpp @@ -52,6 +52,39 @@ IsPoKeyword (const tchar_t *pszChars, int nLength) return IsXKeyword (s_apszPoKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -176,34 +209,7 @@ CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -213,34 +219,7 @@ CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/powershell.cpp b/Externals/crystaledit/editlib/parsers/powershell.cpp index 20023437c43..2e27c20044b 100644 --- a/Externals/crystaledit/editlib/parsers/powershell.cpp +++ b/Externals/crystaledit/editlib/parsers/powershell.cpp @@ -341,6 +341,23 @@ IsCmdletKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszCmdletKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -491,18 +508,7 @@ CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszCha { if (nIdentBegin >= 0) { - if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -512,18 +518,7 @@ CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszCha if (nIdentBegin >= 0) { - if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/python.cpp b/Externals/crystaledit/editlib/parsers/python.cpp index bf7b9c9a29d..dcf1ca04f40 100644 --- a/Externals/crystaledit/editlib/parsers/python.cpp +++ b/Externals/crystaledit/editlib/parsers/python.cpp @@ -392,6 +392,47 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -516,42 +557,7 @@ CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -561,42 +567,7 @@ CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rexx.cpp b/Externals/crystaledit/editlib/parsers/rexx.cpp index c19c78dfaf8..79d78c4da14 100644 --- a/Externals/crystaledit/editlib/parsers/rexx.cpp +++ b/Externals/crystaledit/editlib/parsers/rexx.cpp @@ -111,6 +111,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -256,38 +293,7 @@ CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -297,38 +303,7 @@ CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rsrc.cpp b/Externals/crystaledit/editlib/parsers/rsrc.cpp index 71762164e82..69e1bbc541b 100644 --- a/Externals/crystaledit/editlib/parsers/rsrc.cpp +++ b/Externals/crystaledit/editlib/parsers/rsrc.cpp @@ -175,6 +175,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -348,38 +385,7 @@ CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -389,38 +395,7 @@ CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/ruby.cpp b/Externals/crystaledit/editlib/parsers/ruby.cpp index 5d3fcdf6c5e..4fc063d7ed0 100644 --- a/Externals/crystaledit/editlib/parsers/ruby.cpp +++ b/Externals/crystaledit/editlib/parsers/ruby.cpp @@ -120,6 +120,43 @@ IsRubyConstant (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszRubyConstantsList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -268,38 +305,7 @@ CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -309,38 +315,7 @@ CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rust.cpp b/Externals/crystaledit/editlib/parsers/rust.cpp index 339b3ac0ac6..032c281ac29 100644 --- a/Externals/crystaledit/editlib/parsers/rust.cpp +++ b/Externals/crystaledit/editlib/parsers/rust.cpp @@ -123,6 +123,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j]) && pszChars[j] != '!') + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -296,38 +333,7 @@ CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j]) && pszChars[j] != '!') - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -337,38 +343,7 @@ CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j]) && pszChars[j] != '!') - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | COOKIE_STRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/sh.cpp b/Externals/crystaledit/editlib/parsers/sh.cpp index fa5d4122fa1..b83cb379bc5 100644 --- a/Externals/crystaledit/editlib/parsers/sh.cpp +++ b/Externals/crystaledit/editlib/parsers/sh.cpp @@ -80,6 +80,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -204,38 +241,7 @@ CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -245,38 +251,7 @@ CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/siod.cpp b/Externals/crystaledit/editlib/parsers/siod.cpp index 0cdea385bd8..7159ac20eb3 100644 --- a/Externals/crystaledit/editlib/parsers/siod.cpp +++ b/Externals/crystaledit/editlib/parsers/siod.cpp @@ -336,6 +336,68 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, bool &bDefun) +{ + if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) + { + bDefun = true; + } + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + if (!bDefun) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (!bFunction) + { + for (int j = I; j >= 0; j--) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -483,63 +545,7 @@ CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -549,63 +555,7 @@ CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/smarty.cpp b/Externals/crystaledit/editlib/parsers/smarty.cpp index 964f0595b1d..cb0e926c4df 100644 --- a/Externals/crystaledit/editlib/parsers/smarty.cpp +++ b/Externals/crystaledit/editlib/parsers/smarty.cpp @@ -161,6 +161,55 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszVariableModifierList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, DWORD dwCookie) +{ + if (dwCookie & COOKIE_USER2) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSmarty(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -333,50 +382,7 @@ CrystalLineParser::ParseLineSmartyLanguage (unsigned dwCookie, const tchar_t *ps { if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -405,46 +411,7 @@ CrystalLineParser::ParseLineSmartyLanguage (unsigned dwCookie, const tchar_t *ps if (nIdentBegin >= 0) { - if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_CHAR); diff --git a/Externals/crystaledit/editlib/parsers/sql.cpp b/Externals/crystaledit/editlib/parsers/sql.cpp index 97ef97f3236..a268dc2230e 100644 --- a/Externals/crystaledit/editlib/parsers/sql.cpp +++ b/Externals/crystaledit/editlib/parsers/sql.cpp @@ -453,6 +453,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -600,38 +637,7 @@ CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -641,38 +647,7 @@ CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/tcl.cpp b/Externals/crystaledit/editlib/parsers/tcl.cpp index cf91ec62f83..620433886c2 100644 --- a/Externals/crystaledit/editlib/parsers/tcl.cpp +++ b/Externals/crystaledit/editlib/parsers/tcl.cpp @@ -48,6 +48,39 @@ IsTclKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszTclKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -172,34 +205,7 @@ CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -209,34 +215,7 @@ CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/verilog.cpp b/Externals/crystaledit/editlib/parsers/verilog.cpp index bfa4670e271..246b28f4d48 100644 --- a/Externals/crystaledit/editlib/parsers/verilog.cpp +++ b/Externals/crystaledit/editlib/parsers/verilog.cpp @@ -331,6 +331,23 @@ IsVerilogNumber (const tchar_t *pszChars, int nLength) return true; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -484,18 +501,7 @@ CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -505,18 +511,7 @@ CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/vhdl.cpp b/Externals/crystaledit/editlib/parsers/vhdl.cpp index 224e2a69f18..62c70452c26 100644 --- a/Externals/crystaledit/editlib/parsers/vhdl.cpp +++ b/Externals/crystaledit/editlib/parsers/vhdl.cpp @@ -328,6 +328,40 @@ IsVhdlChar (const tchar_t *pszChars, int nLength) return false; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, unsigned &dwCookie, int &nAttributeBegin) +{ + if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else if (pszChars[nIdentBegin] == '"') + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); + dwCookie |= COOKIE_STRING; + } + else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) + { + DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); + } + else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); + } + else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); + } +} + unsigned CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -446,36 +480,7 @@ CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else if (pszChars[nIdentBegin] == '"') - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - dwCookie |= COOKIE_STRING; - continue; - } - else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) - { - DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie, nAttributeBegin); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -485,35 +490,7 @@ CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else if (pszChars[nIdentBegin] == '"') - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - dwCookie |= COOKIE_STRING; - } - else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) - { - DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie, nAttributeBegin); } dwCookie &= COOKIE_EXT_COMMENT; From a4b4150c4257491c44ad87e893603378225eb633 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Wed, 11 Sep 2024 07:32:12 +0900 Subject: [PATCH 08/22] WIP --- Src/MainFrm.cpp | 14 ++++++- Src/MainFrm.h | 2 + Src/TitleBarHelper.cpp | 95 ++++++++++++++++++++++++------------------ Src/TitleBarHelper.h | 3 ++ 4 files changed, 71 insertions(+), 43 deletions(-) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 84619f60155..68daaa8e694 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -223,6 +223,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_WM_ACTIVATEAPP() ON_WM_NCCALCSIZE() ON_WM_NCHITTEST() + ON_WM_NCLBUTTONDOWN() + ON_WM_NCLBUTTONUP() ON_WM_SIZE() ON_WM_PAINT() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) @@ -2510,14 +2512,22 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point) return __super::OnNcHitTest(point); } +void CMainFrame::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + __super::OnNcLButtonDown(nHitTest, point); +} + +void CMainFrame::OnNcLButtonUp(UINT nFlags, CPoint point) +{ + __super::OnNcLButtonUp(nFlags, point); +} + void CMainFrame::OnPaint() { __super::OnPaint(); CRect rcClient; GetClientRect(&rcClient); CClientDC dc(this); - CRect rc = { rcClient.left, rcClient.top, rcClient.right, rcClient.top + 32 }; - dc.FillSolidRect(&rc, GetSysColor(COLOR_3DFACE)); m_titleBar.DrawIcon(this, dc); const int bw = 64; CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw }; diff --git a/Src/MainFrm.h b/Src/MainFrm.h index b0d517e47f7..c8a80d7892a 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -384,6 +384,8 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnSaveProject(); afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); afx_msg void OnPaint(); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnSize(UINT nType, int cx, int cy); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index d8a11d6ab0b..ca7bbcf1c3a 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -17,7 +17,15 @@ void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM); if (hIcon != nullptr) { - DrawIconEx(dc.m_hDC, 8, 8 + (m_nType == SIZE_MAXIMIZED ? 8 : 0), hIcon, 16, 16, 0, nullptr, DI_NORMAL); + const int height = PointToPixel(28.5f); + const int leftMarginWidth = PointToPixel(36.f); + const int cx = PointToPixel(12.f); + const int cy = PointToPixel(12.f); + const int my = (m_nType == SIZE_MAXIMIZED ? 8 : 0); + CRect rc = { 0, 0, leftMarginWidth, height + my }; + dc.FillSolidRect(&rc, GetSysColor(COLOR_3DFACE)); + DrawIconEx(dc.m_hDC, (leftMarginWidth - cx) / 2, (height - cy) / 2 + my, hIcon, + cx, cy, 0, nullptr, DI_NORMAL); } } @@ -40,6 +48,8 @@ void CTitleBarHelper::OnSize(CWnd* pWnd, UINT nType, int cx, int cy) m_size = CSize(cx, cy); m_nType = nType; m_pWnd = pWnd; + CClientDC dc(pWnd); + m_dpi = dc.GetDeviceCaps(LOGPIXELSX); } int CTitleBarHelper::HitTest(CPoint pt) @@ -47,51 +57,54 @@ int CTitleBarHelper::HitTest(CPoint pt) if (!m_pWnd) return HTNOWHERE; CClientDC dc(m_pWnd); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; - const int height = pointToPixel(24); - const int buttonWidth = pointToPixel(24); + const int height = PointToPixel(24); + const int buttonWidth = PointToPixel(24); CRect rc; + const int bw = buttonWidth; + const int m = 8; m_pWnd->GetWindowRect(&rc); - if (pt.y < rc.top + height) + if (pt.y < rc.top + 4) + { + if (pt.x < rc.left + m) + return HTTOPLEFT; + else if (rc.right - m <= pt.x) + return HTTOPRIGHT; + return HTTOP; + } + if (rc.bottom - m <= pt.y) { - const int bw = buttonWidth; - const int m = 4; - if (pt.y < rc.top + 4) - { - if (pt.x < rc.left + m) - return HTTOPLEFT; - else if (rc.right - m <= pt.x) - return HTTOPRIGHT; - return HTTOP; - } - if (rc.bottom - m <= pt.y) - { - if (pt.x < rc.left + m) - return HTBOTTOMLEFT; - else if (rc.right - m <= pt.x) - return HTBOTTOMRIGHT; - return HTBOTTOM; - } if (pt.x < rc.left + m) - return HTLEFT; - if (rc.right - m <= pt.x) - return HTRIGHT; - if (pt.x < rc.left + bw) - return HTSYSMENU; - if (rc.right - bw * 3 <= pt.x && pt.x < rc.right - bw * 2) - { - return HTMINBUTTON; - } - else if (rc.right - bw * 2 <= pt.x && pt.x < rc.right - bw) - { - return HTMAXBUTTON; - } - else if (rc.right - bw <= pt.x && pt.x < rc.right) - { - return HTCLOSE; - } + return HTBOTTOMLEFT; + else if (rc.right - m <= pt.x) + return HTBOTTOMRIGHT; + return HTBOTTOM; + } + if (pt.x < rc.left + m) + return HTLEFT; + if (rc.right - m <= pt.x) + return HTRIGHT; + if (pt.x < rc.left + bw) + return HTSYSMENU; + if (rc.right - bw * 3 <= pt.x && pt.x < rc.right - bw * 2) + { + return HTMINBUTTON; + } + else if (rc.right - bw * 2 <= pt.x && pt.x < rc.right - bw) + { + return HTMAXBUTTON; + } + else if (rc.right - bw <= pt.x && pt.x < rc.right) + { + return HTCLOSE; + } + if (pt.y < rc.top + height) + { return HTCAPTION; } return HTCLIENT; } + +int CTitleBarHelper::PointToPixel(float point) +{ + return static_cast(point * m_dpi / 72.f); +}; diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 41b94359dd2..481ed08b280 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -21,8 +21,11 @@ class CTitleBarHelper { int HitTest(CPoint pt); private: + int PointToPixel(float point); + CWnd* m_pWnd; CSize m_size; int m_nType; int m_iconSize; + int m_dpi; }; From 7496b3355f9b2077db0b59859a6f9b6578aca180 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Mon, 16 Sep 2024 20:50:30 +0900 Subject: [PATCH 09/22] WIP --- Src/Common/MDITabBar.cpp | 244 ++++++++++++++++++++++----------------- Src/Common/MDITabBar.h | 138 +++++++++++++--------- Src/MainFrm.cpp | 36 ------ Src/MainFrm.h | 5 - Src/TitleBarHelper.cpp | 14 +-- 5 files changed, 218 insertions(+), 219 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 61b9eeaf48b..67fc1f107a7 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -20,10 +20,10 @@ constexpr int RR_SHADOWWIDTH = 3; ///////////////////////////////////////////////////////////////////////////// // CMDITabBar -IMPLEMENT_DYNAMIC(CMDITabBar, CControlBar) +IMPLEMENT_DYNAMIC(CMyTabCtrl, CTabCtrl) -BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) - //{{AFX_MSG_MAP(CMDITabBar) +BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl) + //{{AFX_MSG_MAP(CMyTabCtrl) ON_WM_MBUTTONDOWN() ON_WM_CONTEXTMENU() ON_WM_PAINT() @@ -34,7 +34,20 @@ BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) ON_WM_MOUSELEAVE() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() - ON_MESSAGE(WM_SIZEPARENT, OnSizeParent) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +IMPLEMENT_DYNAMIC(CMDITabBar, CControlBar) + +BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) + //{{AFX_MSG_MAP(CMDITabBar) + ON_WM_SIZE() + ON_WM_NCHITTEST() + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_MESSAGE(WM_NCLBUTTONDBLCLK, OnNcForward) + ON_MESSAGE(WM_NCLBUTTONDOWN, OnNcForward) + ON_MESSAGE(WM_NCLBUTTONUP, OnNcForward) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -43,86 +56,32 @@ static int determineIconSize() return GetSystemMetrics(SM_CXSMICON); } -BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized, float leftMarginPoint, float rightMarginPoint) +BOOL CMyTabCtrl::Create(CMDIFrameWnd* pMainFrame, CWnd* pParent) { - m_bOnTitleBar = bOnTitleBar; - m_bMaximized = bMaximized; - m_leftMarginPoint = leftMarginPoint; - m_rightMarginPoint = rightMarginPoint; - return true; -} - -/** - * @brief Create tab bar. - * @param pParentWnd [in] main frame window pointer - */ -BOOL CMDITabBar::Create(CMDIFrameWnd* pMainFrame) -{ - m_pMainFrame = pMainFrame; - m_dwStyle = CBRS_TOP; - - if (!CWnd::Create(WC_TABCONTROL, nullptr, WS_CHILD | WS_VISIBLE | TCS_OWNERDRAWFIXED, CRect(0, 0, 0, 0), pMainFrame, AFX_IDW_CONTROLBAR_FIRST+30)) + if (!CTabCtrl::Create(WS_CHILD | WS_VISIBLE | TCS_OWNERDRAWFIXED, CRect(0, 0, 0, 0), pParent, 0)) return FALSE; - CClientDC dc(this); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; - const int r = pointToPixel(RR_RADIUS); - const int sw = pointToPixel(RR_SHADOWWIDTH); - TabCtrl_SetPadding(m_hWnd, sw + r * 2 + determineIconSize() / 2, sw + r); - - NONCLIENTMETRICS ncm = { sizeof NONCLIENTMETRICS }; - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0); - m_font.CreateFontIndirect(&ncm.lfMenuFont); - SetFont(&m_font); - + m_pMainFrame = pMainFrame; m_tooltips.Create(m_pMainFrame, TTS_NOPREFIX); m_tooltips.AddTool(this, _T("")); - return TRUE; } - /** * @brief Called before messages are translated. * Passes a mouse message to the ToolTip control for processing. * @param [in] pMsg Points to an MSG structure that contains the message to be chcecked */ -BOOL CMDITabBar::PreTranslateMessage(MSG* pMsg) +BOOL CMyTabCtrl::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_MOUSEMOVE) m_tooltips.RelayEvent(pMsg); // Call the parent method. - return CControlBar::PreTranslateMessage(pMsg); -} - -/** - * @brief This method calculates the horizontal size of a control bar. - */ -CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) -{ - if (!m_bOnTitleBar && GetItemCount() == 0) - return CSize(SHRT_MAX, 0); - - TEXTMETRIC tm; - CClientDC dc(this); - CFont *pOldFont = dc.SelectObject(&m_font); - dc.GetTextMetrics(&tm); - dc.SelectObject(pOldFont); - - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; - const int r = pointToPixel(RR_RADIUS); - const int sw = pointToPixel(RR_SHADOWWIDTH); - - int my = m_bOnTitleBar ? (m_bMaximized ? (8 + 6) : 6) : 0; - CSize size(SHRT_MAX, my + tm.tmHeight + (sw + r) * 2); - SetItemSize(0, size.cy); - return size; + return __super::PreTranslateMessage(pMsg); } -void CMDITabBar::OnPaint() +void CMyTabCtrl::OnPaint() { CPaintDC dc(this); dc.SelectObject(GetFont()); @@ -145,7 +104,7 @@ void CMDITabBar::OnPaint() } } -BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) +BOOL CMyTabCtrl::OnEraseBkgnd(CDC* pDC) { CRect rClient; GetClientRect(rClient); @@ -156,7 +115,7 @@ BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) /** * @brief Called when tab selection is changed. */ -BOOL CMDITabBar::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) +BOOL CMyTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) { TC_ITEM tci; tci.mask = TCIF_PARAM; @@ -171,7 +130,7 @@ BOOL CMDITabBar::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) /** * @brief Show context menu and handle user selection. */ -void CMDITabBar::OnContextMenu(CWnd *pWnd, CPoint point) +void CMyTabCtrl::OnContextMenu(CWnd *pWnd, CPoint point) { CPoint ptClient = point; ScreenToClient(&ptClient); @@ -238,7 +197,7 @@ void CMDITabBar::OnContextMenu(CWnd *pWnd, CPoint point) /** * @brief synchronize the tabs with all mdi client windows. */ -void CMDITabBar::UpdateTabs() +void CMyTabCtrl::UpdateTabs() { Invalidate(); @@ -342,7 +301,7 @@ void CMDITabBar::UpdateTabs() * @brief Called when middle mouse button is pressed. * This function closes the tab when the middle mouse button is pressed. */ -void CMDITabBar::OnMButtonDown(UINT nFlags, CPoint point) +void CMyTabCtrl::OnMButtonDown(UINT nFlags, CPoint point) { int index = GetItemIndexFromPoint(point); if (index < 0) @@ -355,7 +314,7 @@ void CMDITabBar::OnMButtonDown(UINT nFlags, CPoint point) pMDIChild->SendMessage(WM_SYSCOMMAND, SC_CLOSE); } -void CMDITabBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { TCHAR szBuf[256]; TCITEM item; @@ -364,7 +323,7 @@ void CMDITabBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) item.mask = TCIF_TEXT | TCIF_PARAM; item.pszText = szBuf; item.cchTextMax = sizeof(szBuf) / sizeof(TCHAR); - TabCtrl_GetItem(this->m_hWnd, lpDraw->itemID, &item); + GetItem(lpDraw->itemID, &item); const int lpx = ::GetDeviceCaps(lpDraw->hDC, LOGPIXELSX); auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; @@ -372,11 +331,6 @@ void CMDITabBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) const int sw = pointToPixel(RR_SHADOWWIDTH); CRect rc = lpDraw->rcItem; - if (m_bOnTitleBar) - { - rc.top += 2 + (m_bMaximized ? 8 : 0); - rc.bottom -= 1; - } if (lpDraw->itemState & ODS_SELECTED) { const COLORREF clrShadow = CEColor::GetIntermediateColor(GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DFACE), 0.5f); @@ -425,7 +379,7 @@ void CMDITabBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) } } -void CMDITabBar::OnMouseMove(UINT nFlags, CPoint point) +void CMyTabCtrl::OnMouseMove(UINT nFlags, CPoint point) { int nTabItemIndex = GetItemIndexFromPoint(point); CRect rc = GetCloseButtonRect(nTabItemIndex); @@ -462,7 +416,7 @@ void CMDITabBar::OnMouseMove(UINT nFlags, CPoint point) UpdateToolTips(nTabItemIndex); } -void CMDITabBar::OnMouseLeave() +void CMyTabCtrl::OnMouseLeave() { TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) }; tme.dwFlags = TME_LEAVE | TME_CANCEL; @@ -474,7 +428,7 @@ void CMDITabBar::OnMouseLeave() m_bCloseButtonDown = false; } -void CMDITabBar::OnLButtonDown(UINT nFlags, CPoint point) +void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point) { m_bCloseButtonDown = !!m_rcCurrentCloseButtom.PtInRect(point); InvalidateRect(m_rcCurrentCloseButtom); @@ -489,7 +443,7 @@ void CMDITabBar::OnLButtonDown(UINT nFlags, CPoint point) } } -void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point) +void CMyTabCtrl::OnLButtonUp(UINT nFlags, CPoint point) { if (m_nDraggingTabItemIndex >= 0) { @@ -506,35 +460,27 @@ void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point) CWnd::OnLButtonUp(nFlags, point); } -LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam) +void CMDITabBar::OnSize(UINT nType, int cx, int cy) { + __super::OnSize(nType, cx, cy); if (!m_bOnTitleBar) - return __super::OnSizeParent(wParam, lParam); - CClientDC dc(this); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; - AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; - const int leftMargin = pointToPixel(m_leftMarginPoint); - const int rightMargin = pointToPixel(m_rightMarginPoint); - if (m_bMaximized) - { -// lpLayout->rect.top += 8; -// lpLayout->rect.bottom -= 8; - } - lpLayout->rect.left += leftMargin; - lpLayout->rect.right -= rightMargin; - LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast(lpLayout)); - if (m_bMaximized) + return; + m_titleBar.OnSize(this, nType, cx, cy); + if (m_tabCtrl.m_hWnd) { -// lpLayout->rect.top -= 8; -// lpLayout->rect.bottom += 8; + CClientDC dc(this); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; + const int leftMargin = pointToPixel(m_leftMarginPoint); + const int rightMargin = pointToPixel(m_rightMarginPoint); + int my = (m_bMaximized) ? 8 : 0; + CSize size{ 0, cy - my }; + m_tabCtrl.MoveWindow(leftMargin, my, cx - leftMargin - rightMargin, cy - my, true); + m_tabCtrl.SetItemSize(size); } - lpLayout->rect.left -= leftMargin; - lpLayout->rect.right += rightMargin; - return result; } -CRect CMDITabBar::GetCloseButtonRect(int nItem) +CRect CMyTabCtrl::GetCloseButtonRect(int nItem) { CClientDC dc(this); const int lpx = dc.GetDeviceCaps(LOGPIXELSX); @@ -548,19 +494,19 @@ CRect CMDITabBar::GetCloseButtonRect(int nItem) rc.left = rc.right - size.cx - sw - r; rc.right = rc.left + size.cx; int y = (rcClient.top + rcClient.bottom) / 2; - rc.top = y - size.cy / 2 + 1 + ((m_bOnTitleBar && m_bMaximized) ? 8 / 2 : 0); + rc.top = y - size.cy / 2 + 1; rc.bottom = rc.top + size.cy; return rc; } -int CMDITabBar::GetItemIndexFromPoint(CPoint point) const +int CMyTabCtrl::GetItemIndexFromPoint(CPoint point) const { TCHITTESTINFO hit; hit.pt = point; return HitTest(&hit); } -void CMDITabBar::SwapTabs(int nIndexA, int nIndexB) +void CMyTabCtrl::SwapTabs(int nIndexA, int nIndexB) { TC_ITEM tciA = {0}, tciB = {0}; TCHAR szTextA[256], szTextB[256]; @@ -589,7 +535,7 @@ void CMDITabBar::SwapTabs(int nIndexA, int nIndexB) /** * @brief Get the maximum length of the title. */ -int CMDITabBar::GetMaxTitleLength() const +int CMyTabCtrl::GetMaxTitleLength() const { int nMaxTitleLength = m_bAutoMaxWidth ? static_cast(MDITABBAR_MAXTITLELENGTH - (GetItemCount() - 1) * 6) : MDITABBAR_MAXTITLELENGTH; if (nMaxTitleLength < MDITABBAR_MINTITLELENGTH) @@ -602,7 +548,7 @@ int CMDITabBar::GetMaxTitleLength() const * @brief Update tooltip text. * @param [in] nTabItemIndex Index of the tab displaying tooltip. */ -void CMDITabBar::UpdateToolTips(int nTabItemIndex) +void CMyTabCtrl::UpdateToolTips(int nTabItemIndex) { TC_ITEM tci; tci.mask = TCIF_PARAM; @@ -654,3 +600,85 @@ void CMDITabBar::UpdateToolTips(int nTabItemIndex) } } } + +BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized, float leftMarginPoint, float rightMarginPoint) +{ + m_bOnTitleBar = bOnTitleBar; + m_bMaximized = bMaximized; + m_leftMarginPoint = leftMarginPoint; + m_rightMarginPoint = rightMarginPoint; + return true; +} + +/** + * @brief Create tab bar. + * @param pParentWnd [in] main frame window pointer + */ +BOOL CMDITabBar::Create(CMDIFrameWnd* pMainFrame) +{ + m_dwStyle = CBRS_TOP; + + CWnd::Create(WC_STATIC, nullptr, WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), pMainFrame, AFX_IDW_CONTROLBAR_FIRST + 30); + + if (!m_tabCtrl.Create(pMainFrame, this)) + return FALSE; + + CClientDC dc(this); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; + const int r = pointToPixel(RR_RADIUS); + const int sw = pointToPixel(RR_SHADOWWIDTH); + m_tabCtrl.SetPadding(CSize(sw + r * 2 + determineIconSize() / 2, sw + r)); + + NONCLIENTMETRICS ncm = { sizeof NONCLIENTMETRICS }; + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0); + m_font.CreateFontIndirect(&ncm.lfMenuFont); + m_tabCtrl.SetFont(&m_font); + + return TRUE; +} + +/** + * @brief This method calculates the horizontal size of a control bar. + */ +CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) +{ + if (!m_bOnTitleBar && m_tabCtrl.GetItemCount() == 0) + return CSize(SHRT_MAX, 0); + + TEXTMETRIC tm; + CClientDC dc(this); + CFont *pOldFont = dc.SelectObject(&m_font); + dc.GetTextMetrics(&tm); + dc.SelectObject(pOldFont); + + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; + const int r = pointToPixel(RR_RADIUS); + const int sw = pointToPixel(RR_SHADOWWIDTH); + + int my = m_bOnTitleBar ? (m_bMaximized ? (8 + 6) : 6) : 0; + CSize size(SHRT_MAX, my + tm.tmHeight + (sw + r) * 2); + return size; +} + +LRESULT CMDITabBar::OnNcHitTest(CPoint point) +{ + return m_titleBar.HitTest(point); +} + +BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) +{ + CRect rClient; + GetClientRect(rClient); + pDC->FillSolidRect(rClient, GetSysColor(COLOR_3DFACE)); + return TRUE; +} + +void CMDITabBar::OnPaint() +{ + CPaintDC dc(this); + CRect rcClient; + GetClientRect(&rcClient); + m_titleBar.DrawIcon(AfxGetMainWnd(), dc); +} diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index 163de4fb6c5..be5b1c086d4 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -6,6 +6,75 @@ */ #pragma once +#include "TitleBarHelper.h" + +class CMyTabCtrl : public CTabCtrl +{ + enum { MDITABBAR_MINTITLELENGTH = 8, MDITABBAR_MAXTITLELENGTH = 64 }; + + DECLARE_DYNAMIC(CMyTabCtrl) +public: + CMyTabCtrl() + : m_bMouseTracking(false) + , m_bAutoMaxWidth(true) + , m_pMainFrame(nullptr) + , m_bCloseButtonDown(false) + , m_nDraggingTabItemIndex(-1) + , m_bInSelchange(false) + , m_nTooltipTabItemIndex(-1) + {} + +protected: + bool m_bInSelchange; + bool m_bAutoMaxWidth; + bool m_bMouseTracking; + bool m_bCloseButtonDown; + CRect m_rcCurrentCloseButtom; + int m_nDraggingTabItemIndex; + int m_nTooltipTabItemIndex; /**< Index of the tab displaying tooltip */ + CMDIFrameWnd *m_pMainFrame; + CToolTipCtrl m_tooltips; /**< Tooltip for the tab */ + +public: + BOOL Create(CMDIFrameWnd* pMainFrame, CWnd* pParent); + bool GetAutoMaxWidth() const { return m_bAutoMaxWidth; } + void SetAutoMaxWidth(bool bAutoMaxWidth) { m_bAutoMaxWidth = bAutoMaxWidth; } + void UpdateTabs(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMyTabCtrl) + //}}AFX_VIRTUAL +// Implementation +public: + virtual ~CMyTabCtrl() {} + +// Generated message map functions +protected: + virtual BOOL PreTranslateMessage(MSG* pMsg); + + //{{AFX_MSG(CMyTabCtrl) + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnMButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnSelchange(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnMouseLeave(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + + CRect GetCloseButtonRect(int nItem); + int GetItemIndexFromPoint(CPoint pt) const; + void SwapTabs(int nIndexA, int nIndexB); + int GetMaxTitleLength() const; + void UpdateToolTips(int index); +}; + /** * @brief Class for Tab bar. */ @@ -14,22 +83,14 @@ class CMDITabBar : public CControlBar DECLARE_DYNAMIC(CMDITabBar) private: - enum {MDITABBAR_MINTITLELENGTH = 8, MDITABBAR_MAXTITLELENGTH = 64}; bool m_bOnTitleBar; bool m_bMaximized; float m_leftMarginPoint; float m_rightMarginPoint; - bool m_bInSelchange; - CMDIFrameWnd *m_pMainFrame; - bool m_bMouseTracking; - bool m_bCloseButtonDown; - CRect m_rcCurrentCloseButtom; - bool m_bAutoMaxWidth; - int m_nDraggingTabItemIndex; + CMyTabCtrl m_tabCtrl; CFont m_font; - CToolTipCtrl m_tooltips; /**< Tooltip for the tab */ - int m_nTooltipTabItemIndex; /**< Index of the tab displaying tooltip */ + CTitleBarHelper m_titleBar; public: CMDITabBar() @@ -37,66 +98,29 @@ class CMDITabBar : public CControlBar , m_bMaximized(false) , m_leftMarginPoint(0) , m_rightMarginPoint(0) - , m_bInSelchange(false) - , m_pMainFrame(nullptr) - , m_bMouseTracking(false) - , m_bCloseButtonDown(false) - , m_bAutoMaxWidth(true) - , m_nDraggingTabItemIndex(-1) - , m_nTooltipTabItemIndex(-1) {} + {} virtual ~CMDITabBar() {} BOOL Update(bool bOnTitleBar, bool bMaxmized, float iconWidthPoint, float buttonsWidthPoint); BOOL Create(CMDIFrameWnd* pParentWnd); - void UpdateTabs(); - bool GetAutoMaxWidth() const { return m_bAutoMaxWidth; } - void SetAutoMaxWidth(bool bAutoMaxWidth) { m_bAutoMaxWidth = bAutoMaxWidth; } + void UpdateTabs() { m_tabCtrl.UpdateTabs(); } + bool GetAutoMaxWidth() const { return m_tabCtrl.GetAutoMaxWidth(); } + void SetAutoMaxWidth(bool bAutoMaxWidth) { m_tabCtrl.SetAutoMaxWidth(bAutoMaxWidth); } + int GetItemCount() const { return m_tabCtrl.GetItemCount(); } virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) {} virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); - int GetItemCount() const - { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, TCM_GETITEMCOUNT, 0, 0L); } - BOOL GetItem(int nItem, TCITEM* pTabCtrlItem) const - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem); } - BOOL SetItem(int nItem, TCITEM* pTabCtrlItem) - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); } - BOOL InsertItem(int nItem, TCITEM* pTabCtrlItem) - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem); } - BOOL DeleteItem(int nItem) - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_DELETEITEM, nItem, 0L); } - int GetCurSel() const - { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, TCM_GETCURSEL, 0, 0L); } - int SetCurSel(int nItem) - { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, TCM_SETCURSEL, nItem, 0L); } - int HitTest(TCHITTESTINFO* pHitTestInfo) const - { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM) pHitTestInfo); } - BOOL GetItemRect(int nItem, LPRECT lpRect) const - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect); } - BOOL SetItemSize(int x, int y) const - { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_SETITEMSIZE, (WPARAM)0, (LPARAM)MAKELONG(x, y)); } - protected: - virtual BOOL PreTranslateMessage(MSG* pMsg); //{{AFX_MSG(CMDITabBar) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); - afx_msg BOOL OnEraseBkgnd(CDC *pDC); - afx_msg BOOL OnSelchange(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnMButtonDown(UINT nFlags, CPoint point); - afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnMouseLeave(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnNcHitTest(CPoint point); + template + afx_msg LRESULT OnNcForward(WPARAM wParam, LPARAM lParam) { return AfxGetMainWnd()->SendMessage(message, wParam, lParam); } + afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: - CRect GetCloseButtonRect(int nItem); - int GetItemIndexFromPoint(CPoint pt) const; - void SwapTabs(int nIndexA, int nIndexB); - int GetMaxTitleLength() const; - void UpdateToolTips(int index); }; diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 68daaa8e694..30b500f0154 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -222,11 +222,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_MESSAGE(WM_USER+1, OnUser1) ON_WM_ACTIVATEAPP() ON_WM_NCCALCSIZE() - ON_WM_NCHITTEST() - ON_WM_NCLBUTTONDOWN() - ON_WM_NCLBUTTONUP() ON_WM_SIZE() - ON_WM_PAINT() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>)) @@ -2499,42 +2495,10 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs void CMainFrame::OnSize(UINT nType, int cx, int cy) { - m_titleBar.OnSize(this, nType, cx, cy); m_wndTabBar.Update(true, (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); __super::OnSize(nType, cx, cy); } -LRESULT CMainFrame::OnNcHitTest(CPoint point) -{ - LRESULT res = m_titleBar.HitTest(point); - if (res > HTNOWHERE) - return res; - return __super::OnNcHitTest(point); -} - -void CMainFrame::OnNcLButtonDown(UINT nHitTest, CPoint point) -{ - __super::OnNcLButtonDown(nHitTest, point); -} - -void CMainFrame::OnNcLButtonUp(UINT nFlags, CPoint point) -{ - __super::OnNcLButtonUp(nFlags, point); -} - -void CMainFrame::OnPaint() -{ - __super::OnPaint(); - CRect rcClient; - GetClientRect(&rcClient); - CClientDC dc(this); - m_titleBar.DrawIcon(this, dc); - const int bw = 64; - CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw }; - CRect rc2{ rcClient.right - bw * 2, 0, rcClient.right - bw * 1, bw }; - CRect rc3{ rcClient.right - bw * 3, 0, rcClient.right - bw * 2, bw }; -} - BOOL CMainFrame::CreateToolbar() { if (!m_wndMenuBar.Create(this)) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index c8a80d7892a..2d1a0624e34 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -343,7 +343,6 @@ class CMainFrame : public CMDIFrameWnd std::vector m_tempFiles; /**< List of possibly needed temp files. */ DropHandler *m_pDropHandler; std::unique_ptr m_pDirWatcher; - CTitleBarHelper m_titleBar; // Generated message map functions protected: @@ -383,10 +382,6 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnUpdateWindowCloseAll(CCmdUI* pCmdUI); afx_msg void OnSaveProject(); afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); - afx_msg LRESULT OnNcHitTest(CPoint point); - afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); - afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); - afx_msg void OnPaint(); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnToolbarSize(UINT id); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index ca7bbcf1c3a..0a00d1a8b58 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -71,14 +71,6 @@ int CTitleBarHelper::HitTest(CPoint pt) return HTTOPRIGHT; return HTTOP; } - if (rc.bottom - m <= pt.y) - { - if (pt.x < rc.left + m) - return HTBOTTOMLEFT; - else if (rc.right - m <= pt.x) - return HTBOTTOMRIGHT; - return HTBOTTOM; - } if (pt.x < rc.left + m) return HTLEFT; if (rc.right - m <= pt.x) @@ -97,11 +89,7 @@ int CTitleBarHelper::HitTest(CPoint pt) { return HTCLOSE; } - if (pt.y < rc.top + height) - { - return HTCAPTION; - } - return HTCLIENT; + return HTCAPTION; } int CTitleBarHelper::PointToPixel(float point) From 573af396b4b57ba00e5cc5e0d10c82cbf3a5d4a5 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Tue, 17 Sep 2024 21:47:27 +0900 Subject: [PATCH 10/22] WIP --- Src/Common/MDITabBar.cpp | 6 ++++-- Src/TitleBarHelper.cpp | 17 ++++++++--------- Src/TitleBarHelper.h | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 67fc1f107a7..f383b3a99ae 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -465,7 +465,7 @@ void CMDITabBar::OnSize(UINT nType, int cx, int cy) __super::OnSize(nType, cx, cy); if (!m_bOnTitleBar) return; - m_titleBar.OnSize(this, nType, cx, cy); + m_titleBar.OnSize(this, m_bMaximized, cx, cy); if (m_tabCtrl.m_hWnd) { CClientDC dc(this); @@ -680,5 +680,7 @@ void CMDITabBar::OnPaint() CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); - m_titleBar.DrawIcon(AfxGetMainWnd(), dc); + const int lpx = dc.GetDeviceCaps(LOGPIXELSX); + auto pointToPixel = [lpx](float point) -> int { return static_cast(point * lpx / 72); }; + m_titleBar.DrawIcon(AfxGetMainWnd(), dc, pointToPixel(m_leftMarginPoint)); } diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index 0a00d1a8b58..172497459ad 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -10,21 +10,20 @@ #include "TitleBarHelper.h" #include "RoundedRectWithShadow.h" -void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) +void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc, int leftMarginWidth) { HICON hIcon = (HICON)pWnd->SendMessage(WM_GETICON, ICON_SMALL2, 0); if (hIcon == nullptr) hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM); if (hIcon != nullptr) { - const int height = PointToPixel(28.5f); - const int leftMarginWidth = PointToPixel(36.f); + const int my = (m_maximized ? 8 : 0); + const int height = m_size.cy - my; const int cx = PointToPixel(12.f); const int cy = PointToPixel(12.f); - const int my = (m_nType == SIZE_MAXIMIZED ? 8 : 0); - CRect rc = { 0, 0, leftMarginWidth, height + my }; - dc.FillSolidRect(&rc, GetSysColor(COLOR_3DFACE)); - DrawIconEx(dc.m_hDC, (leftMarginWidth - cx) / 2, (height - cy) / 2 + my, hIcon, + const int x = (leftMarginWidth - cx) / 2; + const int y = (height - cy) / 2 + my; + DrawIconEx(dc.m_hDC, x, y, hIcon, cx, cy, 0, nullptr, DI_NORMAL); } } @@ -43,10 +42,10 @@ CRect CTitleBarHelper::GetButtonsRect() return CRect{}; } -void CTitleBarHelper::OnSize(CWnd* pWnd, UINT nType, int cx, int cy) +void CTitleBarHelper::OnSize(CWnd* pWnd, bool maximized, int cx, int cy) { m_size = CSize(cx, cy); - m_nType = nType; + m_maximized = maximized; m_pWnd = pWnd; CClientDC dc(pWnd); m_dpi = dc.GetDeviceCaps(LOGPIXELSX); diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 481ed08b280..27a6fbc74ea 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -13,11 +13,11 @@ class CTitleBarHelper { public: CTitleBarHelper() {} - void DrawIcon(CWnd* pWnd, CDC& dc); + void DrawIcon(CWnd* pWnd, CDC& dc, int leftMarginWidth); void DrawButtons(CDC& dc); CRect GetIconRect(); CRect GetButtonsRect(); - void OnSize(CWnd* pWnd, UINT nType, int cx, int cy); + void OnSize(CWnd* pWnd, bool maximized, int cx, int cy); int HitTest(CPoint pt); private: @@ -25,7 +25,7 @@ class CTitleBarHelper { CWnd* m_pWnd; CSize m_size; - int m_nType; + bool m_maximized; int m_iconSize; int m_dpi; }; From d4eb2969b460cb42327ed4793970e293f38f39d9 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Wed, 18 Sep 2024 21:19:09 +0900 Subject: [PATCH 11/22] WIP --- Src/Common/MDITabBar.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index f383b3a99ae..1b43fb78cc4 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -465,6 +465,7 @@ void CMDITabBar::OnSize(UINT nType, int cx, int cy) __super::OnSize(nType, cx, cy); if (!m_bOnTitleBar) return; + Invalidate(); m_titleBar.OnSize(this, m_bMaximized, cx, cy); if (m_tabCtrl.m_hWnd) { From 3387acbca1abeda0785732182c7c844acb945eec Mon Sep 17 00:00:00 2001 From: sdottaka Date: Thu, 19 Sep 2024 09:13:49 +0900 Subject: [PATCH 12/22] WIP --- Src/MainFrm.cpp | 24 +++++++++++++++++++-- Src/MainFrm.h | 2 ++ Src/Merge.rc | 18 +++++++++++++--- Src/OptionsDef.h | 1 + Src/OptionsInit.cpp | 1 + Src/resource.h | 1 + Translations/WinMerge/Arabic.po | 6 ++++++ Translations/WinMerge/Basque.po | 6 ++++++ Translations/WinMerge/Brazilian.po | 6 ++++++ Translations/WinMerge/Bulgarian.po | 6 ++++++ Translations/WinMerge/Catalan.po | 6 ++++++ Translations/WinMerge/ChineseSimplified.po | 6 ++++++ Translations/WinMerge/ChineseTraditional.po | 6 ++++++ Translations/WinMerge/Corsican.po | 6 ++++++ Translations/WinMerge/Croatian.po | 6 ++++++ Translations/WinMerge/Czech.po | 6 ++++++ Translations/WinMerge/Danish.po | 6 ++++++ Translations/WinMerge/Dutch.po | 6 ++++++ Translations/WinMerge/English.pot | 8 ++++++- Translations/WinMerge/Finnish.po | 6 ++++++ Translations/WinMerge/French.po | 6 ++++++ Translations/WinMerge/Galician.po | 6 ++++++ Translations/WinMerge/German.po | 6 ++++++ Translations/WinMerge/Greek.po | 6 ++++++ Translations/WinMerge/Hungarian.po | 6 ++++++ Translations/WinMerge/Italian.po | 6 ++++++ Translations/WinMerge/Japanese.po | 6 ++++++ Translations/WinMerge/Korean.po | 6 ++++++ Translations/WinMerge/Lithuanian.po | 6 ++++++ Translations/WinMerge/Norwegian.po | 6 ++++++ Translations/WinMerge/Persian.po | 6 ++++++ Translations/WinMerge/Polish.po | 6 ++++++ Translations/WinMerge/Portuguese.po | 6 ++++++ Translations/WinMerge/Romanian.po | 6 ++++++ Translations/WinMerge/Russian.po | 6 ++++++ Translations/WinMerge/Serbian.po | 6 ++++++ Translations/WinMerge/Sinhala.po | 6 ++++++ Translations/WinMerge/Slovak.po | 6 ++++++ Translations/WinMerge/Slovenian.po | 6 ++++++ Translations/WinMerge/Spanish.po | 6 ++++++ Translations/WinMerge/Swedish.po | 6 ++++++ Translations/WinMerge/Tamil.po | 6 ++++++ Translations/WinMerge/Turkish.po | 6 ++++++ Translations/WinMerge/Ukrainian.po | 6 ++++++ 44 files changed, 271 insertions(+), 6 deletions(-) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 688436b39fc..804500e927a 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -253,6 +253,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_COMMAND(ID_VIEW_STATUS_BAR, OnViewStatusBar) ON_COMMAND(ID_VIEW_TAB_BAR, OnViewTabBar) ON_UPDATE_COMMAND_UI(ID_VIEW_TAB_BAR, OnUpdateViewTabBar) + ON_COMMAND(ID_VIEW_TAB_BAR_ON_TITLE_BAR, OnViewTabBarOnTitleBar) + ON_UPDATE_COMMAND_UI(ID_VIEW_TAB_BAR_ON_TITLE_BAR, OnUpdateViewTabBarOnTitleBar) ON_COMMAND(ID_VIEW_RESIZE_PANES, OnResizePanes) ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZE_PANES, OnUpdateResizePanes) ON_COMMAND_RANGE(ID_TOOLBAR_NONE, ID_TOOLBAR_HUGE, OnToolbarSize) @@ -407,7 +409,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.SubclassWindow(m_hWndMDIClient); - m_wndTabBar.Update(true, false, 32.f, 18.f * 3); + m_wndTabBar.Update(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR), false, 32.f, 18.f * 3); if (!m_wndTabBar.Create(this)) { @@ -2242,6 +2244,24 @@ void CMainFrame::OnViewTabBar() __super::ShowControlBar(&m_wndTabBar, bShow, 0); } +/** + * @brief Updates "Show Tabbar" menuitem. + */ +void CMainFrame::OnUpdateViewTabBarOnTitleBar(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR)); +} + +/** + * @brief Show/hide tabbar. + */ +void CMainFrame::OnViewTabBarOnTitleBar() +{ + bool bOnTitleBar = !GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR); + GetOptionsMgr()->SaveOption(OPT_TABBAR_ON_TITLEBAR, bOnTitleBar); + +} + /** * @brief Updates "Automatically Resize Panes" menuitem. */ @@ -2495,7 +2515,7 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs void CMainFrame::OnSize(UINT nType, int cx, int cy) { - m_wndTabBar.Update(true, (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); + m_wndTabBar.Update(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR), (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); __super::OnSize(nType, cx, cy); } diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 4a2a76acd46..c5ab4593c6b 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -373,6 +373,8 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnViewStatusBar(); afx_msg void OnUpdateViewTabBar(CCmdUI* pCmdUI); afx_msg void OnViewTabBar(); + afx_msg void OnUpdateViewTabBarOnTitleBar(CCmdUI* pCmdUI); + afx_msg void OnViewTabBarOnTitleBar(); afx_msg void OnUpdateResizePanes(CCmdUI* pCmdUI); afx_msg void OnResizePanes(); afx_msg void OnFileOpenProject(); diff --git a/Src/Merge.rc b/Src/Merge.rc index bdb8ee25088..c6356c8c120 100644 --- a/Src/Merge.rc +++ b/Src/Merge.rc @@ -355,7 +355,11 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "Ta&b Bar", ID_VIEW_TAB_BAR + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END END POPUP "&Tools" BEGIN @@ -496,7 +500,11 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "Ta&b Bar", ID_VIEW_TAB_BAR + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END MENUITEM SEPARATOR MENUITEM "Com&pare Statistics...", ID_VIEW_DIR_STATISTICS MENUITEM SEPARATOR @@ -732,7 +740,11 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - MENUITEM "Ta&b Bar", ID_VIEW_TAB_BAR + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END MENUITEM "Diff &Pane", ID_VIEW_DETAIL_BAR MENUITEM "Lo&cation Pane", ID_VIEW_LOCATION_BAR MENUITEM SEPARATOR diff --git a/Src/OptionsDef.h b/Src/OptionsDef.h index 397157726bb..fbf8d7a41db 100644 --- a/Src/OptionsDef.h +++ b/Src/OptionsDef.h @@ -301,6 +301,7 @@ inline const String OPT_PLUGINS_OPEN_IN_SAME_FRAME_TYPE {_T("Plugins/OpenInSameF inline const String OPT_SHOW_SELECT_FILES_AT_STARTUP {_T("Settings/ShowFileDialog"s)}; // MDI Tab Bar +inline const String OPT_TABBAR_ON_TITLEBAR {_T("Settings/TabBarOnTitleBar"s)}; inline const String OPT_TABBAR_AUTO_MAXWIDTH {_T("Settings/TabBarAutoMaxWidth"s)}; // MRU diff --git a/Src/OptionsInit.cpp b/Src/OptionsInit.cpp index c3c10defca4..81fdb0aa006 100644 --- a/Src/OptionsInit.cpp +++ b/Src/OptionsInit.cpp @@ -235,6 +235,7 @@ void Init(COptionsMgr *pOptions) pOptions->InitOption(OPT_PATCHCREATOR_INCLUDE_CMD_LINE, false); pOptions->InitOption(OPT_PATCHCREATOR_COPY_TO_CLIPBOARD, false); + pOptions->InitOption(OPT_TABBAR_ON_TITLEBAR, true); pOptions->InitOption(OPT_TABBAR_AUTO_MAXWIDTH, true); pOptions->InitOption(OPT_ACTIVE_FRAME_MAX, true); pOptions->InitOption(OPT_ACTIVE_PANE, 0, 0, 2); diff --git a/Src/resource.h b/Src/resource.h index daf1fabfef9..f8d0bfff116 100644 --- a/Src/resource.h +++ b/Src/resource.h @@ -1200,6 +1200,7 @@ #define ID_PLUGIN_ADD_UNPACKER 35740 #define ID_PLUGIN_ADD_PREDIFFER 35741 #define ID_PLUGIN_DUPLICATE 35742 +#define ID_VIEW_TAB_BAR_ON_TITLE_BAR 35743 #define IDS_SPLASH_GPLTEXT 38977 #define IDS_MESSAGEBOX_OK 39001 #define IDS_MESSAGEBOX_CANCEL 39002 diff --git a/Translations/WinMerge/Arabic.po b/Translations/WinMerge/Arabic.po index 17a400c9d3f..fc99bf1cfc4 100644 --- a/Translations/WinMerge/Arabic.po +++ b/Translations/WinMerge/Arabic.po @@ -374,6 +374,12 @@ msgstr "شريط ال&حالة" msgid "Ta&b Bar" msgstr "شريط الت&بويب" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "أ&دوات" diff --git a/Translations/WinMerge/Basque.po b/Translations/WinMerge/Basque.po index 118ee3a4f86..e3ef304daa5 100644 --- a/Translations/WinMerge/Basque.po +++ b/Translations/WinMerge/Basque.po @@ -423,6 +423,12 @@ msgstr "&Egoera Barra" msgid "Ta&b Bar" msgstr "&Fitxa Barra" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Tresnak" diff --git a/Translations/WinMerge/Brazilian.po b/Translations/WinMerge/Brazilian.po index 5a8ef77d763..cdb377dd319 100644 --- a/Translations/WinMerge/Brazilian.po +++ b/Translations/WinMerge/Brazilian.po @@ -373,6 +373,12 @@ msgstr "&Barra de Status" msgid "Ta&b Bar" msgstr "Ba&rra das Abas" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Ferramentas" diff --git a/Translations/WinMerge/Bulgarian.po b/Translations/WinMerge/Bulgarian.po index 03359d59336..9e01d8cc4aa 100644 --- a/Translations/WinMerge/Bulgarian.po +++ b/Translations/WinMerge/Bulgarian.po @@ -370,6 +370,12 @@ msgstr "&Лента за състоянието" msgid "Ta&b Bar" msgstr "Лента с &раздели" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Инструменти" diff --git a/Translations/WinMerge/Catalan.po b/Translations/WinMerge/Catalan.po index df0489b51ef..75b155d4c5c 100644 --- a/Translations/WinMerge/Catalan.po +++ b/Translations/WinMerge/Catalan.po @@ -421,6 +421,12 @@ msgstr "Barra d'est&at" msgid "Ta&b Bar" msgstr "Barra de ta&bulacions" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Eines" diff --git a/Translations/WinMerge/ChineseSimplified.po b/Translations/WinMerge/ChineseSimplified.po index 2f2162e3e69..324d67809d6 100644 --- a/Translations/WinMerge/ChineseSimplified.po +++ b/Translations/WinMerge/ChineseSimplified.po @@ -377,6 +377,12 @@ msgstr "状态栏(&S)" msgid "Ta&b Bar" msgstr "标签栏(&B)" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "工具(&T)" diff --git a/Translations/WinMerge/ChineseTraditional.po b/Translations/WinMerge/ChineseTraditional.po index 1778df1a029..7ab9f726804 100644 --- a/Translations/WinMerge/ChineseTraditional.po +++ b/Translations/WinMerge/ChineseTraditional.po @@ -421,6 +421,12 @@ msgstr "狀態列 (&S)" msgid "Ta&b Bar" msgstr "頁籤列 (&B)" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "工具 (&T)" diff --git a/Translations/WinMerge/Corsican.po b/Translations/WinMerge/Corsican.po index 1cffd574be4..50de39aae7c 100644 --- a/Translations/WinMerge/Corsican.po +++ b/Translations/WinMerge/Corsican.po @@ -375,6 +375,12 @@ msgstr "Barra di s&tatu" msgid "Ta&b Bar" msgstr "Barra d’&unghjette" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Attrezzi" diff --git a/Translations/WinMerge/Croatian.po b/Translations/WinMerge/Croatian.po index a0d43f08528..3439d28ed4c 100644 --- a/Translations/WinMerge/Croatian.po +++ b/Translations/WinMerge/Croatian.po @@ -420,6 +420,12 @@ msgstr "Traka &statusa" msgid "Ta&b Bar" msgstr "Traka &oznaka panela" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Alati" diff --git a/Translations/WinMerge/Czech.po b/Translations/WinMerge/Czech.po index b14e12e720b..d61edc95483 100644 --- a/Translations/WinMerge/Czech.po +++ b/Translations/WinMerge/Czech.po @@ -420,6 +420,12 @@ msgstr "&Stavový řádek" msgid "Ta&b Bar" msgstr "Panel &záložek" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Nástroje" diff --git a/Translations/WinMerge/Danish.po b/Translations/WinMerge/Danish.po index de748e22be4..9555672c17c 100644 --- a/Translations/WinMerge/Danish.po +++ b/Translations/WinMerge/Danish.po @@ -421,6 +421,12 @@ msgstr "S&tatuslinje" msgid "Ta&b Bar" msgstr "Fa&nelinje" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "Værk&tøjer" diff --git a/Translations/WinMerge/Dutch.po b/Translations/WinMerge/Dutch.po index 3222d73ca02..92622601979 100644 --- a/Translations/WinMerge/Dutch.po +++ b/Translations/WinMerge/Dutch.po @@ -373,6 +373,12 @@ msgstr "Statusbalk" msgid "Ta&b Bar" msgstr "Tab-balk" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Gereedschap" diff --git a/Translations/WinMerge/English.pot b/Translations/WinMerge/English.pot index 649d926d074..513ca00ab66 100644 --- a/Translations/WinMerge/English.pot +++ b/Translations/WinMerge/English.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: WinMerge\n" "Report-Msgid-Bugs-To: https://bugs.winmerge.org/\n" -"POT-Creation-Date: 2024-09-18 01:50+0000\n" +"POT-Creation-Date: 2024-09-19 08:54+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: English \n" @@ -367,6 +367,12 @@ msgstr "" msgid "Ta&b Bar" msgstr "" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "" diff --git a/Translations/WinMerge/Finnish.po b/Translations/WinMerge/Finnish.po index 3ea22647e51..81ed8bc5651 100644 --- a/Translations/WinMerge/Finnish.po +++ b/Translations/WinMerge/Finnish.po @@ -373,6 +373,12 @@ msgstr "Tilarivi" msgid "Ta&b Bar" msgstr "Välilehdet" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Työkalut" diff --git a/Translations/WinMerge/French.po b/Translations/WinMerge/French.po index 16f55c09354..12c35edb9eb 100644 --- a/Translations/WinMerge/French.po +++ b/Translations/WinMerge/French.po @@ -428,6 +428,12 @@ msgstr "Barre d'&état" msgid "Ta&b Bar" msgstr "Barre d'&onglets" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Outils" diff --git a/Translations/WinMerge/Galician.po b/Translations/WinMerge/Galician.po index e8ae11b456e..d3e8b44504a 100644 --- a/Translations/WinMerge/Galician.po +++ b/Translations/WinMerge/Galician.po @@ -374,6 +374,12 @@ msgstr "Barra de e&stado" msgid "Ta&b Bar" msgstr "&Barra de pestanas" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Ferramen&tas" diff --git a/Translations/WinMerge/German.po b/Translations/WinMerge/German.po index 8757f08f610..8a981b4dd4a 100644 --- a/Translations/WinMerge/German.po +++ b/Translations/WinMerge/German.po @@ -423,6 +423,12 @@ msgstr "S&tatusleiste" msgid "Ta&b Bar" msgstr "Ta&b-Leiste" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Tools" diff --git a/Translations/WinMerge/Greek.po b/Translations/WinMerge/Greek.po index b34a494285d..d4229d3f15a 100644 --- a/Translations/WinMerge/Greek.po +++ b/Translations/WinMerge/Greek.po @@ -419,6 +419,12 @@ msgstr "Γραμμή &Καταστάσεως" msgid "Ta&b Bar" msgstr "Γραμμή Σε&λιδοδεικτών" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "Εργα&λεία" diff --git a/Translations/WinMerge/Hungarian.po b/Translations/WinMerge/Hungarian.po index b0c59433871..cb6f4f82549 100644 --- a/Translations/WinMerge/Hungarian.po +++ b/Translations/WinMerge/Hungarian.po @@ -422,6 +422,12 @@ msgstr "&Állapotsor" msgid "Ta&b Bar" msgstr "Fülsáv" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Eszközök" diff --git a/Translations/WinMerge/Italian.po b/Translations/WinMerge/Italian.po index a6077b0f066..3f03c2558db 100644 --- a/Translations/WinMerge/Italian.po +++ b/Translations/WinMerge/Italian.po @@ -374,6 +374,12 @@ msgstr "&Barra stato" msgid "Ta&b Bar" msgstr "&Barra schede" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Strumenti" diff --git a/Translations/WinMerge/Japanese.po b/Translations/WinMerge/Japanese.po index 384da095059..fda875159d2 100644 --- a/Translations/WinMerge/Japanese.po +++ b/Translations/WinMerge/Japanese.po @@ -372,6 +372,12 @@ msgstr "ステータス バー(&S)" msgid "Ta&b Bar" msgstr "タブ バー(&B)" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "ツール(&T)" diff --git a/Translations/WinMerge/Korean.po b/Translations/WinMerge/Korean.po index 0169cb6fb21..38d8af80c9c 100644 --- a/Translations/WinMerge/Korean.po +++ b/Translations/WinMerge/Korean.po @@ -429,6 +429,12 @@ msgstr "상태 표시줄(&S)" msgid "Ta&b Bar" msgstr "탭 표시줄(&B)" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "도구(&T)" diff --git a/Translations/WinMerge/Lithuanian.po b/Translations/WinMerge/Lithuanian.po index 0f43d2a386b..372b212c669 100644 --- a/Translations/WinMerge/Lithuanian.po +++ b/Translations/WinMerge/Lithuanian.po @@ -373,6 +373,12 @@ msgstr "Bū&senos juosta" msgid "Ta&b Bar" msgstr "&Kortelių juosta" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Į&rankiai" diff --git a/Translations/WinMerge/Norwegian.po b/Translations/WinMerge/Norwegian.po index 4345ae9bf0b..d6983482c62 100644 --- a/Translations/WinMerge/Norwegian.po +++ b/Translations/WinMerge/Norwegian.po @@ -372,6 +372,12 @@ msgstr "Stat&uslinje" msgid "Ta&b Bar" msgstr "F&anelinje" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Verktøy" diff --git a/Translations/WinMerge/Persian.po b/Translations/WinMerge/Persian.po index e8c0b31cf5c..bf1ac7f10ca 100644 --- a/Translations/WinMerge/Persian.po +++ b/Translations/WinMerge/Persian.po @@ -421,6 +421,12 @@ msgstr "&S ميله وضعيت " msgid "Ta&b Bar" msgstr "&b ميله جهش " +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&T ابزارها " diff --git a/Translations/WinMerge/Polish.po b/Translations/WinMerge/Polish.po index d9109ced307..5b1950de4ad 100644 --- a/Translations/WinMerge/Polish.po +++ b/Translations/WinMerge/Polish.po @@ -374,6 +374,12 @@ msgstr "Pasek stanu" msgid "Ta&b Bar" msgstr "Pasek kart" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Narzędzia" diff --git a/Translations/WinMerge/Portuguese.po b/Translations/WinMerge/Portuguese.po index 05cd9cd8dae..5f1ae6f9e0f 100644 --- a/Translations/WinMerge/Portuguese.po +++ b/Translations/WinMerge/Portuguese.po @@ -374,6 +374,12 @@ msgstr "Barra de esta&do" msgid "Ta&b Bar" msgstr "Barra de separadores" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Ferramentas" diff --git a/Translations/WinMerge/Romanian.po b/Translations/WinMerge/Romanian.po index 7b708d1582c..e8d8d2c685d 100644 --- a/Translations/WinMerge/Romanian.po +++ b/Translations/WinMerge/Romanian.po @@ -372,6 +372,12 @@ msgstr "Bară de &stare" msgid "Ta&b Bar" msgstr "&Bara de file" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Unel&te" diff --git a/Translations/WinMerge/Russian.po b/Translations/WinMerge/Russian.po index c5c2566e947..dcddebb66f8 100644 --- a/Translations/WinMerge/Russian.po +++ b/Translations/WinMerge/Russian.po @@ -375,6 +375,12 @@ msgstr "&Строка состояния" msgid "Ta&b Bar" msgstr "Панель вкладок" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Инструменты" diff --git a/Translations/WinMerge/Serbian.po b/Translations/WinMerge/Serbian.po index 928a1502e60..7b9e7e89140 100644 --- a/Translations/WinMerge/Serbian.po +++ b/Translations/WinMerge/Serbian.po @@ -418,6 +418,12 @@ msgstr "&Статусна трака" msgid "Ta&b Bar" msgstr "Тра&ка језичака" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "Алатке" diff --git a/Translations/WinMerge/Sinhala.po b/Translations/WinMerge/Sinhala.po index e9f3c86ebf6..4fb98645e9c 100644 --- a/Translations/WinMerge/Sinhala.po +++ b/Translations/WinMerge/Sinhala.po @@ -420,6 +420,12 @@ msgstr "&Status Bar" msgid "Ta&b Bar" msgstr "Ta&b Bar" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "මෙවලම්" diff --git a/Translations/WinMerge/Slovak.po b/Translations/WinMerge/Slovak.po index 1b6b39b7fc1..36e73001815 100644 --- a/Translations/WinMerge/Slovak.po +++ b/Translations/WinMerge/Slovak.po @@ -373,6 +373,12 @@ msgstr "&Stavový riadok" msgid "Ta&b Bar" msgstr "Lišta &záložiek" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Nástroje" diff --git a/Translations/WinMerge/Slovenian.po b/Translations/WinMerge/Slovenian.po index af294eb7ffe..fecda12a8e4 100644 --- a/Translations/WinMerge/Slovenian.po +++ b/Translations/WinMerge/Slovenian.po @@ -373,6 +373,12 @@ msgstr "&Statusna vrstica" msgid "Ta&b Bar" msgstr "Ta&bulatorska vrstica" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Orodja" diff --git a/Translations/WinMerge/Spanish.po b/Translations/WinMerge/Spanish.po index 0b1b10a3451..c3656539536 100644 --- a/Translations/WinMerge/Spanish.po +++ b/Translations/WinMerge/Spanish.po @@ -376,6 +376,12 @@ msgstr "Barra de e&stado" msgid "Ta&b Bar" msgstr "&Barra de pestañas" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Herramientas" diff --git a/Translations/WinMerge/Swedish.po b/Translations/WinMerge/Swedish.po index e1572523c1c..f53638d4385 100644 --- a/Translations/WinMerge/Swedish.po +++ b/Translations/WinMerge/Swedish.po @@ -375,6 +375,12 @@ msgstr "Statusfält" msgid "Ta&b Bar" msgstr "Flikrad" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "Verktyg" diff --git a/Translations/WinMerge/Tamil.po b/Translations/WinMerge/Tamil.po index fe79d4b0bab..e1e0459774f 100644 --- a/Translations/WinMerge/Tamil.po +++ b/Translations/WinMerge/Tamil.po @@ -371,6 +371,12 @@ msgstr "&நிலைப் பட்டி" msgid "Ta&b Bar" msgstr "Ta&b Bar" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&கருவிகள்" diff --git a/Translations/WinMerge/Turkish.po b/Translations/WinMerge/Turkish.po index b6842897a4e..b14f43751a8 100644 --- a/Translations/WinMerge/Turkish.po +++ b/Translations/WinMerge/Turkish.po @@ -372,6 +372,12 @@ msgstr "&Durum çubuğu" msgid "Ta&b Bar" msgstr "&Sekme çubuğu" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Tools" msgstr "&Araçlar" diff --git a/Translations/WinMerge/Ukrainian.po b/Translations/WinMerge/Ukrainian.po index b41020e2393..398d9695ff9 100644 --- a/Translations/WinMerge/Ukrainian.po +++ b/Translations/WinMerge/Ukrainian.po @@ -404,6 +404,12 @@ msgstr "Ря&док стану" msgid "Ta&b Bar" msgstr "Панель &закладок" +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Tools" msgstr "&Сервіс" From 6617b92d0f3ff99ee4ddba5f04e71965eb14aea7 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 21 Sep 2024 21:18:15 +0900 Subject: [PATCH 13/22] WIP --- Src/Common/MDITabBar.cpp | 9 ++++---- Src/MainFrm.cpp | 47 ++++++++++++++++++++++++++++++++-------- Src/MainFrm.h | 2 ++ Src/Win_VersionHelper.h | 6 +++++ 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 1b43fb78cc4..c3bbffd690b 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -463,8 +463,6 @@ void CMyTabCtrl::OnLButtonUp(UINT nFlags, CPoint point) void CMDITabBar::OnSize(UINT nType, int cx, int cy) { __super::OnSize(nType, cx, cy); - if (!m_bOnTitleBar) - return; Invalidate(); m_titleBar.OnSize(this, m_bMaximized, cx, cy); if (m_tabCtrl.m_hWnd) @@ -472,12 +470,13 @@ void CMDITabBar::OnSize(UINT nType, int cx, int cy) CClientDC dc(this); const int lpx = dc.GetDeviceCaps(LOGPIXELSX); auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; - const int leftMargin = pointToPixel(m_leftMarginPoint); - const int rightMargin = pointToPixel(m_rightMarginPoint); + const int leftMargin = m_bOnTitleBar ? pointToPixel(m_leftMarginPoint) : 0; + const int rightMargin = m_bOnTitleBar ? pointToPixel(m_rightMarginPoint) : 0; int my = (m_bMaximized) ? 8 : 0; CSize size{ 0, cy - my }; m_tabCtrl.MoveWindow(leftMargin, my, cx - leftMargin - rightMargin, cy - my, true); m_tabCtrl.SetItemSize(size); + } } @@ -679,6 +678,8 @@ BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) void CMDITabBar::OnPaint() { CPaintDC dc(this); + if (!m_bOnTitleBar) + return; CRect rcClient; GetClientRect(&rcClient); const int lpx = dc.GetDeviceCaps(LOGPIXELSX); diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 804500e927a..b2802f8402f 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -69,6 +69,7 @@ #include "ClipboardHistory.h" #include "locality.h" #include "DirWatcher.h" +#include "Win_VersionHelper.h" #include using std::vector; @@ -409,17 +410,16 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) m_wndMDIClient.SubclassWindow(m_hWndMDIClient); - m_wndTabBar.Update(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR), false, 32.f, 18.f * 3); + if (IsWin10_OrGreater()) + m_bTabsOnTitleBar = GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR); - if (!m_wndTabBar.Create(this)) + m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), false, 32.f, 18.f * 3); + + if (m_bTabsOnTitleBar.value_or(false) && !m_wndTabBar.Create(this)) { TRACE0("Failed to create tab bar\n"); return -1; // fail to create } - m_wndTabBar.SetAutoMaxWidth(GetOptionsMgr()->GetBool(OPT_TABBAR_AUTO_MAXWIDTH)); - - if (!GetOptionsMgr()->GetBool(OPT_SHOW_TABBAR)) - __super::ShowControlBar(&m_wndTabBar, false, 0); if (!CreateToolbar()) { @@ -427,6 +427,17 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) return -1; // fail to create } + if (!m_bTabsOnTitleBar.value_or(false) && !m_wndTabBar.Create(this)) + { + TRACE0("Failed to create tab bar\n"); + return -1; // fail to create + } + + m_wndTabBar.SetAutoMaxWidth(GetOptionsMgr()->GetBool(OPT_TABBAR_AUTO_MAXWIDTH)); + + if (!GetOptionsMgr()->GetBool(OPT_SHOW_TABBAR)) + __super::ShowControlBar(&m_wndTabBar, false, 0); + if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); @@ -1587,6 +1598,18 @@ void CMainFrame::OnViewUsedefaultfont() UpdateFont(frame); } +void CMainFrame::UpdateTitleBarAndTabBar() +{ + CWnd* pWnd1 = &m_wndReBar, *pWnd2 = &m_wndTabBar; + if (m_bTabsOnTitleBar.value_or(false)) + std::swap(pWnd1, pWnd2); + pWnd1->SetWindowPos(pWnd2, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + pWnd2->SetWindowPos(pWnd1, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + for (int i = 0; i < 2; i++) + ShowWindow(IsZoomed() ? SW_RESTORE : SW_MAXIMIZE); + RecalcLayout(); +} + /** * @brief Update any resources necessary after a GUI language change */ @@ -2242,6 +2265,8 @@ void CMainFrame::OnViewTabBar() GetOptionsMgr()->SaveOption(OPT_SHOW_TABBAR, bShow); __super::ShowControlBar(&m_wndTabBar, bShow, 0); + + UpdateTitleBarAndTabBar(); } /** @@ -2249,6 +2274,7 @@ void CMainFrame::OnViewTabBar() */ void CMainFrame::OnUpdateViewTabBarOnTitleBar(CCmdUI* pCmdUI) { + pCmdUI->Enable(m_bTabsOnTitleBar.has_value()); pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR)); } @@ -2258,8 +2284,10 @@ void CMainFrame::OnUpdateViewTabBarOnTitleBar(CCmdUI* pCmdUI) void CMainFrame::OnViewTabBarOnTitleBar() { bool bOnTitleBar = !GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR); + if (m_bTabsOnTitleBar.has_value()) + m_bTabsOnTitleBar = bOnTitleBar; GetOptionsMgr()->SaveOption(OPT_TABBAR_ON_TITLEBAR, bOnTitleBar); - + UpdateTitleBarAndTabBar(); } /** @@ -2510,12 +2538,13 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs { RECT rcWindow = lpncsp->rgrc[0]; __super::OnNcCalcSize(bCalcValidRects, lpncsp); - lpncsp->rgrc[0].top = rcWindow.top + 0; + if (m_bTabsOnTitleBar.value_or(false) && m_wndTabBar.IsVisible()) + lpncsp->rgrc[0].top = rcWindow.top + 0; } void CMainFrame::OnSize(UINT nType, int cx, int cy) { - m_wndTabBar.Update(GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR), (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); + m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); __super::OnSize(nType, cx, cy); } diff --git a/Src/MainFrm.h b/Src/MainFrm.h index c5ab4593c6b..409b148be2b 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -208,6 +208,7 @@ class CMainFrame : public CMDIFrameWnd const PackingInfo * infoUnpacker = nullptr, const PrediffingInfo * infoPrediffer = nullptr, const OpenWebPageParams *pOpenParams = nullptr); + void UpdateTitleBarAndTabBar(); void UpdateResources(); void ApplyDiffOptions(); void SelectFilter(); @@ -343,6 +344,7 @@ class CMainFrame : public CMDIFrameWnd std::vector m_tempFiles; /**< List of possibly needed temp files. */ DropHandler *m_pDropHandler; std::unique_ptr m_pDirWatcher; + std::optional m_bTabsOnTitleBar; // Generated message map functions protected: diff --git a/Src/Win_VersionHelper.h b/Src/Win_VersionHelper.h index 6b31fc670b5..5e458b8b432 100644 --- a/Src/Win_VersionHelper.h +++ b/Src/Win_VersionHelper.h @@ -29,6 +29,12 @@ IsWinVer_OrGreater(WORD wVersion, WORD wBuildNumber = 0) return !!VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask); } +inline bool +IsWin10_OrGreater() +{ + return IsWinVer_OrGreater( 0x0a00, 10240 ); +} + inline bool IsWin11_OrGreater() { From 2b9a6051bc1b1f50156030bf8ea980010ded8c54 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 21 Sep 2024 21:34:19 +0900 Subject: [PATCH 14/22] WIP --- Src/MainFrm.h | 1 - Src/Merge.rc | 30 ++++++++++----------- Translations/WinMerge/Arabic.po | 18 ++++++------- Translations/WinMerge/Basque.po | 20 +++++++------- Translations/WinMerge/Brazilian.po | 18 ++++++------- Translations/WinMerge/Bulgarian.po | 18 ++++++------- Translations/WinMerge/Catalan.po | 20 +++++++------- Translations/WinMerge/ChineseSimplified.po | 18 ++++++------- Translations/WinMerge/ChineseTraditional.po | 20 +++++++------- Translations/WinMerge/Corsican.po | 18 ++++++------- Translations/WinMerge/Croatian.po | 20 +++++++------- Translations/WinMerge/Czech.po | 20 +++++++------- Translations/WinMerge/Danish.po | 20 +++++++------- Translations/WinMerge/Dutch.po | 18 ++++++------- Translations/WinMerge/English.pot | 18 ++++++------- Translations/WinMerge/Finnish.po | 18 ++++++------- Translations/WinMerge/French.po | 20 +++++++------- Translations/WinMerge/Galician.po | 18 ++++++------- Translations/WinMerge/German.po | 20 +++++++------- Translations/WinMerge/Greek.po | 20 +++++++------- Translations/WinMerge/Hungarian.po | 20 +++++++------- Translations/WinMerge/Italian.po | 18 ++++++------- Translations/WinMerge/Japanese.po | 18 ++++++------- Translations/WinMerge/Korean.po | 20 +++++++------- Translations/WinMerge/Lithuanian.po | 18 ++++++------- Translations/WinMerge/Norwegian.po | 18 ++++++------- Translations/WinMerge/Persian.po | 20 +++++++------- Translations/WinMerge/Polish.po | 18 ++++++------- Translations/WinMerge/Portuguese.po | 18 ++++++------- Translations/WinMerge/Romanian.po | 18 ++++++------- Translations/WinMerge/Russian.po | 18 ++++++------- Translations/WinMerge/Serbian.po | 20 +++++++------- Translations/WinMerge/Sinhala.po | 20 +++++++------- Translations/WinMerge/Slovak.po | 18 ++++++------- Translations/WinMerge/Slovenian.po | 18 ++++++------- Translations/WinMerge/Spanish.po | 18 ++++++------- Translations/WinMerge/Swedish.po | 18 ++++++------- Translations/WinMerge/Tamil.po | 18 ++++++------- Translations/WinMerge/Turkish.po | 18 ++++++------- Translations/WinMerge/Ukrainian.po | 20 +++++++------- 40 files changed, 372 insertions(+), 373 deletions(-) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 409b148be2b..39ddafe2a6a 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -22,7 +22,6 @@ #include "OptionsDef.h" #include "OptionsMgr.h" #include "FileOpenFlags.h" -#include "TitleBarHelper.h" class BCMenu; class CDirView; diff --git a/Src/Merge.rc b/Src/Merge.rc index c6356c8c120..cc0412d2dee 100644 --- a/Src/Merge.rc +++ b/Src/Merge.rc @@ -347,6 +347,11 @@ BEGIN END POPUP "&View" BEGIN + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END POPUP "&Toolbar" BEGIN MENUITEM "&None", ID_TOOLBAR_NONE @@ -355,11 +360,6 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "Ta&b Bar" - BEGIN - MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR - MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR - END END POPUP "&Tools" BEGIN @@ -492,6 +492,11 @@ BEGIN MENUITEM "Swap 1st | &3rd", ID_SWAPPANES_SWAP13 END MENUITEM SEPARATOR + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END POPUP "&Toolbar" BEGIN MENUITEM "&None", ID_TOOLBAR_NONE @@ -500,11 +505,6 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "Ta&b Bar" - BEGIN - MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR - MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR - END MENUITEM SEPARATOR MENUITEM "Com&pare Statistics...", ID_VIEW_DIR_STATISTICS MENUITEM SEPARATOR @@ -732,6 +732,11 @@ BEGIN END MENUITEM "Split V&ertically", ID_VIEW_SPLITVERTICALLY MENUITEM SEPARATOR + POPUP "Ta&b Bar" + BEGIN + MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR + MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR + END POPUP "&Toolbar" BEGIN MENUITEM "&None", ID_TOOLBAR_NONE @@ -740,11 +745,6 @@ BEGIN MENUITEM "&Huge", ID_TOOLBAR_HUGE END MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - POPUP "Ta&b Bar" - BEGIN - MENUITEM "&View Tab Bar" ID_VIEW_TAB_BAR - MENUITEM "&On Title Bar", ID_VIEW_TAB_BAR_ON_TITLE_BAR - END MENUITEM "Diff &Pane", ID_VIEW_DETAIL_BAR MENUITEM "Lo&cation Pane", ID_VIEW_LOCATION_BAR MENUITEM SEPARATOR diff --git a/Translations/WinMerge/Arabic.po b/Translations/WinMerge/Arabic.po index fc99bf1cfc4..c5f2deb8585 100644 --- a/Translations/WinMerge/Arabic.po +++ b/Translations/WinMerge/Arabic.po @@ -356,6 +356,15 @@ msgstr "خ&يارات..." msgid "&View" msgstr "&عرض" +msgid "Ta&b Bar" +msgstr "شريط الت&بويب" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&شريط الأدوات" @@ -371,15 +380,6 @@ msgstr "&ضخم" msgid "&Status Bar" msgstr "شريط ال&حالة" -msgid "Ta&b Bar" -msgstr "شريط الت&بويب" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "أ&دوات" diff --git a/Translations/WinMerge/Basque.po b/Translations/WinMerge/Basque.po index e3ef304daa5..cb05dcda577 100644 --- a/Translations/WinMerge/Basque.po +++ b/Translations/WinMerge/Basque.po @@ -399,6 +399,16 @@ msgstr "&Aukerak..." msgid "&View" msgstr "&Ikusi" +#, c-format +msgid "Ta&b Bar" +msgstr "&Fitxa Barra" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Tre&snabarra" @@ -419,16 +429,6 @@ msgstr "" msgid "&Status Bar" msgstr "&Egoera Barra" -#, c-format -msgid "Ta&b Bar" -msgstr "&Fitxa Barra" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Tresnak" diff --git a/Translations/WinMerge/Brazilian.po b/Translations/WinMerge/Brazilian.po index cdb377dd319..4201a3088e6 100644 --- a/Translations/WinMerge/Brazilian.po +++ b/Translations/WinMerge/Brazilian.po @@ -355,6 +355,15 @@ msgstr "&Opções..." msgid "&View" msgstr "&Visualizar" +msgid "Ta&b Bar" +msgstr "Ba&rra das Abas" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&Barra de ferramentas" @@ -370,15 +379,6 @@ msgstr "&Enorme" msgid "&Status Bar" msgstr "&Barra de Status" -msgid "Ta&b Bar" -msgstr "Ba&rra das Abas" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Ferramentas" diff --git a/Translations/WinMerge/Bulgarian.po b/Translations/WinMerge/Bulgarian.po index 9e01d8cc4aa..4da37ebb51b 100644 --- a/Translations/WinMerge/Bulgarian.po +++ b/Translations/WinMerge/Bulgarian.po @@ -352,6 +352,15 @@ msgstr "&Настройки…" msgid "&View" msgstr "И&зглед" +msgid "Ta&b Bar" +msgstr "Лента с &раздели" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Лента с &инструменти" @@ -367,15 +376,6 @@ msgstr "&Огромен" msgid "&Status Bar" msgstr "&Лента за състоянието" -msgid "Ta&b Bar" -msgstr "Лента с &раздели" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Инструменти" diff --git a/Translations/WinMerge/Catalan.po b/Translations/WinMerge/Catalan.po index 75b155d4c5c..44ca62d006c 100644 --- a/Translations/WinMerge/Catalan.po +++ b/Translations/WinMerge/Catalan.po @@ -397,6 +397,16 @@ msgstr "O&pcions..." msgid "&View" msgstr "&Visualització" +#, c-format +msgid "Ta&b Bar" +msgstr "Barra de ta&bulacions" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Barra d'ei&nes" @@ -417,16 +427,6 @@ msgstr "&Immensa" msgid "&Status Bar" msgstr "Barra d'est&at" -#, c-format -msgid "Ta&b Bar" -msgstr "Barra de ta&bulacions" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Eines" diff --git a/Translations/WinMerge/ChineseSimplified.po b/Translations/WinMerge/ChineseSimplified.po index 324d67809d6..eaa34b8b020 100644 --- a/Translations/WinMerge/ChineseSimplified.po +++ b/Translations/WinMerge/ChineseSimplified.po @@ -359,6 +359,15 @@ msgstr "选项(&O)..." msgid "&View" msgstr "视图(&V)" +msgid "Ta&b Bar" +msgstr "标签栏(&B)" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "工具栏(&T)" @@ -374,15 +383,6 @@ msgstr "特大(&H)" msgid "&Status Bar" msgstr "状态栏(&S)" -msgid "Ta&b Bar" -msgstr "标签栏(&B)" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "工具(&T)" diff --git a/Translations/WinMerge/ChineseTraditional.po b/Translations/WinMerge/ChineseTraditional.po index 7ab9f726804..e41b66aa08a 100644 --- a/Translations/WinMerge/ChineseTraditional.po +++ b/Translations/WinMerge/ChineseTraditional.po @@ -397,6 +397,16 @@ msgstr "選項 (&O)..." msgid "&View" msgstr "檢視 (&V)" +#, c-format +msgid "Ta&b Bar" +msgstr "頁籤列 (&B)" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "工具列 (&T)" @@ -417,16 +427,6 @@ msgstr "超大圖示 (&H)" msgid "&Status Bar" msgstr "狀態列 (&S)" -#, c-format -msgid "Ta&b Bar" -msgstr "頁籤列 (&B)" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "工具 (&T)" diff --git a/Translations/WinMerge/Corsican.po b/Translations/WinMerge/Corsican.po index 50de39aae7c..11cb8ff268d 100644 --- a/Translations/WinMerge/Corsican.po +++ b/Translations/WinMerge/Corsican.po @@ -357,6 +357,15 @@ msgstr "&Ozzioni…" msgid "&View" msgstr "&Vista" +msgid "Ta&b Bar" +msgstr "Barra d’&unghjette" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&Barra d’attrezzi" @@ -372,15 +381,6 @@ msgstr "&Tamanta" msgid "&Status Bar" msgstr "Barra di s&tatu" -msgid "Ta&b Bar" -msgstr "Barra d’&unghjette" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Attrezzi" diff --git a/Translations/WinMerge/Croatian.po b/Translations/WinMerge/Croatian.po index 3439d28ed4c..38616c99660 100644 --- a/Translations/WinMerge/Croatian.po +++ b/Translations/WinMerge/Croatian.po @@ -396,6 +396,16 @@ msgstr "Pos&tavke..." msgid "&View" msgstr "&Izgled" +#, c-format +msgid "Ta&b Bar" +msgstr "Traka &oznaka panela" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Traka &alata" @@ -416,16 +426,6 @@ msgstr "" msgid "&Status Bar" msgstr "Traka &statusa" -#, c-format -msgid "Ta&b Bar" -msgstr "Traka &oznaka panela" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Alati" diff --git a/Translations/WinMerge/Czech.po b/Translations/WinMerge/Czech.po index d61edc95483..067f4e90fd7 100644 --- a/Translations/WinMerge/Czech.po +++ b/Translations/WinMerge/Czech.po @@ -396,6 +396,16 @@ msgstr "Možnost&i..." msgid "&View" msgstr "&Zobrazit" +#, c-format +msgid "Ta&b Bar" +msgstr "Panel &záložek" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Panel &nástrojů" @@ -416,16 +426,6 @@ msgstr "" msgid "&Status Bar" msgstr "&Stavový řádek" -#, c-format -msgid "Ta&b Bar" -msgstr "Panel &záložek" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Nástroje" diff --git a/Translations/WinMerge/Danish.po b/Translations/WinMerge/Danish.po index 9555672c17c..0101f0d055d 100644 --- a/Translations/WinMerge/Danish.po +++ b/Translations/WinMerge/Danish.po @@ -397,6 +397,16 @@ msgstr "I&ndstillinger..." msgid "&View" msgstr "&Vis" +#, c-format +msgid "Ta&b Bar" +msgstr "Fa&nelinje" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "&Værktøjslinje" @@ -417,16 +427,6 @@ msgstr "" msgid "&Status Bar" msgstr "S&tatuslinje" -#, c-format -msgid "Ta&b Bar" -msgstr "Fa&nelinje" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "Værk&tøjer" diff --git a/Translations/WinMerge/Dutch.po b/Translations/WinMerge/Dutch.po index 92622601979..883d88d1ca8 100644 --- a/Translations/WinMerge/Dutch.po +++ b/Translations/WinMerge/Dutch.po @@ -355,6 +355,15 @@ msgstr "Opties..." msgid "&View" msgstr "Beeld" +msgid "Ta&b Bar" +msgstr "Tab-balk" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Werkbalk" @@ -370,15 +379,6 @@ msgstr "Enorm" msgid "&Status Bar" msgstr "Statusbalk" -msgid "Ta&b Bar" -msgstr "Tab-balk" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Gereedschap" diff --git a/Translations/WinMerge/English.pot b/Translations/WinMerge/English.pot index 513ca00ab66..b13c81d6536 100644 --- a/Translations/WinMerge/English.pot +++ b/Translations/WinMerge/English.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: WinMerge\n" "Report-Msgid-Bugs-To: https://bugs.winmerge.org/\n" -"POT-Creation-Date: 2024-09-19 08:54+0000\n" +"POT-Creation-Date: 2024-09-21 21:31+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: English \n" @@ -349,28 +349,28 @@ msgstr "" msgid "&View" msgstr "" -msgid "&Toolbar" +msgid "Ta&b Bar" msgstr "" -msgid "&Small" +msgid "&View Tab Bar" msgstr "" -msgid "&Big" +msgid "&On Title Bar" msgstr "" -msgid "&Huge" +msgid "&Toolbar" msgstr "" -msgid "&Status Bar" +msgid "&Small" msgstr "" -msgid "Ta&b Bar" +msgid "&Big" msgstr "" -msgid "&View Tab Bar" +msgid "&Huge" msgstr "" -msgid "&On Title Bar" +msgid "&Status Bar" msgstr "" msgid "&Tools" diff --git a/Translations/WinMerge/Finnish.po b/Translations/WinMerge/Finnish.po index 81ed8bc5651..a9ed8d0a5b7 100644 --- a/Translations/WinMerge/Finnish.po +++ b/Translations/WinMerge/Finnish.po @@ -355,6 +355,15 @@ msgstr "Asetukset..." msgid "&View" msgstr "Näkymä" +msgid "Ta&b Bar" +msgstr "Välilehdet" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Työkalurivi" @@ -370,15 +379,6 @@ msgstr "&Valtava" msgid "&Status Bar" msgstr "Tilarivi" -msgid "Ta&b Bar" -msgstr "Välilehdet" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Työkalut" diff --git a/Translations/WinMerge/French.po b/Translations/WinMerge/French.po index 26b2fe258ff..d81b67b93a6 100644 --- a/Translations/WinMerge/French.po +++ b/Translations/WinMerge/French.po @@ -404,6 +404,16 @@ msgstr "&Préférences..." msgid "&View" msgstr "&Affichage" +#, c-format +msgid "Ta&b Bar" +msgstr "Barre d'&onglets" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Barre d'ou&tils" @@ -424,16 +434,6 @@ msgstr "&Énorme" msgid "&Status Bar" msgstr "Barre d'&état" -#, c-format -msgid "Ta&b Bar" -msgstr "Barre d'&onglets" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Outils" diff --git a/Translations/WinMerge/Galician.po b/Translations/WinMerge/Galician.po index d3e8b44504a..3034ec23b6c 100644 --- a/Translations/WinMerge/Galician.po +++ b/Translations/WinMerge/Galician.po @@ -356,6 +356,15 @@ msgstr "&C&onfiguración..." msgid "&View" msgstr "&Ver" +msgid "Ta&b Bar" +msgstr "&Barra de pestanas" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Barra de ferramen&tas" @@ -371,15 +380,6 @@ msgstr "&Enorme" msgid "&Status Bar" msgstr "Barra de e&stado" -msgid "Ta&b Bar" -msgstr "&Barra de pestanas" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Ferramen&tas" diff --git a/Translations/WinMerge/German.po b/Translations/WinMerge/German.po index 8a981b4dd4a..7454bbb4aa2 100644 --- a/Translations/WinMerge/German.po +++ b/Translations/WinMerge/German.po @@ -399,6 +399,16 @@ msgstr "Einstellunge&n..." msgid "&View" msgstr "&Ansicht" +#, c-format +msgid "Ta&b Bar" +msgstr "Ta&b-Leiste" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "&Symbolleiste" @@ -419,16 +429,6 @@ msgstr "&Riesig" msgid "&Status Bar" msgstr "S&tatusleiste" -#, c-format -msgid "Ta&b Bar" -msgstr "Ta&b-Leiste" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Tools" diff --git a/Translations/WinMerge/Greek.po b/Translations/WinMerge/Greek.po index d4229d3f15a..80bec4cd24d 100644 --- a/Translations/WinMerge/Greek.po +++ b/Translations/WinMerge/Greek.po @@ -395,6 +395,16 @@ msgstr "Επιλ&ογές..." msgid "&View" msgstr "Πρ&οβολή" +#, c-format +msgid "Ta&b Bar" +msgstr "Γραμμή Σε&λιδοδεικτών" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Γραμμή Ε&ργαλείων" @@ -415,16 +425,6 @@ msgstr "" msgid "&Status Bar" msgstr "Γραμμή &Καταστάσεως" -#, c-format -msgid "Ta&b Bar" -msgstr "Γραμμή Σε&λιδοδεικτών" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "Εργα&λεία" diff --git a/Translations/WinMerge/Hungarian.po b/Translations/WinMerge/Hungarian.po index 6d6b7832957..4411b159a13 100644 --- a/Translations/WinMerge/Hungarian.po +++ b/Translations/WinMerge/Hungarian.po @@ -398,6 +398,16 @@ msgstr "&Beállítások..." msgid "&View" msgstr "&Nézet" +#, c-format +msgid "Ta&b Bar" +msgstr "Fülsáv" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Eszköztár" @@ -418,16 +428,6 @@ msgstr "Hatalmas" msgid "&Status Bar" msgstr "&Állapotsor" -#, c-format -msgid "Ta&b Bar" -msgstr "Fülsáv" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Eszközök" diff --git a/Translations/WinMerge/Italian.po b/Translations/WinMerge/Italian.po index 3f03c2558db..1fe597455e5 100644 --- a/Translations/WinMerge/Italian.po +++ b/Translations/WinMerge/Italian.po @@ -356,6 +356,15 @@ msgstr "Op&zioni..." msgid "&View" msgstr "&Visualizza" +msgid "Ta&b Bar" +msgstr "&Barra schede" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Barra s&trumenti" @@ -371,15 +380,6 @@ msgstr "&Gigantesca" msgid "&Status Bar" msgstr "&Barra stato" -msgid "Ta&b Bar" -msgstr "&Barra schede" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Strumenti" diff --git a/Translations/WinMerge/Japanese.po b/Translations/WinMerge/Japanese.po index fda875159d2..a7ad2cd839b 100644 --- a/Translations/WinMerge/Japanese.po +++ b/Translations/WinMerge/Japanese.po @@ -354,6 +354,15 @@ msgstr "設定(&O)..." msgid "&View" msgstr "表示(&V)" +msgid "Ta&b Bar" +msgstr "タブ バー(&B)" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "ツールバー(&T)" @@ -369,15 +378,6 @@ msgstr "特大(&H)" msgid "&Status Bar" msgstr "ステータス バー(&S)" -msgid "Ta&b Bar" -msgstr "タブ バー(&B)" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "ツール(&T)" diff --git a/Translations/WinMerge/Korean.po b/Translations/WinMerge/Korean.po index 38d8af80c9c..125cae1dbb7 100644 --- a/Translations/WinMerge/Korean.po +++ b/Translations/WinMerge/Korean.po @@ -405,6 +405,16 @@ msgstr "옵션(&O)..." msgid "&View" msgstr "보기(&V)" +#, c-format +msgid "Ta&b Bar" +msgstr "탭 표시줄(&B)" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "도구 모음(&T)" @@ -425,16 +435,6 @@ msgstr "매우 크게(&H)" msgid "&Status Bar" msgstr "상태 표시줄(&S)" -#, c-format -msgid "Ta&b Bar" -msgstr "탭 표시줄(&B)" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "도구(&T)" diff --git a/Translations/WinMerge/Lithuanian.po b/Translations/WinMerge/Lithuanian.po index 1dad96d7cef..5c159306eb1 100644 --- a/Translations/WinMerge/Lithuanian.po +++ b/Translations/WinMerge/Lithuanian.po @@ -355,6 +355,15 @@ msgstr "Nu&ostatos..." msgid "&View" msgstr "&Vaizdas" +msgid "Ta&b Bar" +msgstr "&Kortelių juosta" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Mygtukų juos&ta" @@ -370,15 +379,6 @@ msgstr "&Milžiniški mygtukai" msgid "&Status Bar" msgstr "Bū&senos juosta" -msgid "Ta&b Bar" -msgstr "&Kortelių juosta" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Į&rankiai" diff --git a/Translations/WinMerge/Norwegian.po b/Translations/WinMerge/Norwegian.po index d6983482c62..4bc73892cf0 100644 --- a/Translations/WinMerge/Norwegian.po +++ b/Translations/WinMerge/Norwegian.po @@ -354,6 +354,15 @@ msgstr "&Innstillinger..." msgid "&View" msgstr "&Vis" +msgid "Ta&b Bar" +msgstr "F&anelinje" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Verkt&øylinje" @@ -369,15 +378,6 @@ msgstr "" msgid "&Status Bar" msgstr "Stat&uslinje" -msgid "Ta&b Bar" -msgstr "F&anelinje" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Verktøy" diff --git a/Translations/WinMerge/Persian.po b/Translations/WinMerge/Persian.po index bf1ac7f10ca..80189c6c421 100644 --- a/Translations/WinMerge/Persian.po +++ b/Translations/WinMerge/Persian.po @@ -397,6 +397,16 @@ msgstr "&O خيارات ... " msgid "&View" msgstr "&V نما " +#, c-format +msgid "Ta&b Bar" +msgstr "&b ميله جهش " + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "&T ميله ابزار " @@ -417,16 +427,6 @@ msgstr "" msgid "&Status Bar" msgstr "&S ميله وضعيت " -#, c-format -msgid "Ta&b Bar" -msgstr "&b ميله جهش " - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&T ابزارها " diff --git a/Translations/WinMerge/Polish.po b/Translations/WinMerge/Polish.po index 5b1950de4ad..5d6936509b3 100644 --- a/Translations/WinMerge/Polish.po +++ b/Translations/WinMerge/Polish.po @@ -356,6 +356,15 @@ msgstr "Opcje..." msgid "&View" msgstr "Widok" +msgid "Ta&b Bar" +msgstr "Pasek kart" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Pasek narzędzi" @@ -371,15 +380,6 @@ msgstr "Ogromny" msgid "&Status Bar" msgstr "Pasek stanu" -msgid "Ta&b Bar" -msgstr "Pasek kart" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Narzędzia" diff --git a/Translations/WinMerge/Portuguese.po b/Translations/WinMerge/Portuguese.po index b9f8d85bad6..15d5b86354f 100644 --- a/Translations/WinMerge/Portuguese.po +++ b/Translations/WinMerge/Portuguese.po @@ -356,6 +356,15 @@ msgstr "&Opções..." msgid "&View" msgstr "&Ver" +msgid "Ta&b Bar" +msgstr "Barra de separadores" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&Barra de ferramentas" @@ -371,15 +380,6 @@ msgstr "&Enorme" msgid "&Status Bar" msgstr "Barra de esta&do" -msgid "Ta&b Bar" -msgstr "Barra de separadores" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Ferramentas" diff --git a/Translations/WinMerge/Romanian.po b/Translations/WinMerge/Romanian.po index e8d8d2c685d..33e6c161535 100644 --- a/Translations/WinMerge/Romanian.po +++ b/Translations/WinMerge/Romanian.po @@ -354,6 +354,15 @@ msgstr "&Opțiuni..." msgid "&View" msgstr "&Vizualizare" +msgid "Ta&b Bar" +msgstr "&Bara de file" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Bară de unel&te" @@ -369,15 +378,6 @@ msgstr "Uriaș" msgid "&Status Bar" msgstr "Bară de &stare" -msgid "Ta&b Bar" -msgstr "&Bara de file" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Unel&te" diff --git a/Translations/WinMerge/Russian.po b/Translations/WinMerge/Russian.po index dcddebb66f8..071a4222ebd 100644 --- a/Translations/WinMerge/Russian.po +++ b/Translations/WinMerge/Russian.po @@ -357,6 +357,15 @@ msgstr "&Настройки..." msgid "&View" msgstr "&Вид" +msgid "Ta&b Bar" +msgstr "Панель вкладок" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Па&нель инструментов" @@ -372,15 +381,6 @@ msgstr "&Огромные значки" msgid "&Status Bar" msgstr "&Строка состояния" -msgid "Ta&b Bar" -msgstr "Панель вкладок" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Инструменты" diff --git a/Translations/WinMerge/Serbian.po b/Translations/WinMerge/Serbian.po index 7b9e7e89140..c6c610557df 100644 --- a/Translations/WinMerge/Serbian.po +++ b/Translations/WinMerge/Serbian.po @@ -394,6 +394,16 @@ msgstr "Изб&ор..." msgid "&View" msgstr "При&каз" +#, c-format +msgid "Ta&b Bar" +msgstr "Тра&ка језичака" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "&Трака алата" @@ -414,16 +424,6 @@ msgstr "" msgid "&Status Bar" msgstr "&Статусна трака" -#, c-format -msgid "Ta&b Bar" -msgstr "Тра&ка језичака" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "Алатке" diff --git a/Translations/WinMerge/Sinhala.po b/Translations/WinMerge/Sinhala.po index 4fb98645e9c..87890a24ce5 100644 --- a/Translations/WinMerge/Sinhala.po +++ b/Translations/WinMerge/Sinhala.po @@ -396,6 +396,16 @@ msgstr "&විකල්පයන්..." msgid "&View" msgstr "&බැලීම" +#, c-format +msgid "Ta&b Bar" +msgstr "Ta&b Bar" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "මෙවලම් තීරය" @@ -416,16 +426,6 @@ msgstr "" msgid "&Status Bar" msgstr "&Status Bar" -#, c-format -msgid "Ta&b Bar" -msgstr "Ta&b Bar" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "මෙවලම්" diff --git a/Translations/WinMerge/Slovak.po b/Translations/WinMerge/Slovak.po index 36e73001815..d4e7ef43967 100644 --- a/Translations/WinMerge/Slovak.po +++ b/Translations/WinMerge/Slovak.po @@ -355,6 +355,15 @@ msgstr "&Nastavenia..." msgid "&View" msgstr "&Zobraziť" +msgid "Ta&b Bar" +msgstr "Lišta &záložiek" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Lišta &nástrojov" @@ -370,15 +379,6 @@ msgstr "&Obrovská" msgid "&Status Bar" msgstr "&Stavový riadok" -msgid "Ta&b Bar" -msgstr "Lišta &záložiek" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Nástroje" diff --git a/Translations/WinMerge/Slovenian.po b/Translations/WinMerge/Slovenian.po index fecda12a8e4..ee755ebec29 100644 --- a/Translations/WinMerge/Slovenian.po +++ b/Translations/WinMerge/Slovenian.po @@ -355,6 +355,15 @@ msgstr "&Možnosti..." msgid "&View" msgstr "&Prikaz" +msgid "Ta&b Bar" +msgstr "Ta&bulatorska vrstica" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&Orodna vrstica" @@ -370,15 +379,6 @@ msgstr "O&gromne" msgid "&Status Bar" msgstr "&Statusna vrstica" -msgid "Ta&b Bar" -msgstr "Ta&bulatorska vrstica" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Orodja" diff --git a/Translations/WinMerge/Spanish.po b/Translations/WinMerge/Spanish.po index c3656539536..2608956ae91 100644 --- a/Translations/WinMerge/Spanish.po +++ b/Translations/WinMerge/Spanish.po @@ -358,6 +358,15 @@ msgstr "C&onfiguración..." msgid "&View" msgstr "&Ver" +msgid "Ta&b Bar" +msgstr "&Barra de pestañas" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Barra de herramien&tas" @@ -373,15 +382,6 @@ msgstr "&Enorme" msgid "&Status Bar" msgstr "Barra de e&stado" -msgid "Ta&b Bar" -msgstr "&Barra de pestañas" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Herramientas" diff --git a/Translations/WinMerge/Swedish.po b/Translations/WinMerge/Swedish.po index f53638d4385..e2038339f52 100644 --- a/Translations/WinMerge/Swedish.po +++ b/Translations/WinMerge/Swedish.po @@ -357,6 +357,15 @@ msgstr "Alternativ..." msgid "&View" msgstr "Visa" +msgid "Ta&b Bar" +msgstr "Flikrad" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "Verktygsrad" @@ -372,15 +381,6 @@ msgstr "Enorm" msgid "&Status Bar" msgstr "Statusfält" -msgid "Ta&b Bar" -msgstr "Flikrad" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "Verktyg" diff --git a/Translations/WinMerge/Tamil.po b/Translations/WinMerge/Tamil.po index e1e0459774f..986a87a60f3 100644 --- a/Translations/WinMerge/Tamil.po +++ b/Translations/WinMerge/Tamil.po @@ -353,6 +353,15 @@ msgstr "&விருப்பங்கள்..." msgid "&View" msgstr "&பார்வை" +msgid "Ta&b Bar" +msgstr "Ta&b Bar" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&கருவிப்பட்டி" @@ -368,15 +377,6 @@ msgstr "&பெரிய" msgid "&Status Bar" msgstr "&நிலைப் பட்டி" -msgid "Ta&b Bar" -msgstr "Ta&b Bar" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&கருவிகள்" diff --git a/Translations/WinMerge/Turkish.po b/Translations/WinMerge/Turkish.po index b14f43751a8..ac0859c1d8b 100644 --- a/Translations/WinMerge/Turkish.po +++ b/Translations/WinMerge/Turkish.po @@ -354,6 +354,15 @@ msgstr "&Ayarlar..." msgid "&View" msgstr "&Görünüm" +msgid "Ta&b Bar" +msgstr "&Sekme çubuğu" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + msgid "&Toolbar" msgstr "&Araç çubuğu" @@ -369,15 +378,6 @@ msgstr "Çok &büyük" msgid "&Status Bar" msgstr "&Durum çubuğu" -msgid "Ta&b Bar" -msgstr "&Sekme çubuğu" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - msgid "&Tools" msgstr "&Araçlar" diff --git a/Translations/WinMerge/Ukrainian.po b/Translations/WinMerge/Ukrainian.po index 398d9695ff9..b487f298fea 100644 --- a/Translations/WinMerge/Ukrainian.po +++ b/Translations/WinMerge/Ukrainian.po @@ -380,6 +380,16 @@ msgstr "&Налаштування..." msgid "&View" msgstr "Ви&гляд" +#, c-format +msgid "Ta&b Bar" +msgstr "Панель &закладок" + +msgid "&View Tab Bar" +msgstr "" + +msgid "&On Title Bar" +msgstr "" + #, c-format msgid "&Toolbar" msgstr "Пан&ель інструментів" @@ -400,16 +410,6 @@ msgstr "&Величезні піктограми" msgid "&Status Bar" msgstr "Ря&док стану" -#, c-format -msgid "Ta&b Bar" -msgstr "Панель &закладок" - -msgid "&View Tab Bar" -msgstr "" - -msgid "&On Title Bar" -msgstr "" - #, c-format msgid "&Tools" msgstr "&Сервіс" From e1be4c859e35c468534abc75597d142ca942f9ea Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 22 Sep 2024 15:38:28 +0900 Subject: [PATCH 15/22] WIP --- Src/Common/MDITabBar.cpp | 19 ++++++++++++++----- Src/MainFrm.cpp | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index c3bbffd690b..aed632e052a 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -92,8 +92,17 @@ void CMyTabCtrl::OnPaint() CRect rcClient; GetClientRect(&rcClient); + const int nCount = GetItemCount(); + if (nCount == 0) + { + dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); + TCHAR szBuf[256]; + AfxGetMainWnd()->GetWindowText(szBuf, sizeof(szBuf) / sizeof(szBuf[0])); + dc.DrawText(szBuf, -1, &rcClient, DT_LEFT | DT_VCENTER | DT_SINGLELINE); + } + int nCurSel = GetCurSel(); - for (int i = GetItemCount() - 1; i >= 0; --i) + for (int i = nCount - 1; i >= 0; --i) { GetItemRect(i, &dis.rcItem); dis.itemID = i; @@ -472,11 +481,11 @@ void CMDITabBar::OnSize(UINT nType, int cx, int cy) auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; const int leftMargin = m_bOnTitleBar ? pointToPixel(m_leftMarginPoint) : 0; const int rightMargin = m_bOnTitleBar ? pointToPixel(m_rightMarginPoint) : 0; - int my = (m_bMaximized) ? 8 : 0; - CSize size{ 0, cy - my }; - m_tabCtrl.MoveWindow(leftMargin, my, cx - leftMargin - rightMargin, cy - my, true); + int topMargin = ((m_bMaximized && m_bOnTitleBar) ? 8 : 0) + (m_bOnTitleBar ? 1 : 0); + int bottomMargin = m_bOnTitleBar ? 1 : 0; + CSize size{ 0, cy - topMargin - bottomMargin }; + m_tabCtrl.MoveWindow(leftMargin, topMargin, cx - leftMargin - rightMargin, cy - topMargin - bottomMargin, true); m_tabCtrl.SetItemSize(size); - } } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index b2802f8402f..c4e388446ab 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -1605,8 +1605,7 @@ void CMainFrame::UpdateTitleBarAndTabBar() std::swap(pWnd1, pWnd2); pWnd1->SetWindowPos(pWnd2, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); pWnd2->SetWindowPos(pWnd1, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - for (int i = 0; i < 2; i++) - ShowWindow(IsZoomed() ? SW_RESTORE : SW_MAXIMIZE); + SetWindowPos(nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); RecalcLayout(); } From e1296858bab49a5609411293114e9c8c0714f7ed Mon Sep 17 00:00:00 2001 From: sdottaka Date: Tue, 24 Sep 2024 08:18:56 +0900 Subject: [PATCH 16/22] WIP --- Src/BasicFlatStatusBar.h | 6 +- Src/Common/MDITabBar.cpp | 94 +++++++++++------- Src/Common/MDITabBar.h | 19 ++-- Src/MainFrm.cpp | 20 +++- Src/MainFrm.h | 3 + Src/TitleBarHelper.cpp | 199 ++++++++++++++++++++++++++++++++++----- Src/TitleBarHelper.h | 25 +++-- 7 files changed, 291 insertions(+), 75 deletions(-) diff --git a/Src/BasicFlatStatusBar.h b/Src/BasicFlatStatusBar.h index 53fa65e55c2..ccbbe7df57d 100644 --- a/Src/BasicFlatStatusBar.h +++ b/Src/BasicFlatStatusBar.h @@ -15,19 +15,19 @@ class CBasicFlatStatusBar : public CStatusBar { DECLARE_DYNAMIC(CBasicFlatStatusBar) public: - CBasicFlatStatusBar(); + CBasicFlatStatusBar(); protected: CPoint CBasicFlatStatusBar::GetClientCursorPos() const; int GetIndexFromPoint(const CPoint& pt) const; static COLORREF LightenColor(COLORREF color, double amount); - afx_msg void OnPaint(); + afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC *pDC); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnMouseLeave(); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP() bool m_bMouseTracking; int m_nTrackingPane; diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index aed632e052a..87663af07f4 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -45,9 +45,11 @@ BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) ON_WM_NCHITTEST() ON_WM_ERASEBKGND() ON_WM_PAINT() - ON_MESSAGE(WM_NCLBUTTONDBLCLK, OnNcForward) - ON_MESSAGE(WM_NCLBUTTONDOWN, OnNcForward) - ON_MESSAGE(WM_NCLBUTTONUP, OnNcForward) + ON_WM_NCMOUSEMOVE() + ON_WM_NCMOUSELEAVE() + ON_WM_NCLBUTTONDBLCLK() + ON_WM_NCLBUTTONDOWN() + ON_WM_NCLBUTTONUP() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -469,26 +471,6 @@ void CMyTabCtrl::OnLButtonUp(UINT nFlags, CPoint point) CWnd::OnLButtonUp(nFlags, point); } -void CMDITabBar::OnSize(UINT nType, int cx, int cy) -{ - __super::OnSize(nType, cx, cy); - Invalidate(); - m_titleBar.OnSize(this, m_bMaximized, cx, cy); - if (m_tabCtrl.m_hWnd) - { - CClientDC dc(this); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](float point) { return static_cast(point * lpx / 72); }; - const int leftMargin = m_bOnTitleBar ? pointToPixel(m_leftMarginPoint) : 0; - const int rightMargin = m_bOnTitleBar ? pointToPixel(m_rightMarginPoint) : 0; - int topMargin = ((m_bMaximized && m_bOnTitleBar) ? 8 : 0) + (m_bOnTitleBar ? 1 : 0); - int bottomMargin = m_bOnTitleBar ? 1 : 0; - CSize size{ 0, cy - topMargin - bottomMargin }; - m_tabCtrl.MoveWindow(leftMargin, topMargin, cx - leftMargin - rightMargin, cy - topMargin - bottomMargin, true); - m_tabCtrl.SetItemSize(size); - } -} - CRect CMyTabCtrl::GetCloseButtonRect(int nItem) { CClientDC dc(this); @@ -610,12 +592,14 @@ void CMyTabCtrl::UpdateToolTips(int nTabItemIndex) } } -BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized, float leftMarginPoint, float rightMarginPoint) +BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized) { m_bOnTitleBar = bOnTitleBar; m_bMaximized = bMaximized; - m_leftMarginPoint = leftMarginPoint; - m_rightMarginPoint = rightMarginPoint; + CRect rc; + if (m_bMaximized) + AfxGetMainWnd()->GetWindowRect(&rc); + m_top = rc.top; return true; } @@ -627,7 +611,9 @@ BOOL CMDITabBar::Create(CMDIFrameWnd* pMainFrame) { m_dwStyle = CBRS_TOP; - CWnd::Create(WC_STATIC, nullptr, WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), pMainFrame, AFX_IDW_CONTROLBAR_FIRST + 30); + m_titleBar.Init(this); + + CWnd::Create(nullptr, nullptr, WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), pMainFrame, AFX_IDW_CONTROLBAR_FIRST + 30); if (!m_tabCtrl.Create(pMainFrame, this)) return FALSE; @@ -665,8 +651,7 @@ CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); }; const int r = pointToPixel(RR_RADIUS); const int sw = pointToPixel(RR_SHADOWWIDTH); - - int my = m_bOnTitleBar ? (m_bMaximized ? (8 + 6) : 6) : 0; + int my = m_bOnTitleBar ? (m_bMaximized ? (-m_top + 2) : 2) : 0; CSize size(SHRT_MAX, my + tm.tmHeight + (sw + r) * 2); return size; } @@ -676,6 +661,48 @@ LRESULT CMDITabBar::OnNcHitTest(CPoint point) return m_titleBar.HitTest(point); } +void CMDITabBar::OnNcMouseMove(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcMouseMove(nHitTest, point); +} + +void CMDITabBar::OnNcMouseLeave() +{ + m_titleBar.OnNcMouseLeave(); +} + +void CMDITabBar::OnNcLButtonDblClk(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcLButtonDblClk(nHitTest, point); +} + +void CMDITabBar::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcLButtonDown(nHitTest, point); +} + +void CMDITabBar::OnNcLButtonUp(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcLButtonUp(nHitTest, point); +} + +void CMDITabBar::OnSize(UINT nType, int cx, int cy) +{ + __super::OnSize(nType, cx, cy); + Invalidate(); + m_titleBar.OnSize(m_bMaximized, cx, cy); + if (m_tabCtrl.m_hWnd) + { + const int leftMargin = m_bOnTitleBar ? m_titleBar.GetLeftMargin() : 0; + const int rightMargin = m_bOnTitleBar ? m_titleBar.GetRightMargin() : 0; + const int topMargin = ((m_bMaximized && m_bOnTitleBar) ? -m_top : 0) + (m_bOnTitleBar ? 1 : 0); + const int bottomMargin = m_bOnTitleBar ? 1 : 0; + CSize size{ 0, cy - topMargin - bottomMargin }; + m_tabCtrl.MoveWindow(leftMargin, topMargin, cx - leftMargin - rightMargin, cy - topMargin - bottomMargin, true); + m_tabCtrl.SetItemSize(size); + } +} + BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) { CRect rClient; @@ -686,12 +713,11 @@ BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC) void CMDITabBar::OnPaint() { - CPaintDC dc(this); if (!m_bOnTitleBar) - return; + return __super::OnPaint(); + CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); - const int lpx = dc.GetDeviceCaps(LOGPIXELSX); - auto pointToPixel = [lpx](float point) -> int { return static_cast(point * lpx / 72); }; - m_titleBar.DrawIcon(AfxGetMainWnd(), dc, pointToPixel(m_leftMarginPoint)); + m_titleBar.DrawIcon(AfxGetMainWnd(), dc); + m_titleBar.DrawButtons(dc); } diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index be5b1c086d4..9e0408bc1a3 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -86,8 +86,7 @@ class CMDITabBar : public CControlBar bool m_bOnTitleBar; bool m_bMaximized; - float m_leftMarginPoint; - float m_rightMarginPoint; + int m_top; CMyTabCtrl m_tabCtrl; CFont m_font; CTitleBarHelper m_titleBar; @@ -96,11 +95,10 @@ class CMDITabBar : public CControlBar CMDITabBar() : m_bOnTitleBar(true) , m_bMaximized(false) - , m_leftMarginPoint(0) - , m_rightMarginPoint(0) + , m_top(0) {} virtual ~CMDITabBar() {} - BOOL Update(bool bOnTitleBar, bool bMaxmized, float iconWidthPoint, float buttonsWidthPoint); + BOOL Update(bool bOnTitleBar, bool bMaxmized); BOOL Create(CMDIFrameWnd* pParentWnd); void UpdateTabs() { m_tabCtrl.UpdateTabs(); } bool GetAutoMaxWidth() const { return m_tabCtrl.GetAutoMaxWidth(); } @@ -113,12 +111,15 @@ class CMDITabBar : public CControlBar protected: //{{AFX_MSG(CMDITabBar) - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnPaint(); afx_msg LRESULT OnNcHitTest(CPoint point); - template - afx_msg LRESULT OnNcForward(WPARAM wParam, LPARAM lParam) { return AfxGetMainWnd()->SendMessage(message, wParam, lParam); } + afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); + afx_msg void OnNcMouseLeave(); + afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index c4e388446ab..717eb3fff0b 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -224,6 +224,10 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_WM_ACTIVATEAPP() ON_WM_NCCALCSIZE() ON_WM_SIZE() + ON_WM_MOUSEMOVE() + ON_WM_MOUSELEAVE() + ON_WM_NCMOUSEMOVE() + ON_WM_NCMOUSELEAVE() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>)) @@ -413,7 +417,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) if (IsWin10_OrGreater()) m_bTabsOnTitleBar = GetOptionsMgr()->GetBool(OPT_TABBAR_ON_TITLEBAR); - m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), false, 32.f, 18.f * 3); + m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), false); if (m_bTabsOnTitleBar.value_or(false) && !m_wndTabBar.Create(this)) { @@ -2543,10 +2547,22 @@ void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncs void CMainFrame::OnSize(UINT nType, int cx, int cy) { - m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), (nType == SIZE_MAXIMIZED), 32.f, 18.f * 3); + m_wndTabBar.Update(m_bTabsOnTitleBar.value_or(false), (nType == SIZE_MAXIMIZED)); __super::OnSize(nType, cx, cy); } +void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) +{ +} + +void CMainFrame::OnMouseLeave() +{ +} + +void CMainFrame::OnNcMouseMove(UINT nHitTest, CPoint point) +{ +} + BOOL CMainFrame::CreateToolbar() { if (!m_wndMenuBar.Create(this)) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 39ddafe2a6a..fbe7a03858c 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -387,6 +387,9 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnMouseLeave(); + afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg void OnToolbarSize(UINT id); afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index 172497459ad..df7e126c13b 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -10,45 +10,201 @@ #include "TitleBarHelper.h" #include "RoundedRectWithShadow.h" -void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc, int leftMarginWidth) +CTitleBarHelper::CTitleBarHelper() + : m_pWnd(nullptr) + , m_maximized(false) + , m_iconSize(0) + , m_dpi(96) + , m_leftMargin(32.f) + , m_rightMargin(35.f * 3) + , m_bMouseTracking(false) + , m_nTrackingButton(-1) + , m_nHitTest(-1) +{ +} + +void CTitleBarHelper::Init(CWnd *pWnd) +{ + m_pWnd = pWnd; +} + +void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) { HICON hIcon = (HICON)pWnd->SendMessage(WM_GETICON, ICON_SMALL2, 0); if (hIcon == nullptr) hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM); if (hIcon != nullptr) { - const int my = (m_maximized ? 8 : 0); - const int height = m_size.cy - my; - const int cx = PointToPixel(12.f); - const int cy = PointToPixel(12.f); - const int x = (leftMarginWidth - cx) / 2; - const int y = (height - cy) / 2 + my; + const int topMargin = (m_maximized ? -m_rc.top : 0); + const int height = m_size.cy - topMargin; + const int cx = static_cast(PointToPixel(12.f)); + const int cy = static_cast(PointToPixel(12.f)); + const int x = static_cast((PointToPixel(m_leftMargin) - cx) / 2); + const int y = static_cast((height - cy) / 2 + topMargin); DrawIconEx(dc.m_hDC, x, y, hIcon, cx, cy, 0, nullptr, DI_NORMAL); } } -void CTitleBarHelper::DrawButtons(CDC& dc) +static void DrawTopRightEdgeWithCurve(Gdiplus::Graphics& graphics, Gdiplus::Pen& pen, Gdiplus::Rect rect, int cornerRadius) { + Gdiplus::GraphicsPath path; + path.AddLine(rect.X, rect.Y, rect.X + rect.Width - cornerRadius, rect.Y); + path.AddArc(rect.X + rect.Width - cornerRadius, rect.Y, cornerRadius, cornerRadius, 270, 90); + path.AddLine(rect.X + rect.Width, rect.Y + cornerRadius, rect.X + rect.Width, rect.Y + rect.Height); + graphics.DrawPath(&pen, &path); } -CRect CTitleBarHelper::GetIconRect() +static void DrawRoundedRectangle(Gdiplus::Graphics& graphics, Gdiplus::Pen& pen, Gdiplus::Rect rect, int cornerRadius) { - return CRect{}; + Gdiplus::GraphicsPath path; + path.AddArc(rect.X, rect.Y, cornerRadius, cornerRadius, 180, 90); + path.AddArc(rect.X + rect.Width - cornerRadius, rect.Y, cornerRadius, cornerRadius, 270, 90); + path.AddArc(rect.X + rect.Width - cornerRadius, rect.Y + rect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90); + path.AddArc(rect.X, rect.Y + rect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90); + path.CloseFigure(); + graphics.DrawPath(&pen, &path); } -CRect CTitleBarHelper::GetButtonsRect() +void CTitleBarHelper::DrawButtons(CDC& dc) { - return CRect{}; + Gdiplus::Graphics graphics(dc.m_hDC); + CRect rcIcons[3], rcButtons[3]; + const float buttonWidth = PointToPixel(m_rightMargin) / 3.f; + const float iconSize = PointToPixel(6.75); + for (int i = 0; i < 3; i++) + { + rcButtons[i] = GetButtonRect(i); + rcIcons[i] = rcButtons[i]; + rcIcons[i].left = static_cast(rcIcons[i].left + (buttonWidth - iconSize) / 2); + rcIcons[i].right = static_cast(rcIcons[i].left + iconSize); + rcIcons[i].top = static_cast(rcIcons[i].top + (rcButtons[i].Height() - iconSize) / 2); + rcIcons[i].bottom = static_cast(rcIcons[i].top + iconSize); + + Gdiplus::Color color; + color.SetFromCOLORREF((m_nTrackingButton == i) ? GetSysColor(COLOR_WINDOW) : GetSysColor(COLOR_3DFACE)); + Gdiplus::SolidBrush brush(color); + graphics.FillRectangle(&brush, rcButtons[i].left, rcButtons[i].top, rcButtons[i].Width(), rcButtons[i].Height()); + } + + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), PointToPixel(0.75)); + graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].top), Gdiplus::Point(rcIcons[2].right, rcIcons[2].bottom)); + graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].bottom), Gdiplus::Point(rcIcons[2].right, rcIcons[2].top)); + + const int r = static_cast(PointToPixel(0.75)); + if (m_maximized) + { + DrawTopRightEdgeWithCurve(graphics, pen, Gdiplus::Rect(rcIcons[1].left + r, rcIcons[1].top - r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r); + DrawRoundedRectangle(graphics, pen, Gdiplus::Rect(rcIcons[1].left - r, rcIcons[1].top + r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r); + } + else + { + DrawRoundedRectangle(graphics, pen, Gdiplus::Rect(rcIcons[1].left, rcIcons[1].top, rcIcons[1].Width(), rcIcons[1].Height()), r); + } + + const int y = (rcIcons[0].top + rcIcons[0].bottom) / 2; + graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[0].left, y), Gdiplus::Point(rcIcons[0].right, y)); +} + +CRect CTitleBarHelper::GetButtonRect(int button) const +{ + const float w1 = PointToPixel(m_rightMargin) / 3.f; + CRect rcPart; + const int topMargin = (m_maximized ? -m_rc.top : 0); + rcPart.top = topMargin; + rcPart.bottom = m_size.cy; + rcPart.left = static_cast(m_size.cx - (3 - button) * w1); + rcPart.right = static_cast(rcPart.left + w1); + return rcPart; } -void CTitleBarHelper::OnSize(CWnd* pWnd, bool maximized, int cx, int cy) +void CTitleBarHelper::OnSize(bool maximized, int cx, int cy) { m_size = CSize(cx, cy); m_maximized = maximized; - m_pWnd = pWnd; - CClientDC dc(pWnd); + CClientDC dc(m_pWnd); m_dpi = dc.GetDeviceCaps(LOGPIXELSX); + m_pWnd->GetWindowRect(&m_rc); +} + +void CTitleBarHelper::OnNcMouseMove(UINT nHitTest, CPoint point) +{ + if (!m_bMouseTracking) + { + TRACKMOUSEEVENT tme = { sizeof TRACKMOUSEEVENT, TME_LEAVE | TME_NONCLIENT, m_pWnd->m_hWnd }; + TrackMouseEvent(&tme); + m_bMouseTracking = true; + } + int i = HitTest(point); + if (i == HTMINBUTTON) + i = 0; + else if (i == HTMAXBUTTON) + i = 1; + else if (i == HTCLOSE) + i = 2; + else + i = -1; + for (int button : {i, m_nTrackingButton}) + { + if (button != -1) + { + CRect rcPart = GetButtonRect(button); + m_pWnd->InvalidateRect(&rcPart, false); + } + } + m_nTrackingButton = i; +} + +void CTitleBarHelper::OnNcMouseLeave() +{ + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE | TME_CANCEL, m_pWnd->m_hWnd }; + TrackMouseEvent(&tme); + m_bMouseTracking = false; + if (m_nTrackingButton >= 0) + { + CRect rcPart = GetButtonRect(m_nTrackingButton); + m_pWnd->InvalidateRect(&rcPart, false); + } + m_nTrackingButton = -1; +} + +void CTitleBarHelper::OnNcLButtonDblClk(UINT nHitTest, CPoint point) +{ + if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) + { + AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDBLCLK, nHitTest, MAKELPARAM(point.x, point.y)); + } +} + +void CTitleBarHelper::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) + { + AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDOWN, nHitTest, MAKELPARAM(point.x, point.y)); + } + else if (nHitTest == HTMINBUTTON || nHitTest == HTMAXBUTTON || nHitTest == HTCLOSE) + { + m_nHitTest = nHitTest; + } +} + +void CTitleBarHelper::OnNcLButtonUp(UINT nHitTest, CPoint point) +{ + if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) + { + AfxGetMainWnd()->SendMessage(WM_NCLBUTTONUP, nHitTest, MAKELPARAM(point.x, point.y)); + } + else if (m_nHitTest != -1 && m_nHitTest == nHitTest) + { + if (nHitTest == HTMINBUTTON) + AfxGetMainWnd()->ShowWindow(SW_MINIMIZE); + else if (nHitTest == HTMAXBUTTON) + AfxGetMainWnd()->ShowWindow(m_maximized ? SW_RESTORE : SW_MAXIMIZE); + else if (nHitTest == HTCLOSE) + AfxGetMainWnd()->PostMessage(WM_CLOSE); + } + m_nHitTest = -1; } int CTitleBarHelper::HitTest(CPoint pt) @@ -56,10 +212,11 @@ int CTitleBarHelper::HitTest(CPoint pt) if (!m_pWnd) return HTNOWHERE; CClientDC dc(m_pWnd); - const int height = PointToPixel(24); - const int buttonWidth = PointToPixel(24); + const int height = m_size.cy; + const int leftMargin = static_cast(PointToPixel(m_leftMargin)); + const int rightMargin = static_cast(PointToPixel(m_rightMargin)); CRect rc; - const int bw = buttonWidth; + const int bw = rightMargin / 3; const int m = 8; m_pWnd->GetWindowRect(&rc); if (pt.y < rc.top + 4) @@ -74,7 +231,7 @@ int CTitleBarHelper::HitTest(CPoint pt) return HTLEFT; if (rc.right - m <= pt.x) return HTRIGHT; - if (pt.x < rc.left + bw) + if (pt.x < rc.left + leftMargin) return HTSYSMENU; if (rc.right - bw * 3 <= pt.x && pt.x < rc.right - bw * 2) { @@ -91,7 +248,7 @@ int CTitleBarHelper::HitTest(CPoint pt) return HTCAPTION; } -int CTitleBarHelper::PointToPixel(float point) +float CTitleBarHelper::PointToPixel(float point) const { - return static_cast(point * m_dpi / 72.f); + return point * m_dpi / 72.f; }; diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 27a6fbc74ea..b421ac24873 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -12,20 +12,33 @@ class CTitleBarHelper { public: - CTitleBarHelper() {} - void DrawIcon(CWnd* pWnd, CDC& dc, int leftMarginWidth); + CTitleBarHelper(); + void Init(CWnd* pWnd); + void DrawIcon(CWnd* pWnd, CDC& dc); void DrawButtons(CDC& dc); - CRect GetIconRect(); - CRect GetButtonsRect(); - void OnSize(CWnd* pWnd, bool maximized, int cx, int cy); + int GetLeftMargin() const { return static_cast(PointToPixel(m_leftMargin)); } + int GetRightMargin() const { return static_cast(PointToPixel(m_rightMargin)); } + CRect GetButtonRect(int button) const; + void OnSize(bool maximized, int cx, int cy); + void OnNcMouseMove(UINT nHitTest, CPoint point); + void OnNcMouseLeave(); + void OnNcLButtonDblClk(UINT nHitTest, CPoint point); + void OnNcLButtonDown(UINT nHitTest, CPoint point); + void OnNcLButtonUp(UINT nHitTest, CPoint point); int HitTest(CPoint pt); private: - int PointToPixel(float point); + float PointToPixel(float point) const; CWnd* m_pWnd; CSize m_size; + CRect m_rc; bool m_maximized; + bool m_bMouseTracking; + int m_nTrackingButton; + int m_nHitTest; int m_iconSize; int m_dpi; + float m_leftMargin; + float m_rightMargin; }; From 760bef2e4ae636d77fca6d3592e1a53a79e8f64e Mon Sep 17 00:00:00 2001 From: sdottaka Date: Tue, 24 Sep 2024 09:15:34 +0900 Subject: [PATCH 17/22] WIP --- Src/Common/MDITabBar.cpp | 12 ++++++++ Src/Common/MDITabBar.h | 2 ++ Src/TitleBarHelper.cpp | 65 ++++++++++++++++++++++++---------------- Src/TitleBarHelper.h | 5 ++-- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 87663af07f4..61c9b3f53d8 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -50,6 +50,8 @@ BEGIN_MESSAGE_MAP(CMDITabBar, CControlBar) ON_WM_NCLBUTTONDBLCLK() ON_WM_NCLBUTTONDOWN() ON_WM_NCLBUTTONUP() + ON_WM_NCRBUTTONDOWN() + ON_WM_NCRBUTTONUP() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -686,6 +688,16 @@ void CMDITabBar::OnNcLButtonUp(UINT nHitTest, CPoint point) m_titleBar.OnNcLButtonUp(nHitTest, point); } +void CMDITabBar::OnNcRButtonDown(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcRButtonDown(nHitTest, point); +} + +void CMDITabBar::OnNcRButtonUp(UINT nHitTest, CPoint point) +{ + m_titleBar.OnNcRButtonUp(nHitTest, point); +} + void CMDITabBar::OnSize(UINT nType, int cx, int cy) { __super::OnSize(nType, cx, cy); diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index 9e0408bc1a3..b6297911661 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -117,6 +117,8 @@ class CMDITabBar : public CControlBar afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point); afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); + afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index df7e126c13b..0661b34d4db 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -13,13 +13,12 @@ CTitleBarHelper::CTitleBarHelper() : m_pWnd(nullptr) , m_maximized(false) - , m_iconSize(0) , m_dpi(96) , m_leftMargin(32.f) , m_rightMargin(35.f * 3) , m_bMouseTracking(false) , m_nTrackingButton(-1) - , m_nHitTest(-1) + , m_nHitTest(HTNOWHERE) { } @@ -81,21 +80,28 @@ void CTitleBarHelper::DrawButtons(CDC& dc) rcIcons[i].top = static_cast(rcIcons[i].top + (rcButtons[i].Height() - iconSize) / 2); rcIcons[i].bottom = static_cast(rcIcons[i].top + iconSize); + COLORREF colorref; Gdiplus::Color color; - color.SetFromCOLORREF((m_nTrackingButton == i) ? GetSysColor(COLOR_WINDOW) : GetSysColor(COLOR_3DFACE)); + if (m_nTrackingButton == i) + colorref = (i == 2) ? RGB(0xE9, 0x48, 0x56) : GetSysColor(COLOR_WINDOW); + else + colorref = GetSysColor(COLOR_3DFACE); + color.SetFromCOLORREF(colorref); Gdiplus::SolidBrush brush(color); graphics.FillRectangle(&brush, rcButtons[i].left, rcButtons[i].top, rcButtons[i].Width(), rcButtons[i].Height()); } graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), PointToPixel(0.75)); + Gdiplus::Color penColor; + penColor.SetFromCOLORREF(GetSysColor(COLOR_WINDOWTEXT)); + Gdiplus::Pen pen(penColor, PointToPixel(0.75)); graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].top), Gdiplus::Point(rcIcons[2].right, rcIcons[2].bottom)); graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].bottom), Gdiplus::Point(rcIcons[2].right, rcIcons[2].top)); const int r = static_cast(PointToPixel(0.75)); if (m_maximized) { - DrawTopRightEdgeWithCurve(graphics, pen, Gdiplus::Rect(rcIcons[1].left + r, rcIcons[1].top - r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r); + DrawTopRightEdgeWithCurve(graphics, pen, Gdiplus::Rect(rcIcons[1].left + r, rcIcons[1].top - r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r * 3); DrawRoundedRectangle(graphics, pen, Gdiplus::Rect(rcIcons[1].left - r, rcIcons[1].top + r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r); } else @@ -171,15 +177,13 @@ void CTitleBarHelper::OnNcMouseLeave() void CTitleBarHelper::OnNcLButtonDblClk(UINT nHitTest, CPoint point) { - if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) - { + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDBLCLK, nHitTest, MAKELPARAM(point.x, point.y)); - } } void CTitleBarHelper::OnNcLButtonDown(UINT nHitTest, CPoint point) { - if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) { AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDOWN, nHitTest, MAKELPARAM(point.x, point.y)); } @@ -191,11 +195,11 @@ void CTitleBarHelper::OnNcLButtonDown(UINT nHitTest, CPoint point) void CTitleBarHelper::OnNcLButtonUp(UINT nHitTest, CPoint point) { - if (nHitTest == HTCAPTION || nHitTest == HTSYSMENU) + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) { AfxGetMainWnd()->SendMessage(WM_NCLBUTTONUP, nHitTest, MAKELPARAM(point.x, point.y)); } - else if (m_nHitTest != -1 && m_nHitTest == nHitTest) + else if (m_nHitTest != HTNOWHERE && m_nHitTest == nHitTest) { if (nHitTest == HTMINBUTTON) AfxGetMainWnd()->ShowWindow(SW_MINIMIZE); @@ -204,7 +208,18 @@ void CTitleBarHelper::OnNcLButtonUp(UINT nHitTest, CPoint point) else if (nHitTest == HTCLOSE) AfxGetMainWnd()->PostMessage(WM_CLOSE); } - m_nHitTest = -1; + m_nHitTest = HTNOWHERE; +} + +void CTitleBarHelper::OnNcRButtonDown(UINT nHitTest, CPoint point) +{ + AfxGetMainWnd()->SendMessage(WM_NCRBUTTONDOWN, nHitTest, MAKELPARAM(point.x, point.y)); +} + +void CTitleBarHelper::OnNcRButtonUp(UINT nHitTest, CPoint point) +{ + CMenu *pSysMenu = AfxGetMainWnd()->GetSystemMenu(FALSE); + pSysMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, point.x, point.y, m_pWnd, nullptr); } int CTitleBarHelper::HitTest(CPoint pt) @@ -212,14 +227,12 @@ int CTitleBarHelper::HitTest(CPoint pt) if (!m_pWnd) return HTNOWHERE; CClientDC dc(m_pWnd); - const int height = m_size.cy; const int leftMargin = static_cast(PointToPixel(m_leftMargin)); const int rightMargin = static_cast(PointToPixel(m_rightMargin)); - CRect rc; - const int bw = rightMargin / 3; const int m = 8; + CRect rc; m_pWnd->GetWindowRect(&rc); - if (pt.y < rc.top + 4) + if (pt.y < rc.top + m) { if (pt.x < rc.left + m) return HTTOPLEFT; @@ -233,22 +246,22 @@ int CTitleBarHelper::HitTest(CPoint pt) return HTRIGHT; if (pt.x < rc.left + leftMargin) return HTSYSMENU; - if (rc.right - bw * 3 <= pt.x && pt.x < rc.right - bw * 2) - { + CRect rcButton = GetButtonRect(0); + m_pWnd->ClientToScreen(&rcButton); + if (PtInRect(&rcButton, pt)) return HTMINBUTTON; - } - else if (rc.right - bw * 2 <= pt.x && pt.x < rc.right - bw) - { + rcButton = GetButtonRect(1); + m_pWnd->ClientToScreen(&rcButton); + if (PtInRect(&rcButton, pt)) return HTMAXBUTTON; - } - else if (rc.right - bw <= pt.x && pt.x < rc.right) - { + rcButton = GetButtonRect(2); + m_pWnd->ClientToScreen(&rcButton); + if (PtInRect(&rcButton, pt)) return HTCLOSE; - } return HTCAPTION; } float CTitleBarHelper::PointToPixel(float point) const { return point * m_dpi / 72.f; -}; +} diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index b421ac24873..2b77aa51ef7 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -25,6 +25,8 @@ class CTitleBarHelper { void OnNcLButtonDblClk(UINT nHitTest, CPoint point); void OnNcLButtonDown(UINT nHitTest, CPoint point); void OnNcLButtonUp(UINT nHitTest, CPoint point); + void OnNcRButtonDown(UINT nHitTest, CPoint point); + void OnNcRButtonUp(UINT nHitTest, CPoint point); int HitTest(CPoint pt); private: @@ -36,9 +38,8 @@ class CTitleBarHelper { bool m_maximized; bool m_bMouseTracking; int m_nTrackingButton; - int m_nHitTest; - int m_iconSize; int m_dpi; + unsigned m_nHitTest; float m_leftMargin; float m_rightMargin; }; From e485afd08c26936721faa6076718b951c2b3405b Mon Sep 17 00:00:00 2001 From: sdottaka Date: Wed, 25 Sep 2024 08:54:05 +0900 Subject: [PATCH 18/22] WIP --- Src/TitleBarHelper.cpp | 112 ++++++++++++++++++++++------------------- Src/TitleBarHelper.h | 10 ++-- 2 files changed, 68 insertions(+), 54 deletions(-) diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index 0661b34d4db..a8035af7387 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -8,7 +8,6 @@ #include "StdAfx.h" #include "TitleBarHelper.h" -#include "RoundedRectWithShadow.h" CTitleBarHelper::CTitleBarHelper() : m_pWnd(nullptr) @@ -36,10 +35,10 @@ void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) { const int topMargin = (m_maximized ? -m_rc.top : 0); const int height = m_size.cy - topMargin; - const int cx = static_cast(PointToPixel(12.f)); - const int cy = static_cast(PointToPixel(12.f)); - const int x = static_cast((PointToPixel(m_leftMargin) - cx) / 2); - const int y = static_cast((height - cy) / 2 + topMargin); + const int cx = PointToPixel(12.f); + const int cy = PointToPixel(12.f); + const int x = (PointToPixel(m_leftMargin) - cx) / 2; + const int y = (height - cy) / 2 + topMargin; DrawIconEx(dc.m_hDC, x, y, hIcon, cx, cy, 0, nullptr, DI_NORMAL); } @@ -69,8 +68,8 @@ void CTitleBarHelper::DrawButtons(CDC& dc) { Gdiplus::Graphics graphics(dc.m_hDC); CRect rcIcons[3], rcButtons[3]; - const float buttonWidth = PointToPixel(m_rightMargin) / 3.f; - const float iconSize = PointToPixel(6.75); + const float buttonWidth = PointToPixelF(m_rightMargin) / 3.f; + const int iconSize = PointToPixel(6.75); for (int i = 0; i < 3; i++) { rcButtons[i] = GetButtonRect(i); @@ -83,7 +82,7 @@ void CTitleBarHelper::DrawButtons(CDC& dc) COLORREF colorref; Gdiplus::Color color; if (m_nTrackingButton == i) - colorref = (i == 2) ? RGB(0xE9, 0x48, 0x56) : GetSysColor(COLOR_WINDOW); + colorref = (i == 2) ? RGB(0xE9, 0x48, 0x56) : GetIntermediateColor(GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOW), 0.66f); else colorref = GetSysColor(COLOR_3DFACE); color.SetFromCOLORREF(colorref); @@ -92,36 +91,44 @@ void CTitleBarHelper::DrawButtons(CDC& dc) } graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::Color penColor; penColor.SetFromCOLORREF(GetSysColor(COLOR_WINDOWTEXT)); - Gdiplus::Pen pen(penColor, PointToPixel(0.75)); - graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].top), Gdiplus::Point(rcIcons[2].right, rcIcons[2].bottom)); - graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[2].left, rcIcons[2].bottom), Gdiplus::Point(rcIcons[2].right, rcIcons[2].top)); + Gdiplus::Pen pen(penColor, PointToPixelF(0.75)); - const int r = static_cast(PointToPixel(0.75)); + // minimize button + const int y = (rcIcons[0].top + rcIcons[0].bottom) / 2; + graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[0].left, y), Gdiplus::Point(rcIcons[0].right, y)); + + const int r = PointToPixel(0.75); if (m_maximized) { + // maxmize button DrawTopRightEdgeWithCurve(graphics, pen, Gdiplus::Rect(rcIcons[1].left + r, rcIcons[1].top - r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r * 3); DrawRoundedRectangle(graphics, pen, Gdiplus::Rect(rcIcons[1].left - r, rcIcons[1].top + r, rcIcons[1].Width() - 2 * r, rcIcons[1].Height() - 2 * r), r); } else { + // restore button DrawRoundedRectangle(graphics, pen, Gdiplus::Rect(rcIcons[1].left, rcIcons[1].top, rcIcons[1].Width(), rcIcons[1].Height()), r); } - const int y = (rcIcons[0].top + rcIcons[0].bottom) / 2; - graphics.DrawLine(&pen, Gdiplus::Point(rcIcons[0].left, y), Gdiplus::Point(rcIcons[0].right, y)); + // close button + penColor.SetFromCOLORREF(m_nTrackingButton != 2 ? GetSysColor(COLOR_WINDOWTEXT) : RGB(255, 255, 255)); + Gdiplus::Pen pen2(penColor, PointToPixelF(0.75)); + graphics.DrawLine(&pen2, Gdiplus::Point(rcIcons[2].left, rcIcons[2].top), Gdiplus::Point(rcIcons[2].right, rcIcons[2].bottom)); + graphics.DrawLine(&pen2, Gdiplus::Point(rcIcons[2].left, rcIcons[2].bottom), Gdiplus::Point(rcIcons[2].right, rcIcons[2].top)); } CRect CTitleBarHelper::GetButtonRect(int button) const { - const float w1 = PointToPixel(m_rightMargin) / 3.f; CRect rcPart; + const float buttonWidth = PointToPixelF(m_rightMargin) / 3.f; const int topMargin = (m_maximized ? -m_rc.top : 0); rcPart.top = topMargin; rcPart.bottom = m_size.cy; - rcPart.left = static_cast(m_size.cx - (3 - button) * w1); - rcPart.right = static_cast(rcPart.left + w1); + rcPart.left = static_cast(m_size.cx - (3 - button) * buttonWidth); + rcPart.right = static_cast(rcPart.left + buttonWidth); return rcPart; } @@ -177,28 +184,26 @@ void CTitleBarHelper::OnNcMouseLeave() void CTitleBarHelper::OnNcLButtonDblClk(UINT nHitTest, CPoint point) { - if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE && nHitTest != HTSYSMENU) AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDBLCLK, nHitTest, MAKELPARAM(point.x, point.y)); + else if (nHitTest == HTSYSMENU) + AfxGetMainWnd()->PostMessage(WM_CLOSE); } void CTitleBarHelper::OnNcLButtonDown(UINT nHitTest, CPoint point) { - if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) - { + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE && nHitTest != HTSYSMENU) AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDOWN, nHitTest, MAKELPARAM(point.x, point.y)); - } + else if (nHitTest == HTSYSMENU) + ShowSysMenu(CPoint{ point.x + 1, point.y }); else if (nHitTest == HTMINBUTTON || nHitTest == HTMAXBUTTON || nHitTest == HTCLOSE) - { m_nHitTest = nHitTest; - } } void CTitleBarHelper::OnNcLButtonUp(UINT nHitTest, CPoint point) { - if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE) - { + if (nHitTest != HTMINBUTTON && nHitTest != HTMAXBUTTON && nHitTest != HTCLOSE && nHitTest != HTSYSMENU) AfxGetMainWnd()->SendMessage(WM_NCLBUTTONUP, nHitTest, MAKELPARAM(point.x, point.y)); - } else if (m_nHitTest != HTNOWHERE && m_nHitTest == nHitTest) { if (nHitTest == HTMINBUTTON) @@ -213,13 +218,19 @@ void CTitleBarHelper::OnNcLButtonUp(UINT nHitTest, CPoint point) void CTitleBarHelper::OnNcRButtonDown(UINT nHitTest, CPoint point) { - AfxGetMainWnd()->SendMessage(WM_NCRBUTTONDOWN, nHitTest, MAKELPARAM(point.x, point.y)); } void CTitleBarHelper::OnNcRButtonUp(UINT nHitTest, CPoint point) { - CMenu *pSysMenu = AfxGetMainWnd()->GetSystemMenu(FALSE); - pSysMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, point.x, point.y, m_pWnd, nullptr); + ShowSysMenu(point); +} + +void CTitleBarHelper::ShowSysMenu(CPoint point) +{ + CMenu* pSysMenu = AfxGetMainWnd()->GetSystemMenu(FALSE); + BOOL cmd = pSysMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, AfxGetMainWnd(), nullptr); + if (cmd) + AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND, cmd, 0); } int CTitleBarHelper::HitTest(CPoint pt) @@ -227,41 +238,40 @@ int CTitleBarHelper::HitTest(CPoint pt) if (!m_pWnd) return HTNOWHERE; CClientDC dc(m_pWnd); - const int leftMargin = static_cast(PointToPixel(m_leftMargin)); - const int rightMargin = static_cast(PointToPixel(m_rightMargin)); - const int m = 8; + const int leftMargin = PointToPixel(m_leftMargin); + const int rightMargin = PointToPixel(m_rightMargin); + const int borderWidth = PointToPixel(6); CRect rc; m_pWnd->GetWindowRect(&rc); - if (pt.y < rc.top + m) + if (pt.y < rc.top + borderWidth) { - if (pt.x < rc.left + m) + if (pt.x < rc.left + borderWidth) return HTTOPLEFT; - else if (rc.right - m <= pt.x) + else if (rc.right - borderWidth <= pt.x) return HTTOPRIGHT; return HTTOP; } - if (pt.x < rc.left + m) + if (pt.x < rc.left + borderWidth) return HTLEFT; - if (rc.right - m <= pt.x) + if (rc.right - borderWidth <= pt.x) return HTRIGHT; if (pt.x < rc.left + leftMargin) return HTSYSMENU; - CRect rcButton = GetButtonRect(0); - m_pWnd->ClientToScreen(&rcButton); - if (PtInRect(&rcButton, pt)) - return HTMINBUTTON; - rcButton = GetButtonRect(1); - m_pWnd->ClientToScreen(&rcButton); - if (PtInRect(&rcButton, pt)) - return HTMAXBUTTON; - rcButton = GetButtonRect(2); - m_pWnd->ClientToScreen(&rcButton); - if (PtInRect(&rcButton, pt)) - return HTCLOSE; + for (int i = 0; i < 3; i++) + { + static const int htbuttons[]{ HTMINBUTTON, HTMAXBUTTON, HTCLOSE }; + CRect rcButton = GetButtonRect(i); + m_pWnd->ClientToScreen(&rcButton); + if (PtInRect(&rcButton, pt)) + return htbuttons[i]; + } return HTCAPTION; } -float CTitleBarHelper::PointToPixel(float point) const +COLORREF CTitleBarHelper::GetIntermediateColor(COLORREF a, COLORREF b, float ratio) { - return point * m_dpi / 72.f; + const uint8_t R = static_cast((GetRValue(a) - GetRValue(b)) * ratio) + GetRValue(b); + const uint8_t G = static_cast((GetGValue(a) - GetGValue(b)) * ratio) + GetGValue(b); + const uint8_t B = static_cast((GetBValue(a) - GetBValue(b)) * ratio) + GetBValue(b); + return RGB(R, G, B); } diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 2b77aa51ef7..274e9a92052 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -16,8 +16,8 @@ class CTitleBarHelper { void Init(CWnd* pWnd); void DrawIcon(CWnd* pWnd, CDC& dc); void DrawButtons(CDC& dc); - int GetLeftMargin() const { return static_cast(PointToPixel(m_leftMargin)); } - int GetRightMargin() const { return static_cast(PointToPixel(m_rightMargin)); } + int GetLeftMargin() const { return PointToPixel(m_leftMargin); } + int GetRightMargin() const { return PointToPixel(m_rightMargin); } CRect GetButtonRect(int button) const; void OnSize(bool maximized, int cx, int cy); void OnNcMouseMove(UINT nHitTest, CPoint point); @@ -30,7 +30,11 @@ class CTitleBarHelper { int HitTest(CPoint pt); private: - float PointToPixel(float point) const; + float PointToPixelF(float point) const { return point * m_dpi / 72.f; } + int PointToPixel(float point) const { return static_cast(point * m_dpi / 72.f); } + + void ShowSysMenu(CPoint point); + COLORREF GetIntermediateColor(COLORREF a, COLORREF b, float ratio); CWnd* m_pWnd; CSize m_size; From 18aa09aa44b4b437d627c610b6a45492accd8b7f Mon Sep 17 00:00:00 2001 From: sdottaka Date: Wed, 25 Sep 2024 09:09:49 +0900 Subject: [PATCH 19/22] WIP --- Src/MainFrm.cpp | 17 ----------------- Src/MainFrm.h | 3 --- Src/TitleBarHelper.cpp | 21 ++++++++++----------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 717eb3fff0b..fe1df9a05d3 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -70,7 +70,6 @@ #include "locality.h" #include "DirWatcher.h" #include "Win_VersionHelper.h" -#include using std::vector; using boost::begin; @@ -224,10 +223,6 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_WM_ACTIVATEAPP() ON_WM_NCCALCSIZE() ON_WM_SIZE() - ON_WM_MOUSEMOVE() - ON_WM_MOUSELEAVE() - ON_WM_NCMOUSEMOVE() - ON_WM_NCMOUSELEAVE() ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem) // [File] menu ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>)) @@ -2551,18 +2546,6 @@ void CMainFrame::OnSize(UINT nType, int cx, int cy) __super::OnSize(nType, cx, cy); } -void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) -{ -} - -void CMainFrame::OnMouseLeave() -{ -} - -void CMainFrame::OnNcMouseMove(UINT nHitTest, CPoint point) -{ -} - BOOL CMainFrame::CreateToolbar() { if (!m_wndMenuBar.Create(this)) diff --git a/Src/MainFrm.h b/Src/MainFrm.h index fbe7a03858c..39ddafe2a6a 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -387,9 +387,6 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnMouseLeave(); - afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg void OnToolbarSize(UINT id); afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index a8035af7387..a18df1ba4bd 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -31,17 +31,16 @@ void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc) HICON hIcon = (HICON)pWnd->SendMessage(WM_GETICON, ICON_SMALL2, 0); if (hIcon == nullptr) hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM); - if (hIcon != nullptr) - { - const int topMargin = (m_maximized ? -m_rc.top : 0); - const int height = m_size.cy - topMargin; - const int cx = PointToPixel(12.f); - const int cy = PointToPixel(12.f); - const int x = (PointToPixel(m_leftMargin) - cx) / 2; - const int y = (height - cy) / 2 + topMargin; - DrawIconEx(dc.m_hDC, x, y, hIcon, - cx, cy, 0, nullptr, DI_NORMAL); - } + if (hIcon == nullptr) + return; + const int topMargin = (m_maximized ? -m_rc.top : 0); + const int height = m_size.cy - topMargin; + const int cx = PointToPixel(12.f); + const int cy = PointToPixel(12.f); + const int x = (PointToPixel(m_leftMargin) - cx) / 2; + const int y = (height - cy) / 2 + topMargin; + DrawIconEx(dc.m_hDC, x, y, hIcon, + cx, cy, 0, nullptr, DI_NORMAL); } static void DrawTopRightEdgeWithCurve(Gdiplus::Graphics& graphics, Gdiplus::Pen& pen, Gdiplus::Rect rect, int cornerRadius) From a4ba334dc08d24ef86fee964a72b5cc2dad9bcce Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 28 Sep 2024 14:57:23 +0900 Subject: [PATCH 20/22] WIP --- Src/EditorFilepathBar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/EditorFilepathBar.cpp b/Src/EditorFilepathBar.cpp index 511d7afd08e..ead9e5f6630 100644 --- a/Src/EditorFilepathBar.cpp +++ b/Src/EditorFilepathBar.cpp @@ -164,7 +164,7 @@ void CEditorFilePathBar::DoPaint(CDC* pDC) const COLORREF clrShadow = CEColor::GetIntermediateColor(clrBarBackcolor, GetSysColor(COLOR_3DSHADOW), m_Edit[pane].GetActive() ? 0.5f : 0.8f); rc.OffsetRect(-rcBar.left, -rcBar.top); - DrawRoundedRectWithShadow(pDC->m_hDC, rc.left - r, rc.top - 1, rc.right - rc.left + 2 * r, rc.bottom - rc.top + 1, r, sw, + DrawRoundedRectWithShadow(pDC->m_hDC, rc.left - r, rc.top, rc.right - rc.left + 2 * r, rc.bottom - rc.top, r, sw, clrBackcolor, clrShadow, clrBarBackcolor); if (pane == m_nPanes - 1) { From cd1259aaae3c4aab4855d689ad2c0cfa8ccd2c2f Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 28 Sep 2024 15:49:54 +0900 Subject: [PATCH 21/22] Update Japanese.po --- Translations/WinMerge/Japanese.po | 42 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Translations/WinMerge/Japanese.po b/Translations/WinMerge/Japanese.po index fed787d1f4c..f754ed1be55 100644 --- a/Translations/WinMerge/Japanese.po +++ b/Translations/WinMerge/Japanese.po @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: WinMerge\n" "Report-Msgid-Bugs-To: https://bugs.winmerge.org/\n" "POT-Creation-Date: 2020-12-05 22:07+0000\n" -"PO-Revision-Date: 2024-09-28 15:38+0900\n" +"PO-Revision-Date: 2024-09-28 15:49+0900\n" "Last-Translator: Takashi Sawanaka \n" "Language-Team: Japanese \n" "Language: ja\n" @@ -358,10 +358,10 @@ msgid "Ta&b Bar" msgstr "タブ バー(&B)" msgid "&View Tab Bar" -msgstr "" +msgstr "タブ バーを表示(&V)" msgid "&On Title Bar" -msgstr "" +msgstr "タイトルバー上に配置(&O)" msgid "&Toolbar" msgstr "ツールバー(&T)" @@ -4312,60 +4312,72 @@ msgstr "行" msgid "Character" msgstr "文字" -msgid "\n" +msgid "" +"\n" "Previous Difference (Alt+Up)\n" "(Right Button+Wheel Up)\n" "(Alt+Wheel Up)" -msgstr "\n" +msgstr "" +"\n" "前の差異(&P)\tAlt+Up\n" "(Right Button+Wheel Up)\n" "(Alt+Wheel Up)" -msgid "\n" +msgid "" +"\n" "Next Difference (Alt+Down)\n" "(Right Button+Wheel Down)\n" "(Alt+Wheel Down)" -msgstr "\n" +msgstr "" +"\n" "次の差異 (Alt+Down)\n" "(Right Button+Wheel Down)\n" "(Alt+Wheel Down)" -msgid "\n" +msgid "" +"\n" "Copy to Right (Alt+Right)\n" "(Right Button+Wheel Right)\n" "(Alt+Wheel Right)\n" "(Alt+Shift+Wheel Down)" -msgstr "\n" +msgstr "" +"\n" "右側にコピー (Alt+Right)\n" "(Right Button+Wheel Right)\n" "(Alt+Wheel Right)\n" "(Alt+Shift+Wheel Down)" -msgid "\n" +msgid "" +"\n" "Copy to Left (Alt+Left)\n" "(Right Button+Wheel Left)\n" "(Alt+Wheel Left)\n" "(Alt+Shift+Wheel Up)" -msgstr "\n" +msgstr "" +"\n" "左側へコピー (Alt+Left)\n" "(Right Button+Wheel Left)\n" "(Alt+Wheel Left)\n" "(Alt+Shift+Wheel Up)" -msgid "\n" +msgid "" +"\n" "Copy to Right and Advance (Ctrl+Alt+Right)\n" "(Ctrl+Alt+Wheel Right)\n" "(Ctrl+Alt+Shift+Wheel Down)" -msgstr "\n" +msgstr "" +"\n" "右側へコピーし次へ (Ctrl+Alt+Right)\n" "(Ctrl+Alt+Wheel Right)\n" "(Ctrl+Alt+Shift+Wheel Down)" -msgid "\n" +msgid "" +"\n" "Copy to Left and Advance (Ctrl+Alt+Left)\n" "(Ctrl+Alt+Wheel Left)\n" "(Ctrl+Alt+Shift+Wheel Up)" -msgstr "\n" +msgstr "" +"\n" "左側へコピーし次へ (Ctrl+Alt+Left)\n" "(Ctrl+Alt+Wheel Left)\n" "(Ctrl+Alt+Shift+Wheel Up)" From d50e1457c30eb9bfa64f1de0bfb3500802683b99 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 28 Sep 2024 21:43:18 +0900 Subject: [PATCH 22/22] WIP --- Src/Common/MDITabBar.cpp | 2 +- Src/TitleBarHelper.cpp | 80 ++++++++++++++++++++-------------------- Src/TitleBarHelper.h | 2 +- 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/Src/Common/MDITabBar.cpp b/Src/Common/MDITabBar.cpp index 61c9b3f53d8..689cbafb177 100644 --- a/Src/Common/MDITabBar.cpp +++ b/Src/Common/MDITabBar.cpp @@ -660,7 +660,7 @@ CSize CMDITabBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) LRESULT CMDITabBar::OnNcHitTest(CPoint point) { - return m_titleBar.HitTest(point); + return m_titleBar.OnNcHitTest(point); } void CMDITabBar::OnNcMouseMove(UINT nHitTest, CPoint point) diff --git a/Src/TitleBarHelper.cpp b/Src/TitleBarHelper.cpp index a18df1ba4bd..1049fff7ece 100644 --- a/Src/TitleBarHelper.cpp +++ b/Src/TitleBarHelper.cpp @@ -140,6 +140,41 @@ void CTitleBarHelper::OnSize(bool maximized, int cx, int cy) m_pWnd->GetWindowRect(&m_rc); } +LRESULT CTitleBarHelper::OnNcHitTest(CPoint pt) +{ + if (!m_pWnd) + return HTNOWHERE; + CClientDC dc(m_pWnd); + const int leftMargin = PointToPixel(m_leftMargin); + const int rightMargin = PointToPixel(m_rightMargin); + const int borderWidth = PointToPixel(6); + CRect rc; + m_pWnd->GetWindowRect(&rc); + if (pt.y < rc.top + borderWidth) + { + if (pt.x < rc.left + borderWidth) + return HTTOPLEFT; + else if (rc.right - borderWidth <= pt.x) + return HTTOPRIGHT; + return HTTOP; + } + if (pt.x < rc.left + borderWidth) + return HTLEFT; + if (rc.right - borderWidth <= pt.x) + return HTRIGHT; + if (pt.x < rc.left + leftMargin) + return HTSYSMENU; + for (int i = 0; i < 3; i++) + { + static const int htbuttons[]{ HTMINBUTTON, HTMAXBUTTON, HTCLOSE }; + CRect rcButton = GetButtonRect(i); + m_pWnd->ClientToScreen(&rcButton); + if (PtInRect(&rcButton, pt)) + return htbuttons[i]; + } + return HTCAPTION; +} + void CTitleBarHelper::OnNcMouseMove(UINT nHitTest, CPoint point) { if (!m_bMouseTracking) @@ -148,15 +183,13 @@ void CTitleBarHelper::OnNcMouseMove(UINT nHitTest, CPoint point) TrackMouseEvent(&tme); m_bMouseTracking = true; } - int i = HitTest(point); - if (i == HTMINBUTTON) + int i = -1; + if (nHitTest == HTMINBUTTON) i = 0; - else if (i == HTMAXBUTTON) + else if (nHitTest == HTMAXBUTTON) i = 1; - else if (i == HTCLOSE) + else if (nHitTest == HTCLOSE) i = 2; - else - i = -1; for (int button : {i, m_nTrackingButton}) { if (button != -1) @@ -232,41 +265,6 @@ void CTitleBarHelper::ShowSysMenu(CPoint point) AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND, cmd, 0); } -int CTitleBarHelper::HitTest(CPoint pt) -{ - if (!m_pWnd) - return HTNOWHERE; - CClientDC dc(m_pWnd); - const int leftMargin = PointToPixel(m_leftMargin); - const int rightMargin = PointToPixel(m_rightMargin); - const int borderWidth = PointToPixel(6); - CRect rc; - m_pWnd->GetWindowRect(&rc); - if (pt.y < rc.top + borderWidth) - { - if (pt.x < rc.left + borderWidth) - return HTTOPLEFT; - else if (rc.right - borderWidth <= pt.x) - return HTTOPRIGHT; - return HTTOP; - } - if (pt.x < rc.left + borderWidth) - return HTLEFT; - if (rc.right - borderWidth <= pt.x) - return HTRIGHT; - if (pt.x < rc.left + leftMargin) - return HTSYSMENU; - for (int i = 0; i < 3; i++) - { - static const int htbuttons[]{ HTMINBUTTON, HTMAXBUTTON, HTCLOSE }; - CRect rcButton = GetButtonRect(i); - m_pWnd->ClientToScreen(&rcButton); - if (PtInRect(&rcButton, pt)) - return htbuttons[i]; - } - return HTCAPTION; -} - COLORREF CTitleBarHelper::GetIntermediateColor(COLORREF a, COLORREF b, float ratio) { const uint8_t R = static_cast((GetRValue(a) - GetRValue(b)) * ratio) + GetRValue(b); diff --git a/Src/TitleBarHelper.h b/Src/TitleBarHelper.h index 274e9a92052..8f9b98a06e6 100644 --- a/Src/TitleBarHelper.h +++ b/Src/TitleBarHelper.h @@ -20,6 +20,7 @@ class CTitleBarHelper { int GetRightMargin() const { return PointToPixel(m_rightMargin); } CRect GetButtonRect(int button) const; void OnSize(bool maximized, int cx, int cy); + LRESULT OnNcHitTest(CPoint pt); void OnNcMouseMove(UINT nHitTest, CPoint point); void OnNcMouseLeave(); void OnNcLButtonDblClk(UINT nHitTest, CPoint point); @@ -27,7 +28,6 @@ class CTitleBarHelper { void OnNcLButtonUp(UINT nHitTest, CPoint point); void OnNcRButtonDown(UINT nHitTest, CPoint point); void OnNcRButtonUp(UINT nHitTest, CPoint point); - int HitTest(CPoint pt); private: float PointToPixelF(float point) const { return point * m_dpi / 72.f; }