summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/services.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-06 13:51:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-06 13:51:43 +0300
commit2baf1b9fc764b59f963f94faf01cbed28622717a (patch)
tree819beadce3ab775e584430f3fd12f4e6722a02c0 /plugins/TabSRMM/src/chat/services.cpp
parentac92ec1a55354e57b8cc6d4fd77aa2e75a896242 (diff)
TNewWindowData - unneeded structure removed
Diffstat (limited to 'plugins/TabSRMM/src/chat/services.cpp')
-rw-r--r--plugins/TabSRMM/src/chat/services.cpp156
1 files changed, 65 insertions, 91 deletions
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp
index bf7853e93f..82be123c55 100644
--- a/plugins/TabSRMM/src/chat/services.cpp
+++ b/plugins/TabSRMM/src/chat/services.cpp
@@ -28,26 +28,46 @@
#include "../stdafx.h"
-HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup)
+void ShowRoom(SESSION_INFO *si)
{
+ if (si == nullptr)
+ return;
+
+ if (si->hWnd != nullptr) {
+ ActivateExistingTab(si->dat->m_pContainer, si->hWnd);
+ return;
+ }
+
+ wchar_t szName[CONTAINER_NAMELEN + 2]; szName[0] = 0;
+ TContainerData *pContainer = nullptr;
+ if (si->dat != nullptr)
+ pContainer = si->dat->m_pContainer;
+ if (pContainer == nullptr) {
+ GetContainerNameForContact(si->hContact, szName, CONTAINER_NAMELEN);
+ if (!g_Settings.bOpenInDefault && !mir_wstrcmp(szName, L"default"))
+ wcsncpy(szName, L"Chat Rooms", CONTAINER_NAMELEN);
+ szName[CONTAINER_NAMELEN] = 0;
+ pContainer = FindContainerByName(szName);
+ }
+ if (pContainer == nullptr)
+ pContainer = CreateContainer(szName, FALSE, si->hContact);
+ if (pContainer == nullptr)
+ return; // smth went wrong, nothing to do here
+
MCONTACT hContact = si->hContact;
if (M.FindWindow(hContact) != 0)
- return 0;
+ return;
if (hContact != 0 && M.GetByte("limittabs", 0) && !wcsncmp(pContainer->szName, L"default", 6)) {
if ((pContainer = FindMatchingContainer(L"default")) == NULL) {
wchar_t szName[CONTAINER_NAMELEN + 1];
mir_snwprintf(szName, L"default");
if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact)) == NULL)
- return 0;
+ return;
}
}
- TNewWindowData newData = { 0 };
- newData.hContact = hContact;
- memset(&newData.item, 0, sizeof(newData.item));
-
- wchar_t *contactName = pcli->pfnGetContactDisplayName(newData.hContact, 0);
+ wchar_t *contactName = pcli->pfnGetContactDisplayName(hContact, 0);
// cut nickname if larger than x chars...
wchar_t newcontactname[128];
@@ -59,14 +79,10 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT
}
else wcsncpy_s(newcontactname, L"_U_", _TRUNCATE);
- newData.item.pszText = newcontactname;
- newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
- newData.item.iImage = 0;
-
HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS);
// hide the active tab
- if (pContainer->hwndActive && bActivateTab)
+ if (pContainer->hwndActive)
ShowWindow(pContainer->hwndActive, SW_HIDE);
int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->iChilds * 100);
@@ -74,7 +90,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT
pContainer->iTabIndex = iCount;
if (iCount > 0) {
- TCITEM item = { 0 };
+ TCITEM item = {};
for (int i = iCount - 1; i >= 0; i--) {
item.mask = TCIF_PARAM;
TabCtrl_GetItem(hwndTab, i, &item);
@@ -88,97 +104,55 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT
}
}
- int newItem = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &newData.item);
+ TCITEM item = {};
+ item.pszText = newcontactname;
+ item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
+ int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &item);
+
SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0);
- if (bActivateTab)
- TabCtrl_SetCurSel(hwndTab, newItem);
- newData.iTabID = newItem;
- newData.iTabImage = newData.item.iImage;
- newData.pContainer = pContainer;
- newData.iActivate = bActivateTab;
+ TabCtrl_SetCurSel(hwndTab, iTabId);
pContainer->iChilds++;
- newData.bWantPopup = bWantPopup;
- newData.si = si;
- CChatRoomDlg *pDlg = new CChatRoomDlg(&newData);
- pDlg->SetParent(GetDlgItem(pContainer->hwnd, IDC_MSGTABS));
+ CChatRoomDlg *pDlg = new CChatRoomDlg(si);
+ pDlg->m_iTabID = iTabId;
+ pDlg->m_pContainer = pContainer;
+ pDlg->SetParent(hwndTab);
pDlg->Create();
HWND hwndNew = pDlg->GetHwnd();
- if (pContainer->dwFlags & CNT_SIDEBAR) {
- CSrmmWindow *dat = (CSrmmWindow*)GetWindowLongPtr(hwndNew, GWLP_USERDATA);
- if (dat)
- pContainer->SideBar->addSession(dat, pContainer->iTabIndex);
- }
+
+ if (pContainer->dwFlags & CNT_SIDEBAR)
+ pContainer->SideBar->addSession(pDlg, pContainer->iTabIndex);
+
SendMessage(pContainer->hwnd, WM_SIZE, 0, 0);
// if the container is minimized, then pop it up...
if (IsIconic(pContainer->hwnd)) {
- if (bPopupContainer) {
- SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
- SetFocus(pContainer->hwndActive);
- }
- else {
- if (pContainer->dwFlags & CNT_NOFLASH)
- SendMessage(pContainer->hwnd, DM_SETICON, 0, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE));
- else
- FlashContainer(pContainer, 1, 0);
- }
+ SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ SetFocus(pContainer->hwndActive);
}
- if (bActivateTab) {
- if (PluginConfig.m_bHideOnClose && !IsWindowVisible(pContainer->hwnd)) {
- WINDOWPLACEMENT wp = { 0 };
- wp.length = sizeof(wp);
- GetWindowPlacement(pContainer->hwnd, &wp);
-
- BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation
- if (wp.showCmd == SW_SHOWMAXIMIZED)
- ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED);
- else {
- if (bPopupContainer)
- ShowWindow(pContainer->hwnd, SW_SHOWNORMAL);
- else
- ShowWindow(pContainer->hwnd, SW_SHOWMINNOACTIVE);
- }
- SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0);
- SetFocus(hwndNew);
- }
+
+ if (PluginConfig.m_bHideOnClose && !IsWindowVisible(pContainer->hwnd)) {
+ WINDOWPLACEMENT wp = { 0 };
+ wp.length = sizeof(wp);
+ GetWindowPlacement(pContainer->hwnd, &wp);
+
+ BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation
+ if (wp.showCmd == SW_SHOWMAXIMIZED)
+ ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED);
else {
- SetFocus(hwndNew);
- RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE);
- UpdateWindow(pContainer->hwnd);
- if (GetForegroundWindow() != pContainer->hwnd && bPopupContainer == TRUE)
- SetForegroundWindow(pContainer->hwnd);
+ ShowWindow(pContainer->hwnd, SW_SHOWNORMAL);
}
+ SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0);
+ SetFocus(hwndNew);
+ }
+ else {
+ SetFocus(hwndNew);
+ RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE);
+ UpdateWindow(pContainer->hwnd);
+ if (GetForegroundWindow() != pContainer->hwnd)
+ SetForegroundWindow(pContainer->hwnd);
}
if (PluginConfig.m_bIsWin7 && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled && !M.GetByte("forceAeroPeek", 0))
CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING | MB_OK);
- return hwndNew; // return handle of the new dialog
-}
-
-void ShowRoom(SESSION_INFO *si)
-{
- if (si == nullptr)
- return;
-
- if (si->hWnd != nullptr) {
- ActivateExistingTab(si->dat->m_pContainer, si->hWnd);
- return;
- }
-
- wchar_t szName[CONTAINER_NAMELEN + 2]; szName[0] = 0;
- TContainerData *pContainer = nullptr;
- if (si->dat != nullptr)
- pContainer = si->dat->m_pContainer;
- if (pContainer == nullptr) {
- GetContainerNameForContact(si->hContact, szName, CONTAINER_NAMELEN);
- if (!g_Settings.bOpenInDefault && !mir_wstrcmp(szName, L"default"))
- wcsncpy(szName, L"Chat Rooms", CONTAINER_NAMELEN);
- szName[CONTAINER_NAMELEN] = 0;
- pContainer = FindContainerByName(szName);
- }
- if (pContainer == nullptr)
- pContainer = CreateContainer(szName, FALSE, si->hContact);
- if (pContainer)
- si->hWnd = CreateNewRoom(pContainer, si, TRUE, TRUE, FALSE);
}