From a338e594273bda039eec784ecb461395f23bd56e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2012 15:50:17 +0000 Subject: - missing plugins added - fixes for the status plugins' projects - other VS2010 projects cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@13 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/utils/mir_options_notify.cpp | 199 +++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 plugins/utils/mir_options_notify.cpp (limited to 'plugins/utils/mir_options_notify.cpp') diff --git a/plugins/utils/mir_options_notify.cpp b/plugins/utils/mir_options_notify.cpp new file mode 100644 index 0000000000..ddc0a548c1 --- /dev/null +++ b/plugins/utils/mir_options_notify.cpp @@ -0,0 +1,199 @@ +/* +Copyright (C) 2005 Ricardo Pescuma Domenecci + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + + +#include "mir_options_notify.h" + +#include +#include +#include + +extern "C" +{ +#include +#include +#include +#include +#include +#include "templates.h" +} + + +#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) ) + + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Dialog to save options +///////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +BOOL CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_USER+100: + { + HANDLE hNotify = (HANDLE)lParam; + SetWindowLong(hwndDlg, GWL_USERDATA, lParam); + + TranslateDialogDefault(hwndDlg); + + for (int i = 0 ; i < controlsSize ; i++) + { + OptPageControl *ctrl = &controls[i]; + + switch(ctrl->type) + { + case CONTROL_CHECKBOX: + { + CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetByte(hNotify, ctrl->setting, (BYTE)ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED); + break; + } + case CONTROL_SPIN: + { + SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID),0); + SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min)); + SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS,0, MAKELONG(MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue), 0)); + + break; + } + case CONTROL_COLOR: + { + SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF) MNotifyGetDWord(hNotify, ctrl->setting, (DWORD)ctrl->dwDefValue)); + + break; + } + case CONTROL_RADIO: + { + CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED); + break; + } + case CONTROL_TEXT: + { + SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTString(hNotify, ctrl->setting, ctrl->szDefVale)); + + if (ctrl->max > 0) + SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0); + else + SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0); + + break; + } + case CONTROL_TEMPLATE: + { + SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTTemplate(hNotify, ctrl->setting, ctrl->szDefVale)); + + if (ctrl->max > 0) + SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0); + else + SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0); + + break; + } + } + } + + return TRUE; + break; + } + case WM_COMMAND: + { + // Don't make apply enabled during buddy set crap + if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) + { + for (int i = 0 ; i < controlsSize ; i++) + { + if (controls[i].type == CONTROL_SPIN && LOWORD(wParam) == controls[i].nID) + { + return 0; + } + } + } + + SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); + break; + } + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->idFrom) + { + case 0: + { + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + HANDLE hNotify = (HANDLE)GetWindowLong(hwndDlg, GWL_USERDATA); + TCHAR tmp[1024]; + + for (int i = 0 ; i < controlsSize ; i++) + { + OptPageControl *ctrl = &controls[i]; + + switch(ctrl->type) + { + case CONTROL_CHECKBOX: + { + MNotifySetByte(hNotify, ctrl->setting, (BYTE)IsDlgButtonChecked(hwndDlg, ctrl->nID)); + break; + } + case CONTROL_SPIN: + { + MNotifySetWord(hNotify, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0)); + break; + } + case CONTROL_COLOR: + { + MNotifySetDWord(hNotify, ctrl->setting, (DWORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0)); + break; + } + case CONTROL_RADIO: + { + if (IsDlgButtonChecked(hwndDlg, ctrl->nID)) + MNotifySetWord(hNotify, ctrl->setting, (BYTE)ctrl->value); + break; + } + case CONTROL_TEXT: + { + GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp)); + MNotifySetTString(hNotify, ctrl->setting, tmp); + break; + } + case CONTROL_TEMPLATE: + { + GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp)); + MNotifySetTTemplate(hNotify, ctrl->setting, tmp); + break; + } + } + } + + return TRUE; + } + } + break; + } + } + break; + } + } + + return 0; +} -- cgit v1.2.3