summaryrefslogtreecommitdiff
path: root/plugins/Alarms/src/trigger.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-04 08:02:51 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-04 08:02:51 +0000
commit0624d6b4e9b82ccfaabf7a20d00c474a09354e8d (patch)
tree3fcd9ec7f6f5c1d0cd76ce62f83169020ea5fb02 /plugins/Alarms/src/trigger.cpp
parent5544a559d7eea6b6da2a9e512e3480a10f31714d (diff)
Alarms: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@750 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Alarms/src/trigger.cpp')
-rw-r--r--plugins/Alarms/src/trigger.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/plugins/Alarms/src/trigger.cpp b/plugins/Alarms/src/trigger.cpp
new file mode 100644
index 0000000000..532b98920c
--- /dev/null
+++ b/plugins/Alarms/src/trigger.cpp
@@ -0,0 +1,106 @@
+#include "common.h"
+#include "trigger.h"
+
+AlarmList alist;
+//SPECIFICTRIGGERINFO sti;
+TRIGGERDATA td;
+
+unsigned short last_selected_id = 0;
+
+static INT_PTR CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ copy_list(alist);
+ ALARM *i;
+ for(alist.reset(); i = alist.current(); alist.next()) {
+ int pos = SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)i->szTitle);
+ SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_SETITEMDATA, (WPARAM)pos, (LPARAM)i->id);
+ if (i->trigger_id == (unsigned int)lParam)
+ SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_SETCURSEL, (WPARAM)pos, 0);
+ }
+ }
+ return FALSE;
+
+ case WM_COMMAND:
+ if (HIWORD( wParam ) == LBN_SELCHANGE) {
+ int pos = SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_GETCURSEL, 0, 0);
+ if (pos != LB_ERR) {
+ last_selected_id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_GETITEMDATA, pos, 0);
+ }
+ return TRUE;
+ }
+ break;
+ case TM_GETTRIGGERINFO:
+ {
+ //memset(&sti, sizeof(sti), 0);
+ memset(&td, sizeof(td), 0);
+
+ ALARM *i;
+ for(alist.reset(); i = alist.current(); alist.next()) {
+ if (i->trigger_id == wParam) {
+ //sti.cbSize = sizeof(sti);
+ //sti.triggerID = wParam;
+ //sti.pszSummary = i->szTitle;
+ //sti.td = &td;
+
+ td.cbSize = sizeof(td);
+ td.dFlags = DF_TEXT;
+ td.tszText = i->szDesc;
+ //*(SPECIFICTRIGGERINFO **)lParam = &sti;
+ break;
+ }
+ }
+ }
+ return TRUE;
+ case TM_ADDTRIGGER:
+ {
+ ALARM *i;
+ for(alist.reset(); i = alist.current(); alist.next()) {
+ if (i->id == last_selected_id) {
+ i->trigger_id = wParam;
+ alter_alarm_list(i);
+ break;
+ }
+ }
+ }
+ return TRUE;
+ case TM_DELTRIGGER:
+ {
+ ALARM *i;
+ for(alist.reset(); i = alist.current(); alist.next()) {
+ if (i->trigger_id == wParam) {
+ i->trigger_id = 0;
+ alter_alarm_list(i);
+ break;
+ }
+ }
+ }
+ return TRUE;
+
+ case WM_DESTROY:
+ // it seems this is called before the TM_ADDTRIGGER messsage is passed to us....tsk,tsk :P
+ //alist.clear();
+ break;
+
+ }
+ return FALSE;
+}
+
+int LoadTriggerSupport() {
+ if (ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) {
+ TRIGGERREGISTER treg = {0};
+
+ treg.cbSize = sizeof(treg);
+ treg.pszName = Translate("Alarms");
+ treg.hInstance = hInst;
+ treg.pfnDlgProc = DlgProcTriggerOptions;
+ treg.pszTemplate = MAKEINTRESOURCEA(IDD_OPTTRIGGER);
+
+ CallService(MS_TRIGGER_REGISTERTRIGGER, 0, (LPARAM)&treg);
+ }
+
+ return 0;
+}