From 2799d3c1c54f5b4681b45b76cfdacb081312ae88 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jul 2012 20:23:55 +0000 Subject: - crash fix in Clist Modern cache - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@800 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/modern_rowheight_funcs.cpp | 306 ++++++++++++------------ 1 file changed, 153 insertions(+), 153 deletions(-) (limited to 'plugins/Clist_modern/modern_rowheight_funcs.cpp') diff --git a/plugins/Clist_modern/modern_rowheight_funcs.cpp b/plugins/Clist_modern/modern_rowheight_funcs.cpp index 065f6820c1..06de4347ee 100644 --- a/plugins/Clist_modern/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/modern_rowheight_funcs.cpp @@ -29,7 +29,7 @@ Created by Pescuma, modified by Artem Shpynov #include "hdr/modern_row.h" #include "hdr/modern_clcpaint.h" -int g_mutex_nCalcRowHeightLock=0; +int g_mutex_nCalcRowHeightLock = 0; int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact *contact, int item); void RowHeights_CalcRowHeights_Worker(struct ClcData *dat, HWND hwnd); int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact *contact, int item); @@ -38,7 +38,7 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon * */ -ROWCELL * gl_RowTabAccess[TC_ELEMENTSCOUNT+1]={0}; // Массив, через который осуществляется доступ к элементам контакта. +ROWCELL * gl_RowTabAccess[TC_ELEMENTSCOUNT+1] = {0}; // Массив, через который осуществляется доступ к элементам контакта. ROWCELL * gl_RowRoot; void FreeRowCell () @@ -49,19 +49,19 @@ void FreeRowCell () void RowHeight_InitModernRow() { - gl_RowRoot=cppInitModernRow(gl_RowTabAccess); + gl_RowRoot = cppInitModernRow(gl_RowTabAccess); return; } SIZE GetAvatarSize(int imageWidth, int imageHeight, int maxWidth, int maxHeight) { - float scalefactor=0; - SIZE sz={0}; - if (imageWidth==0 || imageHeight==0) return sz; - if (maxWidth==0) maxWidth=maxHeight; - scalefactor=min((float)maxWidth/imageWidth,(float)maxHeight/imageHeight); - sz.cx=(LONG)(imageWidth*scalefactor); - sz.cy=(LONG)(imageHeight*scalefactor); + float scalefactor = 0; + SIZE sz = {0}; + if (imageWidth == 0 || imageHeight == 0) return sz; + if (maxWidth == 0) maxWidth = maxHeight; + scalefactor = min((float)maxWidth/imageWidth,(float)maxHeight/imageHeight); + sz.cx = (LONG)(imageWidth*scalefactor); + sz.cy = (LONG)(imageHeight*scalefactor); return sz; } @@ -70,27 +70,27 @@ int RowHeight_CalcRowHeight(struct ClcData *dat, HWND hwnd, struct ClcContact *c int res; if (MirandaExiting()) return 0; g_mutex_nCalcRowHeightLock++; - res=mod_CalcRowHeight_worker(dat,hwnd,contact,item); + res = mod_CalcRowHeight_worker(dat,hwnd,contact,item); g_mutex_nCalcRowHeightLock--; return res; } int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact *contact, int item) { - BYTE i=0; - int res=0; - int height=0; + BYTE i = 0; + int res = 0; + int height = 0; displayNameCacheEntry * pdnce; - BOOL hasAvatar=FALSE; + BOOL hasAvatar = FALSE; DWORD style; - style=GetWindowLongPtr(hwnd,GWL_STYLE); - pdnce=(displayNameCacheEntry*)pcli->pfnGetCacheEntry(contact->hContact); + style = GetWindowLongPtr(hwnd,GWL_STYLE); + pdnce = (displayNameCacheEntry*)pcli->pfnGetCacheEntry(contact->hContact); if (!RowHeights_Alloc(dat, item + 1)) return -1; if (!pcli->hwndContactTree) return 0; //if (!gl_RowRoot) RowHeight_InitModernRow(); - if (dat->hWnd!=pcli->hwndContactTree || !gl_RowRoot || contact->type == CLCIT_GROUP) + if (dat->hWnd != pcli->hwndContactTree || !gl_RowRoot || contact->type == CLCIT_GROUP) { - int tmp=0; + 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); @@ -98,132 +98,132 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * { char * szCounts = pcli->pfnGetGroupCountsText(dat, contact); // Has the count? - if(szCounts && szCounts[0]) - tmp=max(tmp,dat->fontModernInfo[contact->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS].fontHeight); + if (szCounts && szCounts[0]) + tmp = max(tmp,dat->fontModernInfo[contact->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS].fontHeight); } - tmp=max(tmp, ICON_HEIGHT); - tmp=max(tmp,dat->row_min_heigh); - tmp+=dat->row_border*2; + tmp = max(tmp, ICON_HEIGHT); + tmp = max(tmp,dat->row_min_heigh); + tmp += dat->row_border*2; if (contact->type == CLCIT_GROUP && - contact->group->parent->groupId==0 && - contact->group->parent->cl.items[0]!=contact) - tmp+=dat->row_before_group_space; - if (item!=-1) dat->row_heights[item] = tmp; + contact->group->parent->groupId == 0 && + contact->group->parent->cl.items[0] != contact) + tmp += dat->row_before_group_space; + if (item != -1) dat->row_heights[item] = tmp; return tmp; } - hasAvatar=(dat->use_avatar_service && contact->avatar_data != NULL) ||(!dat->use_avatar_service && contact->avatar_pos != AVATAR_POS_DONT_HAVE); - while (gl_RowTabAccess[i]!=NULL) + hasAvatar = (dat->use_avatar_service && contact->avatar_data !=NULL) ||(!dat->use_avatar_service && contact->avatar_pos !=AVATAR_POS_DONT_HAVE); + while (gl_RowTabAccess[i] != NULL) { - if (gl_RowTabAccess[i]->type!=TC_SPACE) + if (gl_RowTabAccess[i]->type != TC_SPACE) { - gl_RowTabAccess[i]->h=0; - gl_RowTabAccess[i]->w=0; + gl_RowTabAccess[i]->h = 0; + gl_RowTabAccess[i]->w = 0; SetRect(&(gl_RowTabAccess[i]->r),0,0,0,0); switch (gl_RowTabAccess[i]->type) { case TC_TEXT1: { - int tmp=0; + 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) + if (item == -1) { //calculate text width here - SIZE size={0}; - RECT dummyRect={0,0,1024,tmp}; - HDC hdc=CreateCompatibleDC(NULL); + 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) + if (contact->type == CLCIT_GROUP) { char * szCounts = pcli->pfnGetGroupCountsText(dat, contact); - if(szCounts && strlen(szCounts)>0) + if (szCounts && strlen(szCounts)>0) { - RECT count_rc={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; + size.cx += count_rc.right-count_rc.left; + count_rc.right = 0; + count_rc.left = 0; ske_DrawTextA(hdc,szCounts,lstrlenA(szCounts),&count_rc,DT_CALCRECT); - size.cx +=count_rc.right-count_rc.left; + size.cx += count_rc.right-count_rc.left; tmp = max(tmp,count_rc.bottom-count_rc.top); } } - gl_RowTabAccess[i]->w=size.cx; + gl_RowTabAccess[i]->w = size.cx; SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT)); ske_ResetTextEffect(hdc); mod_DeleteDC(hdc); } - gl_RowTabAccess[i]->h=tmp; + gl_RowTabAccess[i]->h = tmp; break; } case TC_TEXT2: { - int tmp=0; - HANDLE hContact=pdnce->m_cache_hContact; + int tmp = 0; + HANDLE hContact = pdnce->m_cache_hContact; 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) + if (item == -1) { //calculate text width here - SIZE size={0}; - RECT dummyRect={0,0,1024,tmp}; - HDC hdc=CreateCompatibleDC(NULL); + 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; + gl_RowTabAccess[i]->w = size.cx; SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT)); ske_ResetTextEffect(hdc); mod_DeleteDC(hdc); } } - gl_RowTabAccess[i]->h=tmp; + gl_RowTabAccess[i]->h = tmp; break; } case TC_TEXT3: { - int tmp=0; - HANDLE hContact=pdnce->m_cache_hContact; + int tmp = 0; + HANDLE hContact = pdnce->m_cache_hContact; 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) + if (item == -1) { //calculate text width here - SIZE size={0}; - RECT dummyRect={0,0,1024,tmp}; - HDC hdc=CreateCompatibleDC(NULL); + 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; + gl_RowTabAccess[i]->w = size.cx; SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT)); ske_ResetTextEffect(hdc); mod_DeleteDC(hdc); } } - gl_RowTabAccess[i]->h=tmp; + gl_RowTabAccess[i]->h = tmp; 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)) + ( 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)) ) { - gl_RowTabAccess[i]->h=ICON_HEIGHT; - gl_RowTabAccess[i]->w=ICON_HEIGHT; + gl_RowTabAccess[i]->h = ICON_HEIGHT; + gl_RowTabAccess[i]->w = ICON_HEIGHT; } break; } @@ -231,17 +231,17 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * { 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) ) ) { - SIZE sz={0}; - int iW=0, iH=0; + SIZE sz = {0}; + int iW = 0, iH = 0; if (dat->use_avatar_service) { if (contact->avatar_data) { - iH=contact->avatar_data->bmHeight; - iW=contact->avatar_data->bmWidth; + iH = contact->avatar_data->bmHeight; + iW = contact->avatar_data->bmWidth; } } else if (dat->avatar_cache.nodes) @@ -249,12 +249,12 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * iW = dat->avatar_cache.nodes[contact->avatar_pos].width; iH = dat->avatar_cache.nodes[contact->avatar_pos].height; } - sz=GetAvatarSize(iW,iH,dat->avatars_maxwidth_size,dat->avatars_maxheight_size); - if ((sz.cx==0 || sz.cy==0) && dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage != -1) - { sz.cx=ICON_HEIGHT; sz.cy=ICON_HEIGHT; } + sz = GetAvatarSize(iW,iH,dat->avatars_maxwidth_size,dat->avatars_maxheight_size); + if ((sz.cx == 0 || sz.cy == 0) && dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage !=-1) + { sz.cx = ICON_HEIGHT; sz.cy = ICON_HEIGHT; } - gl_RowTabAccess[i]->h=sz.cy; - gl_RowTabAccess[i]->w=sz.cx; + gl_RowTabAccess[i]->h = sz.cy; + gl_RowTabAccess[i]->w = sz.cx; } break; @@ -266,20 +266,20 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * if (contact->type == CLCIT_CONTACT && (!contact->isSubcontact || db_get_b(NULL,"CLC","MetaHideExtra",SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) { - BOOL hasExtra=FALSE; + BOOL hasExtra = FALSE; int k; - int width=0; - for (k=0; kextraColumnsCount; k++) - if (contact->iExtraImage[k]!=0xFF || contact->iWideExtraImage[k]!=0xFFFF || !dat->MetaIgnoreEmptyExtra) + int width = 0; + for (k = 0; k < dat->extraColumnsCount; k++) + if (contact->iExtraImage[k] != 0xFF || contact->iWideExtraImage[k] != 0xFFFF || !dat->MetaIgnoreEmptyExtra) { - hasExtra=TRUE; - if (item!=-1) break; - width+=(width>0)?dat->extraColumnSpacing:(dat->extraColumnSpacing-2); + hasExtra = TRUE; + if (item != -1) break; + width += (width>0)?dat->extraColumnSpacing:(dat->extraColumnSpacing-2); } if (hasExtra) { - gl_RowTabAccess[i]->h=ICON_HEIGHT; - gl_RowTabAccess[i]->w=width; + gl_RowTabAccess[i]->h = ICON_HEIGHT; + gl_RowTabAccess[i]->w = width; } } break; @@ -297,12 +297,12 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * if (contact->type == CLCIT_CONTACT && (!contact->isSubcontact || db_get_b(NULL,"CLC","MetaHideExtra",SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) { - int eNum=gl_RowTabAccess[i]->type-TC_EXTRA1; - if (eNumextraColumnsCount) - if (contact->iExtraImage[eNum]!=255 || contact->iWideExtraImage[eNum]!=0xFFFF || !dat->MetaIgnoreEmptyExtra) + int eNum = gl_RowTabAccess[i]->type-TC_EXTRA1; + if (eNum < dat->extraColumnsCount) + if (contact->iExtraImage[eNum] != 255 || contact->iWideExtraImage[eNum] != 0xFFFF || !dat->MetaIgnoreEmptyExtra) { - gl_RowTabAccess[i]->h=ICON_HEIGHT; - gl_RowTabAccess[i]->w=ICON_HEIGHT; + gl_RowTabAccess[i]->h = ICON_HEIGHT; + gl_RowTabAccess[i]->w = ICON_HEIGHT; } } break; @@ -311,17 +311,17 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * { if (contact->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) { - gl_RowTabAccess[i]->h=dat->fontModernInfo[FONTID_CONTACT_TIME].fontHeight; - if (item==-1) + gl_RowTabAccess[i]->h = dat->fontModernInfo[FONTID_CONTACT_TIME].fontHeight; + if (item == -1) { TCHAR szResult[80]; if (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { - SIZE text_size={0}; - RECT rc={0}; + SIZE text_size = {0}; + RECT rc = {0}; // Select font - HDC hdc=CreateCompatibleDC(NULL); + HDC hdc = CreateCompatibleDC(NULL); g_clcPainter.ChangeToFont(hdc,dat,FONTID_CONTACT_TIME,NULL); // Get text size @@ -330,7 +330,7 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * ske_ResetTextEffect(hdc); mod_DeleteDC(hdc); text_size.cx = rc.right - rc.left; - gl_RowTabAccess[i]->w=text_size.cx; + gl_RowTabAccess[i]->w = text_size.cx; } } @@ -342,10 +342,10 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * i++; } - height=cppCalculateRowHeight(gl_RowRoot); - height+=dat->row_border*2; - height=max(height,dat->row_min_heigh); - if (item!=-1) dat->row_heights[item] = height; + height = cppCalculateRowHeight(gl_RowRoot); + height += dat->row_border*2; + height = max(height,dat->row_min_heigh); + if (item != -1) dat->row_heights[item] = height; return height; } @@ -361,8 +361,8 @@ int mod_CalcRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcContact * BOOL RowHeights_Initialize(struct ClcData *dat) { - dat->max_row_height = 0; - dat->row_heights_size = 0; + dat->max_row_height = 0; + dat->row_heights_size = 0; dat->row_heights_allocated = 0; dat->row_heights = NULL; @@ -371,7 +371,7 @@ BOOL RowHeights_Initialize(struct ClcData *dat) void RowHeights_Free(struct ClcData *dat) { - if (dat->row_heights != NULL) + if (dat->row_heights !=NULL) { free(dat->row_heights); dat->row_heights = NULL; @@ -395,9 +395,9 @@ BOOL RowHeights_Alloc(struct ClcData *dat, int size) { int size_grow = size; - size_grow += 100 - (size_grow % 100); + size_grow += 100 - (size_grow % 100); - if (dat->row_heights != NULL) + if (dat->row_heights !=NULL) { int *tmp = (int *) realloc((void *)dat->row_heights, sizeof(int) * size_grow); @@ -438,7 +438,7 @@ BOOL RowHeights_Alloc(struct ClcData *dat, int size) int RowHeights_GetMaxRowHeight(struct ClcData *dat, HWND hwnd) { int max_height = 0, i, tmp; - DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE); + DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE); if (!dat->text_ignore_size_for_row_height) { @@ -458,7 +458,7 @@ int RowHeights_GetMaxRowHeight(struct ClcData *dat, HWND hwnd) { tmp = max(tmp, dat->text_smiley_height); } - max_height += tmp; + max_height += tmp; if (dat->second_line_show) { @@ -467,7 +467,7 @@ int RowHeights_GetMaxRowHeight(struct ClcData *dat, HWND hwnd) { tmp = max(tmp, dat->text_smiley_height); } - max_height += dat->second_line_top_space + tmp; + max_height += dat->second_line_top_space + tmp; } if (dat->third_line_show) @@ -477,7 +477,7 @@ int RowHeights_GetMaxRowHeight(struct ClcData *dat, HWND hwnd) { tmp = max(tmp, dat->text_smiley_height); } - max_height += dat->third_line_top_space + tmp; + max_height += dat->third_line_top_space + tmp; } // Get other font sizes @@ -506,7 +506,7 @@ int RowHeights_GetMaxRowHeight(struct ClcData *dat, HWND hwnd) max_height = max(max_height, ICON_HEIGHT); } - max_height += 2 * dat->row_border; + max_height += 2 * dat->row_border; // Min size max_height = max(max_height, dat->row_min_heigh); @@ -535,23 +535,23 @@ void RowHeights_CalcRowHeights_Worker(struct ClcData *dat, HWND hwnd) if (MirandaExiting()) return; // Draw lines - group=&dat->list; - group->scanIndex=0; - indent=0; - subindex=-1; + group = &dat->list; + group->scanIndex = 0; + indent = 0; + subindex = -1; line_num = -1; RowHeights_Clear(dat); while(TRUE) { - if (subindex==-1) + if (subindex == -1) { - if (group->scanIndex==group->cl.count) + if (group->scanIndex == group->cl.count) { - group=group->parent; + group = group->parent; indent--; - if(group==NULL) break; // Finished list + if (group == NULL) break; // Finished list group->scanIndex++; continue; } @@ -574,29 +574,29 @@ void RowHeights_CalcRowHeights_Worker(struct ClcData *dat, HWND hwnd) else RowHeight_CalcRowHeight(dat, hwnd, Drawing, line_num); //increment by subcontacts - if (group->cl.items[group->scanIndex]->subcontacts!=NULL && group->cl.items[group->scanIndex]->type!=CLCIT_GROUP) + if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta) { - if (subindexcl.items[group->scanIndex]->SubAllocated-1) + if (subindex < group->cl.items[group->scanIndex]->SubAllocated-1) { subindex++; } else { - subindex=-1; + subindex = -1; } } } - if(subindex==-1) + if (subindex == -1) { - if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) + if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) { - group=group->cl.items[group->scanIndex]->group; + group = group->cl.items[group->scanIndex]->group; indent++; - group->scanIndex=0; - subindex=-1; + group->scanIndex = 0; + subindex = -1; continue; } group->scanIndex++; @@ -612,7 +612,7 @@ int RowHeights_GetRowHeight(struct ClcData *dat, HWND hwnd, struct ClcContact *c int res; if (MirandaExiting()) return 0; g_mutex_nCalcRowHeightLock++; - res=RowHeights_GetRowHeight_worker(dat, hwnd, contact, item); + res = RowHeights_GetRowHeight_worker(dat, hwnd, contact, item); g_mutex_nCalcRowHeightLock--; return res; } @@ -625,13 +625,13 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon return RowHeight_CalcRowHeight(dat, hwnd, contact, item); else { - displayNameCacheEntry *pdnce=(displayNameCacheEntry *)pcli->pfnGetCacheEntry(contact->hContact); - DWORD style=GetWindowLongPtr(hwnd,GWL_STYLE); + displayNameCacheEntry *pdnce = (displayNameCacheEntry *)pcli->pfnGetCacheEntry(contact->hContact); + DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE); //TODO replace futher code with new rowheight definition int tmp; - BOOL selected=((item==dat->selection) && (dat->hwndRenameEdit!=NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type!=CLCIT_DIVIDER); - BOOL hottrack=((item==dat->iHotTrack) && (dat->hwndRenameEdit!=NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type!=CLCIT_DIVIDER); - BOOL minimalistic=(g_clcPainter.CheckMiniMode(dat,selected,hottrack)); + BOOL selected = ((item == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type != CLCIT_DIVIDER); + BOOL hottrack = ((item == dat->iHotTrack) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type != CLCIT_DIVIDER); + BOOL minimalistic = (g_clcPainter.CheckMiniMode(dat,selected,hottrack)); if (!RowHeights_Alloc(dat, item + 1)) return -1; @@ -639,13 +639,13 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon { if (!dat->text_ignore_size_for_row_height) { - HANDLE hContact=pdnce->m_cache_hContact; + HANDLE hContact = pdnce->m_cache_hContact; 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); } - height += tmp; + height += tmp; if (!minimalistic && dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { @@ -654,7 +654,7 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon { tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); } - height += dat->second_line_top_space + tmp; + height += dat->second_line_top_space + tmp; } if (!minimalistic && dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) @@ -664,7 +664,7 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon { tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); } - height += dat->third_line_top_space + tmp; + height += dat->third_line_top_space + tmp; } } @@ -672,17 +672,17 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon if (dat->avatars_show && !dat->avatars_ignore_size_for_row_height && contact->type == CLCIT_CONTACT && ( - (dat->use_avatar_service && contact->avatar_data != NULL) || - (!dat->use_avatar_service && contact->avatar_pos != AVATAR_POS_DONT_HAVE) + (dat->use_avatar_service && contact->avatar_data !=NULL) || + (!dat->use_avatar_service && contact->avatar_pos !=AVATAR_POS_DONT_HAVE) ) && !minimalistic ) { height = max(height, dat->avatars_maxheight_size); } // 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)) + if ((style&CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) || + (style&CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) || + (contact->type == CLCIT_INFO && contact->flags&CLCIIF_CHECKBOX)) { height = max(height, dat->checkboxSize); } @@ -691,10 +691,10 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon if (!dat->icon_ignore_size_for_row_height) { if (contact->type == CLCIT_GROUP - || (contact->type == CLCIT_CONTACT && contact->iImage != -1 + || (contact->type == CLCIT_CONTACT && contact->iImage !=-1 && !(dat->icon_hide_on_avatar && dat->avatars_show - && ( (dat->use_avatar_service && contact->avatar_data != NULL) || - (!dat->use_avatar_service && contact->avatar_pos != AVATAR_POS_DONT_HAVE) + && ( (dat->use_avatar_service && contact->avatar_data !=NULL) || + (!dat->use_avatar_service && contact->avatar_pos !=AVATAR_POS_DONT_HAVE) ) && !contact->image_is_special))) { @@ -702,7 +702,7 @@ int RowHeights_GetRowHeight_worker(struct ClcData *dat, HWND hwnd, struct ClcCon } } - height += 2 * dat->row_border; + height += 2 * dat->row_border; // Min size height = max(height, dat->row_min_heigh); @@ -724,12 +724,12 @@ int cliGetRowTopY(struct ClcData *dat, int item) { int i; int y = 0; - if (item >= dat->row_heights_size) + if (item >= dat->row_heights_size) return cliGetRowBottomY(dat,item-1); for (i = 0 ; i < item ; i++) { - y += dat->row_heights[i]; + y += dat->row_heights[i]; } return y; @@ -742,12 +742,12 @@ int cliGetRowBottomY(struct ClcData *dat, int item) int i; int y = 0; - if (item >= dat->row_heights_size) + if (item >= dat->row_heights_size) return -1; for (i = 0 ; i <= item ; i++) { - y += dat->row_heights[i]; + y += dat->row_heights[i]; } return y; @@ -762,7 +762,7 @@ int cliGetRowTotalHeight(struct ClcData *dat) for (i = 0 ; i < dat->row_heights_size ; i++) { - y += dat->row_heights[i]; + y += dat->row_heights[i]; } return y; @@ -779,7 +779,7 @@ int cliRowHitTest(struct ClcData *dat, int pos_y) for (i = 0 ; i < dat->row_heights_size ; i++) { - y += dat->row_heights[i]; + y += dat->row_heights[i]; if (pos_y < y) return i; @@ -790,7 +790,7 @@ int cliRowHitTest(struct ClcData *dat, int pos_y) int cliGetRowHeight(struct ClcData *dat, int item) { - if ( item >= dat->row_heights_size || item <0 ) + if ( item >= dat->row_heights_size || item < 0 ) return dat->max_row_height; return dat->row_heights[ item ]; } -- cgit v1.2.3