From ee23690fa6c847a5284f8145e73328cdaab2b617 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 21 Nov 2023 19:01:35 +0300 Subject: SRMM toolbar buttons that require input window to be visible are marked as BBBF_NOREADONLY --- src/core/stdmsg/src/msgs.cpp | 26 +++++++++++++------------- src/mir_app/src/CMPluginBase.cpp | 7 +++++++ src/mir_app/src/chat.h | 4 +++- src/mir_app/src/file.cpp | 2 +- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/srmm_base.cpp | 4 ++-- src/mir_app/src/srmm_toolbar.cpp | 13 +++++++------ 8 files changed, 35 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 066550d3bd..fcf23c51d8 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -327,21 +327,21 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_ADDCONTACT); bbd.pwszText = LPGENW("&Add"); bbd.pwszTooltip = LPGENW("Add contact permanently to list"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_USERMENU; bbd.dwDefPos = 20; bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_DOWNARROW); bbd.pwszText = LPGENW("&User menu"); bbd.pwszTooltip = LPGENW("User menu"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_DETAILS; bbd.dwDefPos = 30; bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS); bbd.pwszText = LPGENW("User &details"); bbd.pwszTooltip = LPGENW("View user's details"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.bbbFlags |= BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; bbd.dwButtonID = IDC_SRMM_HISTORY; @@ -349,44 +349,44 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_HISTORY); bbd.pwszText = LPGENW("&History"); bbd.pwszTooltip = LPGENW("View user's history (Ctrl+H)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); // chat buttons - bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID; + bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY; bbd.dwButtonID = IDC_SRMM_BOLD; bbd.dwDefPos = 10; bbd.hIcon = g_plugin.getIconHandle(IDI_BBOLD); bbd.pwszText = LPGENW("&Bold"); bbd.pwszTooltip = LPGENW("Make the text bold (Ctrl+B)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_ITALICS; bbd.dwDefPos = 15; bbd.hIcon = g_plugin.getIconHandle(IDI_BITALICS); bbd.pwszText = LPGENW("&Italic"); bbd.pwszTooltip = LPGENW("Make the text italicized (Ctrl+I)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_UNDERLINE; bbd.dwDefPos = 20; bbd.hIcon = g_plugin.getIconHandle(IDI_BUNDERLINE); bbd.pwszText = LPGENW("&Underline"); bbd.pwszTooltip = LPGENW("Make the text underlined (Ctrl+U)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_COLOR; bbd.dwDefPos = 25; bbd.hIcon = g_plugin.getIconHandle(IDI_COLOR); bbd.pwszText = LPGENW("&Color"); bbd.pwszTooltip = LPGENW("Select a foreground color for the text (Ctrl+K)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_BKGCOLOR; bbd.dwDefPos = 30; bbd.hIcon = g_plugin.getIconHandle(IDI_BKGCOLOR); bbd.pwszText = LPGENW("&Background color"); bbd.pwszTooltip = LPGENW("Select a background color for the text (Ctrl+L)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SRMM_CHANMGR; @@ -394,21 +394,21 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.hIcon = g_plugin.getIconHandle(IDI_TOPICBUT); bbd.pwszText = LPGENW("&Room settings"); bbd.pwszTooltip = LPGENW("Control this room (Ctrl+O)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_SHOWNICKLIST; bbd.dwDefPos = 20; bbd.hIcon = g_plugin.getIconHandle(IDI_NICKLIST); bbd.pwszText = LPGENW("&Show/hide nick list"); bbd.pwszTooltip = LPGENW("Show/hide the nick list (Ctrl+N)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); bbd.dwButtonID = IDC_SRMM_FILTER; bbd.dwDefPos = 10; bbd.hIcon = g_plugin.getIconHandle(IDI_FILTER); bbd.pwszText = LPGENW("&Filter"); bbd.pwszTooltip = LPGENW("Enable/disable the event filter (Ctrl+F)"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); return 0; } diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index 8c50bfdd2e..fcf162b4d4 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "stdafx.h" +#include "chat.h" #include "plugins.h" #include "IcoLib.h" @@ -288,6 +289,12 @@ HGENMENU CMPluginBase::addRootMenu(int hMenuObject, LPCWSTR ptszName, int positi return Menu_CreateRoot(hMenuObject, ptszName, position, hIcoLib, this); } +HANDLE CMPluginBase::addButton(const struct BBButton *pButton) +{ + return Srmm_AddButton(pButton, this); +} + + HANDLE CMPluginBase::addTTB(const struct TTBButton *pButton) { return (HANDLE)CallService(MS_TTB_ADDBUTTON, (WPARAM)pButton, (LPARAM)this); diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 3f4fcc8dda..1766669bc5 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define DM_OPTIONSAPPLIED (WM_USER+14) -void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags); +void Srmm_CreateToolbarIcons(CSrmmBaseDialog *pDlg, int flags); void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwndDlg); void CheckChatCompatibility(); @@ -136,4 +136,6 @@ CMStringW Chat_GetFolderName(SESSION_INFO *si = nullptr); void Chat_Serialize(SESSION_INFO *si); bool Chat_Unserialize(SESSION_INFO *si); +EXTERN_C MIR_APP_DLL(HANDLE) Srmm_AddButton(const BBButton *bbdi, HPLUGIN _hLang); + #pragma comment(lib,"comctl32.lib") diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index 7cde57d9f4..491a130183 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -173,7 +173,7 @@ static int SRFileModulesLoaded(WPARAM, LPARAM) bbd.hIcon = g_plugin.getIconHandle(IDI_ATTACH); bbd.pszModuleName = SRFILEMODULE; bbd.pwszTooltip = LPGENW("Send file"); - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); HookEvent(ME_MSG_BUTTONPRESSED, OnToolbarButtonPressed); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRFilePreBuildMenu); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index bd9234ca7e..33ebc19958 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -911,3 +911,4 @@ Clist_GroupSaveExpanded @1003 NONAME ?addFont@CMPluginBase@@QAEHPBD0PB_W111HHPAUtagLOGFONTW@@K@Z @1029 NONAME ?IsReadonly@Contact@@YG_NI@Z @1030 NONAME ?Readonly@Contact@@YGXI_N@Z @1031 NONAME +?addButton@CMPluginBase@@QAEPAXPBUBBButton@@@Z @1032 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 478cde2493..fc9a419bce 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -911,3 +911,4 @@ Clist_GroupSaveExpanded @1003 NONAME ?addFont@CMPluginBase@@QEAAHPEBD0PEB_W111HHPEAUtagLOGFONTW@@K@Z @1029 NONAME ?IsReadonly@Contact@@YA_NI@Z @1030 NONAME ?Readonly@Contact@@YAXI_N@Z @1031 NONAME +?addButton@CMPluginBase@@QEAAPEAXPEBUBBButton@@@Z @1032 NONAME diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 9851972d7f..5e152d3870 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -550,7 +550,7 @@ bool CSrmmBaseDialog::OnInitDialog() } // three buttons below are initiated inside this call, so button creation must precede subclassing - Srmm_CreateToolbarIcons(m_hwnd, isChat() ? BBBF_ISCHATBUTTON : BBBF_ISIMBUTTON); + Srmm_CreateToolbarIcons(this, isChat() ? BBBF_ISCHATBUTTON : BBBF_ISIMBUTTON); mir_subclassWindow(m_btnFilter.GetHwnd(), stubButtonSubclassProc); mir_subclassWindow(m_btnColor.GetHwnd(), stubButtonSubclassProc); @@ -613,7 +613,7 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_CBD_RECREATE: - Srmm_CreateToolbarIcons(m_hwnd, isChat() ? BBBF_ISCHATBUTTON : BBBF_ISIMBUTTON); + Srmm_CreateToolbarIcons(this, isChat() ? BBBF_ISCHATBUTTON : BBBF_ISIMBUTTON); break; case WM_NOTIFY: diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index 29fa5bdffb..ac428385c0 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -68,7 +68,7 @@ static void CB_RegisterSeparators() bbd.bbbFlags = BBBF_ISSEPARATOR | BBBF_ISIMBUTTON; bbd.dwButtonID = i + 1; bbd.dwDefPos = 410 + i; - Srmm_AddButton(&bbd, &g_plugin); + g_plugin.addButton(&bbd); } } @@ -172,6 +172,7 @@ MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi) cbd->m_bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0; cbd->m_bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0; cbd->m_bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0; + cbd->m_bNoReadonly = (bbdi->bbbFlags & BBBF_NOREADONLY) != 0; } } } @@ -261,12 +262,11 @@ MIR_APP_DLL(void) Srmm_ResetToolbar() } } -void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) +void Srmm_CreateToolbarIcons(CSrmmBaseDialog *pDlg, int flags) { + MWindow hwndDlg = pDlg->GetHwnd(); HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE); - CDlgBase *pDlg = CDlgBase::Find(hwndDlg); - for (auto &cbd : arButtonsList) { if (cbd->m_bSeparator) continue; @@ -300,7 +300,7 @@ void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) if (cbd->m_bDisabled) EnableWindow(hwndButton, FALSE); - if (cbd->m_bHidden) + if (cbd->m_bHidden || (pDlg->m_bReadOnly && cbd->m_bNoReadonly)) ShowWindow(hwndButton, SW_HIDE); } else if (hwndButton) @@ -603,7 +603,7 @@ public: bbd.bbbFlags = BBBF_ISSEPARATOR | BBBF_ISIMBUTTON; bbd.dwButtonID = ++dwSepCount; - CustomButtonData *cbd = (CustomButtonData*)Srmm_AddButton(&bbd, &g_plugin); + CustomButtonData *cbd = (CustomButtonData*)g_plugin.addButton(&bbd); TVINSERTSTRUCT tvis; tvis.hParent = nullptr; @@ -741,6 +741,7 @@ MIR_APP_DLL(HANDLE) Srmm_AddButton(const BBButton *bbdi, HPLUGIN _hLang) cbd->m_dwArrowCID = (bbdi->bbbFlags & BBBF_ISARROWBUTTON) ? cbd->m_dwButtonCID + 1 : 0; cbd->m_bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0; cbd->m_bSeparator = (bbdi->bbbFlags & BBBF_ISSEPARATOR) != 0; + cbd->m_bNoReadonly = (bbdi->bbbFlags & BBBF_NOREADONLY) != 0; cbd->m_bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0; cbd->m_bPushButton = (bbdi->bbbFlags & BBBF_ISPUSHBUTTON) != 0; -- cgit v1.2.3