From 856ff580fd9d776c331a6b525fa7d73a24d92f64 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 9 Jun 2022 21:26:35 +0300 Subject: UserInfo -> UI classes --- plugins/SeenPlugin/src/stdafx.h | 1 + plugins/SeenPlugin/src/userinfo.cpp | 56 +++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 30 deletions(-) (limited to 'plugins/SeenPlugin') diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h index c636358661..9172cce71d 100644 --- a/plugins/SeenPlugin/src/stdafx.h +++ b/plugins/SeenPlugin/src/stdafx.h @@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index 2f2966d25a..1a323a5e11 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +static LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_SETCURSOR: @@ -30,47 +30,43 @@ LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam); } -INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +struct UserinfoDlg : public CUserInfoPageDlg { - switch (msg) { - case WM_INITDIALOG: - mir_subclassWindow(GetDlgItem(hdlg, IDC_INFOTEXT), EditProc); - WindowList_Add(g_pUserInfo, hdlg, lparam); - SendMessage(hdlg, WM_REFRESH_UI, lparam, 0); - break; - - case WM_REFRESH_UI: - { - ptrW szout(g_plugin.getWStringA("UserStamp")); - CMStringW str = ParseString((szout != NULL) ? szout : DEFAULT_USERSTAMP, wparam); - SetDlgItemText(hdlg, IDC_INFOTEXT, str); + UserinfoDlg() : + CUserInfoPageDlg(g_plugin, IDD_USERINFO) + {} - if (!mir_wstrcmp(str, TranslateT(""))) - EnableWindow(GetDlgItem(hdlg, IDC_INFOTEXT), FALSE); - } - break; + bool OnInitDialog() override + { + mir_subclassWindow(GetDlgItem(m_hwnd, IDC_INFOTEXT), EditProc); + WindowList_Add(g_pUserInfo, m_hwnd, m_hContact); + return true; + } - case WM_COMMAND: - if (HIWORD(wparam) == EN_SETFOCUS) - SetFocus(GetParent(hdlg)); - break; + bool OnRefresh() override + { + ptrW szout(g_plugin.getWStringA("UserStamp")); + CMStringW str = ParseString((szout != NULL) ? szout : DEFAULT_USERSTAMP, m_hContact); + SetDlgItemText(m_hwnd, IDC_INFOTEXT, str); - case WM_DESTROY: - WindowList_Remove(g_pUserInfo, hdlg); - break; + if (!mir_wstrcmp(str, TranslateT(""))) + EnableWindow(GetDlgItem(m_hwnd, IDC_INFOTEXT), FALSE); + return false; } - return 0; -} + void OnDestroy() override + { + WindowList_Remove(g_pUserInfo, m_hwnd); + } +}; int UserinfoInit(WPARAM wparam, LPARAM hContact) { char *szProto = Proto_GetBaseAccountName(hContact); if (IsWatchedProtocol(szProto) && !db_get_b(hContact, szProto, "ChatRoom", false)) { - OPTIONSDIALOGPAGE uip = { sizeof(uip) }; - uip.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); + USERINFOPAGE uip = {}; uip.szTitle.a = LPGEN("Last seen"); - uip.pfnDlgProc = UserinfoDlgProc; + uip.pDialog = new UserinfoDlg(); g_plugin.addUserInfo(wparam, &uip); } return 0; -- cgit v1.2.3