diff options
author | George Hazan <ghazan@miranda.im> | 2022-06-09 21:26:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-06-09 21:30:54 +0300 |
commit | 856ff580fd9d776c331a6b525fa7d73a24d92f64 (patch) | |
tree | 42c4912b0b9c406c15783af3fc6e8c4857b09de1 /plugins/UserInfoEx/src/psp_origin.cpp | |
parent | 68c2dea66f3e368cc1437f7890c8e62907890fcd (diff) |
UserInfo -> UI classes
Diffstat (limited to 'plugins/UserInfoEx/src/psp_origin.cpp')
-rw-r--r-- | plugins/UserInfoEx/src/psp_origin.cpp | 201 |
1 files changed, 92 insertions, 109 deletions
diff --git a/plugins/UserInfoEx/src/psp_origin.cpp b/plugins/UserInfoEx/src/psp_origin.cpp index c10d4c0fc0..78b85cc707 100644 --- a/plugins/UserInfoEx/src/psp_origin.cpp +++ b/plugins/UserInfoEx/src/psp_origin.cpp @@ -21,126 +21,109 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * This is the dialog procedure for the advanced contact information propertysheetpage.
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+class PSPOriginDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- TranslateDialogDefault(hDlg);
- SetTimer(hDlg, 1, 5000, nullptr);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
-
- pCtrlList->insert(CTzCombo::CreateObj(hDlg, EDIT_TIMEZONE, nullptr));
- }
+ CTimer timer;
+
+public:
+ PSPOriginDlg() :
+ PSPBaseDlg(IDD_CONTACT_ORIGIN),
+ timer(this, 1)
+ {
+ timer.OnEvent = Callback(this, &PSPOriginDlg::onTimer);
+ }
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ timer.Start(5000);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
+
+ m_ctrlList->insert(CTzCombo::CreateObj(m_hwnd, EDIT_TIMEZONE, nullptr));
+ return true;
+ }
+
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ if (!m_hContact)
+ return false;
+
+ MTime mt;
+ if (mt.DBGetStamp(m_hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
+ uint32_t dwStamp;
+
+ dwStamp = DB::Contact::WhenAdded(db_get_dw(m_hContact, pszProto, "UIN", 0), pszProto);
+ if (dwStamp > 0)
+ mt.FromStampAsUTC(dwStamp);
}
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
-
- switch (((LPNMHDR) lParam)->code) {
- case PSN_INFOCHANGED:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- if (hContact) {
- MTime mt;
-
- if (mt.DBGetStamp(hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
- uint32_t dwStamp;
-
- dwStamp = DB::Contact::WhenAdded(db_get_dw(hContact, pszProto, "UIN", 0), pszProto);
- if (dwStamp > 0)
- mt.FromStampAsUTC(dwStamp);
- }
- if (mt.IsValid()) {
- wchar_t szTime[MAX_PATH];
- LPTSTR ptr;
-
- mt.UTCToLocal();
- mt.DateFormatLong(szTime, _countof(szTime));
-
- mir_wstrcat(szTime, L" - ");
- ptr = szTime + mir_wstrlen(szTime);
- mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
- SetDlgItemText(hDlg, TXT_DATEADDED, szTime);
- }
- }
-
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
- { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
- };
-
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
- }
- }
- }
- } /* switch (((LPNMHDR)lParam)->idFrom) */
+ if (mt.IsValid()) {
+ wchar_t szTime[MAX_PATH];
+ LPTSTR ptr;
+
+ mt.UTCToLocal();
+ mt.DateFormatLong(szTime, _countof(szTime));
+
+ mir_wstrcat(szTime, L" - ");
+ ptr = szTime + mir_wstrlen(szTime);
+ mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
+ SetDlgItemText(m_hwnd, TXT_DATEADDED, szTime);
}
- break;
+ return false;
+ }
+
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
+ { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
+ };
+
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
- case WM_COMMAND:
- {
+ void onTimer(CTimer *)
+ {
+ wchar_t szTime[32];
+ CTzCombo::GetObj(m_hwnd, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
+ SetDlgItemText(m_hwnd, TXT_TIME, szTime);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
- break;
-
- case WM_TIMER:
- {
- wchar_t szTime[32];
- CTzCombo::GetObj(hDlg, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
- SetDlgItemText(hDlg, TXT_TIME, szTime);
- break;
- }
-
- case WM_DESTROY:
- KillTimer(hDlg, 1);
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000002;
+ uip.pDialog = new PSPOriginDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADVANCED);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Origin");
+ g_plugin.addUserInfo(wParam, &uip);
}
|