diff options
author | slotwin <slotwin@users.noreply.github.com> | 2014-06-12 20:43:30 +0000 |
---|---|---|
committer | slotwin <slotwin@users.noreply.github.com> | 2014-06-12 20:43:30 +0000 |
commit | 2bf82f155a0e98e6ab6c31a01315582f57bc9aa8 (patch) | |
tree | 24d40945c4e30b25ac64ca3ebdd0386c4757cbfd /plugins/UserInfoEx/src/dlg_anniversarylist.cpp | |
parent | b41e007b3cc5cd3cdba4f06237d0d5ccd0585ca3 (diff) |
UserInfoEx: rearranged option pages (changed options and icons group name to make it more descriptive, changes some other titles)
proper capitalization
code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@9447 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx/src/dlg_anniversarylist.cpp')
-rw-r--r-- | plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 717 |
1 files changed, 303 insertions, 414 deletions
diff --git a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp index 745a82caa7..b62aee6d93 100644 --- a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp +++ b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp @@ -41,21 +41,21 @@ static CAnnivList *gpDlg = NULL; class CAnnivList
{
- HWND _hDlg;
- HWND _hList;
- SIZE _sizeMin;
- RECT _rcWin;
- SHORT _sortOrder;
- int _sortHeader;
- int _curSel;
- int _numRows;
- BYTE _bRemindEnable;
- HANDLE _mHookExit;
- bool _wmINIT;
-
- typedef int (CALLBACK* CMPPROC)(LPARAM, LPARAM LPARAM);
-
- enum EColumn
+ HWND _hDlg;
+ HWND _hList;
+ SIZE _sizeMin;
+ RECT _rcWin;
+ SHORT _sortOrder;
+ int _sortHeader;
+ int _curSel;
+ int _numRows;
+ BYTE _bRemindEnable;
+ HANDLE _mHookExit;
+ bool _wmINIT;
+
+ typedef int (CALLBACK* CMPPROC)(LPARAM, LPARAM LPARAM);
+
+ enum EColumn
{
COLUMN_ETA = 0,
COLUMN_CONTACT,
@@ -65,7 +65,7 @@ class CAnnivList COLUMN_DATE,
};
- enum EFilter
+ enum EFilter
{
FILTER_ALL = 0,
FILTER_BIRTHDAY,
@@ -73,14 +73,14 @@ class CAnnivList FILTER_DISABLED_REMINDER
};
- struct CFilter
+ struct CFilter
{
WORD wDaysBefore;
BYTE bFilterIndex;
LPSTR pszProto;
LPTSTR pszAnniv;
- CFilter()
+ CFilter()
{
wDaysBefore = (WORD)-1;
bFilterIndex = 0;
@@ -89,14 +89,14 @@ class CAnnivList }
} _filter;
- struct CItemData
+ struct CItemData
{
MCONTACT _hContact;
- MAnnivDate* _pDate;
+ MAnnivDate *_pDate;
WORD _wDaysBefore;
BYTE _wReminderState;
- CItemData(MCONTACT hContact, MAnnivDate &date)
+ CItemData(MCONTACT hContact, MAnnivDate &date)
{
_hContact = hContact;
_wReminderState = date.RemindOption();
@@ -104,13 +104,11 @@ class CAnnivList _pDate = new MAnnivDate(date);
}
- ~CItemData()
+ ~CItemData()
{
- if (_pDate)
- {
+ if (_pDate) {
// save changes
- if (_wReminderState != _pDate->RemindOption() || _wDaysBefore != _pDate->RemindOffset())
- {
+ if (_wReminderState != _pDate->RemindOption() || _wDaysBefore != _pDate->RemindOffset()) {
_pDate->RemindOffset(_wDaysBefore);
_pDate->RemindOption(_wReminderState);
_pDate->DBWriteReminderOpts(_hContact);
@@ -121,10 +119,8 @@ class CAnnivList }
};
- /**
- * This class handles the movement of child controls on size change.
- **/
- class CAnchor
+ // This class handles the movement of child controls on size change.
+ class CAnchor
{
public:
enum EAnchor
@@ -137,89 +133,75 @@ class CAnnivList };
private:
- WINDOWPOS* _wndPos;
+ WINDOWPOS *_wndPos;
HDWP _hdWnds;
RECT _rcParent;
- void _ScreenToClient(HWND hWnd, LPRECT rc)
+ void _ScreenToClient(HWND hWnd, LPRECT rc)
{
POINT pt = { rc->left, rc->top };
ScreenToClient(hWnd, &pt);
rc->right += pt.x - rc->left;
rc->bottom += pt.y - rc->top;
- rc->left = pt.x;
- rc->top = pt.y;
+ rc->left = pt.x;
+ rc->top = pt.y;
}
- void _MoveWindow(HWND hWnd, int anchors)
+ void _MoveWindow(HWND hWnd, int anchors)
{
- if (!(_wndPos->flags & SWP_NOSIZE))
- {
+ if (!(_wndPos->flags & SWP_NOSIZE)) {
RECT rcc = _CalcPos(hWnd, anchors);
MoveWindow(hWnd, rcc.left, rcc.top, rcc.right - rcc.left, rcc.bottom - rcc.top, FALSE);
}
}
- RECT _CalcPos(HWND hWnd, int anchors)
+ RECT _CalcPos(HWND hWnd, int anchors)
{
RECT rcc;
GetWindowRect(hWnd, &rcc);
_ScreenToClient(_wndPos->hwnd, &rcc);
- if (!(_wndPos->flags & SWP_NOSIZE))
- {
+ if (!(_wndPos->flags & SWP_NOSIZE)) {
// calculate difference between new and old size
const int cx = _wndPos->cx - _rcParent.right + _rcParent.left;
const int cy = _wndPos->cy - _rcParent.bottom + _rcParent.top;
- if (cx != 0 || cy != 0)
- {
+ if (cx != 0 || cy != 0) {
// move client rect points to the desired new position
if (!(anchors & ANCHOR_LEFT) || (anchors & ANCHOR_RIGHT))
- {
rcc.right += cx;
- }
if (!(anchors & ANCHOR_TOP) || (anchors & ANCHOR_BOTTOM))
- {
rcc.bottom += cy;
- }
if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT)))
- {
rcc.left += cx;
- }
if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP)))
- {
rcc.top += cy;
- }
}
}
return rcc;
}
public:
- CAnchor(WINDOWPOS* wndPos, SIZE minSize)
+ CAnchor(WINDOWPOS *wndPos, SIZE minSize)
{
GetWindowRect(wndPos->hwnd, &_rcParent);
- if (wndPos->cx < minSize.cx) {
+ if (wndPos->cx < minSize.cx)
wndPos->cx = minSize.cx;
- }
- if (wndPos->cy < minSize.cy) {
+ if (wndPos->cy < minSize.cy)
wndPos->cy = minSize.cy;
- }
_wndPos = wndPos;
_hdWnds = BeginDeferWindowPos(2);
}
- ~CAnchor()
+ ~CAnchor()
{
EndDeferWindowPos(_hdWnds);
}
- void MoveCtrl(WORD idCtrl, int anchors)
+ void MoveCtrl(WORD idCtrl, int anchors)
{
- if (!(_wndPos->flags & SWP_NOSIZE))
- {
+ if (!(_wndPos->flags & SWP_NOSIZE)) {
HWND hCtrl = GetDlgItem(_wndPos->hwnd, idCtrl);
RECT rcc = _CalcPos(hCtrl, anchors);
_hdWnds = DeferWindowPos(
@@ -228,7 +210,7 @@ class CAnnivList HWND_NOTOPMOST, //hWndInsertAfter
rcc.left, //int x
rcc.top, //int y
- rcc.right - rcc.left,
+ rcc.right - rcc.left,
rcc.bottom - rcc.top,
SWP_NOZORDER //UINT uFlags
);
@@ -245,7 +227,7 @@ class CAnnivList *
* @return This function returns a number indicating comparison result.
**/
- static int CALLBACK cmpProc(int iItem1, int iItem2, CAnnivList* pDlg)
+ static int CALLBACK cmpProc(int iItem1, int iItem2, CAnnivList *pDlg)
{
int result;
@@ -255,42 +237,36 @@ class CAnnivList szText1[0] = szText2[0] = 0;
switch (pDlg->_sortHeader) {
- case COLUMN_CONTACT:
- case COLUMN_PROTO:
- case COLUMN_DESC:
- {
- ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, MAX_PATH);
- ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, MAX_PATH);
- result = pDlg->_sortOrder * mir_tcscmp(szText1, szText2);
- } break;
-
- case COLUMN_AGE:
- case COLUMN_ETA:
- {
- ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, MAX_PATH);
- ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, MAX_PATH);
- result = pDlg->_sortOrder * (_ttoi(szText1) - _ttoi(szText2));
- } break;
-
- case COLUMN_DATE:
- {
- CItemData *id1 = pDlg->ItemData(iItem1),
- *id2 = pDlg->ItemData(iItem2);
+ case COLUMN_CONTACT:
+ case COLUMN_PROTO:
+ case COLUMN_DESC:
+ ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, MAX_PATH);
+ ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, MAX_PATH);
+ result = pDlg->_sortOrder * mir_tcscmp(szText1, szText2);
+ break;
+
+ case COLUMN_AGE:
+ case COLUMN_ETA:
+ ListView_GetItemText(pDlg->_hList, iItem1, pDlg->_sortHeader, szText1, MAX_PATH);
+ ListView_GetItemText(pDlg->_hList, iItem2, pDlg->_sortHeader, szText2, MAX_PATH);
+ result = pDlg->_sortOrder * (_ttoi(szText1) - _ttoi(szText2));
+ break;
+
+ case COLUMN_DATE:
+ {
+ CItemData *id1 = pDlg->ItemData(iItem1), *id2 = pDlg->ItemData(iItem2);
- if (PtrIsValid(id1) && PtrIsValid(id2)) {
- result = pDlg->_sortOrder * id1->_pDate->Compare(*id2->_pDate);
- break;
- }
- }
- default:
- {
- result = 0;
+ if (PtrIsValid(id1) && PtrIsValid(id2)) {
+ result = pDlg->_sortOrder * id1->_pDate->Compare(*id2->_pDate);
+ break;
}
+ }
+ default:
+ result = 0;
}
}
- else {
+ else
result = 0;
- }
return result;
}
@@ -304,12 +280,11 @@ class CAnnivList *
* @return depends on message
**/
- static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- CAnnivList *pDlg = (CAnnivList*)GetUserData(hDlg);
+ CAnnivList *pDlg = (CAnnivList *)GetUserData(hDlg);
- switch (uMsg)
- {
+ switch (uMsg) {
case WM_INITDIALOG:
{
int i = 0;
@@ -318,18 +293,16 @@ class CAnnivList RECT rc;
// link the class to the window handle
- pDlg = (CAnnivList*)lParam;
- if (!pDlg) {
+ pDlg = (CAnnivList *)lParam;
+ if (!pDlg)
break;
- }
SetUserData(hDlg, lParam);
pDlg->_hDlg = hDlg;
// init pointer listview control
pDlg->_hList = GetDlgItem(hDlg, EDIT_ANNIVERSARY_DATE);
- if (!pDlg->_hList) {
+ if (!pDlg->_hList)
break;
- }
// set icons
hIcon = Skin_GetIcon(ICO_DLG_ANNIVERSARY);
@@ -340,15 +313,13 @@ class CAnnivList ListView_SetExtendedListViewStyle(pDlg->_hList, LVS_EX_FULLROWSELECT);
// add columns
- if (pDlg->AddColumn(CAnnivList::COLUMN_ETA, LPGENT("ETA"), 40) ||
- pDlg->AddColumn(CAnnivList::COLUMN_CONTACT, LPGENT("Contact"), 160) ||
- pDlg->AddColumn(CAnnivList::COLUMN_PROTO, LPGENT("Proto"), 50) ||
- pDlg->AddColumn(CAnnivList::COLUMN_AGE, LPGENT("Age/Nr."), 40) ||
- pDlg->AddColumn(CAnnivList::COLUMN_DESC, LPGENT("Anniversary"), 100) ||
- pDlg->AddColumn(CAnnivList::COLUMN_DATE, LPGENT("Date"), 80))
- {
+ if (pDlg->AddColumn(CAnnivList::COLUMN_ETA, LPGENT("ETA"), 40)
+ || pDlg->AddColumn(CAnnivList::COLUMN_CONTACT, LPGENT("Contact"), 160)
+ || pDlg->AddColumn(CAnnivList::COLUMN_PROTO, LPGENT("Proto"), 50)
+ || pDlg->AddColumn(CAnnivList::COLUMN_AGE, LPGENT("Age/Nr."), 40)
+ || pDlg->AddColumn(CAnnivList::COLUMN_DESC, LPGENT("Anniversary"), 100)
+ || pDlg->AddColumn(CAnnivList::COLUMN_DATE, LPGENT("Date"), 80))
break;
- }
TranslateDialogDefault(hDlg);
@@ -381,7 +352,7 @@ class CAnnivList CheckDlgButton(hDlg, CHECK_POPUP, db_get_b(NULL, MODNAME, SET_ANNIVLIST_POPUP, FALSE));
// set number of days to show contact in advance
- SetDlgItemInt(hDlg, EDIT_DAYS, pDlg->_filter.wDaysBefore , FALSE);
+ SetDlgItemInt(hDlg, EDIT_DAYS, pDlg->_filter.wDaysBefore, FALSE);
if (hCtrl = GetDlgItem(hDlg, CHECK_DAYS)) {
Button_SetCheck(hCtrl, db_get_b(NULL, MODNAME, SET_ANNIVLIST_FILTER_DAYSENABLED, FALSE));
DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_DAYS, BN_CLICKED), (LPARAM)hCtrl);
@@ -391,9 +362,7 @@ class CAnnivList }
return TRUE;
- /**
- * set propertysheet page's background white in aero mode
- **/
+ // set propertysheet page's background white in aero mode
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORDLG:
if (IsAeroMode())
@@ -401,163 +370,130 @@ class CAnnivList break;
case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case EDIT_ANNIVERSARY_DATE:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case EDIT_ANNIVERSARY_DATE:
+ switch (((LPNMHDR)lParam)->code) {
+ // handle changed selection
+ case LVN_ITEMCHANGED:
+ {
+ CItemData *pid;
+ HWND hCheck;
+
+ pDlg->_curSel = ((LPNMLISTVIEW)lParam)->iItem;
+ pid = pDlg->ItemData(pDlg->_curSel);
+ if (pid && pDlg->_bRemindEnable && (hCheck = GetDlgItem(hDlg, CHECK_REMIND))) {
+ SetDlgItemInt(hDlg, EDIT_REMIND, pid->_wDaysBefore, FALSE);
+ Button_SetCheck(hCheck, pid->_wReminderState);
+ DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_REMIND, BN_CLICKED), (LPARAM)hCheck);
+ }
+ }
+ break;
+
+ // resort the list
+ case LVN_COLUMNCLICK:
+ {
+ LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
+
+ if (pDlg->_sortHeader == pnmv->iSubItem)
+ pDlg->_sortOrder *= -1;
+ else {
+ pDlg->_sortOrder = 1;
+ pDlg->_sortHeader = pnmv->iSubItem;
+ }
+ ListView_SortItemsEx(pDlg->_hList, (CMPPROC)cmpProc, pDlg);
+ }
+ break;
+
+ // show contact menu
+ case NM_RCLICK:
{
- switch (((LPNMHDR)lParam)->code)
- {
- /*
- * handle changed selection
- */
- case LVN_ITEMCHANGED:
- {
- CItemData* pid;
- HWND hCheck;
-
- pDlg->_curSel = ((LPNMLISTVIEW)lParam)->iItem;
- pid = pDlg->ItemData(pDlg->_curSel);
- if (pid && pDlg->_bRemindEnable && (hCheck = GetDlgItem(hDlg, CHECK_REMIND))) {
- SetDlgItemInt(hDlg, EDIT_REMIND, pid->_wDaysBefore, FALSE);
- Button_SetCheck(hCheck, pid->_wReminderState);
- DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_REMIND, BN_CLICKED), (LPARAM)hCheck);
- }
- } break;
-
- /*
- * resort the list
- */
- case LVN_COLUMNCLICK:
- {
- LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
-
- if (pDlg->_sortHeader == pnmv->iSubItem) {
- pDlg->_sortOrder *= -1;
- }
- else {
- pDlg->_sortOrder = 1;
- pDlg->_sortHeader = pnmv->iSubItem;
- }
- ListView_SortItemsEx(pDlg->_hList, (CMPPROC)cmpProc, pDlg);
- } break;
-
- /*
- * show contact menu
- */
- case NM_RCLICK:
- {
- CItemData* pid = pDlg->ItemData(pDlg->_curSel);
- if (pid) {
- HMENU hPopup = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) pid->_hContact, 0);
- if (hPopup) {
- POINT pt;
- GetCursorPos(&pt);
- TrackPopupMenu(hPopup, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL);
- DestroyMenu(hPopup);
- }
- }
- } break;
-
- /*
- * handle double click on contact: show message dialog
- */
- case NM_DBLCLK:
- {
- CItemData* pid = pDlg->ItemData(((LPNMITEMACTIVATE)lParam)->iItem);
- if (pid) {
- CallService(MS_MSG_SENDMESSAGE,(WPARAM)pid->_hContact, NULL);
- }
+ CItemData *pid = pDlg->ItemData(pDlg->_curSel);
+ if (pid) {
+ HMENU hPopup = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)pid->_hContact, 0);
+ if (hPopup) {
+ POINT pt;
+ GetCursorPos(&pt);
+ TrackPopupMenu(hPopup, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL);
+ DestroyMenu(hPopup);
}
}
}
+ break;
+
+ // handle double click on contact: show message dialog
+ case NM_DBLCLK:
+ {
+ CItemData *pid = pDlg->ItemData(((LPNMITEMACTIVATE)lParam)->iItem);
+ if (pid)
+ CallService(MS_MSG_SENDMESSAGE,(WPARAM)pid->_hContact, NULL);
+ }
}
- } break;
+ }
+ break;
case WM_COMMAND:
- {
- if (PtrIsValid(pDlg)) {
- CItemData* pid = pDlg->ItemData(pDlg->_curSel);
+ if (PtrIsValid(pDlg)) {
+ CItemData* pid = pDlg->ItemData(pDlg->_curSel);
- // process contact menu command
- if (pid && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)pid->_hContact)) {
- break;
+ // process contact menu command
+ if (pid && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)pid->_hContact))
+ break;
+
+ switch (LOWORD(wParam)) {
+ // enable/disable reminder checkbox is clicked
+ case CHECK_REMIND:
+ if (pDlg->_bRemindEnable && HIWORD(wParam) == BN_CLICKED) {
+ BYTE checkState = Button_GetCheck((HWND)lParam);
+
+ EnableWindow(GetDlgItem(hDlg, EDIT_REMIND), checkState == BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg, SPIN_REMIND), checkState == BST_CHECKED);
+ if (pid && pid->_wReminderState != checkState)
+ pid->_wReminderState = checkState;
}
+ break;
- switch (LOWORD(wParam))
- {
+ // number of days to remind in advance is edited
+ case EDIT_REMIND:
+ if (pid && pDlg->_bRemindEnable && HIWORD(wParam) == EN_CHANGE) {
+ WORD wDaysBefore = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE);
+ if (pid->_wReminderState == BST_CHECKED && pid->_wDaysBefore != wDaysBefore) {
+ pid->_wDaysBefore = wDaysBefore;
+ }
+ }
+ break;
- /*
- * enable/disable reminder checkbox is clicked
- */
- case CHECK_REMIND:
- {
- if (pDlg->_bRemindEnable && HIWORD(wParam) == BN_CLICKED) {
- BYTE checkState = Button_GetCheck((HWND)lParam);
-
- EnableWindow(GetDlgItem(hDlg, EDIT_REMIND), checkState == BST_CHECKED);
- EnableWindow(GetDlgItem(hDlg, SPIN_REMIND), checkState == BST_CHECKED);
- if (pid && pid->_wReminderState != checkState) {
- pid->_wReminderState = checkState;
- }
- }
- } break;
-
- /*
- * number of days to remind in advance is edited
- */
- case EDIT_REMIND:
- {
- if (pid && pDlg->_bRemindEnable && HIWORD(wParam) == EN_CHANGE) {
- WORD wDaysBefore = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE);
- if (pid->_wReminderState == BST_CHECKED && pid->_wDaysBefore != wDaysBefore) {
- pid->_wDaysBefore = wDaysBefore;
- }
- }
- } break;
-
- /*
- * the filter to display only contacts which have an anniversary in a certain
- * period of time is enabled/disabled
- */
- case CHECK_DAYS:
- {
- if (HIWORD(wParam) == BN_CLICKED) {
- BYTE isChecked = Button_GetCheck((HWND)lParam);
- EnableWindow(GetDlgItem(hDlg, EDIT_DAYS), isChecked);
- EnableWindow(GetDlgItem(hDlg, TXT_DAYS), isChecked);
- pDlg->_filter.wDaysBefore = isChecked ? GetDlgItemInt(hDlg, EDIT_DAYS, NULL, FALSE) : (WORD)-1;
- pDlg->RebuildList();
- }
- } break;
-
- /*
- * the number of days a contact must have an anniversary in advance to be displayed is edited
- */
- case EDIT_DAYS:
- {
- if (HIWORD(wParam) == EN_CHANGE) {
- WORD wNewDays = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE);
- if (wNewDays != pDlg->_filter.wDaysBefore) {
- pDlg->_filter.wDaysBefore = wNewDays;
- pDlg->RebuildList();
- }
- }
- } break;
-
- /*
- * the filter selection of the filter combobox has changed
- */
- case COMBO_VIEW:
- {
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- pDlg->_filter.bFilterIndex = ComboBox_GetCurSel((HWND)lParam);
- pDlg->RebuildList();
- }
+ // the filter to display only contacts which have an anniversary in a certain
+ // period of time is enabled/disabled
+ case CHECK_DAYS:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ BYTE isChecked = Button_GetCheck((HWND)lParam);
+ EnableWindow(GetDlgItem(hDlg, EDIT_DAYS), isChecked);
+ EnableWindow(GetDlgItem(hDlg, TXT_DAYS), isChecked);
+ pDlg->_filter.wDaysBefore = isChecked ? GetDlgItemInt(hDlg, EDIT_DAYS, NULL, FALSE) : (WORD)-1;
+ pDlg->RebuildList();
+ }
+ break;
+
+ // the number of days a contact must have an anniversary in advance to be displayed is edited
+ case EDIT_DAYS:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ WORD wNewDays = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE);
+ if (wNewDays != pDlg->_filter.wDaysBefore) {
+ pDlg->_filter.wDaysBefore = wNewDays;
+ pDlg->RebuildList();
}
}
+ break;
+
+ // the filter selection of the filter combobox has changed
+ case COMBO_VIEW:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ pDlg->_filter.bFilterIndex = ComboBox_GetCurSel((HWND)lParam);
+ pDlg->RebuildList();
+ }
}
- } break;
+ }
+ break;
case WM_DRAWITEM:
return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
@@ -566,93 +502,81 @@ class CAnnivList return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
case WM_WINDOWPOSCHANGING:
- {
- if (PtrIsValid(pDlg)) {
- WINDOWPOS* wndPos = (WINDOWPOS*)lParam;
- if (!pDlg->_wmINIT && (wndPos->cx != 0 || wndPos->cy != 0)) {
- //win pos change
- if ( (wndPos->cx == pDlg->_rcWin.right - pDlg->_rcWin.left) &&
- (wndPos->cy == pDlg->_rcWin.bottom - pDlg->_rcWin.top)) {
- //win pos change (store new pos)
- GetWindowRect(hDlg, &pDlg->_rcWin);
+ if (PtrIsValid(pDlg)) {
+ WINDOWPOS *wndPos = (WINDOWPOS *)lParam;
+ if (!pDlg->_wmINIT && (wndPos->cx != 0 || wndPos->cy != 0)) {
+ //win pos change
+ if ((wndPos->cx == pDlg->_rcWin.right - pDlg->_rcWin.left) && (wndPos->cy == pDlg->_rcWin.bottom - pDlg->_rcWin.top))
+ //win pos change (store new pos)
+ GetWindowRect(hDlg, &pDlg->_rcWin);
+ //win size change
+ else {
+ // l change
+ if ((wndPos->cx < pDlg->_sizeMin.cx) && (wndPos->x > pDlg->_rcWin.left)) {
+ wndPos->x = wndPos->x + wndPos->cx - pDlg->_sizeMin.cx;
+ wndPos->cx = pDlg->_sizeMin.cx;
}
- //win size change
- else {
- // l change
- if ( (wndPos->cx < pDlg->_sizeMin.cx) && (wndPos->x > pDlg->_rcWin.left)) {
- wndPos->x = wndPos->x + wndPos->cx - pDlg->_sizeMin.cx;
- wndPos->cx = pDlg->_sizeMin.cx;
- }
- // r change
- else if (wndPos->cx < pDlg->_sizeMin.cx) {
- wndPos->cx = pDlg->_sizeMin.cx;
- }
-
- // t change
- if ( (wndPos->cy < pDlg->_sizeMin.cy) && (wndPos->y > pDlg->_rcWin.top)) {
- wndPos->y = wndPos->y + wndPos->cy - pDlg->_sizeMin.cy;
- wndPos->cy = pDlg->_sizeMin.cy;
- }
- // b change
- else if (wndPos->cy < pDlg->_sizeMin.cy) {
- wndPos->cy = pDlg->_sizeMin.cy;
- }
-
- pDlg->_rcWin.left = wndPos->x;
- pDlg->_rcWin.right = wndPos->x + wndPos->cx;
- pDlg->_rcWin.top = wndPos->y;
- pDlg->_rcWin.bottom = wndPos->y + wndPos->cy;
+ // r change
+ else if (wndPos->cx < pDlg->_sizeMin.cx)
+ wndPos->cx = pDlg->_sizeMin.cx;
+
+ // t change
+ if ((wndPos->cy < pDlg->_sizeMin.cy) && (wndPos->y > pDlg->_rcWin.top)) {
+ wndPos->y = wndPos->y + wndPos->cy - pDlg->_sizeMin.cy;
+ wndPos->cy = pDlg->_sizeMin.cy;
}
+ // b change
+ else if (wndPos->cy < pDlg->_sizeMin.cy)
+ wndPos->cy = pDlg->_sizeMin.cy;
+
+ pDlg->_rcWin.left = wndPos->x;
+ pDlg->_rcWin.right = wndPos->x + wndPos->cx;
+ pDlg->_rcWin.top = wndPos->y;
+ pDlg->_rcWin.bottom = wndPos->y + wndPos->cy;
}
+ }
- CAnchor anchor(wndPos, pDlg->_sizeMin);
- int anchorPos = CAnchor::ANCHOR_LEFT | CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_TOP;
+ CAnchor anchor(wndPos, pDlg->_sizeMin);
+ int anchorPos = CAnchor::ANCHOR_LEFT | CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_TOP;
- anchor.MoveCtrl(IDC_HEADERBAR, anchorPos);
- anchor.MoveCtrl(GROUP_STATS, anchorPos);
+ anchor.MoveCtrl(IDC_HEADERBAR, anchorPos);
+ anchor.MoveCtrl(GROUP_STATS, anchorPos);
- // birthday list
- anchor.MoveCtrl(EDIT_ANNIVERSARY_DATE, CAnchor::ANCHOR_ALL);
+ // birthday list
+ anchor.MoveCtrl(EDIT_ANNIVERSARY_DATE, CAnchor::ANCHOR_ALL);
- anchorPos = CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_BOTTOM;
+ anchorPos = CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_BOTTOM;
- // filter group
- anchor.MoveCtrl(GROUP_FILTER, anchorPos);
- anchor.MoveCtrl(COMBO_VIEW, anchorPos);
- anchor.MoveCtrl(CHECK_DAYS, anchorPos);
- anchor.MoveCtrl(EDIT_DAYS, anchorPos);
- anchor.MoveCtrl(TXT_DAYS, anchorPos);
+ // filter group
+ anchor.MoveCtrl(GROUP_FILTER, anchorPos);
+ anchor.MoveCtrl(COMBO_VIEW, anchorPos);
+ anchor.MoveCtrl(CHECK_DAYS, anchorPos);
+ anchor.MoveCtrl(EDIT_DAYS, anchorPos);
+ anchor.MoveCtrl(TXT_DAYS, anchorPos);
- // filter group
- anchor.MoveCtrl(GROUP_REMINDER, anchorPos);
- anchor.MoveCtrl(CHECK_REMIND, anchorPos);
- anchor.MoveCtrl(EDIT_REMIND, anchorPos);
- anchor.MoveCtrl(SPIN_REMIND, anchorPos);
- anchor.MoveCtrl(TXT_REMIND6, anchorPos);
- anchor.MoveCtrl(CHECK_POPUP, anchorPos);
- }
- } break;
+ // filter group
+ anchor.MoveCtrl(GROUP_REMINDER, anchorPos);
+ anchor.MoveCtrl(CHECK_REMIND, anchorPos);
+ anchor.MoveCtrl(EDIT_REMIND, anchorPos);
+ anchor.MoveCtrl(SPIN_REMIND, anchorPos);
+ anchor.MoveCtrl(TXT_REMIND6, anchorPos);
+ anchor.MoveCtrl(CHECK_POPUP, anchorPos);
+ }
+ break;
- /**
- * This message is sent if eighter the user clicked on the close button or
- * Miranda fires the ME_SYSTEM_SHUTDOWN event.
- **/
+ // This message is sent if eighter the user clicked on the close button or
+ // Miranda fires the ME_SYSTEM_SHUTDOWN event.
case WM_CLOSE:
- {
- DestroyWindow(hDlg);
- } break;
+ DestroyWindow(hDlg);
+ break;
- /**
- * If the anniversary list is destroyed somehow, the data class must be
- * deleted, too.
- **/
+ // If the anniversary list is destroyed somehow, the data class must be deleted, too.
case WM_DESTROY:
- {
- if (PtrIsValid(pDlg)) {
- SetUserData(hDlg, NULL);
- delete pDlg;
- }
- } break;
+ if (PtrIsValid(pDlg)) {
+ SetUserData(hDlg, NULL);
+ delete pDlg;
+ }
+ break;
}
return FALSE;
}
@@ -667,14 +591,14 @@ class CAnnivList * @retval 0 if successful
* @retval 1 if failed
**/
- BYTE AddColumn(int iSubItem, LPCTSTR pszText, int defaultWidth)
+ BYTE AddColumn(int iSubItem, LPCTSTR pszText, int defaultWidth)
{
LVCOLUMN lvc;
CHAR pszSetting[MAXSETTING];
mir_snprintf(pszSetting, SIZEOF(pszSetting), "AnnivDlg_Col%d", iSubItem);
lvc.cx = db_get_w(NULL, MODNAME, pszSetting, defaultWidth);
- lvc.mask = LVCF_WIDTH|LVCF_TEXT;
+ lvc.mask = LVCF_WIDTH | LVCF_TEXT;
lvc.iSubItem = iSubItem;
lvc.pszText = TranslateTS(pszText);
return ListView_InsertColumn(_hList, lvc.iSubItem++, &lvc) == -1;
@@ -690,11 +614,10 @@ class CAnnivList * @retval TRUE if successful
* @retval FALSE if failed
**/
- BYTE AddSubItem(int iItem, int iSubItem, LPTSTR pszText)
+ BYTE AddSubItem(int iItem, int iSubItem, LPTSTR pszText)
{
LVITEM lvi;
- if (iSubItem > 0)
- {
+ if (iSubItem > 0) {
lvi.iItem = iItem;
lvi.iSubItem = iSubItem;
lvi.pszText = pszText;
@@ -723,7 +646,7 @@ class CAnnivList lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = pszText;
- lvi.mask = LVIF_TEXT|TVIF_PARAM;
+ lvi.mask = LVIF_TEXT | TVIF_PARAM;
lvi.lParam = lParam;
return ListView_InsertItem(_hList, &lvi);
}
@@ -746,36 +669,26 @@ class CAnnivList int diff, iItem = -1;
CItemData *pdata;
- //
// first column: ETA
- //
diff = ad.CompareDays(mtNow);
- if (diff < 0)
- {
+ if (diff < 0)
diff += IsLeap(mtNow.Year() + 1) ? 366 : 365;
- }
// is filtered
- if (diff <= _filter.wDaysBefore)
- {
+ if (diff <= _filter.wDaysBefore) {
// read reminder options for the contact
ad.DBGetReminderOpts(hContact);
- if ((_filter.bFilterIndex != FILTER_DISABLED_REMINDER) || (ad.RemindOption() == BST_UNCHECKED))
- {
+ if ((_filter.bFilterIndex != FILTER_DISABLED_REMINDER) || (ad.RemindOption() == BST_UNCHECKED)) {
// set default offset if required
- if (ad.RemindOffset() == (WORD)-1)
- {
+ if (ad.RemindOffset() == (WORD)-1) {
ad.RemindOffset(wDaysBefore);
// create data object
pdata = new CItemData(hContact, ad);
- if (!pdata)
- {
+ if (!pdata)
return FALSE;
- }
// add item
iItem = AddItem(_itot(diff, szText, 10), (LPARAM)pdata);
- if (iItem == -1)
- {
+ if (iItem == -1) {
delete pdata;
return FALSE;
}
@@ -784,7 +697,7 @@ class CAnnivList AddSubItem(iItem, COLUMN_CONTACT, DB::Contact::DisplayName(hContact));
// third column: protocol
- TCHAR* ptszProto = mir_a2t(pszProto);
+ TCHAR *ptszProto = mir_a2t(pszProto);
AddSubItem(iItem, COLUMN_PROTO, ptszProto);
mir_free(ptszProto);
@@ -805,29 +718,26 @@ class CAnnivList return TRUE;
}
- /**
- * This method clears the list and adds contacts again, according to the current filter settings.
- **/
- void RebuildList()
+ // This method clears the list and adds contacts again, according to the current filter settings.
+ void RebuildList()
{
- LPSTR pszProto;
- MTime mtNow;
- MAnnivDate ad;
- int i = 0;
- DWORD age = 0;
- WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
- WORD numMale = 0;
- WORD numFemale = 0;
- WORD numContacts = 0;
- WORD numBirthContacts = 0;
+ LPSTR pszProto;
+ MTime mtNow;
+ MAnnivDate ad;
+ int i = 0;
+ DWORD age = 0;
+ WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
+ WORD numMale = 0;
+ WORD numFemale = 0;
+ WORD numContacts = 0;
+ WORD numBirthContacts = 0;
ShowWindow(_hList, SW_HIDE);
DeleteAllItems();
mtNow.GetLocalTime();
// insert the items into the list
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// ignore meta subcontacts here, as they are not interesting.
if (!db_mc_isSub(hContact)) {
// filter protocol
@@ -838,7 +748,6 @@ class CAnnivList case 'M':
numMale++;
break;
-
case 'F':
numFemale++;
}
@@ -871,20 +780,15 @@ class CAnnivList SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? max(0, (age - (age % numBirthContacts)) / numBirthContacts) : 0, FALSE);
}
- /**
- * This method deletes all items from the listview
- **/
- void DeleteAllItems()
+ // This method deletes all items from the listview
+ void DeleteAllItems()
{
CItemData *pid;
- for (int i = 0; i < _numRows; i++)
- {
+ for (int i = 0; i < _numRows; i++) {
pid = ItemData(i);
- if (pid)
- {
+ if (pid)
delete pid;
- }
}
ListView_DeleteAllItems(_hList);
_numRows = 0;
@@ -897,36 +801,29 @@ class CAnnivList *
* @return pointer to the data strucutre on success or NULL otherwise.
**/
- CItemData* ItemData(int iItem)
+ CItemData *ItemData(int iItem)
{
- if (_hList && iItem >= 0 && iItem < _numRows)
- {
+ if (_hList && iItem >= 0 && iItem < _numRows) {
LVITEM lvi;
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
lvi.iSubItem = 0;
if (ListView_GetItem(_hList, &lvi) && PtrIsValid(lvi.lParam))
- {
- return (CItemData*)lvi.lParam;
- }
+ return (CItemData *)lvi.lParam;
}
return NULL;
}
- /**
- * This method loads all filter settings from db
- **/
- void LoadFilter()
+ // This method loads all filter settings from db
+ void LoadFilter()
{
_filter.wDaysBefore = db_get_w(NULL, MODNAME, SET_ANNIVLIST_FILTER_DAYS, 9);
_filter.bFilterIndex = db_get_b(NULL, MODNAME, SET_ANNIVLIST_FILTER_INDEX, 0);
}
- /**
- * This method saves all filter settings to db
- **/
- void SaveFilter()
+ // This method saves all filter settings to db
+ void SaveFilter()
{
if (_hDlg) {
db_set_w(NULL, MODNAME, SET_ANNIVLIST_FILTER_DAYS, (WORD)GetDlgItemInt(_hDlg, EDIT_DAYS, NULL, FALSE));
@@ -937,10 +834,8 @@ class CAnnivList public:
- /**
- * This is the default constructor.
- **/
- CAnnivList()
+ // This is the default constructor.
+ CAnnivList()
{
_hList = NULL;
_sortHeader = 0;
@@ -960,10 +855,8 @@ public: }
}
- /**
- * This is the default destructor.
- **/
- ~CAnnivList()
+ // This is the default destructor.
+ ~CAnnivList()
{
// delete the shutdown hook
if (_mHookExit) {
@@ -1027,23 +920,20 @@ public: *
* @return always 0
**/
-INT_PTR DlgAnniversaryListShow(WPARAM wParam, LPARAM lParam)
+INT_PTR DlgAnniversaryListShow(WPARAM wParam, LPARAM lParam)
{
if (!gpDlg) {
- try
- {
+ try {
myGlobals.WantAeroAdaption = db_get_b(NULL, MODNAME, SET_PROPSHEET_AEROADAPTION, TRUE);
gpDlg = new CAnnivList();
}
- catch(...)
- {
+ catch(...) {
delete gpDlg;
gpDlg = NULL;
}
}
- else {
+ else
gpDlg->BringToFront();
- }
return 0;
}
@@ -1062,7 +952,6 @@ INT_PTR DlgAnniversaryListShow(WPARAM wParam, LPARAM lParam) *
* @return nothing
**/
-
void DlgAnniversaryListOnTopToolBarLoaded()
{
TTBButton ttb = { sizeof(ttb) };
@@ -1085,10 +974,10 @@ void DlgAnniversaryListLoadModule() CreateServiceFunction(MS_USERINFO_REMINDER_LIST, DlgAnniversaryListShow);
HOTKEYDESC hk = { 0 };
- hk.cbSize = sizeof(HOTKEYDESC);
- hk.pszSection = MODNAME;
- hk.pszName = "AnniversaryList";
- hk.pszDescription = LPGEN("Popup Anniversary list");
- hk.pszService = MS_USERINFO_REMINDER_LIST;
+ hk.cbSize = sizeof(HOTKEYDESC);
+ hk.pszSection = MODNAME;
+ hk.pszName = "AnniversaryList";
+ hk.pszDescription = LPGEN("Popup anniversary list");
+ hk.pszService = MS_USERINFO_REMINDER_LIST;
Hotkey_Register(&hk);
}
|