diff options
author | George Hazan <george.hazan@gmail.com> | 2016-04-27 13:14:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-04-27 13:14:43 +0000 |
commit | fb5f50bc10318b32d3d99480874813a05551d740 (patch) | |
tree | 0a15ed6ba91db7a3ceeaf01767bf2ef7e34c41dd /plugins/Clist_modern/src | |
parent | 6524ac4e637dba2de42df5ca6eac4a9a5501a4d2 (diff) |
persistent cache, no need to call pfnGetCacheEntry each time
git-svn-id: http://svn.miranda-ng.org/main/trunk@16774 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src')
-rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clc.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcitems.cpp | 25 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcpaint.cpp | 98 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcpaint.h | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_commonprototypes.h | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_contact.cpp | 3 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_rowheight_funcs.cpp | 186 |
8 files changed, 150 insertions, 178 deletions
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 9aaeabbe22..af7a5d4ff7 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -69,8 +69,7 @@ void Cache_GetText(ClcData *dat, ClcContact *contact, BOOL forceRenew) { Cache_GetFirstLineText(dat, contact); if (!dat->force_in_dialog) { - ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact); - if ((dat->second_line_show && (forceRenew || pdnce->szSecondLineText == NULL)) || (dat->third_line_show && (forceRenew || pdnce->szThirdLineText == NULL))) + if ((dat->second_line_show && (forceRenew || contact->pce->szSecondLineText == NULL)) || (dat->third_line_show && (forceRenew || contact->pce->szThirdLineText == NULL))) gtaAddRequest(dat, contact->hContact); } } @@ -479,7 +478,7 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) if (GetCurrentThreadId() != g_dwMainThreadID) return; - ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact); + ClcCacheEntry *pdnce = contact->pce; TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0); if (dat->first_line_append_nick && !dat->force_in_dialog) { DBVARIANT dbv = { 0 }; diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index a4183bc8f2..094ca5b4f8 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -273,9 +273,8 @@ static BOOL clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact) if (g_CluiData.bFilterEffective) return FALSE;
if (!contact) return FALSE;
- ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
- if (!pdnce) return FALSE;
- if (pdnce->m_bNoHiddenOffline) return TRUE;
+
+ if (contact->pce->m_bNoHiddenOffline) return TRUE;
if (!group) return FALSE;
if (group->hideOffline) return FALSE;
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 67f9a7afc6..d14f500579 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
{
- ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(cont->hContact);
cont->SubExpanded = (db_get_b(cont->hContact, "CList", "Expanded", 0) && (db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT)));
int subcount = db_mc_getSubCount(cont->hContact);
if (subcount <= 0) {
@@ -48,7 +47,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup) int bHideOffline = db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
for (int j = 0; j < subcount; j++) {
MCONTACT hsub = db_mc_getSub(cont->hContact, j);
- cacheEntry = pcli->pfnGetCacheEntry(hsub);
+ ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hsub);
WORD wStatus = cacheEntry->getStatus();
if (!showOfflineHereGroup && bHideOffline && !cacheEntry->m_bNoHiddenOffline && wStatus == ID_STATUS_OFFLINE)
@@ -149,7 +148,11 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, if (!cont)
return;
+ ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);
+ char *szProto = cacheEntry->m_pszProto;
+
cont->type = CLCIT_CONTACT;
+ cont->pce = cacheEntry;
cont->SubAllocated = 0;
cont->isSubcontact = 0;
cont->subcontacts = NULL;
@@ -157,13 +160,10 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, cont->lastPaintCounter = 0;
cont->image_is_special = FALSE;
cont->hContact = hContact;
+ cont->proto = szProto;
pcli->pfnInvalidateDisplayNameCacheEntry(hContact);
- ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);
- char *szProto = cacheEntry->m_pszProto;
- cont->proto = szProto;
-
if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, cacheEntry->m_iStatus))
cont->flags |= CONTACTF_ONLINE;
@@ -201,21 +201,20 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, cont->bContactRate = db_get_b(hContact, "CList", "Rate", 0);
}
-static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, ClcCacheEntry *cacheEntry)
+static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact)
{
- if (cacheEntry == NULL || group == NULL || dat == NULL)
+ if (group == NULL || dat == NULL)
return NULL;
- MCONTACT hContact = cacheEntry->hContact;
dat->needsResort = 1;
int i;
for (i = group->cl.count - 1; i >= 0; i--)
if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags & CLCIIF_BELOWCONTACTS))
break;
+
i = cli_AddItemToGroup(group, i + 1);
_LoadDataToContact(group->cl.items[i], group, dat, hContact);
- cacheEntry = pcli->pfnGetCacheEntry(hContact);
ClearRowByIndexCache();
return group->cl.items[i];
}
@@ -341,12 +340,12 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat) if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
if (cacheEntry->m_pszProto == NULL) {
if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cacheEntry->m_bNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
- cont = AddContactToGroup(dat, group, cacheEntry);
+ cont = AddContactToGroup(dat, group, hContact);
}
else if (!pcli->pfnIsHiddenMode(dat, cacheEntry->m_iStatus) || cacheEntry->m_bNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
- cont = AddContactToGroup(dat, group, cacheEntry);
+ cont = AddContactToGroup(dat, group, hContact);
}
- else cont = AddContactToGroup(dat, group, cacheEntry);
+ else cont = AddContactToGroup(dat, group, hContact);
}
}
if (cont) {
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index cfaa374d46..5a256386f5 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -152,10 +152,6 @@ HFONT CLCPaint::ChangeToFont(HDC hdc, ClcData *dat, int id, int *fontHeight) int CLCPaint::GetBasicFontID(ClcContact *contact)
{
- ClcCacheEntry *pdnce = NULL;
- if (contact->type == CLCIT_CONTACT)
- pdnce = pcli->pfnGetCacheEntry(contact->hContact);
-
switch (contact->type) {
case CLCIT_GROUP:
return (contact->group->expanded) ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS;
@@ -177,7 +173,7 @@ int CLCPaint::GetBasicFontID(ClcContact *contact) return (contact->flags & CONTACTF_ONLINE) ? FONTID_INVIS : FONTID_OFFINVIS;
}
- switch (pdnce->getStatus()) {
+ switch (contact->pce->getStatus()) {
case ID_STATUS_OFFLINE: return FONTID_OFFLINE;
case ID_STATUS_AWAY: return FONTID_AWAY;
case ID_STATUS_DND: return FONTID_DND;
@@ -657,7 +653,7 @@ void CLCPaint::_RTLRect(RECT *rect, int width) rect->right = right;//-offset;
}
-void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack)
+void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack)
{
int i = 0;
int dx = free_row_rc.left;
@@ -668,14 +664,11 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact int minheight = dat->row_min_heigh;
int mode2 = -1;
BOOL InClistWindow = (dat->hWnd == pcli->hwndContactTree);
- ClcCacheEntry *pdnce = NULL;
- int height = RowHeight_CalcRowHeight(dat, hwnd, Drawing, -1);
+ int height = RowHeight_CalcRowHeight(dat, Drawing, -1);
+ ClcCacheEntry *pdnce = Drawing->pce;
// TO DO DEPRECATE OLD ROW LAYOUT
- if (Drawing->type == CLCIT_CONTACT)
- pdnce = pcli->pfnGetCacheEntry(Drawing->hContact);
-
if (Drawing->type == CLCIT_GROUP &&
Drawing->group->parent->groupId == 0 &&
Drawing->group->parent->cl.items[0] != Drawing) {
@@ -1686,7 +1679,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, if (!gl_RowRoot)
RowHeights_GetRowHeight(dat, hWnd, Drawing, line_num);
else
- RowHeight_CalcRowHeight(dat, hWnd, Drawing, line_num);
+ RowHeight_CalcRowHeight(dat, Drawing, line_num);
// Init settings
int selected = ((line_num == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || is_foreground) && Drawing->type != CLCIT_DIVIDER);
@@ -1822,7 +1815,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, // Store pos
Drawing->pos_check = rc;
}
- _PaintRowItems(hWnd, pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint);
+ _PaintRowItems(pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint);
if (mpRequest) {
if (!dat->force_in_dialog) {
mir_free(mpRequest->pl_Params[1].szValue);
@@ -2010,6 +2003,7 @@ void CLCPaint::_StoreItemPos(ClcContact *contact, int ItemType, RECT *rc) void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *in_row_rc, RECT *in_free_row_rc, int left_pos, int right_pos, int selected)
{
+ ClcCacheEntry *pdnce = Drawing->pce;
int item_iterator, item, item_text = 0, text_left_pos;
BOOL left = TRUE; //TODO remove
RECT free_row_rc = *in_free_row_rc;
@@ -2147,28 +2141,25 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT break;
case ITEM_CONTACT_TIME: /////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
- if (Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) {
- TCHAR szResult[80];
-
- if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) {
- // Select font
- ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL);
-
- // Get text size
- RECT rc;
- SIZE text_size;
- text_size.cy = ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), &rc, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
- text_size.cy = min(text_size.cy, free_row_rc.bottom - free_row_rc.top);
- text_size.cx = rc.right - rc.left;
-
- // Get rc
- rc = _GetRectangle(dat, &row_rc, &free_row_rc, &left_pos, &right_pos, left, text_size.cx, text_size.cx, text_size.cy, HORIZONTAL_SPACE);
- if (rc.left < rc.right) { // Store pos
- Drawing->pos_contact_time = rc;
- _StoreItemPos(Drawing, CIT_TIME, &rc);
- }
+ if (Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) {
+ TCHAR szResult[80];
+
+ if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) {
+ // Select font
+ ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL);
+
+ // Get text size
+ RECT rc;
+ SIZE text_size;
+ text_size.cy = ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), &rc, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
+ text_size.cy = min(text_size.cy, free_row_rc.bottom - free_row_rc.top);
+ text_size.cx = rc.right - rc.left;
+
+ // Get rc
+ rc = _GetRectangle(dat, &row_rc, &free_row_rc, &left_pos, &right_pos, left, text_size.cx, text_size.cx, text_size.cy, HORIZONTAL_SPACE);
+ if (rc.left < rc.right) { // Store pos
+ Drawing->pos_contact_time = rc;
+ _StoreItemPos(Drawing, CIT_TIME, &rc);
}
}
}
@@ -2329,7 +2320,6 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT }
else if (Drawing->type == CLCIT_CONTACT && !CheckMiniMode(dat, selected)) {
int tmp;
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
if (dat->second_line_show) {
if (dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) {
// Get contact time
@@ -2774,21 +2764,19 @@ void CLCPaint::_DrawContactSubText(HDC hdcMem, ClcData *dat, ClcContact *Drawing }
}
else if (Drawing->type == CLCIT_CONTACT) {
+ ClcCacheEntry *pdnce = Drawing->pce;
SIZE text_size = { _rcWidth(prcItem), _rcHeight(prcItem) };
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
- if (pdnce) {
- ChangeToFont(hdcMem, dat, itemType == CIT_SUBTEXT1 ? FONTID_SECONDLINE : FONTID_THIRDLINE, NULL);
- //draw second and third line
- if (selected)
- SetTextColor(hdcMem, dat->selTextColour);
- else if (hottrack)
- _SetHotTrackColour(hdcMem, dat);
- uTextFormat |= DT_VCENTER;
- if (itemType == CIT_SUBTEXT1)
- _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szSecondLineText, 0, -1, pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys);
- else
- _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szThirdLineText, 0, -1, pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys);
- }
+ ChangeToFont(hdcMem, dat, itemType == CIT_SUBTEXT1 ? FONTID_SECONDLINE : FONTID_THIRDLINE, NULL);
+ //draw second and third line
+ if (selected)
+ SetTextColor(hdcMem, dat->selTextColour);
+ else if (hottrack)
+ _SetHotTrackColour(hdcMem, dat);
+ uTextFormat |= DT_VCENTER;
+ if (itemType == CIT_SUBTEXT1)
+ _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szSecondLineText, 0, -1, pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys);
+ else
+ _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szThirdLineText, 0, -1, pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys);
}
text_rc.right = max(text_rc.right, prcItem->right);
text_rc.left = min(text_rc.left, prcItem->left);
@@ -2797,7 +2785,7 @@ void CLCPaint::_DrawContactSubText(HDC hdcMem, ClcData *dat, ClcContact *Drawing void CLCPaint::_DrawContactTime(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *prcItem)
{
TCHAR szResult[80];
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
+ ClcCacheEntry *pdnce = Drawing->pce;
if (!pdnce)
return;
@@ -2922,15 +2910,15 @@ void CLCPaint::_DrawContactItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, _DrawContactLine(hdcMem, Drawing, free_row_rc, rcPaint, text_rc);
}
-void CLCPaint::_PaintRowItems(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint)
+void CLCPaint::_PaintRowItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint)
{
- //Extended LAYOUT
+ // Extended LAYOUT
if (gl_RowRoot && (dat->hWnd == pcli->hwndContactTree)) {
- _PaintRowItemsEx(hwnd, hdcMem, dat, Drawing, row_rc, free_row_rc, selected, hottrack);
+ _PaintRowItemsEx(hdcMem, dat, Drawing, row_rc, free_row_rc, selected, hottrack);
ske_ResetTextEffect(hdcMem);
return;
}
- //END OFF Extended LAYOUT
+ // END OFF Extended LAYOUT
if (!Drawing->ext_fItemsValid) _CalcItemsPos(hdcMem, dat, Drawing, &row_rc, &free_row_rc, left_pos, right_pos, selected);
_DrawContactItems(hdcMem, dat, Drawing, &row_rc, &free_row_rc, selected, hottrack, rcPaint);
ske_ResetTextEffect(hdcMem);
diff --git a/plugins/Clist_modern/src/modern_clcpaint.h b/plugins/Clist_modern/src/modern_clcpaint.h index 377f27d6eb..406bc51137 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.h +++ b/plugins/Clist_modern/src/modern_clcpaint.h @@ -107,7 +107,7 @@ private: void _FillParam(MASKPARAM * lpParam, DWORD dwParamHash, const char* szValue, DWORD dwValueHash);
MODERNMASK* _GetCLCContactRowBackModernMask(ClcGroup *group, ClcContact *Drawing, int indent, int index, BOOL selected, BOOL hottrack, ClcData *dat);
void _RTLRect(RECT *rect, int width);
- void _PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack);
+ void _PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack);
void _DrawStatusIcon(ClcContact *Drawing, ClcData *dat, int iImage, HDC hdcMem, int x, int y, int cx, int cy, DWORD colorbg, DWORD colorfg, int mode);
BOOL _DrawNonEnginedBackground(HDC hdcMem, RECT *rcPaint, RECT clRect, ClcData *dat);
void _PaintClc(HWND hwnd, ClcData *dat, HDC hdc, RECT *rcPaint);
@@ -116,7 +116,7 @@ private: BOOL __IsVisible(RECT *firtRect, RECT *secondRect);
void _GetBlendMode(IN ClcData *dat, IN ClcContact *Drawing, IN BOOL selected, IN BOOL hottrack, IN BOOL bFlag, OUT COLORREF * OutColourFg, OUT int * OutMode);
void _DrawContactItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, RECT *free_row_rc, int selected, int hottrack, RECT *rcPaint);
- void _PaintRowItems(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint);
+ void _PaintRowItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint);
void _DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, int& selected, int& hottrack, RECT *prcItem);
void _DrawContactIcon(HDC hdcMem, ClcData *dat, ClcContact *Drawing, int& selected, int& hottrack, RECT *prcItem);
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index 9d1e0e8515..d83c743db1 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -117,7 +117,7 @@ int ModernSkinButton_ReposButtons(HWND parent, BYTE draw, RECT *r); int ModernSkinButtonUnloadModule(WPARAM, LPARAM);
/* RowHeight */
-int RowHeight_CalcRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
+int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item);
/* SkinEngine */
BOOL ske_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index f7dc4aa4fb..36efba43c6 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -95,8 +95,7 @@ int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100)
return 0;
- ClcCacheEntry *c1 = pcli->pfnGetCacheEntry(contact1->hContact);
- ClcCacheEntry *c2 = pcli->pfnGetCacheEntry(contact2->hContact);
+ ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce;
for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) {
BYTE &by = g_CluiData.bSortByOrder[i];
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index 3a2de1caf3..00119588d1 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -31,7 +31,7 @@ Created by Pescuma, modified by Artem Shpynov #include "modern_clcpaint.h"
int g_mutex_nCalcRowHeightLock = 0;
-int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
+int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item);
void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd);
int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
@@ -69,30 +69,28 @@ SIZE GetAvatarSize(int imageWidth, int imageHeight, int maxWidth, int maxHeight) return sz;
}
-int RowHeight_CalcRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
+int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
{
if (MirandaExiting()) return 0;
g_mutex_nCalcRowHeightLock++;
- int res = mod_CalcRowHeight_worker(dat, hwnd, contact, item);
+ int res = mod_CalcRowHeight_worker(dat, contact, item);
g_mutex_nCalcRowHeightLock--;
return res;
}
-int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
+int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item)
{
- BYTE i = 0;
- int height = 0;
- ClcCacheEntry *pdnce;
- BOOL hasAvatar = FALSE;
- DWORD style;
- style = GetWindowLongPtr(hwnd, GWL_STYLE);
- pdnce = pcli->pfnGetCacheEntry(contact->hContact);
if (!RowHeights_Alloc(dat, item + 1))
return -1;
if (!pcli->hwndContactTree)
return 0;
+ BYTE i = 0;
+ int height = 0;
+ BOOL hasAvatar = FALSE;
+
+ ClcCacheEntry *pdnce = contact->pce;
if (dat->hWnd != pcli->hwndContactTree || !gl_RowRoot || contact->type == CLCIT_GROUP) {
int tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
@@ -123,99 +121,94 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i SetRect(&(gl_RowTabAccess[i]->r), 0, 0, 0, 0);
switch (gl_RowTabAccess[i]->type) {
case TC_TEXT1:
- {
- int tmp = 0;
- tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
- if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, contact->ssText.iMaxSmileyHeight);
- if (item == -1)
{
- //calculate text width here
- SIZE size = { 0 };
- RECT dummyRect = { 0, 0, 1024, tmp };
- HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, g_clcPainter.GetBasicFontID(contact), NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, contact->szText, contact->ssText.plText, 0, dat->text_resize_smileys ? 0 : contact->ssText.iMaxSmileyHeight);
- if (contact->type == CLCIT_GROUP) {
- TCHAR *szCounts = pcli->pfnGetGroupCountsText(dat, contact);
- if (szCounts && mir_tstrlen(szCounts) > 0) {
- RECT count_rc = { 0 };
- // calc width and height
- g_clcPainter.ChangeToFont(hdc, dat, contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, NULL);
- ske_DrawText(hdc, _T(" "), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
- size.cx += count_rc.right - count_rc.left;
- count_rc.right = 0;
- count_rc.left = 0;
- ske_DrawText(hdc, szCounts, (int)mir_tstrlen(szCounts), &count_rc, DT_CALCRECT);
- size.cx += count_rc.right - count_rc.left;
- tmp = max(tmp, count_rc.bottom - count_rc.top);
- }
- }
- gl_RowTabAccess[i]->w = size.cx;
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- ske_ResetTextEffect(hdc);
- DeleteDC(hdc);
- }
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
-
- case TC_TEXT2:
- {
- int tmp = 0;
- if (dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0])
- {
- tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight;
- if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight);
- if (item == -1)
- {
+ int tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
+ if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, contact->ssText.iMaxSmileyHeight);
+ if (item == -1) {
//calculate text width here
-
SIZE size = { 0 };
RECT dummyRect = { 0, 0, 1024, tmp };
HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, FONTID_SECONDLINE, NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight);
+ g_clcPainter.ChangeToFont(hdc, dat, g_clcPainter.GetBasicFontID(contact), NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, contact->szText, contact->ssText.plText, 0, dat->text_resize_smileys ? 0 : contact->ssText.iMaxSmileyHeight);
+ if (contact->type == CLCIT_GROUP) {
+ TCHAR *szCounts = pcli->pfnGetGroupCountsText(dat, contact);
+ if (szCounts && mir_tstrlen(szCounts) > 0) {
+ RECT count_rc = { 0 };
+ // calc width and height
+ g_clcPainter.ChangeToFont(hdc, dat, contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, NULL);
+ ske_DrawText(hdc, _T(" "), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
+ size.cx += count_rc.right - count_rc.left;
+ count_rc.right = 0;
+ count_rc.left = 0;
+ ske_DrawText(hdc, szCounts, (int)mir_tstrlen(szCounts), &count_rc, DT_CALCRECT);
+ size.cx += count_rc.right - count_rc.left;
+ tmp = max(tmp, count_rc.bottom - count_rc.top);
+ }
+ }
gl_RowTabAccess[i]->w = size.cx;
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
ske_ResetTextEffect(hdc);
DeleteDC(hdc);
}
+ gl_RowTabAccess[i]->h = tmp;
}
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
+ break;
+
+ case TC_TEXT2:
+ {
+ int tmp = 0;
+ if (dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) {
+ tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight;
+ if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight);
+ if (item == -1) {
+ //calculate text width here
+
+ SIZE size = { 0 };
+ RECT dummyRect = { 0, 0, 1024, tmp };
+ HDC hdc = CreateCompatibleDC(NULL);
+ g_clcPainter.ChangeToFont(hdc, dat, FONTID_SECONDLINE, NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight);
+ gl_RowTabAccess[i]->w = size.cx;
+ SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
+ ske_ResetTextEffect(hdc);
+ DeleteDC(hdc);
+ }
+ }
+ gl_RowTabAccess[i]->h = tmp;
+ }
+ break;
case TC_TEXT3:
- {
- int tmp = 0;
- if (dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) {
- tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight;
- if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight);
- if (item == -1) {
- //calculate text width here
- SIZE size = { 0 };
- RECT dummyRect = { 0, 0, 1024, tmp };
- HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, FONTID_THIRDLINE, NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight);
- gl_RowTabAccess[i]->w = size.cx;
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- ske_ResetTextEffect(hdc);
- DeleteDC(hdc);
+ {
+ int tmp = 0;
+ if (dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) {
+ tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight;
+ if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight);
+ if (item == -1) {
+ //calculate text width here
+ SIZE size = { 0 };
+ RECT dummyRect = { 0, 0, 1024, tmp };
+ HDC hdc = CreateCompatibleDC(NULL);
+ g_clcPainter.ChangeToFont(hdc, dat, FONTID_THIRDLINE, NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight);
+ gl_RowTabAccess[i]->w = size.cx;
+ SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
+ ske_ResetTextEffect(hdc);
+ DeleteDC(hdc);
+ }
}
+ gl_RowTabAccess[i]->h = tmp;
}
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
+ break;
case TC_STATUS:
if ((contact->type == CLCIT_GROUP && !dat->row_hide_group_icon) ||
(contact->type == CLCIT_CONTACT && contact->iImage != -1 &&
- !(dat->icon_hide_on_avatar && dat->avatars_show && (hasAvatar || (!hasAvatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)) && !contact->image_is_special)))
- {
+ !(dat->icon_hide_on_avatar && dat->avatars_show && (hasAvatar || (!hasAvatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)) && !contact->image_is_special))) {
gl_RowTabAccess[i]->h = ICON_HEIGHT;
gl_RowTabAccess[i]->w = ICON_HEIGHT;
}
@@ -224,8 +217,7 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i case TC_AVATAR:
if (dat->avatars_show &&
contact->type == CLCIT_CONTACT &&
- (hasAvatar || (dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)))
- {
+ (hasAvatar || (dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage != -1))) {
int iW = 0, iH = 0;
if (contact->avatar_data) {
iH = contact->avatar_data->bmHeight;
@@ -245,15 +237,14 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i // Draw extra icons
if (contact->type == CLCIT_CONTACT &&
- (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0))
- {
+ (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
BOOL hasExtra = FALSE;
int width = 0;
for (int k = 0; k < dat->extraColumnsCount; k++)
if (contact->iExtraImage[k] != EMPTY_EXTRA_ICON || !dat->MetaIgnoreEmptyExtra) {
hasExtra = TRUE;
if (item != -1) break;
- width += (width>0) ? dat->extraColumnSpacing : (dat->extraColumnSpacing - 2);
+ width += (width > 0) ? dat->extraColumnSpacing : (dat->extraColumnSpacing - 2);
}
if (hasExtra) {
gl_RowTabAccess[i]->h = ICON_HEIGHT;
@@ -272,8 +263,7 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i case TC_EXTRA8:
case TC_EXTRA9:
if (contact->type == CLCIT_CONTACT &&
- (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0))
- {
+ (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
int eNum = gl_RowTabAccess[i]->type - TC_EXTRA1;
if (eNum < dat->extraColumnsCount)
if (contact->iExtraImage[eNum] != EMPTY_EXTRA_ICON || !dat->MetaIgnoreEmptyExtra) {
@@ -497,7 +487,7 @@ void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd) if (!gl_RowRoot)
RowHeights_GetRowHeight(dat, hwnd, Drawing, line_num);
else
- RowHeight_CalcRowHeight(dat, hwnd, Drawing, line_num);
+ RowHeight_CalcRowHeight(dat, Drawing, line_num);
//increment by subcontacts
if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) {
@@ -535,7 +525,7 @@ int RowHeights_GetRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int it int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
{
if (gl_RowRoot)
- return RowHeight_CalcRowHeight(dat, hwnd, contact, item);
+ return RowHeight_CalcRowHeight(dat, contact, item);
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
//TODO replace futher code with new rowheight definition
@@ -546,7 +536,7 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, return -1;
int height = 0;
- ClcCacheEntry *pdnce = (contact->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(contact->hContact) : NULL;
+ ClcCacheEntry *pdnce = contact->pce;
if (dat->row_variable_height) {
if (!dat->text_ignore_size_for_row_height) {
@@ -579,16 +569,14 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, // 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))
- {
+ (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) {
height = max(height, dat->checkboxSize);
}
// Icon size
if (!dat->icon_ignore_size_for_row_height) {
if (contact->type == CLCIT_GROUP ||
- (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special)))
- {
+ (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special))) {
height = max(height, ICON_HEIGHT);
}
}
|