diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-30 10:38:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-30 10:38:21 +0000 |
commit | daba159a1438dbd00fb40d7b2ffd772da67a86dc (patch) | |
tree | 9957952dd1b787b327d2daba9248141c61d135ae /plugins/AvatarHistory/src/options.cpp | |
parent | f426fe1769798bf8d88ca455bd0d803a2a76f104 (diff) |
AvatarHistory works again
git-svn-id: http://svn.miranda-ng.org/main/trunk@4246 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AvatarHistory/src/options.cpp')
-rw-r--r-- | plugins/AvatarHistory/src/options.cpp | 264 |
1 files changed, 110 insertions, 154 deletions
diff --git a/plugins/AvatarHistory/src/options.cpp b/plugins/AvatarHistory/src/options.cpp index 71cdc2da32..a8d605e1f5 100644 --- a/plugins/AvatarHistory/src/options.cpp +++ b/plugins/AvatarHistory/src/options.cpp @@ -21,98 +21,44 @@ Avatar History Plugin #include "AvatarHistory.h"
#include "../utils/mir_options.h"
-
-
-// Prototypes /////////////////////////////////////////////////////////////////////////////////////
-
Options opts;
-
-static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
+// Prototypes /////////////////////////////////////////////////////////////////////////////////////
static OptPageControl optionsControls[] = {
- { NULL, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "%sEnabled", TRUE }
+ { NULL, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "%sEnabled", TRUE }
};
-
static OptPageControl popupsControls[] = {
- { NULL, CONTROL_CHECKBOX, IDC_POPUPS, "AvatarPopups", AVH_DEF_AVPOPUPS },
- { &opts.popup_bkg_color, CONTROL_COLOR, IDC_BGCOLOR, "PopupsBgColor", AVH_DEF_POPUPBG },
- { &opts.popup_text_color, CONTROL_COLOR, IDC_TEXTCOLOR, "PopupsTextColor", AVH_DEF_POPUPFG },
- { &opts.popup_use_win_colors, CONTROL_CHECKBOX, IDC_WINCOLORS, "PopupsWinColors", FALSE },
- { &opts.popup_use_default_colors, CONTROL_CHECKBOX, IDC_DEFAULTCOLORS, "PopupsDefaultColors", AVH_DEF_DEFPOPUPS },
- { &opts.popup_delay_type, CONTROL_RADIO, IDC_DELAYFROMPU, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_DEFAULT },
- { NULL, CONTROL_RADIO, IDC_DELAYCUSTOM, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_CUSTOM },
- { NULL, CONTROL_RADIO, IDC_DELAYPERMANENT, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_PERMANENT },
- { &opts.popup_timeout, CONTROL_SPIN, IDC_DELAY, "PopupsTimeout", 10, IDC_DELAY_SPIN, (WORD) 1, (WORD) 255 },
- { &opts.popup_right_click_action, CONTROL_COMBO, IDC_RIGHT_ACTION, "PopupsRightClick", POPUP_ACTION_CLOSEPOPUP },
- { &opts.popup_left_click_action, CONTROL_COMBO, IDC_LEFT_ACTION, "PopupsLeftClick", POPUP_ACTION_OPENAVATARHISTORY },
- { &opts.popup_show_changed, CONTROL_CHECKBOX, IDC_CHANGED_L, "PopupsShowChanged", TRUE },
- { &opts.popup_changed, CONTROL_TEXT, IDC_CHANGED, "PopupsTextChanged", (ULONG_PTR) DEFAULT_TEMPLATE_CHANGED },
- { &opts.popup_show_removed, CONTROL_CHECKBOX, IDC_REMOVED_L, "PopupsShowRemoved", TRUE },
- { &opts.popup_removed, CONTROL_TEXT, IDC_REMOVED, "PopupsTextRemoved", (ULONG_PTR) DEFAULT_TEMPLATE_REMOVED }
+ { NULL, CONTROL_CHECKBOX, IDC_POPUPS, "AvatarPopups", AVH_DEF_AVPOPUPS },
+ { &opts.popup_bkg_color, CONTROL_COLOR, IDC_BGCOLOR, "PopupsBgColor", AVH_DEF_POPUPBG },
+ { &opts.popup_text_color, CONTROL_COLOR, IDC_TEXTCOLOR, "PopupsTextColor", AVH_DEF_POPUPFG },
+ { &opts.popup_use_win_colors, CONTROL_CHECKBOX, IDC_WINCOLORS, "PopupsWinColors", FALSE },
+ { &opts.popup_use_default_colors, CONTROL_CHECKBOX, IDC_DEFAULTCOLORS, "PopupsDefaultColors", AVH_DEF_DEFPOPUPS },
+ { &opts.popup_delay_type, CONTROL_RADIO, IDC_DELAYFROMPU, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_DEFAULT },
+ { NULL, CONTROL_RADIO, IDC_DELAYCUSTOM, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_CUSTOM },
+ { NULL, CONTROL_RADIO, IDC_DELAYPERMANENT, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_PERMANENT },
+ { &opts.popup_timeout, CONTROL_SPIN, IDC_DELAY, "PopupsTimeout", 10, IDC_DELAY_SPIN, (WORD) 1, (WORD) 255 },
+ { &opts.popup_right_click_action, CONTROL_COMBO, IDC_RIGHT_ACTION, "PopupsRightClick", POPUP_ACTION_CLOSEPOPUP },
+ { &opts.popup_left_click_action, CONTROL_COMBO, IDC_LEFT_ACTION, "PopupsLeftClick", POPUP_ACTION_OPENAVATARHISTORY },
+ { &opts.popup_show_changed, CONTROL_CHECKBOX, IDC_CHANGED_L, "PopupsShowChanged", TRUE },
+ { &opts.popup_changed, CONTROL_TEXT, IDC_CHANGED, "PopupsTextChanged", (ULONG_PTR) DEFAULT_TEMPLATE_CHANGED },
+ { &opts.popup_show_removed, CONTROL_CHECKBOX, IDC_REMOVED_L, "PopupsShowRemoved", TRUE },
+ { &opts.popup_removed, CONTROL_TEXT, IDC_REMOVED, "PopupsTextRemoved", (ULONG_PTR) DEFAULT_TEMPLATE_REMOVED }
};
-
-// Functions //////////////////////////////////////////////////////////////////////////////////////
-
-
-int OptInit(WPARAM wParam,LPARAM lParam)
-{
- OPTIONSDIALOGPAGE odp;
-
- ZeroMemory(&odp,sizeof(odp));
- odp.cbSize=sizeof(odp);
- odp.position=0;
- odp.hInstance=hInst;
- odp.ptszGroup = LPGENT("History"); // group to put your item under
- odp.ptszTitle = LPGENT("Avatar"); // name of the item
- odp.pfnDlgProc = OptionsDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
- Options_AddPage(wParam, &odp);
-
- if(ServiceExists(MS_POPUP_ADDPOPUPT))
- {
- ZeroMemory(&odp,sizeof(odp));
- odp.cbSize=sizeof(odp);
- odp.position=0;
- odp.hInstance=hInst;
- odp.ptszGroup = LPGENT("PopUps");
- odp.ptszTitle = LPGENT("Avatar Change");
- odp.pfnDlgProc = PopupsDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUPS);
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
- Options_AddPage(wParam, &odp);
- }
-
- return 0;
-}
-
-
-void LoadOptions()
-{
- LoadOpts(optionsControls, MAX_REGS(optionsControls), MODULE_NAME);
- LoadOpts(popupsControls, MAX_REGS(popupsControls), MODULE_NAME);
-
- opts.log_per_contact_folders = DBGetContactSettingByte(NULL, MODULE_NAME, "LogPerContactFolders", 0);
- opts.log_keep_same_folder = DBGetContactSettingByte(NULL, MODULE_NAME, "LogKeepSameFolder", 0);
- opts.log_store_as_hash = DBGetContactSettingByte(NULL, MODULE_NAME, "StoreAsHash", 1);
-}
-
+// Options dialog procedure ///////////////////////////////////////////////////////////////////////
static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
return SaveOptsDlgProc(optionsControls, MAX_REGS(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
+// Popup options dialog procedure /////////////////////////////////////////////////////////////////
static void PopupsEnableDisableCtrls(HWND hwndDlg)
{
BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_POPUPS);
-
EnableWindow(GetDlgItem(hwndDlg, IDC_COLOURS_G), enabled);
EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR_L), enabled);
EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR_L), enabled);
@@ -127,97 +73,107 @@ static void PopupsEnableDisableCtrls(HWND hwndDlg) EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ACTION), enabled);
EnableWindow(GetDlgItem(hwndDlg, IDC_PREV), enabled);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), enabled &&
- !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) &&
- !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR), enabled &&
- !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) &&
- !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULTCOLORS), enabled &&
- !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_WINCOLORS), enabled &&
- !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY), enabled &&
- IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), enabled && !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR), enabled && !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULTCOLORS), enabled && !IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_WINCOLORS), enabled && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY), enabled && IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM));
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGED_L), enabled);
EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVED_L), enabled);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGED), enabled &&
- IsDlgButtonChecked(hwndDlg, IDC_CHANGED_L));
- EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVED), enabled &&
- IsDlgButtonChecked(hwndDlg, IDC_REMOVED_L));
-
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGED), enabled && IsDlgButtonChecked(hwndDlg, IDC_CHANGED_L));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVED), enabled && IsDlgButtonChecked(hwndDlg, IDC_REMOVED_L));
}
-
static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Do nothing"));
- SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Close popup"));
- SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Show avatar history"));
- SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Show contact history"));
-
- SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Do nothing"));
- SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Close popup"));
- SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Show avatar history"));
- SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM) TranslateT("Show contact history"));
-
- // Needs to be called here in this case
- BOOL ret = SaveOptsDlgProc(popupsControls, MAX_REGS(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
-
- PopupsEnableDisableCtrls(hwndDlg);
-
- return ret;
- }
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_POPUPS:
- case IDC_WINCOLORS:
- case IDC_DEFAULTCOLORS:
- case IDC_DELAYFROMPU:
- case IDC_DELAYPERMANENT:
- case IDC_DELAYCUSTOM:
- case IDC_CHANGED_L:
- case IDC_REMOVED_L:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- PopupsEnableDisableCtrls(hwndDlg);
-
- break;
- }
- case IDC_PREV:
- {
- Options op = opts;
-
- if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU))
- op.popup_delay_type = POPUP_DELAY_DEFAULT;
- else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM))
- op.popup_delay_type = POPUP_DELAY_CUSTOM;
- else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT))
- op.popup_delay_type = POPUP_DELAY_PERMANENT;
-
- op.popup_timeout = GetDlgItemInt(hwndDlg,IDC_DELAY, NULL, FALSE);
- op.popup_bkg_color = SendDlgItemMessage(hwndDlg,IDC_BGCOLOR,CPM_GETCOLOUR,0,0);
- op.popup_text_color = SendDlgItemMessage(hwndDlg,IDC_TEXTCOLOR,CPM_GETCOLOUR,0,0);
- op.popup_use_win_colors = IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) != 0;
- op.popup_use_default_colors = IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS) != 0;
-
- HANDLE hContact = db_find_first();
- ShowTestPopup(hContact,TranslateT("Test Contact"), TranslateT("Test description"), &op);
-
- break;
- }
- }
+ switch (msg) {
+ case WM_INITDIALOG:
+ SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Do nothing"));
+ SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Close popup"));
+ SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show avatar history"));
+ SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show contact history"));
+
+ SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Do nothing"));
+ SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Close popup"));
+ SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show avatar history"));
+ SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Show contact history"));
+
+ // Needs to be called here in this case
+ SaveOptsDlgProc(popupsControls, MAX_REGS(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+ PopupsEnableDisableCtrls(hwndDlg);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_POPUPS:
+ case IDC_WINCOLORS:
+ case IDC_DEFAULTCOLORS:
+ case IDC_DELAYFROMPU:
+ case IDC_DELAYPERMANENT:
+ case IDC_DELAYCUSTOM:
+ case IDC_CHANGED_L:
+ case IDC_REMOVED_L:
+ if (HIWORD(wParam) == BN_CLICKED)
+ PopupsEnableDisableCtrls(hwndDlg);
+ break;
+
+ case IDC_PREV:
+ Options op = opts;
+ if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU))
+ op.popup_delay_type = POPUP_DELAY_DEFAULT;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM))
+ op.popup_delay_type = POPUP_DELAY_CUSTOM;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT))
+ op.popup_delay_type = POPUP_DELAY_PERMANENT;
+
+ op.popup_timeout = GetDlgItemInt(hwndDlg,IDC_DELAY, NULL, FALSE);
+ op.popup_bkg_color = SendDlgItemMessage(hwndDlg,IDC_BGCOLOR,CPM_GETCOLOUR,0,0);
+ op.popup_text_color = SendDlgItemMessage(hwndDlg,IDC_TEXTCOLOR,CPM_GETCOLOUR,0,0);
+ op.popup_use_win_colors = IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) != 0;
+ op.popup_use_default_colors = IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS) != 0;
+
+ HANDLE hContact = db_find_first();
+ ShowTestPopup(hContact,TranslateT("Test Contact"), TranslateT("Test description"), &op);
break;
}
}
return SaveOptsDlgProc(popupsControls, MAX_REGS(popupsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
+
+// Functions //////////////////////////////////////////////////////////////////////////////////////
+
+int OptInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hInstance = hInst;
+ odp.ptszGroup = LPGENT("History"); // group to put your item under
+ odp.ptszTitle = LPGENT("Avatar"); // name of the item
+ odp.pfnDlgProc = OptionsDlgProc;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
+ Options_AddPage(wParam, &odp);
+
+ if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
+ odp.ptszGroup = LPGENT("PopUps");
+ odp.ptszTitle = LPGENT("Avatar Change");
+ odp.pfnDlgProc = PopupsDlgProc;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUPS);
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
+ Options_AddPage(wParam, &odp);
+ }
+
+ return 0;
+}
+
+void LoadOptions()
+{
+ LoadOpts(optionsControls, MAX_REGS(optionsControls), MODULE_NAME);
+ LoadOpts(popupsControls, MAX_REGS(popupsControls), MODULE_NAME);
+
+ opts.log_per_contact_folders = db_get_b(NULL, MODULE_NAME, "LogPerContactFolders", 0);
+ opts.log_keep_same_folder = db_get_b(NULL, MODULE_NAME, "LogKeepSameFolder", 0);
+ opts.log_store_as_hash = db_get_b(NULL, MODULE_NAME, "StoreAsHash", 1);
+}
|