summaryrefslogtreecommitdiff
path: root/plugins/Alarms/src/frame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Alarms/src/frame.cpp')
-rw-r--r--plugins/Alarms/src/frame.cpp720
1 files changed, 351 insertions, 369 deletions
diff --git a/plugins/Alarms/src/frame.cpp b/plugins/Alarms/src/frame.cpp
index 15fa91accc..cdcb4b755a 100644
--- a/plugins/Alarms/src/frame.cpp
+++ b/plugins/Alarms/src/frame.cpp
@@ -13,6 +13,8 @@ HFONT hFont = 0;
COLORREF fontColour, framebk;
HBRUSH bk_brush = 0;
+#define CLUIFrameTitleBarClassName "CLUIFrameTitleBar"
+
AlarmList alarm_list;
CRITICAL_SECTION list_cs;
@@ -27,7 +29,8 @@ HANDLE hMenuShowReminders = 0;
void FixMainMenu();
-int height_client_to_frame(int client_height, LONG style, LONG ex_style) {
+int height_client_to_frame(int client_height, LONG style, LONG ex_style)
+{
RECT tr;
tr.top = tr.right = tr.left = 0;
tr.bottom = client_height;
@@ -36,52 +39,56 @@ int height_client_to_frame(int client_height, LONG style, LONG ex_style) {
return 0;
}
-LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
switch(msg) {
- case WM_CREATE:
- return TRUE;
- case WM_SHOWWINDOW:
- if ((BOOL)wParam) {
- DBWriteContactSettingByte(0, MODULE, "ReminderFrameVisible", 1);
- Utils_RestoreWindowPosition(hwnd, 0, MODULE, "reminders_window");
- PostMessage(hwnd, WM_SIZE, 0, 0);
- } else {
- DBWriteContactSettingByte(0, MODULE, "ReminderFrameVisible", 0);
- Utils_SaveWindowPosition(hwnd, 0, MODULE, "reminders_window");
- }
- break;
- case WM_SIZE:
- {
- HWND child = (HWND)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- RECT r;
- GetClientRect(hwnd, &r);
-
- SetWindowPos(child, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);
- InvalidateRect(child, 0, TRUE);
- InvalidateRect(hwnd, 0, TRUE);
- }
- break;
-
- case WM_CLOSE:
+ case WM_CREATE:
+ return TRUE;
+
+ case WM_SHOWWINDOW:
+ if (wParam) {
+ db_set_b(0, MODULE, "ReminderFrameVisible", 1);
+ Utils_RestoreWindowPosition(hwnd, 0, MODULE, "reminders_window");
+ PostMessage(hwnd, WM_SIZE, 0, 0);
+ } else {
+ db_set_b(0, MODULE, "ReminderFrameVisible", 0);
Utils_SaveWindowPosition(hwnd, 0, MODULE, "reminders_window");
- ShowWindow(hwnd, SW_HIDE);
- FixMainMenu();
- return TRUE;
+ }
+ break;
+ case WM_SIZE:
+ {
+ HWND child = (HWND)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ RECT r;
+ GetClientRect(hwnd, &r);
+
+ SetWindowPos(child, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);
+ InvalidateRect(child, 0, TRUE);
+ InvalidateRect(hwnd, 0, TRUE);
+ }
+ break;
+
+ case WM_CLOSE:
+ Utils_SaveWindowPosition(hwnd, 0, MODULE, "reminders_window");
+ ShowWindow(hwnd, SW_HIDE);
+ FixMainMenu();
+ return TRUE;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
-bool FrameIsFloating() {
+bool FrameIsFloating()
+{
if (frame_id == -1)
return true; // no frames, always floating
- return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0);
+ return CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0;
}
ALARM context_menu_alarm = {0};
-LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
MEASUREITEMSTRUCT *mis;
DRAWITEMSTRUCT *dis;
SIZE textSize;
@@ -89,360 +96,340 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
switch(msg) {
- case WM_CREATE:
- {
- hwnd_list = CreateWindow(_T("LISTBOX"), _T(""),
- (WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT | LBS_STANDARD | LBS_NOTIFY | LBS_OWNERDRAWFIXED) & ~LBS_SORT
- & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst,0);
- }
- return FALSE;
- case WMU_INITIALIZE:
- PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
- SetTimer(hwnd, ID_FRAME_UPDATE_TIMER, 5000, 0);
- SetTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER, 200, 0);
- return TRUE;
+ case WM_CREATE:
+ hwnd_list = CreateWindow(_T("LISTBOX"), _T(""),
+ (WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT | LBS_STANDARD | LBS_NOTIFY | LBS_OWNERDRAWFIXED) & ~LBS_SORT
+ & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst,0);
+ return FALSE;
- case WM_MEASUREITEM:
- mis = (MEASUREITEMSTRUCT *)lParam;
- mis->itemHeight = options.row_height;
- return TRUE;
+ case WMU_INITIALIZE:
+ PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
+ SetTimer(hwnd, ID_FRAME_UPDATE_TIMER, 5000, 0);
+ SetTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER, 200, 0);
+ return TRUE;
- case WM_DRAWITEM:
- dis = (DRAWITEMSTRUCT *)lParam;
- if (dis->itemID != (DWORD)-1) {
- ALARM alarm = {0};
- EnterCriticalSection(&list_cs);
- ALARM &list_alarm = alarm_list.at(dis->itemData);
- copy_alarm_data(&alarm, &list_alarm);
- LeaveCriticalSection(&list_cs);
+ case WM_MEASUREITEM:
+ mis = (MEASUREITEMSTRUCT *)lParam;
+ mis->itemHeight = options.row_height;
+ return TRUE;
- RECT r;
- GetClientRect(hwnd, &r);
+ case WM_DRAWITEM:
+ dis = (DRAWITEMSTRUCT *)lParam;
+ if (dis->itemID != (DWORD)-1) {
+ ALARM alarm = {0};
+ EnterCriticalSection(&list_cs);
+ ALARM &list_alarm = alarm_list.at(dis->itemData);
+ copy_alarm_data(&alarm, &list_alarm);
+ LeaveCriticalSection(&list_cs);
- int min = MinutesInFuture(alarm.time, alarm.occurrence);
+ RECT r;
+ GetClientRect(hwnd, &r);
- FillRect(dis->hDC, &dis->rcItem, bk_brush);
+ int min = MinutesInFuture(alarm.time, alarm.occurrence);
- dis->rcItem.left += options.indent;
+ FillRect(dis->hDC, &dis->rcItem, bk_brush);
- SetBkMode(dis->hDC, TRANSPARENT);
- SetTextColor(dis->hDC, fontColour);
+ dis->rcItem.left += options.indent;
- HICON hIcon = (min <= 5 ? hIconList2 : hIconList1);
- //DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom -GetSystemMetrics(SM_CYSMICON))>>1,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - 16)>>1,hIcon,0, 0, 0, NULL, DI_NORMAL);
+ SetBkMode(dis->hDC, TRANSPARENT);
+ SetTextColor(dis->hDC, fontColour);
- GetTextExtentPoint32(dis->hDC,alarm.szTitle,lstrlen(alarm.szTitle),&textSize);
+ HICON hIcon = (min <= 5 ? hIconList2 : hIconList1);
+ DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - 16)>>1,hIcon,0, 0, 0, NULL, DI_NORMAL);
- TCHAR buff[100];
- if (min >= 60) {
- mir_sntprintf(buff, 100, TranslateT("%dh %dm"), min / 60, min % 60);
- } else {
- mir_sntprintf(buff, 100, TranslateT("%dm"), min);
- }
+ GetTextExtentPoint32(dis->hDC,alarm.szTitle,lstrlen(alarm.szTitle),&textSize);
- GetTextExtentPoint32(dis->hDC,buff,lstrlen(buff),&timeSize);
-
- if (textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
- // need elipsis
- TCHAR titlebuff[512];
- int len = lstrlen(alarm.szTitle);
- if (len > 511) len = 511;
- while(len > 0 && textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
- len--;
- _tcsncpy(titlebuff, alarm.szTitle, len);
- titlebuff[len] = 0;
- _tcscat(titlebuff, _T("..."));
- GetTextExtentPoint32(dis->hDC,titlebuff,lstrlen(titlebuff),&textSize);
- }
- TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,titlebuff,lstrlen(titlebuff));
- TextOut(dis->hDC,dis->rcItem.right - timeSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom - timeSize.cy)>>1, buff,lstrlen(buff));
- } else {
- TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,alarm.szTitle,lstrlen(alarm.szTitle));
- TextOut(dis->hDC,dis->rcItem.right - timeSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom - timeSize.cy)>>1, buff,lstrlen(buff));
+ TCHAR buff[100];
+ if (min >= 60)
+ mir_sntprintf(buff, 100, TranslateT("%dh %dm"), min / 60, min % 60);
+ else
+ mir_sntprintf(buff, 100, TranslateT("%dm"), min);
+
+ GetTextExtentPoint32(dis->hDC,buff,lstrlen(buff),&timeSize);
+
+ if (textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
+ // need elipsis
+ TCHAR titlebuff[512];
+ int len = lstrlen(alarm.szTitle);
+ if (len > 511) len = 511;
+ while(len > 0 && textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
+ len--;
+ _tcsncpy(titlebuff, alarm.szTitle, len);
+ titlebuff[len] = 0;
+ _tcscat(titlebuff, _T("..."));
+ GetTextExtentPoint32(dis->hDC,titlebuff,lstrlen(titlebuff),&textSize);
}
+ TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,titlebuff,lstrlen(titlebuff));
+ TextOut(dis->hDC,dis->rcItem.right - timeSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom - timeSize.cy)>>1, buff,lstrlen(buff));
+ }
+ else {
+ TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,alarm.szTitle,lstrlen(alarm.szTitle));
+ TextOut(dis->hDC,dis->rcItem.right - timeSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom - timeSize.cy)>>1, buff,lstrlen(buff));
+ }
- SetBkMode(dis->hDC, OPAQUE);
+ SetBkMode(dis->hDC, OPAQUE);
- free_alarm_data(&alarm);
- } else {
- FillRect(dis->hDC, &dis->rcItem, bk_brush);
- }
- return TRUE;
+ free_alarm_data(&alarm);
+ }
+ else FillRect(dis->hDC, &dis->rcItem, bk_brush);
- case WM_CTLCOLORLISTBOX:
- break;
- case WM_ERASEBKGND:
- {
- HDC hdc = (HDC)wParam;
- RECT r;
- GetClientRect(hwnd, &r);
- FillRect(hdc, &r, bk_brush);
- }
- return TRUE;
+ return TRUE;
- case WM_PRINTCLIENT:
- {
- /*
- HDC hdc = (HDC)wParam;
- RECT r;
- GetClientRect(hwnd, &r);
- */
- }
- return TRUE;
+ case WM_CTLCOLORLISTBOX:
+ break;
- case WM_PAINT:
- {
- RECT r;
- if (GetUpdateRect(hwnd, &r, FALSE)) {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)(PRF_CLIENT | PRF_CHILDREN));
- EndPaint(hwnd, &ps);
- }
+ case WM_ERASEBKGND:
+ {
+ HDC hdc = (HDC)wParam;
+ RECT r;
+ GetClientRect(hwnd, &r);
+ FillRect(hdc, &r, bk_brush);
+ }
+ return TRUE;
+
+ case WM_PRINTCLIENT:
+ return TRUE;
+
+ case WM_PAINT:
+ {
+ RECT r;
+ if (GetUpdateRect(hwnd, &r, FALSE)) {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+ SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)(PRF_CLIENT | PRF_CHILDREN));
+ EndPaint(hwnd, &ps);
}
- return TRUE;
+ }
+ return TRUE;
- case WM_SHOWWINDOW:
- if ((BOOL)wParam) PostMessage(hwnd, WMU_SIZE_LIST, 0, 0);
- break;
+ case WM_SHOWWINDOW:
+ if ((BOOL)wParam) PostMessage(hwnd, WMU_SIZE_LIST, 0, 0);
+ break;
- case WM_SIZE:
- if (IsWindowVisible(hwnd)) {
- SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
-
- if (frame_id != -1) {
- //CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW));
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW);
- }
- InvalidateRect(hwnd, 0, TRUE);
- }
- break;
+ case WM_SIZE:
+ if (IsWindowVisible(hwnd)) {
+ SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
- case WMU_SIZE_LIST:
- {
- if (SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0) != options.row_height)
- SendMessage(hwnd_list, LB_SETITEMHEIGHT, 0, options.row_height);
-
- int itemheight = SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0),
- count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
-
- if (options.auto_size_vert && IsWindowVisible(hwnd)) {
- if (FrameIsFloating()) {
-
-#define CLUIFrameTitleBarClassName "CLUIFrameTitleBar"
-
- int height = height_client_to_frame(itemheight * count, GetWindowLongPtr(GetParent(hwnd), GWL_STYLE), GetWindowLongPtr(GetParent(hwnd), GWL_EXSTYLE));
- HWND titleBarHwnd = FindWindowEx(GetParent(hwnd), 0, _T(CLUIFrameTitleBarClassName), 0);
- if (titleBarHwnd) {
- RECT tbr;
- GetWindowRect(titleBarHwnd, &tbr);
- height += (tbr.bottom - tbr.top);
- }
- RECT rp_window;
- GetWindowRect(GetParent(hwnd), &rp_window);
- SetWindowPos(GetParent(hwnd), 0, 0, 0, rp_window.right - rp_window.left, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
-
- /*
- RECT rp_client, rp_window, r_window;
- GetClientRect(GetParent(hwnd), &rp_client);
- GetWindowRect(GetParent(hwnd), &rp_window);
- GetWindowRect(hwnd, &r_window);
- int diff = (rp_window.bottom - rp_window.top) - (rp_client.bottom - rp_client.top);
- if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- diff += rp_window.top - r_window.top;
- SetWindowPos(GetParent(hwnd), 0, 0, 0, rp_window.right - rp_window.left, count * itemheight + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
- */
- } else if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && frame_id != -1) {
- int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM)(count * itemheight));
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS));
+ if (frame_id != -1) {
+ //CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW));
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW);
+ }
+ InvalidateRect(hwnd, 0, TRUE);
+ }
+ break;
+
+ case WMU_SIZE_LIST:
+ {
+ if (SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0) != options.row_height)
+ SendMessage(hwnd_list, LB_SETITEMHEIGHT, 0, options.row_height);
+
+ int itemheight = SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0),
+ count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
+
+ if (options.auto_size_vert && IsWindowVisible(hwnd)) {
+ if (FrameIsFloating()) {
+ int height = height_client_to_frame(itemheight * count, GetWindowLongPtr(GetParent(hwnd), GWL_STYLE), GetWindowLongPtr(GetParent(hwnd), GWL_EXSTYLE));
+ HWND titleBarHwnd = FindWindowEx(GetParent(hwnd), 0, _T(CLUIFrameTitleBarClassName), 0);
+ if (titleBarHwnd) {
+ RECT tbr;
+ GetWindowRect(titleBarHwnd, &tbr);
+ height += (tbr.bottom - tbr.top);
}
+ RECT rp_window;
+ GetWindowRect(GetParent(hwnd), &rp_window);
+ SetWindowPos(GetParent(hwnd), 0, 0, 0, rp_window.right - rp_window.left, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
+ }
+ else if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && frame_id != -1) {
+ int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM)(count * itemheight));
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS));
}
+ }
- RECT r, r2;
- GetClientRect(hwnd, &r);
- GetClientRect(hwnd_list, &r2);
- int width, height, winheight;
+ RECT r, r2;
+ GetClientRect(hwnd, &r);
+ GetClientRect(hwnd_list, &r2);
+ int width, height, winheight;
- width = r.right - r.left;
- winheight = r.bottom - r.top;
+ width = r.right - r.left;
+ winheight = r.bottom - r.top;
- height = min(count * itemheight, winheight - (winheight % itemheight));
- if (r2.right - r2.left != width || (r.bottom - r.top > 0 && r2.bottom - r2.top != height)) {
- SetWindowPos(hwnd_list, 0, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
- InvalidateRect(hwnd_list, 0, FALSE);
- }
-
- if (options.auto_showhide) {
- if (ServiceExists(MS_CLIST_FRAMES_SHFRAME) && frame_id != -1) {
- if (IsWindowVisible(hwnd) && count == 0) {
- CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
- } else if (!IsWindowVisible(hwnd) && count > 0) {
- // we have reminders - show if not linked to clist or if clist is visible
- if ((!options.hide_with_clist && FrameIsFloating()) || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
- CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_FMREDRAW | FU_FMPOS));
- }
+ height = min(count * itemheight, winheight - (winheight % itemheight));
+ if (r2.right - r2.left != width || (r.bottom - r.top > 0 && r2.bottom - r2.top != height)) {
+ SetWindowPos(hwnd_list, 0, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
+ InvalidateRect(hwnd_list, 0, FALSE);
+ }
+
+ if (options.auto_showhide) {
+ if (ServiceExists(MS_CLIST_FRAMES_SHFRAME) && frame_id != -1) {
+ if (IsWindowVisible(hwnd) && count == 0) {
+ CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
+ }
+ else if (!IsWindowVisible(hwnd) && count > 0) {
+ // we have reminders - show if not linked to clist or if clist is visible
+ if ((!options.hide_with_clist && FrameIsFloating()) || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
+ CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_FMREDRAW | FU_FMPOS));
}
- } else {
- if (IsWindowVisible(hwnd) && count == 0)
- SetReminderFrameVisible(false);
- else if (!IsWindowVisible(hwnd) && count > 0)
- // we have reminders - show if not linked to clist or if clist is visible
- if (!options.hide_with_clist || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)))
- SetReminderFrameVisible(true);
}
}
-
- }
- return TRUE;
- case WMU_FILL_LIST:
- {
- // calculate the period to display alarms for
- SYSTEMTIME t1, t2;
- GetLocalTime(&t1);
- TimeForMinutesInFuture(60 * options.reminder_period, &t2);
-
- int sel = SendMessage(hwnd_list, LB_GETCURSEL, 0, 0),
- top = SendMessage(hwnd_list, LB_GETTOPINDEX, 0, 0);
-
- SendMessage(hwnd_list, WM_SETREDRAW, (WPARAM)FALSE, 0);
-
- EnterCriticalSection(&list_cs);
- SendMessage(hwnd_list, LB_RESETCONTENT, 0, 0);
- copy_list(alarm_list, t1, t2);
- alarm_list.sort();
- int index = 0;
- ALARM *i;
- for(alarm_list.reset(); i = alarm_list.current(); alarm_list.next(), index++) {
- if (i->flags & (ALF_HIDDEN | ALF_SUSPENDED | ALF_NOREMINDER))
- continue;
- SendMessage(hwnd_list, LB_ADDSTRING, 0, (LPARAM)index);
+ else {
+ if (IsWindowVisible(hwnd) && count == 0)
+ SetReminderFrameVisible(false);
+ else if (!IsWindowVisible(hwnd) && count > 0)
+ // we have reminders - show if not linked to clist or if clist is visible
+ if (!options.hide_with_clist || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)))
+ SetReminderFrameVisible(true);
}
- LeaveCriticalSection(&list_cs);
+ }
+ }
+ return TRUE;
+
+ case WMU_FILL_LIST:
+ {
+ // calculate the period to display alarms for
+ SYSTEMTIME t1, t2;
+ GetLocalTime(&t1);
+ TimeForMinutesInFuture(60 * options.reminder_period, &t2);
+
+ int sel = SendMessage(hwnd_list, LB_GETCURSEL, 0, 0),
+ top = SendMessage(hwnd_list, LB_GETTOPINDEX, 0, 0);
+
+ SendMessage(hwnd_list, WM_SETREDRAW, (WPARAM)FALSE, 0);
+
+ EnterCriticalSection(&list_cs);
+ SendMessage(hwnd_list, LB_RESETCONTENT, 0, 0);
+ copy_list(alarm_list, t1, t2);
+ alarm_list.sort();
+ int index = 0;
+ ALARM *i;
+ for(alarm_list.reset(); i = alarm_list.current(); alarm_list.next(), index++) {
+ if (i->flags & (ALF_HIDDEN | ALF_SUSPENDED | ALF_NOREMINDER))
+ continue;
+ SendMessage(hwnd_list, LB_ADDSTRING, 0, (LPARAM)index);
+ }
+ LeaveCriticalSection(&list_cs);
- SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
- SendMessage(hwnd_list, WM_SETREDRAW, (WPARAM)TRUE, 0);
+ SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
+ SendMessage(hwnd_list, WM_SETREDRAW, (WPARAM)TRUE, 0);
- if (sel != LB_ERR && sel < index) SendMessage(hwnd_list, LB_SETCURSEL, (WPARAM)sel, 0);
- if (top != LB_ERR && top < index) SendMessage(hwnd_list, LB_SETTOPINDEX, (WPARAM)top, 0);
+ if (sel != LB_ERR && sel < index) SendMessage(hwnd_list, LB_SETCURSEL, (WPARAM)sel, 0);
+ if (top != LB_ERR && top < index) SendMessage(hwnd_list, LB_SETTOPINDEX, (WPARAM)top, 0);
+ }
+ return TRUE;
+
+ case WM_TIMER:
+ if (wParam == ID_FRAME_UPDATE_TIMER)
+ SendMessage(hwnd, WMU_FILL_LIST, 0, 0);
+ else if (wParam == ID_FRAME_SHOWHIDE_TIMER && options.hide_with_clist) { // link show/hide with clist
+ // hide if we're visible and clist isn't (possible only when floating if frames are present)
+ if (!IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)) && IsWindowVisible(hwnd)) {
+ if (ServiceExists(MS_CLIST_FRAMES_SHFRAME))
+ CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
+ else
+ SetReminderFrameVisible(false);
}
- return TRUE;
-
- case WM_TIMER:
- if (wParam == ID_FRAME_UPDATE_TIMER)
- SendMessage(hwnd, WMU_FILL_LIST, 0, 0);
- else if (wParam == ID_FRAME_SHOWHIDE_TIMER && options.hide_with_clist) { // link show/hide with clist
- // hide if we're visible and clist isn't (possible only when floating if frames are present)
- if (!IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)) && IsWindowVisible(hwnd)) {
+ // we're not visible but clist is - show depending on hide_with_clist and auto_showhide options
+ if (!IsWindowVisible(hwnd) && IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
+ // if not auto show/hide, show (reminders or not) if we're not visible and the clist is
+ // otherwise, show only if there are reminders
+ int count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
+ if (!options.auto_showhide || count > 0) {
if (ServiceExists(MS_CLIST_FRAMES_SHFRAME))
CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
else
- SetReminderFrameVisible(false);
- }
- // we're not visible but clist is - show depending on hide_with_clist and auto_showhide options
- if (!IsWindowVisible(hwnd) && IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
- // if not auto show/hide, show (reminders or not) if we're not visible and the clist is
- // otherwise, show only if there are reminders
- int count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
- if (!options.auto_showhide || count > 0) {
- if (ServiceExists(MS_CLIST_FRAMES_SHFRAME))
- CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
- else
- SetReminderFrameVisible(true);
- }
+ SetReminderFrameVisible(true);
}
}
- return TRUE;
+ }
+ return TRUE;
+
+ case WM_CONTEXTMENU:
+ {
+ POINT pt;
+ GetCursorPos(&pt);
+ ScreenToClient(hwnd_list, &pt);
+
+ EnterCriticalSection(&list_cs);
+ DWORD item = SendMessage(hwnd_list, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
+
+ HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)), submenu = GetSubMenu(menu, 0);
+ TranslateMenu(submenu);
+
+ if (HIWORD(item) == 0) {
+ int sel = LOWORD(item);
+ if (sel >= 0) {
+ // one-off alarms can't be suspended
+ int index = SendMessage(hwnd_list, LB_GETITEMDATA, (WPARAM)sel, 0);
+ ALARM &list_alarm = alarm_list.at(index);
+ copy_alarm_data(&context_menu_alarm, &list_alarm);
+ if (context_menu_alarm.occurrence == OC_ONCE)
+ EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_SUSPEND, MF_BYCOMMAND | MF_GRAYED);
- case WM_CONTEXTMENU:
- {
- /*
- */
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwnd_list, &pt);
+ }
+ }
+ else {
+ EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_SUSPEND, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_EDIT, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_DELETE, MF_BYCOMMAND | MF_GRAYED);
+ }
+ LeaveCriticalSection(&list_cs);
- EnterCriticalSection(&list_cs);
- DWORD item = SendMessage(hwnd_list, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
+ //ClientToScreen(hwnd_list, &pt);
+ GetCursorPos(&pt);
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)), submenu = GetSubMenu(menu, 0);
- TranslateMenu(submenu);
-
- if (HIWORD(item) == 0) {
- int sel = LOWORD(item);
- if (sel >= 0) {
- // one-off alarms can't be suspended
- int index = SendMessage(hwnd_list, LB_GETITEMDATA, (WPARAM)sel, 0);
- ALARM &list_alarm = alarm_list.at(index);
- copy_alarm_data(&context_menu_alarm, &list_alarm);
- if (context_menu_alarm.occurrence == OC_ONCE)
- EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_SUSPEND, MF_BYCOMMAND | MF_GRAYED);
+ BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(menu);
+ if (ret) PostMessage(hwnd, WM_COMMAND, ret, 0);
+ }
+ return TRUE;
- }
- } else {
- EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_SUSPEND, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_EDIT, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_DELETE, MF_BYCOMMAND | MF_GRAYED);
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case ID_REMINDERFRAMECONTEXT_OPTIONS:
+ {
+ OPENOPTIONSDIALOG oop;
+ oop.cbSize = sizeof(oop);
+ oop.pszGroup = Translate("Events");
+ oop.pszPage = Translate("Alarms");
+ oop.pszTab = 0;
+ Options_Open(&oop);
+ }
+ break;
+ case ID_REMINDERFRAMECONTEXT_SUSPEND:
+ if (context_menu_alarm.occurrence != OC_ONCE) {
+ suspend(context_menu_alarm.id);
+ PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
+ if (hwndOptionsDialog) {
+ // refresh options list
+ PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
}
- LeaveCriticalSection(&list_cs);
-
- //ClientToScreen(hwnd_list, &pt);
- GetCursorPos(&pt);
-
- BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
- DestroyMenu(menu);
- if (ret) PostMessage(hwnd, WM_COMMAND, ret, 0);
}
- return TRUE;
-
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case ID_REMINDERFRAMECONTEXT_OPTIONS:
- {
- OPENOPTIONSDIALOG oop;
- oop.cbSize = sizeof(oop);
- oop.pszGroup = Translate("Events");
- oop.pszPage = Translate("Alarms");
- oop.pszTab = 0;
- Options_Open(&oop);
- }
- break;
- case ID_REMINDERFRAMECONTEXT_SUSPEND:
- if (context_menu_alarm.occurrence != OC_ONCE) {
- suspend(context_menu_alarm.id);
- PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
- if (hwndOptionsDialog) {
- // refresh options list
- PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
- }
- }
- break;
- case ID_REMINDERFRAMECONTEXT_EDIT:
- EditNonModal(context_menu_alarm);
- break;
- case ID_REMINDERFRAMECONTEXT_DELETE:
- remove(context_menu_alarm.id);
- PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
- if (hwndOptionsDialog) {
- // refresh options list
- PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
- }
- break;
-
- case ID_REMINDERFRAMECONTEXT_NEWALARM:
- NewAlarmMenuFunc(0, 0);
- break;
- }
- return TRUE;
-
- case WM_DESTROY:
- KillTimer(hwnd, ID_FRAME_UPDATE_TIMER);
- KillTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER);
- free_alarm_data(&context_menu_alarm);
break;
+ case ID_REMINDERFRAMECONTEXT_EDIT:
+ EditNonModal(context_menu_alarm);
+ break;
+ case ID_REMINDERFRAMECONTEXT_DELETE:
+ remove(context_menu_alarm.id);
+ PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
+ if (hwndOptionsDialog) {
+ // refresh options list
+ PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
+ }
+ break;
+
+ case ID_REMINDERFRAMECONTEXT_NEWALARM:
+ NewAlarmMenuFunc(0, 0);
+ break;
+ }
+ return TRUE;
+
+ case WM_DESTROY:
+ KillTimer(hwnd, ID_FRAME_UPDATE_TIMER);
+ KillTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER);
+ free_alarm_data(&context_menu_alarm);
+ break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -458,7 +445,7 @@ int ReloadFont(WPARAM wParam, LPARAM lParam)
SendMessage(hwnd_list, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
DeleteObject(bk_brush);
- bk_brush = CreateSolidBrush(DBGetContactSettingDword(0, "Alarm", "clFrameBack", GetSysColor(COLOR_3DFACE)));
+ bk_brush = CreateSolidBrush(db_get_dw(0, "Alarm", "clFrameBack", GetSysColor(COLOR_3DFACE)));
RefreshReminderFrame();
return 0;
@@ -485,6 +472,7 @@ void FixMainMenu()
/////////////////////////
// only used when no multiwindow functionality is available
+
bool ReminderFrameVisible()
{
return IsWindowVisible(hwnd_frame) ? true : false;
@@ -506,6 +494,7 @@ INT_PTR ShowHideMenuFunc(WPARAM wParam, LPARAM lParam)
FixMainMenu();
return 0;
}
+
//////////////////////////////
int CreateFrame()
@@ -518,28 +507,25 @@ int CreateFrame()
wndclass.hInstance = hInst;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
+ wndclass.hbrBackground = 0;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = _T("AlarmsFrame");
RegisterClass(&wndclass);
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
-
hwnd_plugin = CreateWindow(_T("AlarmsFrame"), TranslateT("Alarms"),
WS_CHILD | WS_CLIPCHILDREN,
0,0,10,10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL,hInst,NULL);
- CLISTFrame Frame = {0};
-
- Frame.cbSize=sizeof(CLISTFrame);
- Frame.name = Frame.TBname = Translate("Alarms");
- Frame.hWnd=hwnd_plugin;
- Frame.align=alBottom;
- Frame.Flags=F_VISIBLE|F_SHOWTB|F_SHOWTBTIP;
- Frame.height=30;
-
- frame_id=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0);
- } else {
+ CLISTFrame Frame = { sizeof(CLISTFrame) };
+ Frame.tname = TranslateT("Alarms");
+ Frame.hWnd = hwnd_plugin;
+ Frame.align = alBottom;
+ Frame.Flags = F_TCHAR | F_VISIBLE | F_SHOWTB | F_SHOWTBTIP;
+ Frame.height = 30;
+ frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0);
+ }
+ else {
wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = FrameContainerWindowProc;
wndclass.cbClsExtra = 0;
@@ -567,15 +553,12 @@ int CreateFrame()
// create menu item
CreateServiceFunction(MODULE "/ShowHideReminders", ShowHideMenuFunc);
- CLISTMENUITEM mi = {0};
-
- mi.cbSize=sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_ALL;
-
mi.hIcon=hIconMenuShowHide;
- mi.pszName = Translate("Show Reminders");
- mi.pszService= MODULE "/ShowHideReminders";
- mi.pszPopupName = Translate("Alarms");
+ mi.pszName = LPGEN("Show Reminders");
+ mi.pszService = MODULE "/ShowHideReminders";
+ mi.pszPopupName = LPGEN("Alarms");
mi.position = 500010000;
hMenuShowReminders = Menu_AddMainMenuItem(&mi);
/////////////////////
@@ -585,16 +568,15 @@ int CreateFrame()
if (IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
ShowWindow(hwnd_frame, SW_SHOW);
RefreshReminderFrame();
- } else {
- ShowWindow(hwnd_frame, SW_HIDE);
}
- } else {
- if (DBGetContactSettingByte(0, MODULE, "ReminderFrameVisible", 1) == 1) {
+ else ShowWindow(hwnd_frame, SW_HIDE);
+ }
+ else {
+ if (db_get_b(0, MODULE, "ReminderFrameVisible", 1) == 1) {
ShowWindow(hwnd_frame, SW_SHOW);
RefreshReminderFrame();
- } else {
- ShowWindow(hwnd_frame, SW_HIDE);
}
+ else ShowWindow(hwnd_frame, SW_HIDE);
}
}
@@ -629,7 +611,7 @@ int CreateFrame()
HookEvent(ME_FONT_RELOAD, ReloadFont);
// create the brush used for the background in the absence of clist_modern skinning features - match clist
- bk_brush = CreateSolidBrush(DBGetContactSettingDword(0, "Alarm", "clFrameBack", GetSysColor(COLOR_3DFACE)));
+ bk_brush = CreateSolidBrush(db_get_dw(0, "Alarm", "clFrameBack", GetSysColor(COLOR_3DFACE)));
SendMessage(hwnd_list, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);