diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-11 20:46:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-11 20:46:17 +0300 |
commit | 1a23578ffa4dd87cc024f362bd8b2fadfa087e23 (patch) | |
tree | b98bd46ac4c6004d2f6c02615eafd7046e061018 /src/mir_app | |
parent | a81484f320776e7c945e2f74172f979745dd870b (diff) |
group chats:
- massive extinction of all remaining GC_* messages;
- color chooser completely moved to mir_app;
- color buttons' subclass function also moved to mir_app;
- all code management transferred to a bunch of virtual functions, members of CChatRoomDlg;
- numerous small fixes, like fix for a broken highlight in StdMsg
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 11 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 35 | ||||
-rw-r--r-- | src/mir_app/src/colorchooser.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 13 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 13 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 18 | ||||
-rw-r--r-- | src/mir_app/src/srmm_util.cpp | 22 |
7 files changed, 97 insertions, 19 deletions
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index d8cfe40999..72863f26d7 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -242,7 +242,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p chatApi.UM_RemoveUser(&si->pUsers, pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
if (pszID)
return TRUE;
@@ -268,7 +268,7 @@ BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -283,7 +283,7 @@ BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wcha if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -298,7 +298,7 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -349,7 +349,7 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) replaceStrW(ui->pszNick, gce->ptszText);
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
if (chatApi.OnChangeNick)
chatApi.OnChangeNick(si);
}
@@ -1110,7 +1110,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.IsHighlighted = IsHighlighted;
chatApi.RemoveFormatting = RemoveFormatting;
chatApi.ReloadSettings = LoadGlobalSettings;
- chatApi.ColorChooser = ColorChooser;
chatApi.pLogIconBmpBits = pLogIconBmpBits;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index d7ac64cd01..d6d5126f33 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -85,7 +85,7 @@ static int FontsChanged(WPARAM, LPARAM) chatApi.MM_FontsChanged();
chatApi.MM_FixColors();
- chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
return 0;
}
@@ -95,7 +95,7 @@ static int IconsChanged(WPARAM, LPARAM) LoadMsgLogBitmaps();
chatApi.MM_IconsChanged();
- chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, FALSE);
+ Chat_UpdateOptions();
return 0;
}
@@ -113,7 +113,11 @@ static int PreShutdown(WPARAM, LPARAM) static int SmileyOptionsChanged(WPARAM, LPARAM)
{
- chatApi.SM_BroadcastMessage(nullptr, GC_REDRAWLOG, 0, 1, FALSE);
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ SESSION_INFO *si = g_arSessions[i];
+ if (si->pDlg)
+ si->pDlg->RedrawLog();
+ }
return 0;
}
@@ -296,15 +300,15 @@ static INT_PTR __stdcall stubRoomControl(void *param) SM_SetOffline(si);
SM_SetStatus(si, ID_STATUS_OFFLINE);
if (si->pDlg) {
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateStatusBar();
+ si->pDlg->UpdateNickList();
}
break;
case SESSION_ONLINE:
SM_SetStatus(si, ID_STATUS_ONLINE);
if (si->pDlg)
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->UpdateStatusBar();
break;
case WINDOW_CLEARLOG:
@@ -409,9 +413,9 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) if (p->pDlg && p->bInitDone) {
if (SM_AddEvent(p->ptszID, p->pszModule, gce, FALSE))
- SendMessage(p->pDlg->GetHwnd(), GC_ADDLOG, 0, 0);
+ p->pDlg->AddLog();
else
- SendMessage(p->pDlg->GetHwnd(), GC_REDRAWLOG2, 0, 0);
+ p->pDlg->RedrawLog2();
}
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
@@ -555,9 +559,9 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) int isOk = SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
if (si->pDlg) {
if (isOk)
- SendMessage(si->pDlg->GetHwnd(), GC_ADDLOG, 0, 0);
+ si->pDlg->AddLog();
else
- SendMessage(si->pDlg->GetHwnd(), GC_REDRAWLOG2, 0, 0);
+ si->pDlg->RedrawLog2();
}
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
@@ -689,7 +693,7 @@ MIR_APP_DLL(int) Chat_SetStatusbarText(const char *szModule, const wchar_t *wszI db_set_s(si->hContact, si->pszModule, "StatusBar", "");
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->UpdateStatusBar();
}
return 0;
}
@@ -724,6 +728,15 @@ MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, vo return GC_EVENT_ERROR;
}
+EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions()
+{
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ SESSION_INFO *si = g_arSessions[i];
+ if (si->pDlg)
+ si->pDlg->UpdateOptions();
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// module initialization
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index aa6fd06cb1..731239b8c1 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -265,8 +265,8 @@ public: }
};
-void ColorChooser(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser)
+void CSrmmBaseDialog::ShowColorChooser(int iCtrlId)
{
- CColorChooserDlg *pDialog = new CColorChooserDlg(si, bFG, hwndDlg, hwndTarget, hwndChooser);
+ CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == m_pColor->GetCtrlId(), m_hwnd, m_pEntry->GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
pDialog->Show();
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 1628ca17a9..4c35385bb0 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -412,3 +412,16 @@ Srmm_LogStreamCallback @412 Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IAEXHPBUUSERINFO@@PB_WH@Z @414 NONAME
?ClearLog@CSrmmBaseDialog@@QAEXXZ @415 NONAME
+?CloseTab@CSrmmBaseDialog@@UAEX_N@Z @416 NONAME
+?UpdateStatusBar@CSrmmBaseDialog@@UAEXXZ @417 NONAME
+Chat_UpdateOptions @418 NONAME
+?RedrawLog@CSrmmBaseDialog@@UAEXXZ @419 NONAME
+?UpdateOptions@CSrmmBaseDialog@@UAEXXZ @420 NONAME
+?ShowColorChooser@CSrmmBaseDialog@@QAEXH@Z @421 NONAME
+?ShowFilterMenu@CSrmmBaseDialog@@UAEXXZ @422 NONAME
+_Srmm_ButtonSubclassProc@16 @423 NONAME
+?StreamInEvents@CSrmmBaseDialog@@UAEXPAULOGINFO@@_N@Z @424 NONAME
+?AddLog@CSrmmBaseDialog@@UAEXXZ @425 NONAME
+?RedrawLog2@CSrmmBaseDialog@@QAEXXZ @426 NONAME
+?ScrollToBottom@CSrmmBaseDialog@@UAEXXZ @427 NONAME
+?UpdateNickList@CSrmmBaseDialog@@UAEXXZ @428 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index ad9ab48e67..b9521316af 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -412,3 +412,16 @@ Srmm_LogStreamCallback @412 Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IEAAXHPEBUUSERINFO@@PEB_W_J@Z @414 NONAME
?ClearLog@CSrmmBaseDialog@@QEAAXXZ @415 NONAME
+?CloseTab@CSrmmBaseDialog@@UEAAX_N@Z @416 NONAME
+?UpdateStatusBar@CSrmmBaseDialog@@UEAAXXZ @417 NONAME
+Chat_UpdateOptions @418 NONAME
+?RedrawLog@CSrmmBaseDialog@@UEAAXXZ @419 NONAME
+?UpdateOptions@CSrmmBaseDialog@@UEAAXXZ @420 NONAME
+?ShowColorChooser@CSrmmBaseDialog@@QEAAXH@Z @421 NONAME
+?ShowFilterMenu@CSrmmBaseDialog@@UEAAXXZ @422 NONAME
+Srmm_ButtonSubclassProc @423 NONAME
+?StreamInEvents@CSrmmBaseDialog@@UEAAXPEAULOGINFO@@_N@Z @424 NONAME
+?AddLog@CSrmmBaseDialog@@UEAAXXZ @425 NONAME
+?RedrawLog2@CSrmmBaseDialog@@QEAAXXZ @426 NONAME
+?ScrollToBottom@CSrmmBaseDialog@@UEAAXXZ @427 NONAME
+?UpdateNickList@CSrmmBaseDialog@@UEAAXXZ @428 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 1f017289b4..8df17b3fd7 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -32,6 +32,9 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si m_si(si), m_pLog(nullptr), m_pEntry(nullptr), + m_pFilter(nullptr), + m_pColor(nullptr), + m_pBkColor(nullptr), m_hContact(0) { m_bFilterEnabled = db_get_b(0, CHAT_MODULE, "FilterEnabled", 0) != 0; @@ -138,6 +141,14 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return CDlgBase::DlgProc(msg, wParam, lParam); } +void CSrmmBaseDialog::AddLog() +{ + if (m_si->pLogEnd) + StreamInEvents(m_si->pLog, false); + else + ClearLog(); +} + void CSrmmBaseDialog::ClearLog() { if (m_pLog != nullptr) @@ -162,3 +173,10 @@ void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_ gch.pDest = &gcd; NotifyEventHooks(chatApi.hSendEvent, 0, (WPARAM)&gch); } + +void CSrmmBaseDialog::RedrawLog2() +{ + m_si->LastTime = 0; + if (m_si->pLog) + StreamInEvents(m_si->pLogEnd, TRUE); +} diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index 78ed59e436..e9aeffc33c 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -72,3 +72,25 @@ MIR_APP_DLL(DWORD) CALLBACK Srmm_MessageStreamCallback(DWORD_PTR dwCookie, LPBYT } return 0; } + +EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK Srmm_ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_RBUTTONUP: + if (db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) != 0) { + CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); + if (pDlg == nullptr) + break; + + if (hwnd == pDlg->m_pFilter->GetHwnd()) + pDlg->ShowFilterMenu(); + else if (hwnd == pDlg->m_pColor->GetHwnd()) + pDlg->ShowColorChooser(pDlg->m_pColor->GetCtrlId()); + else if (hwnd == pDlg->m_pBkColor->GetHwnd()) + pDlg->ShowColorChooser(pDlg->m_pBkColor->GetCtrlId()); + } + break; + } + + return mir_callNextSubclass(hwnd, Srmm_ButtonSubclassProc, msg, wParam, lParam); +} |