From dab02845fea8031dd3d7864dc1efc211a434f969 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 14 Jul 2012 19:40:31 +0000 Subject: - code cleaning - sync git-svn-id: http://svn.miranda-ng.org/main/trunk@975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/clc.cpp | 64 +++++++++---------- src/modules/clist/clc.h | 36 +++++------ src/modules/clist/clcfiledrop.cpp | 2 +- src/modules/clist/clcidents.cpp | 18 +++--- src/modules/clist/clcitems.cpp | 40 ++++++------ src/modules/clist/clcutils.cpp | 131 +++++++++++++++++--------------------- src/modules/clist/clistcore.cpp | 4 +- src/modules/clist/contact.cpp | 2 +- 8 files changed, 143 insertions(+), 154 deletions(-) (limited to 'src/modules/clist') diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp index f7d9ba1411..4097f5a0f3 100644 --- a/src/modules/clist/clc.cpp +++ b/src/modules/clist/clc.cpp @@ -393,8 +393,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *) lParam; if (dbcws->value.type == DBVT_ASCIIZ || dbcws->value.type == DBVT_UTF8) { int groupId = atoi(dbcws->szSetting) + 1; - struct ClcContact *contact; - struct ClcGroup *group; + ClcContact *contact; + ClcGroup *group; TCHAR szFullName[512]; int i, nameLen, eq; //check name of group and ignore message if just being expanded/collapsed @@ -472,7 +472,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case INTM_GROUPCHANGED: { - struct ClcContact *contact; + ClcContact *contact; BYTE iExtraImage[MAXEXTRACOLUMNS]; BYTE flags = 0; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) @@ -503,13 +503,13 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case INTM_ICONCHANGED: { - struct ClcContact *contact = NULL; - struct ClcGroup *group = NULL; + ClcContact *contact = NULL; + ClcGroup *group = NULL; int recalcScrollBar = 0, shouldShow; WORD status; char *szProto; HANDLE hSelItem = NULL; - struct ClcContact *selcontact = NULL; + ClcContact *selcontact = NULL; szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto == NULL) @@ -553,7 +553,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, dat->needsResort = 1; } if (hSelItem) { - struct ClcGroup *selgroup; + ClcGroup *selgroup; if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); else @@ -564,7 +564,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case INTM_NAMECHANGED: { - struct ClcContact *contact; + ClcContact *contact; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) break; @@ -575,7 +575,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case INTM_PROTOCHANGED: { - struct ClcContact *contact = NULL; + ClcContact *contact = NULL; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) break; contact->proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); @@ -587,7 +587,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case INTM_NOTONLISTCHANGED: { DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *) lParam; - struct ClcContact *contact; + ClcContact *contact; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) break; if (contact->type != CLCIT_CONTACT) @@ -607,7 +607,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, { WORD apparentMode; char *szProto; - struct ClcContact *contact; + ClcContact *contact; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) break; szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); @@ -631,7 +631,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case INTM_IDLECHANGED: { char *szProto; - struct ClcContact *contact; + ClcContact *contact; if ( !cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) break; szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); @@ -764,8 +764,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } if (changeGroupExpand) { int hit; - struct ClcContact *contact; - struct ClcGroup *group; + ClcContact *contact; + ClcGroup *group; if (dat->filterSearch) { // this shouldn't clear filtering, but it should refresh highlighting somehow? } else { @@ -816,7 +816,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, else if (wParam < ' ') break; else if (wParam == ' ' && dat->szQuickSearch[0] == '\0' && GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_CHECKBOXES) { - struct ClcContact *contact; + ClcContact *contact; NMCLISTCONTROL nm; if (cli.pfnGetRowByIndex(dat, dat->selection, &contact, NULL) == -1) break; @@ -889,7 +889,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, break; case TIMERID_INFOTIP: { CLCINFOTIP it; - struct ClcContact *contact; + ClcContact *contact; int hit; RECT clRect; POINT ptClientOffset = { 0 }; @@ -938,8 +938,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_MBUTTONDOWN: case WM_LBUTTONDOWN: { - struct ClcContact *contact; - struct ClcGroup *group; + ClcContact *contact; + ClcGroup *group; int hit; DWORD hitFlags; @@ -968,8 +968,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, if (hit != -1 && contact->type == CLCIT_GROUP) if (hitFlags & CLCHT_ONITEMICON) { - struct ClcGroup *selgroup; - struct ClcContact *selcontact; + ClcGroup *selgroup; + ClcContact *selcontact; dat->selection = cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, &selgroup); cli.pfnSetGroupExpand(hwnd, dat, contact->group, -1); if (dat->selection != -1) { @@ -1076,7 +1076,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, target = cli.pfnGetDropTargetInformation(hwnd, dat, pt); if (dat->dragStage & DRAGSTAGEF_OUTSIDE && target != DROPTARGET_OUTSIDE) { NMCLISTCONTROL nm; - struct ClcContact *contact; + ClcContact *contact; cli.pfnGetRowByIndex(dat, dat->iDragItem, &contact, NULL); nm.hdr.code = CLN_DRAGSTOP; nm.hdr.hwndFrom = hwnd; @@ -1099,7 +1099,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case DROPTARGET_OUTSIDE: { NMCLISTCONTROL nm; - struct ClcContact *contact; + ClcContact *contact; if (pt.x >= 0 && pt.x < clRect.right && ((pt.y < 0 && pt.y > -dat->dragAutoScrollHeight) @@ -1128,7 +1128,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } default: { - struct ClcGroup *group; + ClcGroup *group; cli.pfnGetRowByIndex(dat, dat->iDragItem, NULL, &group); if (group->parent) hNewCursor = LoadCursor(cli.hInst, MAKEINTRESOURCE(IDC_DROPUSER)); @@ -1166,7 +1166,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, break; case DROPTARGET_ONGROUP: { - struct ClcContact *contactn, *contacto; + ClcContact *contactn, *contacto; cli.pfnGetRowByIndex(dat, dat->selection, &contactn, NULL); cli.pfnGetRowByIndex(dat, dat->iDragItem, &contacto, NULL); if (contacto->type == CLCIT_CONTACT) //dropee is a contact @@ -1181,8 +1181,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case DROPTARGET_INSERTION: { - struct ClcContact *contact, *destcontact; - struct ClcGroup *destgroup; + ClcContact *contact, *destcontact; + ClcGroup *destgroup; cli.pfnGetRowByIndex(dat, dat->iDragItem, &contact, NULL); if (cli.pfnGetRowByIndex(dat, dat->iInsertionMark, &destcontact, &destgroup) == -1 || destgroup != contact->group->parent) CallService(MS_CLIST_GROUPMOVEBEFORE, contact->groupId, 0); @@ -1198,7 +1198,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case DROPTARGET_OUTSIDE: { NMCLISTCONTROL nm; - struct ClcContact *contact; + ClcContact *contact; cli.pfnGetRowByIndex(dat, dat->iDragItem, &contact, NULL); nm.hdr.code = CLN_DROPPED; nm.hdr.hwndFrom = hwnd; @@ -1211,8 +1211,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } default: { - struct ClcGroup *group; - struct ClcContact *contact; + ClcGroup *group; + ClcContact *contact; cli.pfnGetRowByIndex(dat, dat->iDragItem, &contact, &group); if (group->parent) { //move to root if (contact->type == CLCIT_CONTACT) //dropee is a contact @@ -1230,7 +1230,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_LBUTTONDBLCLK: { - struct ClcContact *contact; + ClcContact *contact; DWORD hitFlags; ReleaseCapture(); dat->iHotTrack = -1; @@ -1254,7 +1254,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } case WM_CONTEXTMENU: { - struct ClcContact *contact; + ClcContact *contact; HMENU hMenu = NULL; POINT pt; DWORD hitFlags; @@ -1320,7 +1320,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_COMMAND: { - struct ClcContact *contact; + ClcContact *contact; int hit = cli.pfnGetRowByIndex(dat, dat->selection, &contact, NULL); if (hit == -1) break; diff --git a/src/modules/clist/clc.h b/src/modules/clist/clc.h index bbcdf85528..b8bb4d9035 100644 --- a/src/modules/clist/clc.h +++ b/src/modules/clist/clc.h @@ -39,25 +39,25 @@ HMENU fnBuildGroupPopupMenu(struct ClcGroup* group); LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); /* clcidents.c */ -int fnGetRowsPriorTo(struct ClcGroup *group, struct ClcGroup *subgroup, int contactIndex); -int fnFindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, struct ClcContact **contact, struct ClcGroup **subgroup, int *isVisible); -int fnGetRowByIndex(struct ClcData *dat, int testindex, struct ClcContact **contact, struct ClcGroup **subgroup); -HANDLE fnContactToHItem(struct ClcContact* contact); -HANDLE fnContactToItemHandle(struct ClcContact * contact, DWORD * nmFlags); +int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); +int fnFindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); +int fnGetRowByIndex(struct ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); +HANDLE fnContactToHItem(ClcContact* contact); +HANDLE fnContactToItemHandle(ClcContact * contact, DWORD * nmFlags); /* clcitems.c */ struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers); -struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, struct ClcGroup *group, struct ClcContact *contact, int updateTotalCount); +struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount); -void fnFreeContact(struct ClcContact *p); -void fnFreeGroup(struct ClcGroup *group); -int fnAddInfoItemToGroup(struct ClcGroup *group, int flags, const TCHAR *pszText); -int fnAddItemToGroup(struct ClcGroup *group, int iAboveItem); +void fnFreeContact(ClcContact *p); +void fnFreeGroup(ClcGroup *group); +int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText); +int fnAddItemToGroup(ClcGroup *group, int iAboveItem); void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int updateTotalCount, int checkHideOffline); -int fnAddContactToGroup(struct ClcData *dat, struct ClcGroup *group, HANDLE hContact); +int fnAddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact); void fnDeleteItemFromTree(HWND hwnd, HANDLE hItem); void fnRebuildEntireList(HWND hwnd, struct ClcData *dat); -int fnGetGroupContentsCount(struct ClcGroup *group, int visibleOnly); +int fnGetGroupContentsCount(ClcGroup *group, int visibleOnly); void fnSortCLC(HWND hwnd, struct ClcData *dat, int useInsertionSort); void fnSaveStateAndRebuildList(HWND hwnd, struct ClcData *dat); @@ -65,18 +65,18 @@ void fnSaveStateAndRebuildList(HWND hwnd, struct ClcData *dat); LRESULT fnProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); /* clcutils.c */ -char* fnGetGroupCountsText(struct ClcData *dat, struct ClcContact *contact); -int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcContact **contact, struct ClcGroup **group, DWORD * flags); +char* fnGetGroupCountsText(struct ClcData *dat, ClcContact *contact); +int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD * flags); void fnScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth); void fnEnsureVisible(HWND hwnd, struct ClcData *dat, int iItem, int partialOk); void fnRecalcScrollBar(HWND hwnd, struct ClcData *dat); -void fnSetGroupExpand(HWND hwnd, struct ClcData *dat, struct ClcGroup *group, int newState); +void fnSetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState); void fnDoSelectionDefaultAction(HWND hwnd, struct ClcData *dat); int fnFindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefixOk); void fnEndRename(HWND hwnd, struct ClcData *dat, int save); void fnDeleteFromContactList(HWND hwnd, struct ClcData *dat); void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat); -void fnCalcEipPosition(struct ClcData *dat, struct ClcContact *contact, struct ClcGroup *group, POINT *result); +void fnCalcEipPosition(struct ClcData *dat, ClcContact *contact, ClcGroup *group, POINT *result); int fnGetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt); int fnClcStatusToPf2(int status); int fnIsHiddenMode(struct ClcData *dat, int status); @@ -88,7 +88,7 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour); void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour); void fnLoadClcOptions(HWND hwnd, struct ClcData *dat); void fnRecalculateGroupCheckboxes(HWND hwnd, struct ClcData *dat); -void fnSetGroupChildCheckboxes(struct ClcGroup *group, int checked); +void fnSetGroupChildCheckboxes(ClcGroup *group, int checked); void fnInvalidateItem(HWND hwnd, struct ClcData *dat, int iItem); int fnGetRowBottomY(struct ClcData *dat, int item); @@ -180,7 +180,7 @@ void fnDrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, HICON eventIcon); /* contact.c */ void fnChangeContactIcon (HANDLE hContact, int iIcon, int add); void fnLoadContactTree (void); -int fnCompareContacts (const struct ClcContact *contact1, const struct ClcContact *contact2); +int fnCompareContacts (const ClcContact *contact1, const ClcContact *contact2); void fnSortContacts (void); int fnSetHideOffline (WPARAM wParam, LPARAM lParam); diff --git a/src/modules/clist/clcfiledrop.cpp b/src/modules/clist/clcfiledrop.cpp index 10d101e705..a190e714c5 100644 --- a/src/modules/clist/clcfiledrop.cpp +++ b/src/modules/clist/clcfiledrop.cpp @@ -71,7 +71,7 @@ ULONG CDropTarget::Release(void) static HANDLE HContactFromPoint(HWND hwnd, struct ClcData *dat, int x, int y, int *hitLine) { int hit; - struct ClcContact *contact; + ClcContact *contact; DWORD hitFlags; char *szProto; DWORD protoCaps; diff --git a/src/modules/clist/clcidents.cpp b/src/modules/clist/clcidents.cpp index 60e8fb6c3b..ad144c04d3 100644 --- a/src/modules/clist/clcidents.cpp +++ b/src/modules/clist/clcidents.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* the CLC uses 3 different ways to identify elements in its list, this file contains routines to convert between them. -1) struct ClcContact/struct ClcGroup pair. Only ever used within the duration +1) ClcContact/ClcGroup pair. Only ever used within the duration of a single operation, but used at some point in nearly everything 2) index integer. The 0-based number of the item from the top. Only visible items are counted (ie not closed groups). Used for saving selection and drag @@ -40,7 +40,7 @@ contains routines to convert between them. 2->1: GetRowByIndex() */ -int fnGetRowsPriorTo(struct ClcGroup *group, struct ClcGroup *subgroup, int contactIndex) +int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) { int count = 0; @@ -70,16 +70,16 @@ int fnGetRowsPriorTo(struct ClcGroup *group, struct ClcGroup *subgroup, int cont return -1; } -int fnFindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, struct ClcContact **contact, struct ClcGroup **subgroup, int *isVisible) +int fnFindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) { int index = 0; int nowVisible = 1; - struct ClcGroup *group = &dat->list; + ClcGroup *group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { - struct ClcGroup *tgroup; + ClcGroup *tgroup; group = group->parent; if (group == NULL) break; @@ -135,10 +135,10 @@ int fnFindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, struct ClcContact * return 0; } -int fnGetRowByIndex(struct ClcData *dat, int testindex, struct ClcContact **contact, struct ClcGroup **subgroup) +int fnGetRowByIndex(struct ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup) { int index = 0; - struct ClcGroup *group = &dat->list; + ClcGroup *group = &dat->list; if (testindex<0) return (-1); @@ -170,7 +170,7 @@ int fnGetRowByIndex(struct ClcData *dat, int testindex, struct ClcContact **cont return -1; } -HANDLE fnContactToHItem(struct ClcContact * contact) +HANDLE fnContactToHItem(ClcContact * contact) { switch (contact->type) { case CLCIT_CONTACT: @@ -183,7 +183,7 @@ HANDLE fnContactToHItem(struct ClcContact * contact) return NULL; } -HANDLE fnContactToItemHandle(struct ClcContact * contact, DWORD * nmFlags) +HANDLE fnContactToItemHandle(ClcContact * contact, DWORD * nmFlags) { switch (contact->type) { case CLCIT_CONTACT: diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp index f52d0bc234..554cb80dcf 100644 --- a/src/modules/clist/clcitems.cpp +++ b/src/modules/clist/clcitems.cpp @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //routines for managing adding/removal of items in the list, including sorting -int fnAddItemToGroup(struct ClcGroup *group, int iAboveItem) +int fnAddItemToGroup(ClcGroup *group, int iAboveItem) { - struct ClcContact* newItem = cli.pfnCreateClcContact(); + ClcContact* newItem = cli.pfnCreateClcContact(); newItem->type = CLCIT_DIVIDER; newItem->flags = 0; newItem->szText[0] = '\0'; @@ -40,7 +40,7 @@ int fnAddItemToGroup(struct ClcGroup *group, int iAboveItem) struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { TCHAR *pBackslash, *pNextField, szThisField[ SIZEOF(dat->list.cl.items[0]->szText) ]; - struct ClcGroup *group = &dat->list; + ClcGroup *group = &dat->list; int i, compareResult; dat->needsResort = 1; @@ -89,7 +89,7 @@ struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, group->cl.items[i]->type = CLCIT_GROUP; lstrcpyn(group->cl.items[i]->szText, szThisField, SIZEOF(group->cl.items[i]->szText)); group->cl.items[i]->groupId = (WORD) (pNextField ? 0 : groupId); - group->cl.items[i]->group = (struct ClcGroup *) mir_alloc(sizeof(struct ClcGroup)); + group->cl.items[i]->group = (ClcGroup *) mir_alloc(sizeof(struct ClcGroup)); group->cl.items[i]->group->parent = group; group = group->cl.items[i]->group; memset(&group->cl, 0, sizeof(group->cl)); @@ -120,14 +120,14 @@ struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, return group; } -void fnFreeContact(struct ClcContact* p) +void fnFreeContact(ClcContact* p) { if (p->type == CLCIT_GROUP) { cli.pfnFreeGroup(p->group); mir_free(p->group); } } -void fnFreeGroup(struct ClcGroup *group) +void fnFreeGroup(ClcGroup *group) { int i; for (i=0; i < group->cl.count; i++) { @@ -141,7 +141,7 @@ void fnFreeGroup(struct ClcGroup *group) } static int iInfoItemUniqueHandle = 0; -int fnAddInfoItemToGroup(struct ClcGroup *group, int flags, const TCHAR *pszText) +int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) { int i=0; @@ -167,7 +167,7 @@ int fnAddInfoItemToGroup(struct ClcGroup *group, int flags, const TCHAR *pszText return i; } -int fnAddContactToGroup(struct ClcData *dat, struct ClcGroup *group, HANDLE hContact) +int fnAddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact) { char *szProto; WORD apparentMode; @@ -218,7 +218,7 @@ int fnAddContactToGroup(struct ClcData *dat, struct ClcGroup *group, HANDLE hCon void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int updateTotalCount, int checkHideOffline) { - struct ClcGroup *group; + ClcGroup *group; DBVARIANT dbv; DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); WORD status = ID_STATUS_OFFLINE; @@ -286,7 +286,7 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int upd group->totalMembers++; } -struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, struct ClcGroup *group, struct ClcContact *contact, int updateTotalCount) +struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount) { int iContact; if ((iContact = List_IndexOf((SortedList*)&group->cl, contact)) == -1) @@ -321,8 +321,8 @@ struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, struct ClcGroup *group, struct void fnDeleteItemFromTree(HWND hwnd, HANDLE hItem) { - struct ClcContact *contact; - struct ClcGroup *group; + ClcContact *contact; + ClcGroup *group; struct ClcData *dat = (struct ClcData *) GetWindowLongPtr(hwnd, 0); dat->needsResort = 1; @@ -361,7 +361,7 @@ void fnRebuildEntireList(HWND hwnd, struct ClcData *dat) char *szProto; DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); HANDLE hContact; - struct ClcGroup *group; + ClcGroup *group; DBVARIANT dbv; dat->list.expanded = 1; @@ -445,10 +445,10 @@ void fnRebuildEntireList(HWND hwnd, struct ClcData *dat) cli.pfnSortCLC(hwnd, dat, 0); } -int fnGetGroupContentsCount(struct ClcGroup *group, int visibleOnly) +int fnGetGroupContentsCount(ClcGroup *group, int visibleOnly) { int count = group->cl.count; - struct ClcGroup *topgroup = group; + ClcGroup *topgroup = group; group->scanIndex = 0; for (;;) { @@ -486,10 +486,10 @@ static int __cdecl ContactSortProc(const void* p1, const void* p2) return (int)((INT_PTR) contact2[0]->hContact - (INT_PTR) contact1[0]->hContact); } -static void InsertionSort(struct ClcContact **pContactArray, int nArray, int (*CompareProc) (const void *, const void *)) +static void InsertionSort(ClcContact **pContactArray, int nArray, int (*CompareProc) (const void *, const void *)) { int i, j; - struct ClcContact* testElement; + ClcContact* testElement; for (i = 1; i < nArray; i++) { if (CompareProc(&pContactArray[i - 1], &pContactArray[i]) > 0) { @@ -502,7 +502,7 @@ static void InsertionSort(struct ClcContact **pContactArray, int nArray, int (*C pContactArray[j] = testElement; } } } -static void SortGroup(struct ClcData *dat, struct ClcGroup *group, int useInsertionSort) +static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort) { int i, sortCount; @@ -556,8 +556,8 @@ static void SortGroup(struct ClcData *dat, struct ClcGroup *group, int useInsert void fnSortCLC(HWND hwnd, struct ClcData *dat, int useInsertionSort) { - struct ClcContact *selcontact; - struct ClcGroup *group = &dat->list, *selgroup; + ClcContact *selcontact; + ClcGroup *group = &dat->list, *selgroup; HANDLE hSelItem; if (dat->needsResort) { diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index 6c1b1e94e7..6323d4c863 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -27,18 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HANDLE hHideInfoTipEvent; -char* fnGetGroupCountsText(struct ClcData *dat, struct ClcContact *contact) +char* fnGetGroupCountsText(struct ClcData *dat, ClcContact *contact) { - static char szName[32]; - int onlineCount, totalCount; - struct ClcGroup *group, *topgroup; - if (contact->type != CLCIT_GROUP || !(dat->exStyle & CLS_EX_SHOWGROUPCOUNTS)) return ""; - group = topgroup = contact->group; - onlineCount = 0; - totalCount = group->totalMembers; + ClcGroup *group = contact->group, *topgroup = group; + int onlineCount = 0; + int totalCount = group->totalMembers; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { @@ -59,26 +55,26 @@ char* fnGetGroupCountsText(struct ClcData *dat, struct ClcContact *contact) } if (onlineCount == 0 && dat->exStyle & CLS_EX_HIDECOUNTSWHENEMPTY) return ""; + + static char szName[32]; mir_snprintf(szName, SIZEOF(szName), "(%u/%u)", onlineCount, totalCount); return szName; } -int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcContact **contact, struct ClcGroup **group, DWORD * flags) +int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD * flags) { ClcContact *hitcontact = NULL; ClcGroup *hitgroup = NULL; int hit, indent, width, i; int checkboxWidth; SIZE textSize; - HDC hdc; - RECT clRect; HFONT hFont; DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); - POINT pt; if (flags) *flags = 0; + POINT pt; pt.x = testx; pt.y = testy; ClientToScreen(hwnd, &pt); @@ -99,8 +95,9 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcCo return -1; } } - while (hwndParent); + while (hwndParent); + RECT clRect; GetClientRect(hwnd, &clRect); if (testx < 0 || testy < 0 || testy >= clRect.bottom || testx >= clRect.right) { if (flags) { @@ -166,7 +163,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcCo return hit; } } - hdc = GetDC(hwnd); + HDC hdc = GetDC(hwnd); if (hitcontact->type == CLCIT_GROUP) hFont = (HFONT)SelectObject(hdc, dat->fontInfo[FONTID_GROUPS].hFont); else @@ -303,7 +300,7 @@ void fnRecalcScrollBar(HWND hwnd, struct ClcData *dat) SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) & nm); } -void fnSetGroupExpand(HWND hwnd, struct ClcData *dat, struct ClcGroup *group, int newState) +void fnSetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState) { int contentCount; int groupy; @@ -344,7 +341,7 @@ void fnSetGroupExpand(HWND hwnd, struct ClcData *dat, struct ClcGroup *group, in void fnDoSelectionDefaultAction(HWND hwnd, struct ClcData *dat) { - struct ClcContact *contact; + ClcContact *contact; if (dat->selection == -1) return; @@ -359,7 +356,7 @@ void fnDoSelectionDefaultAction(HWND hwnd, struct ClcData *dat) int fnFindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefixOk) { - struct ClcGroup *group = &dat->list; + ClcGroup *group = &dat->list; int testlen = lstrlen(text); group->scanIndex = 0; @@ -374,7 +371,7 @@ int fnFindRowByText(HWND hwnd, struct ClcData *dat, const TCHAR *text, int prefi if (group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER) { if ((prefixOk && !_tcsnicmp(text, group->cl.items[group->scanIndex]->szText, testlen)) || ( !prefixOk && !lstrcmpi(text, group->cl.items[group->scanIndex]->szText))) { - struct ClcGroup *contactGroup = group; + ClcGroup *contactGroup = group; int contactScanIndex = group->scanIndex; for (; group; group = group->parent) cli.pfnSetGroupExpand(hwnd, dat, group, 1); @@ -434,7 +431,7 @@ void fnEndRename(HWND, struct ClcData *dat, int save) void fnDeleteFromContactList(HWND hwnd, struct ClcData *dat) { - struct ClcContact *contact; + ClcContact *contact; if (dat->selection == -1) return; dat->szQuickSearch[0] = 0; @@ -481,11 +478,9 @@ static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPara void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat) { - struct ClcContact *contact; - struct ClcGroup *group; - RECT clRect; + ClcContact *contact; + ClcGroup *group; POINT pt; - int h; KillTimer(hwnd, TIMERID_RENAME); ReleaseCapture(); @@ -495,9 +490,11 @@ void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat) return; if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP) return; + + RECT clRect; GetClientRect(hwnd, &clRect); cli.pfnCalcEipPosition(dat, contact, group, &pt); - h = cli.pfnGetRowHeight(dat, dat->selection); + int h = cli.pfnGetRowHeight(dat, dat->selection); dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, pt.x, pt.y, clRect.right - pt.x, h, hwnd, NULL, cli.hInst, NULL); OldRenameEditWndProc = (WNDPROC) SetWindowLongPtr(dat->hwndRenameEdit, GWLP_WNDPROC, (LONG_PTR) RenameEditSubclassProc); SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM) (contact->type == CLCIT_GROUP ? dat->fontInfo[FONTID_GROUPS].hFont : dat->fontInfo[FONTID_CONTACTS].hFont), 0); @@ -507,7 +504,7 @@ void fnBeginRenameSelection(HWND hwnd, struct ClcData *dat) SetFocus(dat->hwndRenameEdit); } -void fnCalcEipPosition(struct ClcData *dat, struct ClcContact *, struct ClcGroup *group, POINT *result) +void fnCalcEipPosition(struct ClcData *dat, ClcContact *, ClcGroup *group, POINT *result) { int indent; for (indent = 0; group->parent; indent++, group = group->parent); @@ -518,18 +515,16 @@ void fnCalcEipPosition(struct ClcData *dat, struct ClcContact *, struct ClcGroup int fnGetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt) { RECT clRect; - int hit; - struct ClcContact *contact, *movecontact; - struct ClcGroup *group, *movegroup; - DWORD hitFlags; - GetClientRect(hwnd, &clRect); dat->selection = dat->iDragItem; dat->iInsertionMark = -1; if ( !PtInRect(&clRect, pt)) return DROPTARGET_OUTSIDE; - hit = cli.pfnHitTest(hwnd, dat, pt.x, pt.y, &contact, &group, &hitFlags); + ClcContact *contact, *movecontact; + ClcGroup *group, *movegroup; + DWORD hitFlags; + int hit = cli.pfnHitTest(hwnd, dat, pt.x, pt.y, &contact, &group, &hitFlags); cli.pfnGetRowByIndex(dat, dat->iDragItem, &movecontact, &movegroup); if (hit == dat->iDragItem) return DROPTARGET_ONSELF; @@ -537,8 +532,8 @@ int fnGetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt) return DROPTARGET_ONNOTHING; if (movecontact->type == CLCIT_GROUP) { - struct ClcContact *bottomcontact = NULL, *topcontact = NULL; - struct ClcGroup *topgroup = NULL; + ClcContact *bottomcontact = NULL, *topcontact = NULL; + ClcGroup *topgroup = NULL; int topItem = -1, bottomItem = -1; int ok = 0; if (pt.y + dat->yScroll < cli.pfnGetRowTopY(dat, hit) + dat->insertionMarkHitHeight) { @@ -623,10 +618,10 @@ int fnIsHiddenMode(struct ClcData *dat, int status) void fnHideInfoTip(HWND, struct ClcData *dat) { - CLCINFOTIP it = { 0 }; - if (dat->hInfoTipItem == NULL) return; + + CLCINFOTIP it = { 0 }; it.isGroup = IsHContactGroup(dat->hInfoTipItem); it.hItem = (HANDLE) ((UINT_PTR) dat->hInfoTipItem & ~HCONTACT_ISGROUP); it.cbSize = sizeof(it); @@ -717,31 +712,29 @@ void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour) void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) { dat->rowHeight = DBGetContactSettingByte(NULL, "CLC", "RowHeight", CLCDEFAULT_ROWHEIGHT); - { - int i; - LOGFONT lf; - SIZE fontSize; + + LOGFONT lf; + SIZE fontSize; - HDC hdc = GetDC(hwnd); - for (i=0; i <= FONTID_MAX; i++) - { - if ( !dat->fontInfo[i].changed) - DeleteObject(dat->fontInfo[i].hFont); + HDC hdc = GetDC(hwnd); + for (int i=0; i <= FONTID_MAX; i++) { + if ( !dat->fontInfo[i].changed) + DeleteObject(dat->fontInfo[i].hFont); - cli.pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); - lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); + cli.pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); + lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); - dat->fontInfo[i].hFont = CreateFontIndirect(&lf); - dat->fontInfo[i].changed = 0; + dat->fontInfo[i].hFont = CreateFontIndirect(&lf); + dat->fontInfo[i].changed = 0; - HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); - GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); - SelectObject(hdc, holdfont); + HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); + GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); + SelectObject(hdc, holdfont); - dat->fontInfo[i].fontHeight = fontSize.cy; - } - ReleaseDC(hwnd, hdc); + dat->fontInfo[i].fontHeight = fontSize.cy; } + ReleaseDC(hwnd, hdc); + dat->leftMargin = DBGetContactSettingByte(NULL, "CLC", "LeftMargin", CLCDEFAULT_LEFTMARGIN); dat->exStyle = DBGetContactSettingDword(NULL, "CLC", "ExStyle", cli.pfnGetDefaultExStyle()); dat->scrollTime = DBGetContactSettingWord(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME); @@ -773,29 +766,27 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) dat->hotTextColour = DBGetContactSettingDword(NULL, "CLC", "HotTextColour", CLCDEFAULT_HOTTEXTCOLOUR); dat->quickSearchColour = DBGetContactSettingDword(NULL, "CLC", "QuickSearchColour", CLCDEFAULT_QUICKSEARCHCOLOUR); dat->useWindowsColours = DBGetContactSettingByte(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); - { - NMHDR hdr; - hdr.code = CLN_OPTIONSCHANGED; - hdr.hwndFrom = hwnd; - hdr.idFrom = GetDlgCtrlID(hwnd); - SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) & hdr); - } + + NMHDR hdr; + hdr.code = CLN_OPTIONSCHANGED; + hdr.hwndFrom = hwnd; + hdr.idFrom = GetDlgCtrlID(hwnd); + SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) & hdr); + SendMessage(hwnd, WM_SIZE, 0, 0); } #define GSIF_HASMEMBERS 0x80000000 #define GSIF_ALLCHECKED 0x40000000 #define GSIF_INDEXMASK 0x3FFFFFFF + void fnRecalculateGroupCheckboxes(HWND, struct ClcData *dat) { - struct ClcGroup *group; - int check; - - group = &dat->list; + ClcGroup *group = &dat->list; group->scanIndex = GSIF_ALLCHECKED; for (;;) { if ((group->scanIndex & GSIF_INDEXMASK) == group->cl.count) { - check = (group->scanIndex & (GSIF_HASMEMBERS | GSIF_ALLCHECKED)) == (GSIF_HASMEMBERS | GSIF_ALLCHECKED); + int check = (group->scanIndex & (GSIF_HASMEMBERS | GSIF_ALLCHECKED)) == (GSIF_HASMEMBERS | GSIF_ALLCHECKED); if (group->parent == NULL) break; group->parent->scanIndex |= group->scanIndex & GSIF_HASMEMBERS; @@ -821,11 +812,9 @@ void fnRecalculateGroupCheckboxes(HWND, struct ClcData *dat) } } -void fnSetGroupChildCheckboxes(struct ClcGroup *group, int checked) +void fnSetGroupChildCheckboxes(ClcGroup *group, int checked) { - int i; - - for (i=0; i < group->cl.count; i++) { + for (int i=0; i < group->cl.count; i++) { if (group->cl.items[i]->type == CLCIT_GROUP) { cli.pfnSetGroupChildCheckboxes(group->cl.items[i]->group, checked); if (checked) @@ -844,10 +833,10 @@ void fnSetGroupChildCheckboxes(struct ClcGroup *group, int checked) void fnInvalidateItem(HWND hwnd, struct ClcData *dat, int iItem) { - RECT rc; if (iItem == -1) return; + RECT rc; GetClientRect(hwnd, &rc); rc.top = cli.pfnGetRowTopY(dat, iItem) - dat->yScroll; rc.bottom = rc.top + cli.pfnGetRowHeight(dat, iItem); diff --git a/src/modules/clist/clistcore.cpp b/src/modules/clist/clistcore.cpp index 924634ad06..0ac6bb9a7f 100644 --- a/src/modules/clist/clistcore.cpp +++ b/src/modules/clist/clistcore.cpp @@ -39,9 +39,9 @@ static void fnPaintClc(HWND, ClcData*, HDC, RECT*) { } -static struct ClcContact* fnCreateClcContact(void) +static ClcContact* fnCreateClcContact(void) { - return (struct ClcContact*)mir_calloc(sizeof(struct ClcContact)); + return (ClcContact*)mir_calloc(sizeof(ClcContact)); } static BOOL fnInvalidateRect(HWND hwnd, CONST RECT* lpRect, BOOL bErase) diff --git a/src/modules/clist/contact.cpp b/src/modules/clist/contact.cpp index 9404446db5..a523c3b262 100644 --- a/src/modules/clist/contact.cpp +++ b/src/modules/clist/contact.cpp @@ -92,7 +92,7 @@ void fnLoadContactTree(void) CallService(MS_CLUI_LISTENDREBUILD, 0, 0); } -int fnCompareContacts(const struct ClcContact* c1, const struct ClcContact* c2) +int fnCompareContacts(const ClcContact* c1, const ClcContact* c2) { HANDLE a = c1->hContact, b = c2->hContact; TCHAR namea[128], *nameb; -- cgit v1.2.3