summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-22 20:27:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-22 20:27:47 +0000
commit65aa3fa63030769ceeca17d4a82f915c185dc734 (patch)
tree2147a48503ef602dfec1507cee7b99fc05e299ef /src/modules
parentba020540c064ebd48bf6b77e5bd5e11255766f23 (diff)
metacontact options -> CDlgBase
git-svn-id: http://svn.miranda-ng.org/main/trunk@13766 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/metacontacts/meta_main.cpp2
-rw-r--r--src/modules/metacontacts/meta_options.cpp216
-rw-r--r--src/modules/metacontacts/metacontacts.h4
3 files changed, 81 insertions, 141 deletions
diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp
index 74f8c48551..aeb488aad4 100644
--- a/src/modules/metacontacts/meta_main.cpp
+++ b/src/modules/metacontacts/meta_main.cpp
@@ -67,7 +67,7 @@ int LoadMetacontacts(void)
db_set_dw(hContact, META_PROTO, "IdleTS", 0);
}
- Meta_ReadOptions(&options);
+ Meta_ReadOptions();
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
pd.szName = META_FILTER;
diff --git a/src/modules/metacontacts/meta_options.cpp b/src/modules/metacontacts/meta_options.cpp
index e130463da1..0ff0b9b48c 100644
--- a/src/modules/metacontacts/meta_options.cpp
+++ b/src/modules/metacontacts/meta_options.cpp
@@ -25,149 +25,94 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "metacontacts.h"
MetaOptions options;
-MetaOptions options_changes;
-INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+int Meta_WriteOptions()
{
- switch ( msg ) {
- case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
- options_changes = options;
-
- CheckDlgButton(hwndDlg, IDC_CHK_SUPPRESSSTATUS, options_changes.bSuppressStatus ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_RAD_UID, options_changes.menu_contact_label == DNT_UID ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_DID, options_changes.menu_contact_label == DNT_DID ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_RAD_MSG, options_changes.menu_function == FT_MSG ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_MENU, options_changes.menu_function == FT_MENU ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_INFO, options_changes.menu_function == FT_INFO ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_RAD_NICK, options_changes.clist_contact_name == CNNT_NICK ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_NAME, options_changes.clist_contact_name == CNNT_DISPLAYNAME ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_LOCKHANDLE, options_changes.bLockHandle ? BST_CHECKED : BST_UNCHECKED);
- {
- TCHAR buff[40];
- _itot(options_changes.days_history, buff, SIZEOF(buff));
- SetDlgItemText(hwndDlg, IDC_ED_DAYS, buff);
- }
- return TRUE;
-
- case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC_CHK_SUPPRESSSTATUS:
- options_changes.bSuppressStatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_SUPPRESSSTATUS) != 0;
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_UID:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_UID)) {
- options_changes.menu_contact_label = DNT_UID;
- CheckDlgButton(hwndDlg, IDC_RAD_DID, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_DID:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_DID)) {
- options_changes.menu_contact_label = DNT_DID;
- CheckDlgButton(hwndDlg, IDC_RAD_UID, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_MSG:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_MSG)) {
- options_changes.menu_function = FT_MSG;
- CheckDlgButton(hwndDlg, IDC_RAD_MENU, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_INFO, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_MENU:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_MENU)) {
- options_changes.menu_function = FT_MENU;
- CheckDlgButton(hwndDlg, IDC_RAD_MSG, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_INFO, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_INFO:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_INFO)) {
- options_changes.menu_function = FT_INFO;
- CheckDlgButton(hwndDlg, IDC_RAD_MSG, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_MENU, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_NICK:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NICK)) {
- options_changes.clist_contact_name = CNNT_NICK;
- CheckDlgButton(hwndDlg, IDC_RAD_NAME, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_RAD_NAME:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NAME)) {
- options_changes.clist_contact_name = CNNT_DISPLAYNAME;
- CheckDlgButton(hwndDlg, IDC_RAD_NICK, BST_UNCHECKED);
- }
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_CHK_LOCKHANDLE:
- options_changes.bLockHandle = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOCKHANDLE) != 0;
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- }
- else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
- SendMessage( GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
+ db_set_b(NULL, META_PROTO, "LockHandle", options.bLockHandle);
+ db_set_b(NULL, META_PROTO, "SuppressStatus", options.bSuppressStatus);
+ db_set_w(NULL, META_PROTO, "MenuContactLabel", (WORD)options.menu_contact_label);
+ db_set_w(NULL, META_PROTO, "MenuContactFunction", (WORD)options.menu_function);
+ db_set_w(NULL, META_PROTO, "CListContactName", (WORD)options.clist_contact_name);
+ db_set_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", (DWORD)(options.set_status_from_offline_delay));
+ return 0;
+}
+
+int Meta_ReadOptions()
+{
+ db_mc_enable(db_get_b(NULL, META_PROTO, "Enabled", true) != 0);
+ options.bSuppressStatus = db_get_b(NULL, META_PROTO, "SuppressStatus", true) != 0;
+ options.menu_contact_label = (int)db_get_w(NULL, META_PROTO, "MenuContactLabel", DNT_UID);
+ options.menu_function = (int)db_get_w(NULL, META_PROTO, "MenuContactFunction", FT_MENU);
+ options.clist_contact_name = (int)db_get_w(NULL, META_PROTO, "CListContactName", CNNT_DISPLAYNAME);
+ options.set_status_from_offline_delay = (int)db_get_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", DEFAULT_SET_STATUS_SLEEP_TIME);
+ options.bLockHandle = db_get_b(NULL, META_PROTO, "LockHandle", false) != 0;
+ return 0;
+}
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
- TCHAR buff[40];
- GetDlgItemText(hwndDlg, IDC_ED_DAYS, buff, SIZEOF(buff));
- if (buff[0] != 0)
- options_changes.days_history = _ttoi(buff);
+class CMetaOptionsDlg : public CDlgBase
+{
+ CCtrlCheck m_btnUid, m_btnDid, m_btnCheck;
+ CCtrlCheck m_btnMsg, m_btnMenu, m_btnInfo;
+ CCtrlCheck m_btnNick, m_btnName, m_btnLock;
+
+public:
+ CMetaOptionsDlg() :
+ CDlgBase(hInst, IDD_METAOPTIONS),
+ m_btnUid(this, IDC_RAD_UID),
+ m_btnDid(this, IDC_RAD_DID),
+ m_btnMsg(this, IDC_RAD_MSG),
+ m_btnMenu(this, IDC_RAD_MENU),
+ m_btnInfo(this, IDC_RAD_INFO),
+ m_btnNick(this, IDC_RAD_NICK),
+ m_btnName(this, IDC_RAD_NAME),
+ m_btnLock(this, IDC_CHK_LOCKHANDLE),
+ m_btnCheck(this, IDC_CHK_SUPPRESSSTATUS)
+ {
+ }
+
+ virtual void OnInitDialog()
+ {
+ m_btnLock.SetState(options.bLockHandle);
+ m_btnCheck.SetState(options.bSuppressStatus);
- options = options_changes;
- Meta_WriteOptions(&options);
+ if (options.menu_contact_label == DNT_UID)
+ m_btnUid.SetState(true);
+ else
+ m_btnDid.SetState(true);
- Meta_SuppressStatus(options.bSuppressStatus);
- Meta_SetAllNicks();
- return TRUE;
+ switch (options.menu_function) {
+ case FT_MSG: m_btnMsg.SetState(true); break;
+ case FT_MENU: m_btnMenu.SetState(true); break;
+ case FT_INFO: m_btnInfo.SetState(true); break;
}
- break;
+
+ if (options.clist_contact_name == CNNT_NICK)
+ m_btnNick.SetState(true);
+ else
+ m_btnName.SetState(true);
}
- return FALSE;
-}
+ virtual void OnApply()
+ {
+ options.bLockHandle = m_btnLock.GetState() != 0;
+ options.bSuppressStatus = m_btnCheck.GetState() != 0;
-int Meta_WriteOptions(MetaOptions *opt)
-{
- db_set_b(NULL, META_PROTO, "SuppressStatus", opt->bSuppressStatus);
- db_set_w(NULL, META_PROTO, "MenuContactLabel", (WORD)opt->menu_contact_label);
- db_set_w(NULL, META_PROTO, "MenuContactFunction", (WORD)opt->menu_function);
- db_set_w(NULL, META_PROTO, "CListContactName", (WORD)opt->clist_contact_name);
- db_set_dw(NULL, META_PROTO, "DaysHistory", (DWORD)(opt->days_history));
- db_set_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", (DWORD)(opt->set_status_from_offline_delay));
- db_set_b(NULL, META_PROTO, "LockHandle", opt->bLockHandle);
- return 0;
-}
+ if (m_btnUid.GetState()) options.menu_contact_label = DNT_UID;
+ else if (m_btnDid.GetState()) options.menu_contact_label = DNT_DID;
-int Meta_ReadOptions(MetaOptions *opt)
-{
- db_mc_enable(db_get_b(NULL, META_PROTO, "Enabled", true) != 0);
- opt->bSuppressStatus = db_get_b(NULL, META_PROTO, "SuppressStatus", true) != 0;
- opt->menu_contact_label = (int)db_get_w(NULL, META_PROTO, "MenuContactLabel", DNT_UID);
- opt->menu_function = (int)db_get_w(NULL, META_PROTO, "MenuContactFunction", FT_MENU);
- opt->clist_contact_name = (int)db_get_w(NULL, META_PROTO, "CListContactName", CNNT_DISPLAYNAME);
- opt->days_history = (int)db_get_dw(NULL, META_PROTO, "DaysHistory", 0);
- opt->set_status_from_offline_delay = (int)db_get_dw(NULL, META_PROTO, "SetStatusFromOfflineDelay", DEFAULT_SET_STATUS_SLEEP_TIME);
- opt->bLockHandle = db_get_b(NULL, META_PROTO, "LockHandle", false) != 0;
- return 0;
-}
+ if (m_btnMsg.GetState()) options.menu_function = FT_MSG;
+ else if (m_btnMenu.GetState()) options.menu_function = FT_MENU;
+ else if (m_btnInfo.GetState()) options.menu_function = FT_INFO;
+
+ if (m_btnNick.GetState()) options.clist_contact_name = CNNT_NICK;
+ else if (m_btnName.GetState()) options.clist_contact_name = CNNT_DISPLAYNAME;
+
+ Meta_WriteOptions();
+
+ Meta_SuppressStatus(options.bSuppressStatus);
+ Meta_SetAllNicks();
+ }
+};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -175,13 +120,10 @@ int Meta_OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = hInst;
odp.flags = ODPF_BOLDGROUPS;
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_METAOPTIONS);
odp.pszTitle = LPGEN("Metacontacts");
odp.pszGroup = LPGEN("Contacts");
- odp.pfnDlgProc = DlgProcOpts;
+ odp.pDialog = new CMetaOptionsDlg();
Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h
index 34d4190285..2c4ff0715c 100644
--- a/src/modules/metacontacts/metacontacts.h
+++ b/src/modules/metacontacts/metacontacts.h
@@ -92,15 +92,13 @@ struct MetaOptions
int menu_contact_label;
int menu_function;
int clist_contact_name;
- int days_history;
int set_status_from_offline_delay;
};
extern MetaOptions options;
int Meta_OptInit(WPARAM wParam, LPARAM lParam);
-int Meta_WriteOptions(MetaOptions *opt);
-int Meta_ReadOptions(MetaOptions *opt);
+int Meta_ReadOptions();
// API function headers
void CreateApiServices();