summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-02-07 18:41:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-02-07 18:41:51 +0300
commitcdfc2aae2e8565a9dd9db0f65e93985dc11e6455 (patch)
treeb5cb8e402e7495e0c14fe8c61fdcfb991f739262 /src
parent223306302f39455970b67a97ba62e4a542224f7a (diff)
fxes #3024 (Сделать переводимыми различные тестовые окна )
Diffstat (limited to 'src')
-rw-r--r--src/core/stdpopup/src/options.cpp599
1 files changed, 302 insertions, 297 deletions
diff --git a/src/core/stdpopup/src/options.cpp b/src/core/stdpopup/src/options.cpp
index 40c51c372d..ad599987c8 100644
--- a/src/core/stdpopup/src/options.cpp
+++ b/src/core/stdpopup/src/options.cpp
@@ -82,80 +82,62 @@ void SaveOptions()
g_plugin.setDword("AvatarPadding", options.av_padding);
}
-void ShowExamplePopups()
+class CMainOptDlg : public CDlgBase
{
- PopupData pd = { sizeof(PopupData) };
- pd.hIcon = hPopupIcon;
- pd.flags = PDF_UNICODE;
-
- pd.pwszTitle = TranslateT("Example");
- pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
- ShowPopup(pd);
-
- pd.pwszTitle = TranslateT("Example With a Long Title");
- pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
- ShowPopup(pd);
-
- pd.pwszTitle = TranslateT("Example");
- pd.pwszText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
- ShowPopup(pd);
-
- for (auto &hContact : Contacts()) {
- if (options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) {
- AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
- if (ace && (ace->dwFlags & AVS_BITMAP_VALID)) {
- pd.hContact = hContact;
- pd.pwszText = TranslateT("An avatar.");
- ShowPopup(pd);
- break;
- }
- }
+ CCtrlCheck chkTimeout, chkNoTimeout;
+ CCtrlButton btnPreview;
+
+public:
+ CMainOptDlg() :
+ CDlgBase(g_plugin, IDD_OPT1),
+ btnPreview(this, IDC_BTN_PREVIEW),
+ chkTimeout(this, IDC_RAD_TIMEOUT),
+ chkNoTimeout(this, IDC_RAD_NOTIMEOUT)
+ {
+ btnPreview.OnClick = Callback(this, &CMainOptDlg::onClick_Preview);
+
+ chkTimeout.OnChange = chkNoTimeout.OnChange = Callback(this, &CMainOptDlg::onChange_Timeout);
}
-}
-static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_SETCURSEL, (int)options.location, 0);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (options.right_icon ? 1 : 0), 0);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("No time"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on right"));
+ bool OnInitDialog() override
+ {
+ SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_SETCURSEL, (int)options.location, 0);
+
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ICON, CB_SETCURSEL, (options.right_icon ? 1 : 0), 0);
+
+ SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("No time"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on left"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on right"));
if (ServiceExists(MS_AV_DRAWAVATAR))
- SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time above avatar"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_SETCURSEL, (int)options.time_layout, 0);
+ SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time above avatar"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_SETCURSEL, (int)options.time_layout, 0);
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar"));
if (ServiceExists(MS_AV_DRAWAVATAR)) {
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
}
else {
- HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV);
+ HWND hw = GetDlgItem(m_hwnd, IDC_CMB_AV);
EnableWindow(hw, FALSE);
- hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE);
+ hw = GetDlgItem(m_hwnd, IDC_SPIN_AVSIZE);
EnableWindow(hw, FALSE);
- hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE);
+ hw = GetDlgItem(m_hwnd, IDC_ED_AVSIZE);
EnableWindow(hw, FALSE);
}
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0);
+ SendDlgItemMessage(m_hwnd, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0);
- CheckDlgButton(hwndDlg, IDC_CHK_GLOBALHOVER, options.global_hover ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CHK_GLOBALHOVER, options.global_hover ? BST_CHECKED : BST_UNCHECKED);
{
// initialise and fill listbox
- HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS);
+ HWND hwndList = GetDlgItem(m_hwnd, IDC_LST_STATUS);
ListView_DeleteAllItems(hwndList);
SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
@@ -192,286 +174,311 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
ListView_SetCheckState(hwndList, i, options.disable_full_screen);
}
- SendDlgItemMessage(hwndDlg, IDC_SPIN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 1));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 1));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 1));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 1));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
if (options.default_timeout == -1) {
- CheckDlgButton(hwndDlg, IDC_RAD_NOTIMEOUT, BST_CHECKED);
- HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
+ CheckDlgButton(m_hwnd, IDC_RAD_NOTIMEOUT, BST_CHECKED);
+ HWND hw = GetDlgItem(m_hwnd, IDC_ED_TIMEOUT);
EnableWindow(hw, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 7, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_TIMEOUT, 7, FALSE);
}
else {
- CheckDlgButton(hwndDlg, IDC_RAD_TIMEOUT, BST_CHECKED);
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
+ CheckDlgButton(m_hwnd, IDC_RAD_TIMEOUT, BST_CHECKED);
+ SetDlgItemInt(m_hwnd, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
}
if (options.right_icon)
- CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, BST_CHECKED);
+ CheckDlgButton(m_hwnd, IDC_RAD_RIGHTICON, BST_CHECKED);
else
- CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, BST_CHECKED);
+ CheckDlgButton(m_hwnd, IDC_RAD_LEFTICON, BST_CHECKED);
if (ServiceExists(MS_AV_DRAWAVATAR)) {
switch (options.av_layout) {
- case PAV_NONE: CheckDlgButton(hwndDlg, IDC_RAD_NOAV, BST_CHECKED); break;
- case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, BST_CHECKED); break;
- case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, BST_CHECKED); break;
+ case PAV_NONE: CheckDlgButton(m_hwnd, IDC_RAD_NOAV, BST_CHECKED); break;
+ case PAV_RIGHT: CheckDlgButton(m_hwnd, IDC_RAD_RIGHTAV, BST_CHECKED); break;
+ case PAV_LEFT: CheckDlgButton(m_hwnd, IDC_RAD_LEFTAV, BST_CHECKED); break;
}
}
else {
- CheckDlgButton(hwndDlg, IDC_RAD_NOAV, BST_CHECKED);
- HWND hw = GetDlgItem(hwndDlg, IDC_RAD_RIGHTAV);
+ CheckDlgButton(m_hwnd, IDC_RAD_NOAV, BST_CHECKED);
+ HWND hw = GetDlgItem(m_hwnd, IDC_RAD_RIGHTAV);
EnableWindow(hw, FALSE);
- hw = GetDlgItem(hwndDlg, IDC_RAD_LEFTAV);
+ hw = GetDlgItem(m_hwnd, IDC_RAD_LEFTAV);
EnableWindow(hw, FALSE);
}
- SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, options.av_size, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_INDENT, options.text_indent, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sb_width, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_WIDTH, options.win_width, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_AVSIZE, options.av_size, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_INDENT, options.text_indent, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_SBWIDTH, options.sb_width, FALSE);
+ SetDlgItemInt(m_hwnd, IDC_ED_PADDING, options.padding, FALSE);
switch (options.location) {
- case PL_BOTTOMRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMRIGHT, BST_CHECKED); break;
- case PL_BOTTOMLEFT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMLEFT, BST_CHECKED); break;
- case PL_TOPRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_TOPRIGHT, BST_CHECKED); break;
- case PL_TOPLEFT: CheckDlgButton(hwndDlg, IDC_RAD_TOPLEFT, BST_CHECKED); break;
+ case PL_BOTTOMRIGHT: CheckDlgButton(m_hwnd, IDC_RAD_BOTTOMRIGHT, BST_CHECKED); break;
+ case PL_BOTTOMLEFT: CheckDlgButton(m_hwnd, IDC_RAD_BOTTOMLEFT, BST_CHECKED); break;
+ case PL_TOPRIGHT: CheckDlgButton(m_hwnd, IDC_RAD_TOPRIGHT, BST_CHECKED); break;
+ case PL_TOPLEFT: CheckDlgButton(m_hwnd, IDC_RAD_TOPLEFT, BST_CHECKED); break;
}
- SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE);
- CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round ? BST_CHECKED : BST_UNCHECKED);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("No animate"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Horizontal animate"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Vertical animate"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_SETCURSEL, options.animate, 0);
-
- CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg ? BST_CHECKED : BST_UNCHECKED);
- return FALSE;
-
- case WM_COMMAND:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if (HIWORD(wParam) == BN_CLICKED) {
- if (LOWORD(wParam) == IDC_BTN_PREVIEW)
- ShowExamplePopups();
- else {
- HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
- switch (LOWORD(wParam)) {
- case IDC_RAD_NOTIMEOUT:
- EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT));
- break;
- case IDC_RAD_TIMEOUT:
- EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT));
- break;
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ SetDlgItemInt(m_hwnd, IDC_ED_TRANS, options.opacity, FALSE);
+ CheckDlgButton(m_hwnd, IDC_CHK_BORDER, options.border ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CHK_ROUNDCORNERS, options.round ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CHK_ROUNDCORNERSAV, options.av_round ? BST_CHECKED : BST_UNCHECKED);
+
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("No animate"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Horizontal animate"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ANIMATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Vertical animate"));
+ SendDlgItemMessage(m_hwnd, IDC_CMB_ANIMATE, CB_SETCURSEL, options.animate, 0);
+
+ CheckDlgButton(m_hwnd, IDC_CHK_TRANSBG, options.trans_bg ? BST_CHECKED : BST_UNCHECKED);
+ return true;
+ }
+
+ bool OnApply()
+ {
+ BOOL trans;
+ int new_val;
+ if (IsDlgButtonChecked(m_hwnd, IDC_RAD_NOTIMEOUT))
+ options.default_timeout = -1;
+ else {
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_TIMEOUT, &trans, FALSE);
+ if (trans) options.default_timeout = new_val;
}
- break;
-
- case WM_NOTIFY:
- if (IsWindowVisible(hwndDlg) && ((LPNMHDR)lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) {
- switch (((LPNMHDR)lParam)->code) {
- case LVN_ITEMCHANGED:
- NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
- if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
+ if (options.default_timeout == 0) {
+ SetDlgItemInt(m_hwnd, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
+ MessageBox(m_hwnd, TranslateT("You cannot set a default timeout of 0.\nValue has been reset."), TranslateT("Error"), MB_OK | MB_ICONWARNING);
+ options.default_timeout = 7; // prevent instant timeout
}
- else if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
- BOOL trans;
- int new_val;
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NOTIMEOUT))
- options.default_timeout = -1;
- else {
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE);
- if (trans) options.default_timeout = new_val;
- }
- if (options.default_timeout == 0) {
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
- MessageBox(hwndDlg, TranslateT("You cannot set a default timeout of 0.\nValue has been reset."), TranslateT("Error"), MB_OK | MB_ICONWARNING);
- options.default_timeout = 7; // prevent instant timeout
- }
-
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
- if (trans) options.win_width = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE);
- if (trans) options.win_max_height = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE);
- if (trans) options.av_size = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE);
- if (trans) options.text_indent = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE);
- if (trans) options.sb_width = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE);
- if (trans) options.padding = new_val;
-
- options.location = (PopupLocation)SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_GETCURSEL, 0, 0);
- options.right_icon = (SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0) == 1);
- options.av_layout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0);
- options.time_layout = (PopupTimeLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_GETCURSEL, 0, 0);
-
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE);
- if (trans) options.opacity = new_val;
- options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false;
- options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false;
- options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
- options.animate = SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_GETCURSEL, 0, 0);
- options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false;
- options.global_hover = IsDlgButtonChecked(hwndDlg, IDC_CHK_GLOBALHOVER) ? true : false;
- int i = 0;
- for (; i < _countof(options.disable_status); i++)
- options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1);
- options.disable_full_screen = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1);
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_WIDTH, &trans, FALSE);
+ if (trans) options.win_width = new_val;
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_MAXHEIGHT, &trans, FALSE);
+ if (trans) options.win_max_height = new_val;
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_AVSIZE, &trans, FALSE);
+ if (trans) options.av_size = new_val;
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_INDENT, &trans, FALSE);
+ if (trans) options.text_indent = new_val;
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_SBWIDTH, &trans, FALSE);
+ if (trans) options.sb_width = new_val;
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_PADDING, &trans, FALSE);
+ if (trans) options.padding = new_val;
+
+ options.location = (PopupLocation)SendDlgItemMessage(m_hwnd, IDC_CMB_PLACEMENT, CB_GETCURSEL, 0, 0);
+ options.right_icon = (SendDlgItemMessage(m_hwnd, IDC_CMB_ICON, CB_GETCURSEL, 0, 0) == 1);
+ options.av_layout = (PopupAvLayout)SendDlgItemMessage(m_hwnd, IDC_CMB_AV, CB_GETCURSEL, 0, 0);
+ options.time_layout = (PopupTimeLayout)SendDlgItemMessage(m_hwnd, IDC_CMB_TIME, CB_GETCURSEL, 0, 0);
+
+ new_val = GetDlgItemInt(m_hwnd, IDC_ED_TRANS, &trans, FALSE);
+ if (trans) options.opacity = new_val;
+ options.border = IsDlgButtonChecked(m_hwnd, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHK_BORDER)) ? true : false;
+ options.round = IsDlgButtonChecked(m_hwnd, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHK_ROUNDCORNERS)) ? true : false;
+ options.av_round = IsDlgButtonChecked(m_hwnd, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(m_hwnd, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
+ options.animate = SendDlgItemMessage(m_hwnd, IDC_CMB_ANIMATE, CB_GETCURSEL, 0, 0);
+ options.trans_bg = IsDlgButtonChecked(m_hwnd, IDC_CHK_TRANSBG) ? true : false;
+ options.global_hover = IsDlgButtonChecked(m_hwnd, IDC_CHK_GLOBALHOVER) ? true : false;
+
+ int i = 0;
+ for (; i < _countof(options.disable_status); i++)
+ options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(m_hwnd, IDC_LST_STATUS), i) == 1);
+ options.disable_full_screen = (ListView_GetCheckState(GetDlgItem(m_hwnd, IDC_LST_STATUS), i) == 1);
+
+ SaveOptions();
+ return true;
+ }
- SaveOptions();
- return TRUE;
+ void onClick_Preview(CCtrlButton*)
+ {
+ PopupData pd = { sizeof(PopupData) };
+ pd.hIcon = hPopupIcon;
+ pd.flags = PDF_UNICODE;
+
+ pd.pwszTitle = TranslateT("Example");
+ pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
+ ShowPopup(pd);
+
+ pd.pwszTitle = TranslateT("Example With a Long Title");
+ pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
+ ShowPopup(pd);
+
+ pd.pwszTitle = TranslateT("Example");
+ pd.pwszText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
+ ShowPopup(pd);
+
+ for (auto &hContact : Contacts()) {
+ if (options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) {
+ AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ if (ace && (ace->dwFlags & AVS_BITMAP_VALID)) {
+ pd.hContact = hContact;
+ pd.pwszText = TranslateT("An avatar.");
+ ShowPopup(pd);
+ break;
+ }
+ }
}
- break;
}
- return 0;
-}
+ void onChange_Timeout(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ED_TIMEOUT), chkTimeout.GetState());
+ }
+};
-LIST<POPUPCLASS> arNewClasses(3);
+/////////////////////////////////////////////////////////////////////////////////////////
+// Classes' options dialog
-static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+class CClassesOptDlg : public CDlgBase
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
+ LIST<POPUPCLASS> arNewClasses;
+
+ CCtrlEdit edtTimeout;
+ CCtrlCheck chkTimeout;
+ CCtrlColor m_backColor, m_textColor;
+ CCtrlButton btnPreview;
+ CCtrlListBox m_list;
+
+ POPUPCLASS *getCurData()
+ {
+ int index = m_list.GetCurSel();
+ return (index != -1) ? (POPUPCLASS *)m_list.GetItemData(index) : nullptr;
+ }
+public:
+ CClassesOptDlg() :
+ CDlgBase(g_plugin, IDD_CLASSES),
+ arNewClasses(3),
+ m_list(this, IDC_LST_CLASSES),
+ m_backColor(this, IDC_COL_BG),
+ m_textColor(this, IDC_COL_TEXT),
+ btnPreview(this, IDC_BTN_PREVIEW),
+ chkTimeout(this, IDC_CHK_TIMEOUT),
+ edtTimeout(this, IDC_ED_TIMEOUT)
+ {
arNewClasses = arClasses;
- {
- int index;
- for (int i = 0; i < arNewClasses.getCount(); i++) {
- POPUPCLASS *pc = arNewClasses[i];
- if (pc->flags & PCF_UNICODE)
- index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription.w);
- else
- index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription.a);
-
- SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i);
- }
+
+ m_list.OnSelChange = Callback(this, &CClassesOptDlg::onSelChange_List);
+
+ chkTimeout.OnChange = Callback(this, &CClassesOptDlg::onCheck_Timeout);
+ edtTimeout.OnChange = Callback(this, &CClassesOptDlg::onChange_Timeout);
+ m_backColor.OnChange = Callback(this, &CClassesOptDlg::onChange_BackColor);
+ m_textColor.OnChange = Callback(this, &CClassesOptDlg::onChange_TextColor);
+ }
+
+ ~CClassesOptDlg()
+ {
+ arNewClasses.destroy();
+ }
+
+ bool OnInitDialog() override
+ {
+ for (auto &it: arNewClasses) {
+ if (it->flags & PCF_UNICODE)
+ m_list.AddString(it->pszDescription.w, (LPARAM)it);
+ else
+ m_list.AddString(_A2T(it->pszDescription.a), (LPARAM)it);
}
- return FALSE;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_LST_CLASSES && HIWORD(wParam) == LBN_SELCHANGE) {
- int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COL_BG), index != -1);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIMEOUT), index != -1);
- if (index != -1) {
- int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
- SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)arNewClasses[i]->colorText);
- SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)arNewClasses[i]->colorBack);
- CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, arNewClasses[i]->iSeconds != -1 ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
- return TRUE;
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ arClasses = arNewClasses;
+
+ char setting[256];
+ for (auto &pc : arClasses) {
+ mir_snprintf(setting, "%s/Timeout", pc->pszName);
+ g_plugin.setWord(setting, pc->iSeconds);
+ mir_snprintf(setting, "%s/TextCol", pc->pszName);
+ g_plugin.setDword(setting, (uint32_t)pc->colorText);
+ mir_snprintf(setting, "%s/BgCol", pc->pszName);
+ g_plugin.setDword(setting, (uint32_t)pc->colorBack);
}
- if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
- int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
- if (index != -1) {
- int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
- BOOL tr;
- int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE);
- arNewClasses[i]->iSeconds = t;
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ return true;
+ }
+
+ void onSelChange_List(CCtrlListBox *)
+ {
+ auto *p = getCurData();
+ btnPreview.Enable(p != nullptr);
+ chkTimeout.Enable(p != nullptr);
+ m_textColor.Enable(p != nullptr);
+ m_backColor.Enable(p != nullptr);
+
+ if (p) {
+ m_textColor.SetColor(p->colorText);
+ m_backColor.SetColor(p->colorBack);
+ chkTimeout.SetState(p->iSeconds != -1);
+ edtTimeout.SetInt(p->iSeconds);
}
- else {
- int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
- if (index != -1) {
- int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
- switch (LOWORD(wParam)) {
- case IDC_CHK_TIMEOUT:
- {
- BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked);
- if (isChecked) arNewClasses[i]->iSeconds = 0;
- else arNewClasses[i]->iSeconds = -1;
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_COL_TEXT:
- arNewClasses[i]->colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
+ edtTimeout.Enable(p != nullptr && chkTimeout.GetState());
+ }
- case IDC_COL_BG:
- arNewClasses[i]->colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
+ void onChange_Timeout(CCtrlEdit *)
+ {
+ auto *p = getCurData();
+ if (p) {
+ p->iSeconds = edtTimeout.GetInt();
+ NotifyChange();
+ }
+ }
- case IDC_BTN_PREVIEW:
- if (arNewClasses[i]->flags & PCF_UNICODE) {
- POPUPCLASS pc = *arNewClasses[i];
- pc.PluginWindowProc = nullptr;
- POPUPDATACLASS d = { sizeof(d) };
- d.pszClassName = pc.pszName;
- d.szTitle.w = L"Preview";
- d.szText.w = L"The quick brown fox jumps over the lazy dog.";
- CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
- }
- else {
- POPUPCLASS pc = *arNewClasses[i];
- pc.PluginWindowProc = nullptr;
- POPUPDATACLASS d = { sizeof(d) };
- d.pszClassName = pc.pszName;
- d.szTitle.a = "Preview";
- d.szText.a = "The quick brown fox jumps over the lazy dog.";
- CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
- }
- break;
- }
- }
+ void onCheck_Timeout(CCtrlCheck *)
+ {
+ auto *p = getCurData();
+ if (p) {
+ bool bIsChecked = chkTimeout.GetState();
+ p->iSeconds = (bIsChecked) ? 0 : -1;
+
+ edtTimeout.Enable(bIsChecked);
+ edtTimeout.SetInt(p->iSeconds);
}
- break;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- arClasses = arNewClasses;
- char setting[256];
- for (auto &pc : arClasses) {
- mir_snprintf(setting, "%s/Timeout", pc->pszName);
- g_plugin.setWord(setting, pc->iSeconds);
- mir_snprintf(setting, "%s/TextCol", pc->pszName);
- g_plugin.setDword(setting, (uint32_t)pc->colorText);
- mir_snprintf(setting, "%s/BgCol", pc->pszName);
- g_plugin.setDword(setting, (uint32_t)pc->colorBack);
+ }
+
+ void onChange_TextColor(CCtrlBase *)
+ {
+ auto *p = getCurData();
+ if (p)
+ p->colorText = m_textColor.GetColor();
+ }
+
+ void onChange_BackColor(CCtrlBase *)
+ {
+ auto *p = getCurData();
+ if (p)
+ p->colorBack = m_backColor.GetColor();
+ }
+
+ void onClick_Preview(CCtrlButton*)
+ {
+ auto *p = getCurData();
+ if (p) {
+ POPUPCLASS pc = *p;
+ pc.PluginWindowProc = nullptr;
+
+ POPUPDATACLASS d = { sizeof(d) };
+ d.pszClassName = pc.pszName;
+ if (p->flags & PCF_UNICODE) {
+ d.szTitle.w = TranslateT("Preview");
+ d.szText.w = TranslateT("The quick brown fox jumps over the lazy dog.");
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
+ }
+ else {
+ d.pszClassName = pc.pszName;
+ d.szTitle.a = Translate("Preview");
+ d.szText.a = Translate("The quick brown fox jumps over the lazy dog.");
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
}
- return TRUE;
}
- break;
-
- case WM_DESTROY:
- arNewClasses.destroy();
- break;
}
- return 0;
-}
+};
int OptInit(WPARAM wParam, LPARAM)
{
@@ -480,14 +487,12 @@ int OptInit(WPARAM wParam, LPARAM)
odp.position = -790000000;
odp.szTitle.a = LPGEN("Popups");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1);
odp.szTab.a = LPGEN("Settings");
- odp.pfnDlgProc = DlgProcOpts1;
+ odp.pDialog = new CMainOptDlg();
g_plugin.addOptions(wParam, &odp);
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CLASSES);
odp.szTab.a = LPGEN("Classes");
- odp.pfnDlgProc = DlgProcOptsClasses;
+ odp.pDialog = new CClassesOptDlg();
g_plugin.addOptions(wParam, &odp);
return 0;
}