diff options
author | George Hazan <ghazan@miranda.im> | 2020-10-18 20:35:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-10-18 20:35:26 +0300 |
commit | eac1cd04921742a14a2c57c651687724621397dc (patch) | |
tree | 3aecb0bf9f1c8f6abdd7d26f28a45574fcd4a2bc /plugins/TabSRMM/src/tabctrl.cpp | |
parent | 6417935db337da37eb829d35487dbfda49ed1092 (diff) |
code cleaning
Diffstat (limited to 'plugins/TabSRMM/src/tabctrl.cpp')
-rw-r--r-- | plugins/TabSRMM/src/tabctrl.cpp | 117 |
1 files changed, 67 insertions, 50 deletions
diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp index 618f31d3d1..4366282fc5 100644 --- a/plugins/TabSRMM/src/tabctrl.cpp +++ b/plugins/TabSRMM/src/tabctrl.cpp @@ -33,6 +33,36 @@ static WNDPROC OldTabControlClassProc; #define FIXED_TAB_SIZE 100
+/////////////////////////////////////////////////////////////////////////////////////////
+// window data for the tab control window class
+
+struct TabControlData
+{
+ HWND hwnd;
+ DWORD dwStyle;
+ DWORD cx, cy;
+ HANDLE hTheme, hThemeButton, hbp;
+ int xpad;
+ int iBeginIndex;
+ int iHoveredTabIndex;
+ int iHoveredCloseIcon;
+ HWND hwndDrag;
+
+ bool bVisualStyles;
+ bool bDragging;
+ bool bRefreshWithoutClip;
+ bool bSavePos;
+ bool bTipActive;
+ bool bAeroTabs;
+ bool bCloseButton;
+
+ HIMAGELIST himlDrag;
+ TContainerData *pContainer;
+ CMsgDialog *dragDat;
+ CMsgDialog *helperDat; // points to the client data of the active tab
+ CImageItem *helperItem, *helperGlowItem; // aero ui, holding the skin image for the tabs
+};
+
// returns the index of the tab under the mouse pointer. Used for
// context menu popup and tooltips
// pt: mouse coordinates, obtained from GetCursorPos()
@@ -922,6 +952,35 @@ skip_tabs: EndPaint(hwnd, &ps);
}
+static bool TabBeginDrag(HWND hwnd, bool bSavePos)
+{
+ POINT pt;
+ pt.x = (short)LOWORD(GetMessagePos());
+ pt.y = (short)HIWORD(GetMessagePos());
+ if (DragDetect(hwnd, pt) && TabCtrl_GetItemCount(hwnd) > 1) {
+ int i = GetTabItemFromMouse(hwnd, &pt);
+ if (i != -1) {
+ HWND hDlg = GetTabWindow(hwnd, i);
+ CMsgDialog *dat = (CMsgDialog *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ if (dat) {
+ TabControlData *tabdat = (TabControlData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ tabdat->bDragging = true;
+ tabdat->iBeginIndex = i;
+ tabdat->hwndDrag = hDlg;
+ tabdat->dragDat = dat;
+ tabdat->himlDrag = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 1, 0);
+ tabdat->bSavePos = bSavePos;
+ ImageList_AddIcon(tabdat->himlDrag, dat->m_hTabIcon);
+ ImageList_BeginDrag(tabdat->himlDrag, 0, 8, 8);
+ ImageList_DragEnter(hwnd, pt.x, pt.y);
+ SetCapture(hwnd);
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
POINT pt;
@@ -1097,55 +1156,13 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara CallService("mToolTip/HideTip", 0, 0);
tabdat->bTipActive = false;
- if (GetKeyState(VK_CONTROL) & 0x8000) {
- pt.x = (short)LOWORD(GetMessagePos());
- pt.y = (short)HIWORD(GetMessagePos());
- if (DragDetect(hwnd, pt) && TabCtrl_GetItemCount(hwnd) > 1) {
- int i = GetTabItemFromMouse(hwnd, &pt);
- if (i != -1) {
- HWND hDlg = GetTabWindow(hwnd, i);
- CMsgDialog *dat = (CMsgDialog*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- if (dat) {
- tabdat->bDragging = true;
- tabdat->iBeginIndex = i;
- tabdat->hwndDrag = hDlg;
- tabdat->dragDat = dat;
- tabdat->bSavePos = true;
- tabdat->himlDrag = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 1, 0);
- ImageList_AddIcon(tabdat->himlDrag, dat->m_hTabIcon);
- ImageList_BeginDrag(tabdat->himlDrag, 0, 8, 8);
- ImageList_DragEnter(hwnd, pt.x, pt.y);
- SetCapture(hwnd);
- }
- return TRUE;
- }
- }
- }
-
- if (GetKeyState(VK_MENU) & 0x8000) {
- pt.x = (short)LOWORD(GetMessagePos());
- pt.y = (short)HIWORD(GetMessagePos());
- if (DragDetect(hwnd, pt) && TabCtrl_GetItemCount(hwnd) > 1) {
- int i = GetTabItemFromMouse(hwnd, &pt);
- if (i != -1) {
- HWND hDlg = GetTabWindow(hwnd, i);
- CMsgDialog *dat = (CMsgDialog*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- if (dat) {
- tabdat->bDragging = true;
- tabdat->iBeginIndex = i;
- tabdat->hwndDrag = hDlg;
- tabdat->dragDat = dat;
- tabdat->himlDrag = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 1, 0);
- tabdat->bSavePos = false;
- ImageList_AddIcon(tabdat->himlDrag, dat->m_hTabIcon);
- ImageList_BeginDrag(tabdat->himlDrag, 0, 8, 8);
- ImageList_DragEnter(hwnd, pt.x, pt.y);
- SetCapture(hwnd);
- }
- return TRUE;
- }
- }
- }
+ if (GetKeyState(VK_CONTROL) & 0x8000)
+ if (TabBeginDrag(hwnd, true))
+ return TRUE;
+
+ if (GetKeyState(VK_MENU) & 0x8000)
+ if (TabBeginDrag(hwnd, false))
+ return TRUE;
if (tabdat->bCloseButton) {
GetCursorPos(&pt);
@@ -1172,8 +1189,8 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara ImageList_DragMove(pt.x, pt.y);
}
+ GetCursorPos(&pt);
{
- GetCursorPos(&pt);
int iOld = tabdat->iHoveredTabIndex;
tabdat->iHoveredTabIndex = GetTabItemFromMouse(hwnd, &pt);
if (tabdat->iHoveredTabIndex != iOld)
|