diff options
author | George Hazan <ghazan@miranda.im> | 2018-02-13 15:39:00 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-02-13 15:39:00 +0300 |
commit | 1e406589b96cc4f97adebd5d680c1288d93cc307 (patch) | |
tree | 7ea9cc07497c8fc90078691bc353a86da4187dc9 /plugins/StatusManager | |
parent | eb6bf8f4cc700ca89df670b01c27bf30465e91cc (diff) |
StatusManager: profile addition dialog => UI classes
Diffstat (limited to 'plugins/StatusManager')
-rw-r--r-- | plugins/StatusManager/res/resource.rc | 4 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_options.cpp | 78 |
2 files changed, 44 insertions, 38 deletions
diff --git a/plugins/StatusManager/res/resource.rc b/plugins/StatusManager/res/resource.rc index 0e38cf1268..9424df8dd2 100644 --- a/plugins/StatusManager/res/resource.rc +++ b/plugins/StatusManager/res/resource.rc @@ -172,8 +172,8 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPT CAPTION "Add new profile" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDC_OK,68,39,50,14 - PUSHBUTTON "Cancel",IDC_CANCEL,14,39,50,14 + DEFPUSHBUTTON "OK",IDOK,68,39,50,14 + PUSHBUTTON "Cancel",IDCANCEL,14,39,50,14 EDITTEXT IDC_PROFILENAME,14,21,104,14,ES_AUTOHSCROLL LTEXT "Profile name",IDC_STATIC,11,11,55,8 END diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 6e48296d4d..c0253b26e1 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -445,48 +445,52 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w return FALSE; } -/////////////////////////////////////////////////////////////////////////////// -// for db cleanup +///////////////////////////////////////////////////////////////////////////////////////// +// new profile dialog -static int DeleteSetting(const char *szSetting, void *lParam) +class CAddProfileDlg : public CDlgBase { - LIST<char> *p = (LIST<char> *)lParam; - p->insert(mir_strdup(szSetting)); - return 0; -} + CCtrlEdit edtProfile; + CCtrlButton btnOk; -INT_PTR CALLBACK addProfileDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static HWND hwndParent; +public: + CAddProfileDlg() + : CDlgBase(hInst, IDD_ADDPROFILE), + btnOk(this, IDOK), + edtProfile(this, IDC_PROFILENAME) + { + edtProfile.OnChange = Callback(this, &CAddProfileDlg::onChange_Edit); + } - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - hwndParent = (HWND)lParam; - EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE); - break; + void OnInitDialog() override + { + btnOk.Disable(); + } - case WM_COMMAND: - if (LOWORD(wParam) == IDC_OK) { - wchar_t profileName[128]; - GetDlgItemText(hwndDlg, IDC_PROFILENAME, profileName, _countof(profileName)); - SendMessage(hwndParent, UM_ADDPROFILE, 0, (LPARAM)profileName); - // done and exit - DestroyWindow(hwndDlg); - } - else if (LOWORD(wParam) == IDC_CANCEL) { - DestroyWindow(hwndDlg); - } - else if (LOWORD(wParam) == IDC_PROFILENAME) { - (SendDlgItemMessage(hwndDlg, IDC_PROFILENAME, EM_LINELENGTH, 0, 0) > 0) ? EnableWindow(GetDlgItem(hwndDlg, IDC_OK), TRUE) : EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE); - } - break; + void OnApply() override + { + ptrW profileName(edtProfile.GetText()); + SendMessage(m_hwndParent, UM_ADDPROFILE, 0, (LPARAM)profileName.get()); + } - case WM_DESTROY: - EnableWindow(hwndParent, TRUE); - break; + void OnDestroy() override + { + EnableWindow(m_hwndParent, TRUE); + } + + void onChange_Edit(CCtrlEdit*) + { + btnOk.Enable(edtProfile.SendMsg(EM_LINELENGTH, 0, 0) > 0); } +}; +///////////////////////////////////////////////////////////////////////////////////////// +// advanced options dialog + +static int DeleteSetting(const char *szSetting, void *lParam) +{ + LIST<char> *p = (LIST<char> *)lParam; + p->insert(mir_strdup(szSetting)); return 0; } @@ -718,8 +722,10 @@ public: // add a profile void onClick_Add(CCtrlButton*) - { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDPROFILE), m_hwnd, addProfileDlgProc, (LPARAM)m_hwnd); + { + CAddProfileDlg *pDlg = new CAddProfileDlg(); + pDlg->SetParent(m_hwnd); + pDlg->Show(); EnableWindow(m_hwnd, FALSE); } |