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