diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:37:22 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:37:22 +0000 |
commit | 10a3bfa53858f75fa64833ce5d860a14a756c38a (patch) | |
tree | ad7d5b7f857c5120a77d3b1e60b46512ebf47f56 /message_notify/options.cpp | |
parent | 7f6efd8c36003cb710319a358f62f1a0d8900384 (diff) |
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@7 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'message_notify/options.cpp')
-rw-r--r-- | message_notify/options.cpp | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/message_notify/options.cpp b/message_notify/options.cpp new file mode 100644 index 0000000..9460843 --- /dev/null +++ b/message_notify/options.cpp @@ -0,0 +1,250 @@ +#include "common.h"
+#include "options.h"
+
+Options options;
+
+static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+
+ {
+ // initialise and fill listbox
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS);
+ ListView_DeleteAllItems(hwndList);
+
+ SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+
+ LVCOLUMN lvc = {0};
+ // Initialize the LVCOLUMN structure.
+ // The mask specifies that the format, width, text, and
+ // subitem members of the structure are valid.
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+
+ lvc.iSubItem = 0;
+ lvc.pszText = TranslateT("Status");
+ lvc.cx = 120; // width of column in pixels
+ ListView_InsertColumn(hwndList, 0, &lvc);
+
+
+ LVITEM lvI = {0};
+
+ // Some code to create the list-view control.
+ // Initialize LVITEM members that are common to all
+ // items.
+ lvI.mask = LVIF_TEXT;
+
+ char *strptr;
+ wchar_t buff[256];
+ for(int i = 0; i < 9; i++) {
+ strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_ONLINE + i), (LPARAM)0);
+ MultiByteToWideChar((int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, strptr, -1, buff, 256);
+ lvI.pszText = buff;
+ lvI.iItem = i;
+ ListView_InsertItem(hwndList, &lvI);
+ ListView_SetCheckState(hwndList, i, options.disable_status[i]);
+ }
+ }
+
+ {
+ CheckDlgButton(hwndDlg, IDC_CHK_TABS, options.consider_tabs ? TRUE : FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ switch(options.notify_when) {
+ case NOTIFY_CLOSED:
+ CheckDlgButton(hwndDlg, IDC_RAD_CLOSED, TRUE);
+ EnableWindow(hwnd, FALSE);
+ break;
+ case NOTIFY_NFORE:
+ CheckDlgButton(hwndDlg, IDC_RAD_NFORE, TRUE);
+ EnableWindow(hwnd, TRUE);
+ break;
+ case NOTIFY_ALWAYS:
+ CheckDlgButton(hwndDlg, IDC_RAD_ALWAYS, TRUE);
+ EnableWindow(hwnd, FALSE);
+ break;
+ };
+ }
+ CheckDlgButton(hwndDlg, IDC_CHK_CLOSE, options.close_win ? TRUE : FALSE);
+ if(options.timeout == -1) {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 0, FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
+ EnableWindow(hwnd, FALSE);
+ } else {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, TRUE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.timeout, FALSE);
+ }
+
+ CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, options.set_colours ? TRUE : FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_SETCOLOUR, 0, (LPARAM)options.bkCol);
+ SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_SETCOLOUR, 0, (LPARAM)options.textCol);
+ if(!options.set_colours) {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
+ EnableWindow(hwnd, FALSE);
+ hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
+ EnableWindow(hwnd, FALSE);
+ }
+
+ return FALSE;
+ case WM_COMMAND:
+ if(LOWORD(wParam) == IDC_CP_BK || LOWORD(wParam) == IDC_CP_TXT) {
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ }
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ switch( LOWORD( wParam )) {
+ case IDC_ED_TIMEOUT:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ }
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_RAD_CLOSED:
+ case IDC_RAD_ALWAYS:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ EnableWindow(hwnd, FALSE);
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_RAD_NFORE:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ EnableWindow(hwnd, TRUE);
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_SETTIMEOUT:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT));
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_SETCOLOURS:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
+ hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_CLOSE:
+ case IDC_CHK_TABS:
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ }
+ }
+ 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;
+ }
+ } else
+ if (((LPNMHDR)lParam)->code == (DWORD)PSN_APPLY ) {
+ options.consider_tabs = IsDlgButtonChecked(hwndDlg, IDC_CHK_TABS) ? true : false;
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_CLOSED))
+ options.notify_when = NOTIFY_CLOSED;
+ else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NFORE))
+ options.notify_when = NOTIFY_NFORE;
+ else
+ options.notify_when = NOTIFY_ALWAYS;
+ options.close_win = IsDlgButtonChecked(hwndDlg, IDC_CHK_CLOSE) ? true : false;
+
+ if(IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT)) {
+ BOOL trans;
+ int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE);
+ if(trans) options.timeout = t;
+ } else
+ options.timeout = -1;
+
+ options.set_colours = IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS) ? true : false;
+ options.bkCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_GETCOLOUR, 0, 0);
+ options.textCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_GETCOLOUR, 0, 0);
+
+ for(int i = 0; i < 9; i++)
+ options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) ? true : false);
+ SaveOptions();
+
+ if(options.notify_when == NOTIFY_NFORE)
+ StartFocusTimer();
+ else
+ StopFocusTimer();
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ break;
+ }
+ return FALSE;
+
+}
+
+
+int OptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+#define OPTIONPAGE_OLD_SIZE2 60
+ //odp.cbSize = sizeof(odp);
+ odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pszTitle = Translate(MODULE);
+ odp.pszGroup = Translate("Popups");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts;
+
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+void LoadOptions() {
+ options.notify_when = DBGetContactSettingByte(0, MODULE, "NotifyWhen", NOTIFY_NFORE);
+ options.timeout = (int)DBGetContactSettingDword(0, MODULE, "Timeout", 5);
+ options.set_colours = (DBGetContactSettingByte(0, MODULE, "SetColours", 0) == 1);
+ options.bkCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "BkColour", (DWORD)0xFFFFFF);
+ options.textCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "TextColour", (DWORD)0x000000);
+ options.consider_tabs = (DBGetContactSettingByte(0, MODULE, "ConsiderTabs", 1) == 1);
+ options.close_win = (DBGetContactSettingByte(0, MODULE, "CloseWin", 0) == 1);
+
+ char buff[128];
+ for(int i = 0; i < 9; i++) {
+ sprintf(buff, "DisableStatus%d", i);
+ options.disable_status[i] = (DBGetContactSettingByte(0, MODULE, buff, 0) == 1);
+ }
+}
+
+void SaveOptions() {
+ DBWriteContactSettingByte(0, MODULE, "NotifyWhen", options.notify_when);
+ DBWriteContactSettingDword(0, MODULE, "Timeout", (DWORD)options.timeout);
+ DBWriteContactSettingByte(0, MODULE, "SetColours", options.set_colours ? 1 : 0);
+ DBWriteContactSettingDword(0, MODULE, "BkColour", (DWORD)options.bkCol);
+ DBWriteContactSettingDword(0, MODULE, "TextColour", (DWORD)options.textCol);
+ DBWriteContactSettingByte(0, MODULE, "ConsiderTabs", options.consider_tabs ? 1 : 0);
+ DBWriteContactSettingByte(0, MODULE, "CloseWin", options.close_win ? 1 : 0);
+ char buff[128];
+ for(int i = 0; i < 9; i++) {
+ sprintf(buff, "DisableStatus%d", i);
+ DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0);
+ }
+}
+
+
|