From 2a18cb546bac91077a193691368162d8f07992a1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Apr 2016 18:00:05 +0000 Subject: we don't need that FindItem's implementation in nicer+ anymore, it's already in the core git-svn-id: http://svn.miranda-ng.org/main/trunk@16791 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/clc.cpp | 26 +++---- plugins/Clist_nicer/src/clc.h | 4 -- plugins/Clist_nicer/src/clcidents.cpp | 107 ---------------------------- plugins/Clist_nicer/src/clcmsgs.cpp | 8 +-- plugins/Clist_nicer/src/clistmenus.cpp | 8 +-- plugins/Clist_nicer/src/rowheight_funcs.cpp | 37 +++------- plugins/Clist_nicer/src/rowheight_funcs.h | 21 +++--- 7 files changed, 40 insertions(+), 171 deletions(-) delete mode 100644 plugins/Clist_nicer/src/clcidents.cpp (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 35237961cf..8bb428058e 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -275,7 +275,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L { WORD iExtraImage[EXTRA_ICON_COUNT]; BYTE flags = 0; - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) memset(iExtraImage, 0xFF, sizeof(iExtraImage)); else { memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage)); @@ -284,7 +284,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L pcli->pfnDeleteItemFromTree(hwnd, wParam); if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(wParam, NULL, dat)) { pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1); - if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { + if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage)); if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; @@ -322,13 +322,13 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L !CLVM_GetContactHiddenStatus(hContact, szProto, dat)) && ((cfg::dat.bFilterEffective ? TRUE : !pcli->pfnIsHiddenMode(dat, status)) || pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown - if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, &group, NULL)) { + if (!pcli->pfnFindItem(hwnd, dat, hContact, &contact, &group, NULL)) { if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) { if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = (UINT_PTR)pcli->pfnContactToHItem(selcontact); pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0); recalcScrollBar = 1; - FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL); + pcli->pfnFindItem(hwnd, dat, hContact, &contact, NULL, NULL); if (contact) { contact->iImage = (WORD)lParam; pcli->pfnNotifyNewContact(hwnd, hContact); @@ -395,14 +395,14 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_METACHANGEDEVENT: - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; if (lParam == 0) pcli->pfnInitAutoRebuild(hwnd); return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_NAMECHANGED: - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); @@ -413,7 +413,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_CODEPAGECHANGED: - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; contact->codePage = db_get_dw(wParam, "Tab_SRMsg", "ANSIcodepage", db_get_dw(wParam, "UserInfo", "ANSIcodepage", CP_ACP)); @@ -433,7 +433,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); } - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; contact->ace = cEntry; @@ -460,7 +460,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L TExtraCache *p; char *szProto = NULL; - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) p = cfg::getCache(wParam, NULL); else { p = contact->pExtra; @@ -472,7 +472,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_STATUSCHANGED: - if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { + if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { WORD wStatus = db_get_w(wParam, contact->proto, "Status", ID_STATUS_OFFLINE); if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) { contact->wStatus = wStatus; @@ -485,7 +485,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L break; case INTM_PROTOCHANGED: - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; contact->proto = GetContactProto(wParam); @@ -520,7 +520,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_IDLECHANGED: - if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { + if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; char *szProto = (char*)cws->szModule; if (szProto == NULL) @@ -542,7 +542,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L MCONTACT hContact = wParam; TExtraCache *p; - if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL)) { + if (!pcli->pfnFindItem(hwnd, dat, hContact, &contact, NULL, NULL)) { p = cfg::getCache(hContact, szProto); if (!dat->bisEmbedded && szProto) { // may be a subcontact, forward the xstatus MCONTACT hMasterContact = db_mc_tryMeta(hContact); diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h index 58d9c11594..2e3eea72f7 100644 --- a/plugins/Clist_nicer/src/clc.h +++ b/plugins/Clist_nicer/src/clc.h @@ -363,10 +363,6 @@ struct protoMenu HICON hIcon; }; -// clcidents.c -int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); -HANDLE ContactToItemHandle(ClcContact *contact, DWORD *nmFlags); - // clcitems.c void RebuildEntireList(HWND hwnd, struct ClcData *dat); DWORD INTSORT_GetLastMsgTime(MCONTACT hContact); diff --git a/plugins/Clist_nicer/src/clcidents.cpp b/plugins/Clist_nicer/src/clcidents.cpp deleted file mode 100644 index 609c7c2a5d..0000000000 --- a/plugins/Clist_nicer/src/clcidents.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-16 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-03 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" - -/* the CLC uses 3 different ways to identify elements in its list, this file -contains routines to convert between them. - -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 - highlight -3) hItem handle. Either the hContact or (hGroup|HCONTACT_ISGROUP). Used - exclusively externally - -1->2: GetRowsPriorTo() -1->3: ContactToHItem() -3->1: FindItem() -2->1: GetRowByIndex() -*/ - -int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) -{ - int index = 0; - int nowVisible = 1; - ClcGroup *group = &dat->list; - - group->scanIndex = 0; - for (;;) { - if (group->scanIndex == group->cl.count) { - ClcGroup *tgroup; - group = group->parent; - if (group == NULL) - break; - nowVisible = 1; - for (tgroup = group; tgroup; tgroup = tgroup->parent) { - if (!(group->expanded)) { - nowVisible = 0; break; - } - } - group->scanIndex++; - continue; - } - if (nowVisible) - index++; - if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && ((UINT_PTR)hItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) || - (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == (UINT_PTR)hItem) || - (IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == ((UINT_PTR)hItem & ~HCONTACT_ISINFO))) { - if (isVisible) { - if (!nowVisible) - *isVisible = 0; - else { - int posy = RowHeight::getItemTopY(dat, index + 1); - if (posy < dat->yScroll) - *isVisible = 0; - else { - RECT clRect; - GetClientRect(hwnd, &clRect); - if (posy >= dat->yScroll + clRect.bottom) - *isVisible = 0; - else - *isVisible = 1; - } - } - } - if (contact) - *contact = group->cl.items[group->scanIndex]; - if (subgroup) - *subgroup = group; - return 1; - } - if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { - group = group->cl.items[group->scanIndex]->group; - group->scanIndex = 0; - nowVisible &= (group->expanded); - continue; - } - group->scanIndex++; - } - - if (isVisible) *isVisible = FALSE; - if (contact) *contact = NULL; - if (subgroup) *subgroup = NULL; - return 0; -} diff --git a/plugins/Clist_nicer/src/clcmsgs.cpp b/plugins/Clist_nicer/src/clcmsgs.cpp index 3c8e58591b..4769366144 100644 --- a/plugins/Clist_nicer/src/clcmsgs.cpp +++ b/plugins/Clist_nicer/src/clcmsgs.cpp @@ -33,7 +33,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM { ClcContact *contact; ClcGroup *group; - if (wParam == 0 || !FindItem(hwnd, dat, (HANDLE)wParam, &contact, &group, NULL)) + if (wParam == 0 || !pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) return 0; if (lParam) @@ -46,7 +46,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_GETSTATUSMSG: if (wParam) { ClcContact *contact = NULL; - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) @@ -65,7 +65,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_TOGGLEPRIORITYCONTACT: if (wParam) { ClcContact *contact = NULL; - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) return 0; @@ -78,7 +78,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_QUERYPRIORITYCONTACT: if (wParam) { ClcContact *contact = NULL; - if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) + if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) return 0; diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index d48d2c9741..203f0faf2f 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -92,7 +92,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message")); if (cfg::clcdat) { - FindItem(pcli->hwndContactTree, cfg::clcdat, (HANDLE)hContact, &contact, NULL, NULL); + pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if (contact && contact->type != CLCIT_CONTACT) { DestroyWindow(hWnd); return FALSE; @@ -204,7 +204,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0), dwXMask = 0; LRESULT checked = 0; - FindItem(pcli->hwndContactTree, cfg::clcdat, (HANDLE)hContact, &contact, NULL, NULL); + pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if (iSel != CB_ERR) { dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR); @@ -291,7 +291,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA case WM_USER + 120: // set visibility status { ClcContact *contact = NULL; - if (FindItem(pcli->hwndContactTree, cfg::clcdat, (HANDLE)hContact, &contact, NULL, NULL)) { + if (pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if (contact) { WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0); @@ -306,7 +306,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA { ClcContact *contact = NULL; - if (FindItem(pcli->hwndContactTree, cfg::clcdat, (HANDLE)hContact, &contact, NULL, NULL)) { + if (pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if (contact) { WORD wApparentMode = 0; diff --git a/plugins/Clist_nicer/src/rowheight_funcs.cpp b/plugins/Clist_nicer/src/rowheight_funcs.cpp index 79090e0b5c..0fbe7ebe01 100644 --- a/plugins/Clist_nicer/src/rowheight_funcs.cpp +++ b/plugins/Clist_nicer/src/rowheight_funcs.cpp @@ -129,41 +129,33 @@ int RowHeight::getMaxRowHeight(ClcData *dat, const HWND hwnd) // Calc and store row height for all items in the list void RowHeight::calcRowHeights(ClcData *dat, HWND hwnd) { - int indent, subindex, line_num; - ClcContact *Drawing; - ClcGroup *group; DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); // Draw lines - group = &dat->list; + ClcGroup *group = &dat->list; group->scanIndex = 0; - indent = 0; - //subindex=-1; - line_num = -1; + int line_num = -1; Clear(dat); while (true) { if (group->scanIndex == group->cl.count) { group = group->parent; - indent--; if (group == NULL) break; // Finished list group->scanIndex++; continue; } // Get item to draw - Drawing = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl.items[group->scanIndex]; line_num++; // Calc row height - getRowHeight(dat, Drawing, line_num, dwStyle); + getRowHeight(dat, cc, line_num, dwStyle); - if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (group->cl.items[group->scanIndex]->group->expanded & 0x0000ffff)) { - group = group->cl.items[group->scanIndex]->group; - indent++; + if (cc->type == CLCIT_GROUP && (cc->group->expanded & 0x0000ffff)) { + group = cc->group; group->scanIndex = 0; - subindex = -1; continue; } group->scanIndex++; @@ -173,42 +165,33 @@ void RowHeight::calcRowHeights(ClcData *dat, HWND hwnd) // Calc item top Y (using stored data) int RowHeight::getItemTopY(ClcData *dat, int item) { - int i; - int y = 0; - if (item >= dat->row_heights_size) return -1; - for (i = 0; i < item; i++) { + int y = 0; + for (int i = 0; i < item; i++) y += dat->row_heights[i]; - } return y; } - // Calc item bottom Y (using stored data) int RowHeight::getItemBottomY(ClcData *dat, int item) { - int i; - int y = 0; - if (item >= dat->row_heights_size) return -1; - for (i = 0; i <= item; i++) { + int y = 0; + for (int i = 0; i <= item; i++) y += dat->row_heights[i]; - } return y; } - // Calc total height of rows (using stored data) int RowHeight::getTotalHeight(ClcData *dat) { int y = 0; - for (int i = 0; i < dat->row_heights_size; i++) y += dat->row_heights[i]; diff --git a/plugins/Clist_nicer/src/rowheight_funcs.h b/plugins/Clist_nicer/src/rowheight_funcs.h index 60a0998e1c..aa49af8a10 100644 --- a/plugins/Clist_nicer/src/rowheight_funcs.h +++ b/plugins/Clist_nicer/src/rowheight_funcs.h @@ -16,7 +16,7 @@ public: static int getMaxRowHeight(ClcData *dat, const HWND hwnd); // Calc and store row height - static int getRowHeight(ClcData *dat, ClcContact* contact, int item, DWORD style) + static int getRowHeight(ClcData *dat, ClcContact *contact, int item, DWORD style) { if (!Alloc(dat, item + 1)) return -1; @@ -36,39 +36,36 @@ public: // Checkbox size if ((style & CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) || - (style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) || - (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) { + (style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) || + (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) { height = max(height, dat->checkboxSize); } - //height += 2 * dat->row_border; // Min size height = max(height, contact->type == CLCIT_GROUP ? dat->group_row_height : dat->min_row_heigh); height += cfg::dat.bRowSpacing; dat->row_heights[item] = height; - //contact->iRowHeight = item; - return height; } // Calc and store row height for all itens in the list - static void calcRowHeights (ClcData *dat, HWND hwnd); + static void calcRowHeights(ClcData *dat, HWND hwnd); // Calc item top Y (using stored data) - static int getItemTopY (ClcData *dat, int item); + static int getItemTopY(ClcData *dat, int item); // Calc item bottom Y (using stored data) - static int getItemBottomY (ClcData *dat, int item); + static int getItemBottomY(ClcData *dat, int item); // Calc total height of rows (using stored data) - static int getTotalHeight (ClcData *dat); + static int getTotalHeight(ClcData *dat); // Return the line that pos_y is at or -1 (using stored data). Y start at 0 - static int hitTest (ClcData *dat, int pos_y); + static int hitTest(ClcData *dat, int pos_y); // Returns the height of the chosen row - static int getHeight (ClcData *dat, int item); + static int getHeight(ClcData *dat, int item); }; #endif // __ROWHEIGHT_FUNCS_H__ -- cgit v1.2.3