summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp87
1 files changed, 48 insertions, 39 deletions
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index 37118cf764..864d880ef6 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -1656,38 +1656,34 @@ static void InitListView(HWND AHLV)
void OnListResize(HWND hwndDlg)
{
- HWND hList, hText, hBtnNew, hBtnClose;
- RECT lr, cr, tr, clsr;
- int th, btnh, btnw, MARGIN;
- POINT org = {0};
-
- hList = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- hText = GetDlgItem(hwndDlg, IDC_REMINDERDATA);
- hBtnNew = GetDlgItem(hwndDlg, IDC_ADDNEWREMINDER);
- hBtnClose = GetDlgItem(hwndDlg, IDCANCEL);
+ HWND hList = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
+ HWND hText = GetDlgItem(hwndDlg, IDC_REMINDERDATA);
+ HWND hBtnNew = GetDlgItem(hwndDlg, IDC_ADDNEWREMINDER);
+ HWND hBtnClose = GetDlgItem(hwndDlg, IDCANCEL);
+ POINT org = {};
ClientToScreen(hwndDlg, &org);
- GetClientRect(hwndDlg, &cr);
+ RECT lr, cr, tr, clsr;
+ GetClientRect(hwndDlg, &cr);
GetWindowRect(hList, &lr); OffsetRect(&lr, -org.x, -org.y);
GetWindowRect(hText, &tr); OffsetRect(&tr, -org.x, -org.y);
GetWindowRect(hBtnClose, &clsr); OffsetRect(&clsr, -org.x, -org.y);
- MARGIN = lr.left;
-
- th = tr.bottom - tr.top;
- btnh = clsr.bottom - clsr.top;
- btnw = clsr.right - clsr.left;
+ int iMargin = lr.left;
+ int th = tr.bottom - tr.top;
+ int btnh = clsr.bottom - clsr.top;
+ int btnw = clsr.right - clsr.left;
- clsr.left = cr.right - MARGIN - btnw;
- clsr.top = cr.bottom - MARGIN - btnh;
+ clsr.left = cr.right - iMargin - btnw;
+ clsr.top = cr.bottom - iMargin - btnh;
- tr.left = MARGIN;
- tr.right = cr.right - MARGIN;
- tr.bottom = clsr.top - MARGIN - 2;
+ tr.left = iMargin;
+ tr.right = cr.right - iMargin;
+ tr.bottom = clsr.top - iMargin - 2;
tr.top = tr.bottom - th;
- lr.right = cr.right - MARGIN;
+ lr.right = cr.right - iMargin;
lr.bottom = tr.top - 5;
MoveWindow(hList, lr.left, lr.top, lr.right - lr.left, lr.bottom - lr.top, FALSE);
@@ -1697,6 +1693,9 @@ void OnListResize(HWND hwndDlg)
clsr.left -= btnw + 2;
MoveWindow(hBtnNew, clsr.left, clsr.top, btnw, btnh, FALSE);
+ GetWindowRect(hList, &cr);
+ ListView_SetColumnWidth(hList, 1, cr.right - cr.left - ListView_GetColumnWidth(hList, 0) - 4);
+
RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
@@ -1740,7 +1739,7 @@ static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam)
static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
+ HWND hList = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
int idx, cx1, cx2;
switch (Message) {
@@ -1758,7 +1757,7 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
case WM_RELOAD:
SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
- InitListView(GetDlgItem(hwndDlg, IDC_LISTREMINDERS));
+ InitListView(hList);
return TRUE;
case WM_CONTEXTMENU:
@@ -1782,19 +1781,19 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
}
LV_COLUMN lvCol;
- lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_DEFAULTWIDTH;
- lvCol.pszText = TranslateT("Reminder text");
- lvCol.cx = lvCol.cxDefault = cx1;
- ListView_InsertColumn(H, 0, &lvCol);
+ lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_DEFAULTWIDTH;
lvCol.pszText = TranslateT("Date of activation");
- lvCol.cx = lvCol.cxDefault = cx2;
- ListView_InsertColumn(H, 0, &lvCol);
+ lvCol.cx = cx1;
+ ListView_InsertColumn(hList, 0, &lvCol);
+
+ lvCol.pszText = TranslateT("Reminder text");
+ lvCol.cx = cx2;
+ ListView_InsertColumn(hList, 1, &lvCol);
- InitListView(H);
+ InitListView(hList);
- SetWindowLongPtr(GetDlgItem(H, 0), GWL_ID, IDC_LISTREMINDERS_HEADER);
+ SetWindowLongPtr(GetDlgItem(hList, 0), GWL_ID, IDC_LISTREMINDERS_HEADER);
LV = hwndDlg;
Utils_RestoreWindowPosition(hwndDlg, 0, MODULENAME, "ListReminders");
@@ -1814,18 +1813,28 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
break;
case NM_DBLCLK:
- int i = ListView_GetSelectionMark(H);
+ int i = ListView_GetSelectionMark(hList);
if (i != -1)
EditReminder(arReminders[i]);
break;
}
}
+ else if (wParam == IDC_LISTREMINDERS_HEADER) {
+ LPNMHEADER NM = (LPNMHEADER)lParam;
+ switch (NM->hdr.code) {
+ case HDN_ENDTRACK:
+ RECT rc;
+ GetWindowRect(hList, &rc);
+ ListView_SetColumnWidth(hList, 1, rc.right - rc.left - ListView_GetColumnWidth(hList, 0) - 4);
+ break;
+ }
+ }
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case ID_CONTEXTMENUREMINDER_EDIT:
- idx = ListView_GetSelectionMark(H);
+ idx = ListView_GetSelectionMark(hList);
if (idx != -1)
EditReminder(arReminders[idx]);
return TRUE;
@@ -1844,25 +1853,25 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
if (arReminders.getCount() && IDOK == MessageBox(hwndDlg, TranslateT("Are you sure you want to delete all reminders?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
DeleteReminders();
- InitListView(GetDlgItem(hwndDlg, IDC_LISTREMINDERS));
+ InitListView(hList);
}
return TRUE;
case ID_CONTEXTMENUREMINDER_DELETE:
- idx = ListView_GetSelectionMark(H);
+ idx = ListView_GetSelectionMark(hList);
if (idx != -1 && IDOK == MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this reminder?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
DeleteReminder(arReminders[idx]);
JustSaveReminders();
- InitListView(H);
+ InitListView(hList);
}
return TRUE;
}
break;
case WM_DESTROY:
- cx1 = ListView_GetColumnWidth(H, 0);
- cx2 = ListView_GetColumnWidth(H, 1);
+ cx1 = ListView_GetColumnWidth(hList, 0);
+ cx2 = ListView_GetColumnWidth(hList, 1);
g_plugin.setString("ColWidth", CMStringA(FORMAT, "%d,%d", cx1, cx2));
Utils_SaveWindowPosition(hwndDlg, 0, MODULENAME, "ListReminders");