summaryrefslogtreecommitdiff
path: root/plugins/MagneticWindows/src/Options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MagneticWindows/src/Options.cpp')
-rw-r--r--plugins/MagneticWindows/src/Options.cpp151
1 files changed, 65 insertions, 86 deletions
diff --git a/plugins/MagneticWindows/src/Options.cpp b/plugins/MagneticWindows/src/Options.cpp
index 8d986a26f5..6729e33861 100644
--- a/plugins/MagneticWindows/src/Options.cpp
+++ b/plugins/MagneticWindows/src/Options.cpp
@@ -1,117 +1,96 @@
#include "MagneticWindowsCore.h"
-HANDLE hInitOptionsHook;
TOptions Options = {
- true,
- cDefaultSnapWidth,
- false
+ true,
+ cDefaultSnapWidth,
+ false
};
+INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ TCHAR str[64];
-INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
- case WM_INITDIALOG: {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_CHK_SNAP, Options.DoSnap?BST_CHECKED:BST_UNCHECKED);
- SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETRANGE, FALSE, MAKELONG(1,32));
- SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETPOS, TRUE, Options.SnapWidth);
-
- TCHAR str[64];
- mir_sntprintf(str, SIZEOF(str),TranslateT("%d pix"), Options.SnapWidth);
- SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), Options.DoSnap);
- EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), Options.DoSnap);
-
- CheckDlgButton(hwndDlg, IDC_CHK_SCRIVERWORKAROUND, Options.ScriverWorkAround?BST_CHECKED:BST_UNCHECKED);
-
- break;
- }
- case WM_HSCROLL: {
- TCHAR str[64];
- mir_sntprintf(str, SIZEOF(str), TranslateT("%d pix"), SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0));
- SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
+ CheckDlgButton(hwndDlg, IDC_CHK_SNAP, Options.DoSnap?BST_CHECKED:BST_UNCHECKED);
+ SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETRANGE, FALSE, MAKELONG(1,32));
+ SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETPOS, TRUE, Options.SnapWidth);
- case WM_COMMAND: {
- WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam);
-
- switch(idCtrl) {
- case IDC_CHK_SNAP: {
- if (wNotifyCode == BN_CLICKED) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
- EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- }
- case IDC_CHK_SCRIVERWORKAROUND: {
- if (wNotifyCode == BN_CLICKED) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- }
- }
- break;
- }
+ mir_sntprintf(str, SIZEOF(str),TranslateT("%d pix"), Options.SnapWidth);
+ SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
- case WM_NOTIFY: { //Here we have pressed either the OK or the APPLY button.
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_RESET:
- LoadOptions();
- break;
-
- case PSN_APPLY: {
- Options.DoSnap = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP) == TRUE);
- Options.SnapWidth = SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0);
- Options.ScriverWorkAround = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SCRIVERWORKAROUND) == TRUE);
-
- db_set_b(NULL, MODULE_NAME, "DoSnap", Options.DoSnap);
- db_set_b(NULL, MODULE_NAME, "SnapWidth", Options.SnapWidth);
- db_set_b(NULL, MODULE_NAME, "ScriverWorkAround", Options.ScriverWorkAround);
-
- break;
- }
- }
- break;
- }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), Options.DoSnap);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), Options.DoSnap);
+
+ CheckDlgButton(hwndDlg, IDC_CHK_SCRIVERWORKAROUND, Options.ScriverWorkAround?BST_CHECKED:BST_UNCHECKED);
+ break;
+
+ case WM_HSCROLL:
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%d pix"), SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0));
+ SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_COMMAND:
+ switch( LOWORD(wParam)) {
+ case IDC_CHK_SNAP:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
break;
-
- }
- default:
+ case IDC_CHK_SCRIVERWORKAROUND:
+ if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+ }
+ break;
+
+ case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_RESET:
+ LoadOptions();
+ break;
+
+ case PSN_APPLY:
+ Options.DoSnap = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP) == TRUE);
+ Options.SnapWidth = SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0);
+ Options.ScriverWorkAround = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SCRIVERWORKAROUND) == TRUE);
+
+ db_set_b(NULL, MODULE_NAME, "DoSnap", Options.DoSnap);
+ db_set_b(NULL, MODULE_NAME, "SnapWidth", Options.SnapWidth);
+ db_set_b(NULL, MODULE_NAME, "ScriverWorkAround", Options.ScriverWorkAround);
+ break;
+ }
+ }
+ break;
}
return 0;
-
}
-int InitOptions(WPARAM wParam, LPARAM) {
- OPTIONSDIALOGPAGE Opt = { 0 };
-
- Opt.cbSize = sizeof(Opt);
+int InitOptions(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE Opt = { sizeof(Opt) };
Opt.pfnDlgProc = OptionsDlgProc;
Opt.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAGNETICWINDOWS);
Opt.hInstance = hInst;
Opt.pszGroup = LPGEN("Customize");
Opt.pszTitle = LPGEN("Magnetic Windows");
Opt.flags = ODPF_BOLDGROUPS;
-
Options_AddPage(wParam, &Opt);
-
return 0;
}
-void LoadOptions() {
+void LoadOptions()
+{
Options.DoSnap = db_get_b(NULL, MODULE_NAME, "DoSnap", 1) != 0;
Options.SnapWidth = db_get_b(NULL, MODULE_NAME, "SnapWidth", cDefaultSnapWidth);
Options.ScriverWorkAround = db_get_b(NULL, MODULE_NAME, "ScriverWorkAround", 0) != 0;
-} \ No newline at end of file
+}