pull/3/head
chen 1 year ago
parent 45c8aab648
commit f378694a32

@ -497,7 +497,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
// CTRL + SHIFT + MOUSEWHEEL: // CTRL + SHIFT + MOUSEWHEEL:
// will switch to the first/last tab // will switch to the first/last tab
// .............................................................................. // ..............................................................................
//是否被拖动 //是否被拖动,如是,会交换当前鼠标所在位置和目标位置的数据
if (_isDragging) if (_isDragging)
return TRUE; return TRUE;
@ -589,7 +589,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
return TRUE; return TRUE;
} }
//左键按下
case WM_LBUTTONDOWN : case WM_LBUTTONDOWN :
{ {
if (::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS) if (::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS)
@ -600,7 +600,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
setActiveTab(nTab); setActiveTab(nTab);
} }
} }
//是否关闭
if (_drawTabCloseButton) if (_drawTabCloseButton)
{ {
int xPos = LOWORD(lParam); int xPos = LOWORD(lParam);
@ -629,7 +629,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
return TRUE; return TRUE;
} }
//右键按下,处理选项
case WM_RBUTTONDOWN : //rightclick selects tab aswell case WM_RBUTTONDOWN : //rightclick selects tab aswell
{ {
// TCS_BUTTONS doesn't select the tab // TCS_BUTTONS doesn't select the tab
@ -645,7 +645,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
::CallWindowProc(_tabBarDefaultProc, hwnd, WM_LBUTTONDOWN, wParam, lParam); ::CallWindowProc(_tabBarDefaultProc, hwnd, WM_LBUTTONDOWN, wParam, lParam);
return TRUE; return TRUE;
} }
//鼠标移动
case WM_MOUSEMOVE : case WM_MOUSEMOVE :
{ {
if (_mightBeDragging && !_isDragging) if (_mightBeDragging && !_isDragging)
@ -678,7 +678,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
POINT p{}; POINT p{};
p.x = LOWORD(lParam); p.x = LOWORD(lParam);
p.y = HIWORD(lParam); p.y = HIWORD(lParam);
//是否拖动tag光标移动tab数据交换判断并进行相关操作
if (_isDragging) if (_isDragging)
{ {
exchangeItemData(p); exchangeItemData(p);
@ -766,7 +766,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
break; break;
} }
//鼠标移开,重绘鼠标区域,重置相关变量
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
{ {
if (_isCloseHover) if (_isCloseHover)
@ -780,7 +780,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
notify(TCN_MOUSELEAVING, _currentHoverTabItem); notify(TCN_MOUSELEAVING, _currentHoverTabItem);
break; break;
} }
//释放左键,告知操作结束
case WM_LBUTTONUP : case WM_LBUTTONUP :
{ {
_mightBeDragging = false; _mightBeDragging = false;
@ -828,7 +828,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
break; break;
} }
//抓取鼠标输入的改变
case WM_CAPTURECHANGED : case WM_CAPTURECHANGED :
{ {
if (_isDragging) if (_isDragging)
@ -838,20 +838,20 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
break; break;
} }
//重绘tab
case WM_DRAWITEM : case WM_DRAWITEM :
{ {
drawItem((DRAWITEMSTRUCT *)lParam); drawItem((DRAWITEMSTRUCT *)lParam);
return TRUE; return TRUE;
} }
//是否按下control键
case WM_KEYDOWN : case WM_KEYDOWN :
{ {
if (wParam == VK_LCONTROL) if (wParam == VK_LCONTROL)
::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_PLUS_TAB))); ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_PLUS_TAB)));
return TRUE; return TRUE;
} }
//鼠标中键释放
case WM_MBUTTONUP: case WM_MBUTTONUP:
{ {
int xPos = LOWORD(lParam); int xPos = LOWORD(lParam);
@ -860,7 +860,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
notify(TCN_TABDELETE, currentTabOn); notify(TCN_TABDELETE, currentTabOn);
return TRUE; return TRUE;
} }
//双击鼠标左键
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
{ {
if (_isDbClk2Close) if (_isDbClk2Close)
@ -872,7 +872,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
return TRUE; return TRUE;
} }
//如果程序正在使用暗黑模式将会用指定的画刷填充整个Tab的客户区代替了系统默认的橡皮擦背景操作。
case WM_ERASEBKGND: case WM_ERASEBKGND:
{ {
if (!NppDarkMode::isEnabled()) if (!NppDarkMode::isEnabled())
@ -886,7 +886,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
return 1; return 1;
} }
//在Tab控件需要重绘时调用这里会进行大量的绘制操作内容包括Tab本身和每一个Tab的文字、关闭按钮等元素。
case WM_PAINT: case WM_PAINT:
{ {
if (!NppDarkMode::isEnabled()) if (!NppDarkMode::isEnabled())
@ -1057,7 +1057,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);
} }
//实现了Tab的绘制过程包括对Tab背景颜色、文字颜色的调整判断并处理当前Tab的激活状态处理Tab的图标和标题等。
void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
{ {
RECT rect = pDrawItemStruct->rcItem; RECT rect = pDrawItemStruct->rcItem;
@ -1379,7 +1379,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
::RestoreDC(hDC, nSavedDC); ::RestoreDC(hDC, nSavedDC);
} }
//用于改变鼠标光标的形状,根据用户托拽标签的不同位置(是否在同一应用中、是否在一个有效的放置位置等)表现为不同的光标形状。
void TabBarPlus::draggingCursor(POINT screenPoint) void TabBarPlus::draggingCursor(POINT screenPoint)
{ {
HWND hWin = ::WindowFromPoint(screenPoint); HWND hWin = ::WindowFromPoint(screenPoint);
@ -1402,7 +1402,7 @@ void TabBarPlus::draggingCursor(POINT screenPoint)
::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_OUT_TAB))); ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_OUT_TAB)));
} }
} }
//简单地把指定的标签设为活动状态。
void TabBarPlus::setActiveTab(int tabIndex) void TabBarPlus::setActiveTab(int tabIndex)
{ {
// TCM_SETCURFOCUS is busted on WINE/ReactOS for single line (non-TCS_BUTTONS) tabs... // TCM_SETCURFOCUS is busted on WINE/ReactOS for single line (non-TCS_BUTTONS) tabs...
@ -1415,7 +1415,7 @@ void TabBarPlus::setActiveTab(int tabIndex)
::SendMessage(_hSelf, TCM_SETCURSEL, tabIndex, 0); ::SendMessage(_hSelf, TCM_SETCURSEL, tabIndex, 0);
notify(TCN_SELCHANGE, tabIndex); notify(TCN_SELCHANGE, tabIndex);
} }
//交换两个Tab的数据实现两个Tab的位置交换。
void TabBarPlus::exchangeTabItemData(int oldTab, int newTab) void TabBarPlus::exchangeTabItemData(int oldTab, int newTab)
{ {
//1. shift their data, and insert the source //1. shift their data, and insert the source
@ -1457,7 +1457,7 @@ void TabBarPlus::exchangeTabItemData(int oldTab, int newTab)
//2. set to focus //2. set to focus
setActiveTab(newTab); setActiveTab(newTab);
} }
//在接收到鼠标托拽消息的时候被调用,用于各个标签的排序和交换位置。
void TabBarPlus::exchangeItemData(POINT point) void TabBarPlus::exchangeItemData(POINT point)
{ {
// Find the destination tab... // Find the destination tab...
@ -1494,7 +1494,7 @@ void TabBarPlus::exchangeItemData(POINT point)
} }
//用于处理与关闭按钮相关的操作,如获取关闭按钮的大小及位置,判断是否点击到了关闭按钮等。
CloseButtonZone::CloseButtonZone() CloseButtonZone::CloseButtonZone()
{ {
// TODO: get width/height of close button dynamically // TODO: get width/height of close button dynamically

Loading…
Cancel
Save