summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/tabs.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-08-30 15:20:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-08-30 15:20:16 +0300
commitca52c77ab6e2b8f9fe85bd6ce8ba82129734fb84 (patch)
treee06b16d1524c6cf3969337f94ece17fea624934b /plugins/Scriver/src/tabs.cpp
parenta8f4c176d9983951d3f1b9803e08c7170a27eacd (diff)
Scriver:
- fixes #2037 (when tabs are used, "Save settings for contacts" corrupts window position); - rest of tabs options switched to UI; - version bump
Diffstat (limited to 'plugins/Scriver/src/tabs.cpp')
-rw-r--r--plugins/Scriver/src/tabs.cpp333
1 files changed, 139 insertions, 194 deletions
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp
index 167a6465e4..f3722a02ff 100644
--- a/plugins/Scriver/src/tabs.cpp
+++ b/plugins/Scriver/src/tabs.cpp
@@ -45,20 +45,20 @@ static void GetChildWindowRect(ParentWindowData *dat, RECT *rcChild)
GetClientRect(dat->hwndTabs, &rcTabs);
TabCtrl_AdjustRect(dat->hwndTabs, FALSE, &rcTabs);
rcStatus.top = rcStatus.bottom = 0;
- if (dat->flags2 & SMF2_SHOWSTATUSBAR)
+ if (dat->flags2.bShowStatusBar)
GetWindowRect(dat->hwndStatus, &rcStatus);
rcChild->left = 0;
rcChild->right = rc.right;
- if (dat->flags2 & SMF2_TABSATBOTTOM) {
+ if (dat->flags2.bTabsAtBottom) {
rcChild->top = 2;
- if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1))
+ if ((dat->flags2.bUseTabs && !(dat->flags2.bHideOneTab)) || (dat->childrenCount > 1))
rcChild->bottom = rcTabs.bottom + 4;
else
rcChild->bottom = rc.bottom - rc.top - (rcStatus.bottom - rcStatus.top);
}
else {
- if ((dat->flags2 & SMF2_USETABS && !(dat->flags2 & SMF2_HIDEONETAB)) || (dat->childrenCount > 1))
+ if ((dat->flags2.bUseTabs && !(dat->flags2.bHideOneTab)) || (dat->childrenCount > 1))
rcChild->top = rcTabs.top;
else
rcChild->top = 2;
@@ -282,26 +282,26 @@ static void ActivateChildByIndex(ParentWindowData *dat, int index)
static void SetContainerWindowStyle(ParentWindowData *dat)
{
- ShowWindow(dat->hwndStatus, (dat->flags2 & SMF2_SHOWSTATUSBAR) ? SW_SHOW : SW_HIDE);
+ ShowWindow(dat->hwndStatus, (dat->flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
DWORD ws = GetWindowLongPtr(dat->hwnd, GWL_STYLE) & ~(WS_CAPTION);
- if (dat->flags2 & SMF2_SHOWTITLEBAR)
+ if (dat->flags2.bShowTitleBar)
ws |= WS_CAPTION;
SetWindowLongPtr(dat->hwnd, GWL_STYLE, ws);
ws = GetWindowLongPtr(dat->hwnd, GWL_EXSTYLE)& ~WS_EX_LAYERED;
- ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
+ ws |= dat->flags2.bUseTransparency ? WS_EX_LAYERED : 0;
SetWindowLongPtr(dat->hwnd, GWL_EXSTYLE, ws);
- if (dat->flags2 & SMF2_USETRANSPARENCY)
+ if (dat->flags2.bUseTransparency)
SetLayeredWindowAttributes(dat->hwnd, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
ws = GetWindowLongPtr(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM | 0x2000);
- if (dat->flags2 & SMF2_TABSATBOTTOM)
+ if (dat->flags2.bTabsAtBottom)
ws |= TCS_BOTTOM;
ws |= 0x2000;
- if (dat->flags2 & SMF2_TABCLOSEBUTTON)
+ if (dat->flags2.bTabCloseButton)
TabCtrl_SetPadding(dat->hwndTabs, GetSystemMetrics(SM_CXEDGE) + 12, GetSystemMetrics(SM_CYEDGE) + 1);
else
TabCtrl_SetPadding(dat->hwndTabs, GetSystemMetrics(SM_CXEDGE) + 4, GetSystemMetrics(SM_CYEDGE) + 1);
@@ -437,7 +437,7 @@ static LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
}
}
- else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) {
+ else if (dat->srcTab >= 0 && g_dat.flags2.bTabCloseButton) {
int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
RECT rect;
@@ -568,44 +568,6 @@ __forceinline void UnsubclassTabCtrl(HWND hwnd)
/////////////////////////////////////////////////////////////////////////////////////////
-static int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags, int showCmd)
-{
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(hwnd, &wp);
-
- char szSettingName[64];
- mir_snprintf(szSettingName, "%sx", szNamePrefix);
- int x = db_get_dw(hContact, szModule, szSettingName, -1);
- mir_snprintf(szSettingName, "%sy", szNamePrefix);
- int y = db_get_dw(hContact, szModule, szSettingName, -1);
- if (x == -1)
- return 1;
-
- if (flags & RWPF_NOSIZE)
- OffsetRect(&wp.rcNormalPosition, x - wp.rcNormalPosition.left, y - wp.rcNormalPosition.top);
- else {
- wp.rcNormalPosition.left = x;
- wp.rcNormalPosition.top = y;
- mir_snprintf(szSettingName, "%swidth", szNamePrefix);
- wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact, szModule, szSettingName, -1);
- mir_snprintf(szSettingName, "%sheight", szNamePrefix);
- wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact, szModule, szSettingName, -1);
- }
- wp.flags = 0;
- wp.showCmd = showCmd;
-
- HMONITOR hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- GetMonitorInfo(hMonitor, &mi);
- RECT rcDesktop = mi.rcWork;
- if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom ||
- wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
- SetWindowPlacement(hwnd, &wp);
- return 0;
-}
-
struct NewMessageWindowLParam
{
MCONTACT hContact;
@@ -623,7 +585,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
switch (msg) {
case WM_INITDIALOG:
{
- int savePerContact = g_plugin.bSavePerContact;
+ int savePerContact = g_plugin.bSavePerContact && !g_dat.flags2.bUseTabs;
NewMessageWindowLParam *newData = (NewMessageWindowLParam *)lParam;
dat = (ParentWindowData *)mir_alloc(sizeof(ParentWindowData));
dat->hContact = newData->hContact;
@@ -667,7 +629,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
MCONTACT hSContact = savePerContact ? dat->hContact : 0;
dat->bTopmost = g_plugin.getByte(hSContact, SRMSGSET_TOPMOST, SRMSGDEFSET_TOPMOST);
- if (ScriverRestoreWindowPosition(hwndDlg, hSContact, SRMM_MODULE, (newData->isChat && !savePerContact) ? "chat" : "", 0, SW_HIDE))
+ if (Utils_RestoreWindowPosition(hwndDlg, hSContact, SRMM_MODULE, (newData->isChat && !savePerContact) ? "chat" : "", RWPF_HIDDEN))
SetWindowPos(hwndDlg, nullptr, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW);
if (!savePerContact && g_plugin.bCascade)
@@ -728,7 +690,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
GetClientRect(hwndDlg, &rc);
GetWindowRect(hwndDlg, &rcWindow);
rcStatus.top = rcStatus.bottom = 0;
- if (dat->flags2 & SMF2_SHOWSTATUSBAR) {
+ if (dat->flags2.bShowStatusBar) {
GetWindowRect(dat->hwndStatus, &rcStatus);
SetupStatusBar(dat);
}
@@ -746,7 +708,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
dat->childRect = rcChild;
MoveWindow(dat->hwndActive, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, TRUE);
RedrawWindow(GetDlgItem(dat->hwndActive, IDC_SRMM_LOG), nullptr, nullptr, RDW_INVALIDATE);
- if (dat->flags2 & SMF2_SHOWSTATUSBAR) {
+ if (dat->flags2.bShowStatusBar) {
SendMessage(dat->hwndStatus, WM_SIZE, 0, 0);
RedrawWindow(dat->hwndStatus, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
@@ -759,7 +721,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
return TRUE;
case WM_CLOSE:
- if (g_dat.flags2 & SMF2_HIDECONTAINERS && dat->childrenCount > 0)
+ if (g_dat.flags2.bHideContainer && dat->childrenCount > 0)
ShowWindow(hwndDlg, SW_HIDE);
else
DestroyWindow(hwndDlg);
@@ -902,9 +864,9 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
case WM_ACTIVATE:
if (LOWORD(wParam) == WA_INACTIVE) {
ws = GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
- ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
+ ws |= dat->flags2.bUseTransparency ? WS_EX_LAYERED : 0;
SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, ws);
- if (dat->flags2 & SMF2_USETRANSPARENCY)
+ if (dat->flags2.bUseTransparency)
SetLayeredWindowAttributes(hwndDlg, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
break;
}
@@ -918,9 +880,9 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
dat->nFlash = 0;
}
ws = GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
- ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
+ ws |= dat->flags2.bUseTransparency ? WS_EX_LAYERED : 0;
SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, ws);
- if (dat->flags2 & SMF2_USETRANSPARENCY)
+ if (dat->flags2.bUseTransparency)
SetLayeredWindowAttributes(hwndDlg, RGB(255, 255, 255), (BYTE)(255 - g_dat.activeAlpha), LWA_ALPHA);
break;
@@ -999,8 +961,6 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case WM_DESTROY:
- char szSettingName[64];
-
for (int i = dat->childrenCount; i >= 0; i--) {
TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE;
@@ -1016,46 +976,30 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
WindowList_Remove(g_dat.hParentWindowList, hwndDlg);
{
- int savePerContact = g_plugin.bSavePerContact;
+ int savePerContact = g_plugin.bSavePerContact && !dat->flags2.bUseTabs;
MCONTACT hContact = (savePerContact) ? dat->hContact : 0;
-
- WINDOWPLACEMENT wp = { sizeof(wp) };
- GetWindowPlacement(hwndDlg, &wp);
-
- char *szNamePrefix = (!savePerContact && dat->isChat) ? "chat" : "";
- if (!dat->windowWasCascaded) {
- mir_snprintf(szSettingName, "%sx", szNamePrefix);
- g_plugin.setDword(hContact, szSettingName, wp.rcNormalPosition.left);
- mir_snprintf(szSettingName, "%sy", szNamePrefix);
- g_plugin.setDword(hContact, szSettingName, wp.rcNormalPosition.top);
- }
- mir_snprintf(szSettingName, "%swidth", szNamePrefix);
- g_plugin.setDword(hContact, szSettingName, wp.rcNormalPosition.right - wp.rcNormalPosition.left);
- mir_snprintf(szSettingName, "%sheight", szNamePrefix);
- g_plugin.setDword(hContact, szSettingName, wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
+ Utils_SaveWindowPosition(hwndDlg, hContact, SRMM_MODULE, (!savePerContact && dat->isChat) ? "chat" : "");
g_plugin.setByte(hContact, SRMSGSET_TOPMOST, (BYTE)dat->bTopmost);
- if (g_dat.lastParent == dat)
- g_dat.lastParent = dat->prev;
+ }
- if (g_dat.lastChatParent == dat)
- g_dat.lastChatParent = dat->prev;
+ if (g_dat.lastParent == dat)
+ g_dat.lastParent = dat->prev;
- if (dat->prev != nullptr)
- dat->prev->next = dat->next;
+ if (g_dat.lastChatParent == dat)
+ g_dat.lastChatParent = dat->prev;
- if (dat->next != nullptr)
- dat->next->prev = dat->prev;
+ if (dat->prev != nullptr)
+ dat->prev->next = dat->next;
- UnsubclassTabCtrl(dat->hwndTabs);
- mir_free(dat);
- }
- break;
+ if (dat->next != nullptr)
+ dat->next->prev = dat->prev;
- case DM_ERRORDECIDED:
+ UnsubclassTabCtrl(dat->hwndTabs);
+ mir_free(dat);
break;
case CM_STARTFLASHING:
- if ((GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) {// && !(g_dat.flags2 & SMF2_STAYMINIMIZED)) {
+ if ((GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) {
dat->nFlash = 0;
SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
}
@@ -1064,17 +1008,17 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
case CM_POPUPWINDOW:
EnableWindow(hwndDlg, TRUE);
if (wParam) { /* incoming message */
- if (g_dat.flags & SMF_STAYMINIMIZED) {
+ if (g_dat.flags.bStayMinimized) {
if (!IsWindowVisible(hwndDlg))
ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE);
- if (dat->childrenCount == 1 || ((g_dat.flags2 & SMF2_SWITCHTOACTIVE) && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
+ if (dat->childrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
SendMessage(hwndDlg, CM_ACTIVATECHILD, 0, (LPARAM)lParam);
}
else {
ShowWindow(hwndDlg, IsIconic(hwndDlg) ? SW_SHOWNORMAL : SW_SHOWNA);
- if (dat->childrenCount == 1 || ((g_dat.flags2 & SMF2_SWITCHTOACTIVE) && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
+ if (dat->childrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
SendMessage(hwndDlg, CM_ACTIVATECHILD, 0, (LPARAM)lParam);
SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
@@ -1127,7 +1071,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
return TRUE;
case CM_GETTOOLBARSTATUS:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)(dat->flags2 & SMF2_SHOWTOOLBAR) != 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)(dat->flags2.bShowToolBar) != 0);
return TRUE;
case DM_SENDMESSAGE:
@@ -1197,7 +1141,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
if (tcd->iFlags & TCDF_TEXT) {
tci.mask |= TCIF_TEXT;
tci.pszText = tcd->pszText;
- if (g_dat.flags2 & SMF2_LIMITNAMES) {
+ if (g_dat.flags2.bLimitNames) {
wchar_t *ltext = limitText(tcd->pszText, g_dat.limitNamesLength);
if (ltext != tcd->pszText)
tci.pszText = ptszTemp = ltext;
@@ -1221,7 +1165,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case DM_SWITCHINFOBAR:
- dat->flags2 ^= SMF2_SHOWINFOBAR;
+ dat->flags2.bShowInfoBar = !dat->flags2.bShowInfoBar;
for (int i = 0; i < dat->childrenCount; i++) {
CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i);
@@ -1231,13 +1175,13 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case DM_SWITCHSTATUSBAR:
- dat->flags2 ^= SMF2_SHOWSTATUSBAR;
- ShowWindow(dat->hwndStatus, (dat->flags2 & SMF2_SHOWSTATUSBAR) ? SW_SHOW : SW_HIDE);
+ dat->flags2.bShowStatusBar = !dat->flags2.bShowStatusBar;
+ ShowWindow(dat->hwndStatus, (dat->flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
SendMessage(hwndDlg, WM_SIZE, 0, 0);
break;
case DM_SWITCHTOOLBAR:
- dat->flags2 ^= SMF2_SHOWTOOLBAR;
+ dat->flags2.bShowToolBar = !dat->flags2.bShowToolBar;
for (int i = 0; i < dat->childrenCount; i++) {
CScriverWindow * pDlg = GetChildFromTab(dat->hwndTabs, i);
@@ -1248,9 +1192,9 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case DM_SWITCHTITLEBAR:
- dat->flags2 ^= SMF2_SHOWTITLEBAR;
+ dat->flags2.bShowTitleBar = !dat->flags2.bShowTitleBar;
ws = GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
- if (dat->flags2 & SMF2_SHOWTITLEBAR)
+ if (dat->flags2.bShowTitleBar)
ws |= WS_CAPTION;
SetWindowLongPtr(hwndDlg, GWL_STYLE, ws);
@@ -1285,7 +1229,6 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM, LPARAM lParam)
return;
TabCtrlData *tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- HANDLE hTheme = nullptr;
int tstate = 0;
wchar_t szLabel[1024];
TCITEM tci;
@@ -1293,129 +1236,131 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM, LPARAM lParam)
tci.pszText = szLabel;
tci.cchTextMax = _countof(szLabel);
tci.dwStateMask = TCIS_HIGHLIGHTED;
- if (TabCtrl_GetItem(hwnd, iTabIndex, &tci)) {
- IMAGEINFO info;
- RECT rIcon = lpDIS->rcItem;
- RECT rect = lpDIS->rcItem;
- RECT rectTab = lpDIS->rcItem;
- int bSelected = lpDIS->itemState & ODS_SELECTED;
- int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
- UINT dwFormat;
- if (!IsAppThemed())
- FillRect(lpDIS->hDC, &rect, GetSysColorBrush(COLOR_BTNFACE));
- else {
- if (lpDIS->itemState & ODS_SELECTED)
- tstate = TTIS_SELECTED;
- else if (lpDIS->itemState & ODS_FOCUS)
- tstate = TTIS_FOCUSED;
- else if (lpDIS->itemState & ODS_HOTLIGHT)
- tstate = TTIS_HOT;
- else
- tstate = TTIS_NORMAL;
+ if (!TabCtrl_GetItem(hwnd, iTabIndex, &tci))
+ return;
- if (!bSelected)
- InflateRect(&rectTab, 1, 1);
+ IMAGEINFO info;
+ RECT rIcon = lpDIS->rcItem;
+ RECT rect = lpDIS->rcItem;
+ RECT rectTab = lpDIS->rcItem;
+ int bSelected = lpDIS->itemState & ODS_SELECTED;
+ int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
+ UINT dwFormat;
+ HANDLE hTheme = nullptr;
+ if (!IsAppThemed())
+ FillRect(lpDIS->hDC, &rect, GetSysColorBrush(COLOR_BTNFACE));
+ else {
+ if (lpDIS->itemState & ODS_SELECTED)
+ tstate = TTIS_SELECTED;
+ else if (lpDIS->itemState & ODS_FOCUS)
+ tstate = TTIS_FOCUSED;
+ else if (lpDIS->itemState & ODS_HOTLIGHT)
+ tstate = TTIS_HOT;
+ else
+ tstate = TTIS_NORMAL;
- hTheme = OpenThemeData(hwnd, L"TAB");
- if (IsThemeBackgroundPartiallyTransparent(hTheme, TABP_TABITEM, tstate))
- DrawThemeParentBackground(hwnd, lpDIS->hDC, &rectTab);
- DrawThemeBackground(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, &rectTab, nullptr);
+ if (!bSelected)
+ InflateRect(&rectTab, 1, 1);
+
+ hTheme = OpenThemeData(hwnd, L"TAB");
+ if (IsThemeBackgroundPartiallyTransparent(hTheme, TABP_TABITEM, tstate))
+ DrawThemeParentBackground(hwnd, lpDIS->hDC, &rectTab);
+ DrawThemeBackground(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, &rectTab, nullptr);
+ }
+ if (atTop) {
+ dwFormat = DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
+ rIcon.top = rect.top + GetSystemMetrics(SM_CYEDGE);
+ if (tci.iImage >= 0) {
+ rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
+ ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
+ ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
}
- if (atTop) {
- dwFormat = DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
- rIcon.top = rect.top + GetSystemMetrics(SM_CYEDGE);
- if (tci.iImage >= 0) {
- rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
- ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
- ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
- }
- if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.right = rIcon.left - 1;
- }
- rect.top += GetSystemMetrics(SM_CYEDGE) + 2;
+ if (dat->flags2.bTabCloseButton) {
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.right = rIcon.left - 1;
}
- else {
- dwFormat = DT_SINGLELINE | DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
- rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
- if (tci.iImage >= 0) {
- ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
- rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 1;
- ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
- }
- if (dat->flags2 & SMF2_TABCLOSEBUTTON) {
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 2;
- rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- rect.right = rIcon.left - 1;
- }
- rect.bottom -= GetSystemMetrics(SM_CYEDGE) + 2;
+ rect.top += GetSystemMetrics(SM_CYEDGE) + 2;
+ }
+ else {
+ dwFormat = DT_SINGLELINE | DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_NOCLIP;
+ rIcon.left = rect.left + GetSystemMetrics(SM_CXEDGE) + (bSelected ? 6 : 2);
+ if (tci.iImage >= 0) {
+ ImageList_GetImageInfo(g_dat.hTabIconList, tci.iImage, &info);
+ rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 1;
+ ImageList_DrawEx(g_dat.hTabIconList, tci.iImage, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.left = rIcon.left + (info.rcImage.right - info.rcImage.left);
}
+ if (dat->flags2.bTabCloseButton) {
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rIcon.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top) - 2;
+ rIcon.left = rect.right - GetSystemMetrics(SM_CXEDGE) - (bSelected ? 6 : 2) - (info.rcImage.right - info.rcImage.left);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, lpDIS->hDC, rIcon.left, rIcon.top, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ rect.right = rIcon.left - 1;
+ }
+ rect.bottom -= GetSystemMetrics(SM_CYEDGE) + 2;
+ }
- if (hTheme)
- DrawThemeText(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, szLabel, -1, dwFormat, 0, &rect);
- else
- DrawText(lpDIS->hDC, szLabel, -1, &rect, dwFormat);
-
- if (tcdat->bDragged && iTabIndex == tcdat->destTab && iTabIndex != tcdat->srcTab) {
- RECT hlRect = lpDIS->rcItem;
- if (bSelected) {
- hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
+ if (hTheme)
+ DrawThemeText(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, szLabel, -1, dwFormat, 0, &rect);
+ else
+ DrawText(lpDIS->hDC, szLabel, -1, &rect, dwFormat);
+
+ if (tcdat->bDragged && iTabIndex == tcdat->destTab && iTabIndex != tcdat->srcTab) {
+ RECT hlRect = lpDIS->rcItem;
+ if (bSelected) {
+ hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
+ hlRect.top += GetSystemMetrics(SM_CYEDGE);
+ hlRect.left += GetSystemMetrics(SM_CXEDGE);
+ hlRect.right -= GetSystemMetrics(SM_CXEDGE);
+ }
+ else {
+ if (atTop) {
hlRect.top += GetSystemMetrics(SM_CYEDGE);
- hlRect.left += GetSystemMetrics(SM_CXEDGE);
- hlRect.right -= GetSystemMetrics(SM_CXEDGE);
+ hlRect.bottom += GetSystemMetrics(SM_CYEDGE);
}
else {
- if (atTop) {
- hlRect.top += GetSystemMetrics(SM_CYEDGE);
- hlRect.bottom += GetSystemMetrics(SM_CYEDGE);
- }
- else {
- hlRect.top -= GetSystemMetrics(SM_CYEDGE);
- hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
- }
+ hlRect.top -= GetSystemMetrics(SM_CYEDGE);
+ hlRect.bottom -= GetSystemMetrics(SM_CYEDGE);
}
- FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
- hlRect.left++;
- hlRect.top++;
- hlRect.right--;
- hlRect.bottom--;
- FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
}
- if (hTheme)
- CloseThemeData(hTheme);
+ FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
+ hlRect.left++;
+ hlRect.top++;
+ hlRect.right--;
+ hlRect.bottom--;
+ FrameRect(lpDIS->hDC, &hlRect, GetSysColorBrush(COLOR_HIGHLIGHT));
}
+ if (hTheme)
+ CloseThemeData(hTheme);
}
-HWND GetParentWindow(MCONTACT hContact, BOOL bChat)
+HWND GetParentWindow(MCONTACT hContact, bool bChat)
{
NewMessageWindowLParam newData = { 0 };
newData.hContact = hContact;
newData.isChat = bChat;
- if (g_dat.flags2 & SMF2_USETABS) {
- if (!bChat || !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) {
+ if (g_dat.flags2.bUseTabs) {
+ if (!bChat || !g_dat.flags2.bSeparateChats) {
if (g_dat.lastParent != nullptr) {
int tabsNum = (int)SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
- if (!(g_dat.flags2 & SMF2_LIMITTABS) || tabsNum < g_dat.limitTabsNum)
+ if (!g_dat.flags2.bLimitTabs || tabsNum < g_dat.limitTabsNum)
return g_dat.lastParent->hwnd;
}
}
else {
if (g_dat.lastChatParent != nullptr) {
int tabsNum = (int)SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
- if (!(g_dat.flags2 & SMF2_LIMITCHATSTABS) || tabsNum < g_dat.limitChatsTabsNum)
+ if (!g_dat.flags2.bLimitChatTabs || tabsNum < g_dat.limitChatsTabsNum)
return g_dat.lastChatParent->hwnd;
}
}
}
- if (!(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS))
- newData.isChat = FALSE;
+ if (!g_dat.flags2.bSeparateChats)
+ newData.isChat = false;
return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MSGWIN), nullptr, DlgProcParentWindow, (LPARAM)&newData);
}