summaryrefslogtreecommitdiff
path: root/plugins/Alarms/src
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2016-12-19 06:04:51 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2016-12-19 06:04:51 +0300
commit758762fbc91f2002a9e41957ca34a5d772d575f4 (patch)
tree0bc6698fe63d0b081b3e83fd711e22e5902adeaa /plugins/Alarms/src
parent83175855d796e139c67d145e710336ec44660319 (diff)
plugins:
alarms: added days of week. closes #318
Diffstat (limited to 'plugins/Alarms/src')
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/alarmlist.cpp68
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/alarmlist.h6
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/frame.cpp2
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/options.cpp242
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/resource.h15
-rwxr-xr-x[-rw-r--r--]plugins/Alarms/src/stdafx.h2
6 files changed, 318 insertions, 17 deletions
diff --git a/plugins/Alarms/src/alarmlist.cpp b/plugins/Alarms/src/alarmlist.cpp
index cc41317231..05154d5d46 100644..100755
--- a/plugins/Alarms/src/alarmlist.cpp
+++ b/plugins/Alarms/src/alarmlist.cpp
@@ -27,6 +27,7 @@ void free_alarm_data(ALARM *alarm) {
void copy_alarm_data(ALARM *dest, ALARM *src) {
dest->action = src->action;
dest->flags = src->flags;
+ dest->day_mask = src->day_mask;
dest->id = src->id;
dest->occurrence = src->occurrence;
dest->snoozer = src->snoozer;
@@ -45,8 +46,8 @@ void GetPluginTime(SYSTEMTIME *t) {
*t = last_check;
}
-int MinutesInFuture(SYSTEMTIME time, Occurrence occ) {
- if (!UpdateAlarm(time, occ)) return 0;
+int MinutesInFuture(SYSTEMTIME time, Occurrence occ, int selected_days) {
+ if (!UpdateAlarm(time, occ, selected_days)) return 0;
SYSTEMTIME now;
GetPluginTime(&now);
@@ -87,7 +88,40 @@ void TimeForMinutesInFuture(int mins, SYSTEMTIME *time) {
// update an alarm so that the systemtime reflects the next time the alarm will go off, based on the last_check time
-bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
+
+bool is_day_selected(int day, int selected_days)
+{
+ switch (day)
+ {
+ case 0:
+ return selected_days & ALDF_7;
+ break;
+ case 1:
+ return selected_days & ALDF_1;
+ break;
+ case 2:
+ return selected_days & ALDF_2;
+ break;
+ case 3:
+ return selected_days & ALDF_3;
+ break;
+ case 4:
+ return selected_days & ALDF_4;
+ break;
+ case 5:
+ return selected_days & ALDF_5;
+ break;
+ case 6:
+ return selected_days & ALDF_6;
+ break;
+ default:
+ return false;
+ }
+
+// return false;
+}
+
+bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ, int selected_days) {
FILETIME ft_now, ft_then;
ULARGE_INTEGER uli_then;
@@ -96,6 +130,7 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
case OC_DAILY:
case OC_WEEKDAYS:
case OC_WEEKLY:
+ case OC_SELECTED_DAYS:
time.wDay = last_check.wDay;
case OC_MONTHLY:
time.wMonth = last_check.wMonth;
@@ -160,6 +195,24 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
} while(temp.wDayOfWeek == 0 || temp.wDayOfWeek == 6 || CompareFileTime(&ft_then, &ft_now) < 0);
}
break;
+ case OC_SELECTED_DAYS: //////TODO:::::
+ {
+ SYSTEMTIME temp;
+ uli_then.HighPart = ft_then.dwHighDateTime;
+ uli_then.LowPart = ft_then.dwLowDateTime;
+ FileTimeToSystemTime(&ft_now, &temp);
+ int day = temp.wDayOfWeek;
+ while (CompareFileTime(&ft_then, &ft_now) < 0 || (selected_days && !is_day_selected(day, selected_days))) {
+ uli_then.QuadPart += mult.QuadPart * (ULONGLONG)24 * (ULONGLONG)60;
+ ft_then.dwHighDateTime = uli_then.HighPart;
+ ft_then.dwLowDateTime = uli_then.LowPart;
+ if (day < 7)
+ day++;
+ else
+ day = 0;
+ }
+ }
+ break;
case OC_DAILY:
uli_then.HighPart = ft_then.dwHighDateTime;
uli_then.LowPart = ft_then.dwLowDateTime;
@@ -239,7 +292,7 @@ void LoadAlarms() {
break;
}
- if (UpdateAlarm(alarm.time, alarm.occurrence)) {
+ if (UpdateAlarm(alarm.time, alarm.occurrence, alarm.day_mask)) {
mir_snprintf(buff, "ActionFlags%d", i);
alarm.action = (unsigned short)db_get_dw(0, MODULE, buff, AAF_POPUP | AAF_SOUND);
if (alarm.action & AAF_COMMAND) {
@@ -273,6 +326,9 @@ void LoadAlarms() {
mir_snprintf(buff, "Flags%d", i);
alarm.flags = db_get_dw(0, MODULE, buff, alarm.flags);
+ mir_snprintf(buff, "SelectedDays%d", i);
+ alarm.flags = db_get_dw(0, MODULE, buff, alarm.day_mask);
+
alarm.id = next_alarm_id++;
alarms.push_back(&alarm);
}
@@ -344,6 +400,8 @@ void SaveAlarms() {
mir_snprintf(buff, "Flags%d", index);
db_set_dw(0, MODULE, buff, i->flags);
+ mir_snprintf(buff, "SelectedDays%d", index);
+ db_set_dw(0, MODULE, buff, i->day_mask);
}
db_set_w(0, MODULE, "Count", index);
}
@@ -580,7 +638,7 @@ void CheckAlarms() {
mir_cslock lck(alarm_cs);
ALARM *i;
for(alarms.reset(); i = alarms.current(); alarms.next()) {
- if (!UpdateAlarm(i->time, i->occurrence)) {
+ if (!UpdateAlarm(i->time, i->occurrence, i->day_mask)) {
// somehow an expired one-off alarm is in our list
remove_list.push_back(i);
continue;
diff --git a/plugins/Alarms/src/alarmlist.h b/plugins/Alarms/src/alarmlist.h
index af8e90b666..a18b8a4aa1 100644..100755
--- a/plugins/Alarms/src/alarmlist.h
+++ b/plugins/Alarms/src/alarmlist.h
@@ -11,11 +11,11 @@ void free_alarm_data(ALARM *alarm);
void copy_alarm_data(ALARM *dest, ALARM *src);
-int MinutesInFuture(SYSTEMTIME time, Occurrence occ);
+int MinutesInFuture(SYSTEMTIME time, Occurrence occ, int selected_days = 0);
void TimeForMinutesInFuture(int mins, SYSTEMTIME *time);
static bool operator<(const ALARM &a1, const ALARM &a2) {
- return MinutesInFuture(a1.time, a1.occurrence) < MinutesInFuture(a2.time, a2.occurrence); // less-than inverted 'cause we want ascending order
+ return MinutesInFuture(a1.time, a1.occurrence, a1.day_mask) < MinutesInFuture(a2.time, a2.occurrence, a2.day_mask); // less-than inverted 'cause we want ascending order
}
class AlarmList {
@@ -138,7 +138,7 @@ void suspend(unsigned short alarm_id);
void GetPluginTime(SYSTEMTIME *t);
// increase 'time' to next occurrence
-bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ);
+bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ, int selected_days = 0);
const ULARGE_INTEGER mult = { 600000000, 0}; // number of 100 microsecond blocks in a minute
diff --git a/plugins/Alarms/src/frame.cpp b/plugins/Alarms/src/frame.cpp
index 6df1829178..96d464ff8d 100644..100755
--- a/plugins/Alarms/src/frame.cpp
+++ b/plugins/Alarms/src/frame.cpp
@@ -124,7 +124,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
RECT r;
GetClientRect(hwnd, &r);
- int min = MinutesInFuture(alarm.time, alarm.occurrence);
+ int min = MinutesInFuture(alarm.time, alarm.occurrence, alarm.day_mask);
FillRect(dis->hDC, &dis->rcItem, bk_brush);
diff --git a/plugins/Alarms/src/options.cpp b/plugins/Alarms/src/options.cpp
index f7cdda24b8..fd51a07bc6 100644..100755
--- a/plugins/Alarms/src/options.cpp
+++ b/plugins/Alarms/src/options.cpp
@@ -45,6 +45,14 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (int i = 1; i <= 31; i++)
SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)_itow(i, buff, 10));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, 0, 0);
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
@@ -86,6 +94,34 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
+ break;
+
+ case OC_SELECTED_DAYS:
+ CheckDlgButton(hwndDlg, IDC_RAD_DAYS, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CAL), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DATE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), TRUE);
+
break;
case OC_WEEKDAYS:
@@ -96,6 +132,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
break;
case OC_ONCE:
@@ -103,6 +148,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), FALSE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
break;
case OC_WEEKLY:
@@ -112,6 +166,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
break;
case OC_MONTHLY:
@@ -121,6 +184,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
break;
case OC_YEARLY:
@@ -128,8 +200,32 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
break;
}
+ if (add_edit_alarm->day_mask & ALDF_1)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY1, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_2)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY2, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_3)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY3, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_4)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY4, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_5)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY5, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_6)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY6, TRUE);
+ if (add_edit_alarm->day_mask & ALDF_7)
+ CheckDlgButton(hwndDlg, IDC_CHK_DAY7, TRUE);
+
CheckDlgButton(hwndDlg, IDC_CHK_SUSPEND, (add_edit_alarm->flags & ALF_SUSPENDED) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_NOSTARTUP, (add_edit_alarm->flags & ALF_NOSTARTUP) ? BST_CHECKED : BST_UNCHECKED);
@@ -139,7 +235,7 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_alarm->time);
SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_alarm->time);
SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, add_edit_alarm->time.wDay - 1, 0);
- SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence), FALSE);
+ SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence, add_edit_alarm->day_mask), FALSE);
if (add_edit_alarm->action & AAF_SOUND) {
CheckDlgButton(hwndDlg, IDC_CHK_ASOUND, BST_CHECKED);
@@ -211,6 +307,8 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
add_edit_alarm->occurrence = OC_ONCE;
else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_DAILY))
add_edit_alarm->occurrence = OC_DAILY;
+ else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_DAYS))
+ add_edit_alarm->occurrence = OC_SELECTED_DAYS;
else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKDAYS))
add_edit_alarm->occurrence = OC_WEEKDAYS;
else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKLY))
@@ -227,6 +325,35 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETRANGE, (WPARAM)(GDTR_MIN | GDTR_MAX), (LPARAM)r);
}
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY1))
+ add_edit_alarm->day_mask |= ALDF_1;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_1;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY2))
+ add_edit_alarm->day_mask |= ALDF_2;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_2;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY3))
+ add_edit_alarm->day_mask |= ALDF_3;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_3;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY4))
+ add_edit_alarm->day_mask |= ALDF_4;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_4;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY5))
+ add_edit_alarm->day_mask |= ALDF_5;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_5;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY6))
+ add_edit_alarm->day_mask |= ALDF_6;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_6;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY7))
+ add_edit_alarm->day_mask |= ALDF_7;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_7;
+
if (add_edit_alarm->occurrence == OC_ONCE || add_edit_alarm->occurrence == OC_YEARLY)
SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_GETSYSTEMTIME, 0, (LPARAM)&add_edit_alarm->time);
@@ -241,7 +368,7 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
add_edit_alarm->time.wMinute = temp_time.wMinute;
add_edit_alarm->time.wSecond = temp_time.wSecond;
- UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence);
+ UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence, add_edit_alarm->day_mask);
return TRUE;
case WMU_SETTIME:
@@ -252,7 +379,7 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, add_edit_alarm->time.wDayOfWeek, 0);
SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_alarm->time);
SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, add_edit_alarm->time.wDay - 1, 0);
- SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence), FALSE);
+ SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence, add_edit_alarm->day_mask), FALSE);
return TRUE;
case WM_NOTIFY:
@@ -325,6 +452,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), FALSE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -337,6 +473,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -349,6 +494,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -361,6 +515,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -373,6 +536,15 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -385,6 +557,36 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), FALSE);
+
+ SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+ SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+ break;
+
+ case IDC_RAD_DAYS:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_CAL), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DATE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DAY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DAYNUM), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RELMIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_SUSPEND), TRUE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY1), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY2), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY3), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY4), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY5), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY6), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DAY7), TRUE);
+
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
break;
@@ -429,7 +631,38 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
- if (!UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence)) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY1))
+ add_edit_alarm->day_mask |= ALDF_1;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_1;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY2))
+ add_edit_alarm->day_mask |= ALDF_2;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_2;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY3))
+ add_edit_alarm->day_mask |= ALDF_3;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_3;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY4))
+ add_edit_alarm->day_mask |= ALDF_4;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_4;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY5))
+ add_edit_alarm->day_mask |= ALDF_5;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_5;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY6))
+ add_edit_alarm->day_mask |= ALDF_6;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_6;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_DAY7))
+ add_edit_alarm->day_mask |= ALDF_7;
+ else
+ add_edit_alarm->day_mask &= ~ALDF_7;
+
+
+
+ if (!UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence, add_edit_alarm->day_mask)) {
MessageBox(hwndDlg, TranslateT("The alarm time you have selected is in the past."), TranslateT("Error"), MB_OK | MB_ICONERROR);
return TRUE;
}
@@ -445,6 +678,7 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP
add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOSTARTUP) ? ALF_NOSTARTUP : 0;
add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOREMINDER) ? ALF_NOREMINDER : 0;
+
if (add_edit_alarm->action & AAF_COMMAND) {
GetDlgItemText(hwndDlg, IDC_ED_COMMAND, buff, _countof(buff));
replaceStrW(add_edit_alarm->szCommand, buff);
diff --git a/plugins/Alarms/src/resource.h b/plugins/Alarms/src/resource.h
index 924503bbd9..790f66e72b 100644..100755
--- a/plugins/Alarms/src/resource.h
+++ b/plugins/Alarms/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by ..\res\resource.rc
+// Used by X:\install\git\miranda\miranda-ng\plugins\Alarms\res\resource.rc
//
#define IDD_DIALOG1 101
#define IDD_OPT1 102
@@ -70,6 +70,15 @@
#define IDC_CHK_LOOPSOUND 1065
#define IDC_ED_DESC 1066
#define IDC_DATE 1071
+#define IDC_RAD_DAYS 1072
+#define IDC_CHK_DAY1 1073
+#define IDC_CHK_DAY2 1074
+#define IDC_CHK_DAY3 1075
+#define IDC_CHK_DAY4 1076
+#define IDC_CHK_DAY5 1077
+#define IDC_CHK_DAY6 1078
+#define IDC_CHECK7 1079
+#define IDC_CHK_DAY7 1079
#define ID_REMINDERFRAMECONTEXT_SUSPEND 40003
#define ID_REMINDERFRAMECONTEXT_EDIT 40004
#define ID_REMINDERFRAMECONTEXT_DELETE 40005
@@ -80,9 +89,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 127
+#define _APS_NEXT_RESOURCE_VALUE 128
#define _APS_NEXT_COMMAND_VALUE 40008
-#define _APS_NEXT_CONTROL_VALUE 1072
+#define _APS_NEXT_CONTROL_VALUE 1080
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/Alarms/src/stdafx.h b/plugins/Alarms/src/stdafx.h
index c9d5be5729..fcbd50182a 100644..100755
--- a/plugins/Alarms/src/stdafx.h
+++ b/plugins/Alarms/src/stdafx.h
@@ -44,7 +44,7 @@ typedef struct ALARM_tag {
wchar_t *szCommand;
wchar_t *szCommandParams;
BYTE sound_num;
- int flags;
+ int flags, day_mask;
} ALARM;
#endif