summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat
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
parentac92ec1a55354e57b8cc6d4fd77aa2e75a896242 (diff)
TNewWindowData - unneeded structure removed
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r--plugins/TabSRMM/src/chat/chat.h2
-rw-r--r--plugins/TabSRMM/src/chat/chat_resource.h2
-rw-r--r--plugins/TabSRMM/src/chat/services.cpp156
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp15
5 files changed, 72 insertions, 105 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index de0f4cc330..9551527c54 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -114,8 +114,6 @@ HICON LoadIconEx(char *pszIcoLibName);
// services.c
void ShowRoom(SESSION_INFO *si);
-HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup);
-
// manager.c
SESSION_INFO* SM_FindSessionByHWND(HWND h);
SESSION_INFO* SM_FindSessionByHCONTACT(MCONTACT h);
diff --git a/plugins/TabSRMM/src/chat/chat_resource.h b/plugins/TabSRMM/src/chat/chat_resource.h
index 564aa61fe7..277097f308 100644
--- a/plugins/TabSRMM/src/chat/chat_resource.h
+++ b/plugins/TabSRMM/src/chat/chat_resource.h
@@ -12,7 +12,6 @@
#define IDD_OPTIONS4 408
#define IDD_ADDHIGHLIGHT 409
#define IDC_SMILEY 1007
-#define IDC_SPLITTERY 1008
#define IDC_FILTER 1013
#define IDC_CHANMGR 1014
#define IDC_SHOWNICKLIST 1015
@@ -34,7 +33,6 @@
#define IDC_LIMIT 1050
#define IDC_LOGTIMESTAMP 1051
#define IDC_GROUP 1057
-#define IDC_SPLITTERX 1058
#define IDC_RADIO2 1062
#define IDC_RADIO3 1063
#define IDC_TEXT 1064
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);
}
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index dd9568becc..47feb637df 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -274,7 +274,7 @@ void DoFlashAndSoundWorker(FLASH_PARAMS* p)
else if (dat->m_iFlashIcon) {
dat->m_hTabIcon = dat->m_iFlashIcon;
- TCITEM item = { 0 };
+ TCITEM item = {};
item.mask = TCIF_IMAGE;
item.iImage = 0;
TabCtrl_SetItem(GetParent(si->hWnd), dat->m_iTabID, &item);
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 152c958ae8..97e50a8b93 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -1512,8 +1512,8 @@ static void __cdecl phase2(void * lParam)
// the actual group chat session window procedure.Handles the entire chat session window
// which is usually a (tabbed) child of a container class window.
-CChatRoomDlg::CChatRoomDlg(TNewWindowData *pData)
- : CTabBaseDlg(pData, IDD_CHANNEL),
+CChatRoomDlg::CChatRoomDlg(SESSION_INFO *_si)
+ : CTabBaseDlg(IDD_CHANNEL),
m_btnOk(this, IDOK),
m_list(this, IDC_LIST),
m_btnBold(this, IDC_BOLD),
@@ -1528,7 +1528,7 @@ CChatRoomDlg::CChatRoomDlg(TNewWindowData *pData)
{
m_bType = SESSIONTYPE_CHAT;
- si = newData->si;
+ si = _si;
m_hContact = si->hContact;
m_szProto = GetContactProto(si->hContact);
@@ -1575,10 +1575,7 @@ void CChatRoomDlg::OnInitDialog()
m_cache = CContactCache::getContactCache(m_hContact);
m_cache->updateNick();
m_cache->updateUIN();
- newData->item.lParam = (LPARAM)m_hwnd;
- TabCtrl_SetItem(m_hwndParent, newData->iTabID, &newData->item);
- m_iTabID = newData->iTabID;
- m_pContainer = newData->pContainer;
+
si->hWnd = m_hwnd;
si->dat = this;
m_bIsAutosizingInput = IsAutoSplitEnabled();
@@ -2060,7 +2057,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_cache->getStatus() != m_cache->getOldStatus()) {
wcsncpy_s(m_wszStatus, pcli->pfnGetStatusModeDescription(m_wStatus, 0), _TRUNCATE);
- TCITEM item = { 0 };
+ TCITEM item = {};
item.mask = TCIF_TEXT;
item.pszText = m_wszTitle;
TabCtrl_SetItem(m_hwndParent, m_iTabID, &item);
@@ -3037,7 +3034,7 @@ LABEL_SHOWWINDOW:
i++;
TabCtrl_SetCurSel(m_hwndParent, i);
- TCITEM item = { 0 };
+ TCITEM item = {};
item.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwndParent, i, &item); // retrieve dialog hwnd for the now active tab...
m_pContainer->hwndActive = (HWND)item.lParam;