From 3e102800404c38bc615cc06fd7117f2b4daeb6c5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 7 Jul 2012 08:29:51 +0000 Subject: removed mir_free_and_nil for local buffers git-svn-id: http://svn.miranda-ng.org/main/trunk@809 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/clist_modern_10.vcxproj | 1 + .../Clist_modern/clist_modern_10.vcxproj.filters | 18 +- plugins/Clist_modern/hdr/modern_commonheaders.h | 2 +- plugins/Clist_modern/modern_cachefuncs.cpp | 202 +- plugins/Clist_modern/modern_clc.cpp | 20 +- plugins/Clist_modern/modern_clcidents.cpp | 2 +- plugins/Clist_modern/modern_clcitems.cpp | 20 +- plugins/Clist_modern/modern_clcopts.cpp | 40 +- plugins/Clist_modern/modern_clcpaint.cpp | 5142 ++++++++++---------- plugins/Clist_modern/modern_clcutils.cpp | 9 +- plugins/Clist_modern/modern_clistevents.cpp | 2 +- plugins/Clist_modern/modern_clistmod.cpp | 2 +- plugins/Clist_modern/modern_clistopts.cpp | 4 +- plugins/Clist_modern/modern_clistsettings.cpp | 54 +- plugins/Clist_modern/modern_clisttray.cpp | 13 +- plugins/Clist_modern/modern_clui.cpp | 38 +- plugins/Clist_modern/modern_cluiframes.cpp | 117 +- plugins/Clist_modern/modern_commonheaders.cpp | 6 +- plugins/Clist_modern/modern_contact.cpp | 2 +- plugins/Clist_modern/modern_docking.cpp | 2 +- plugins/Clist_modern/modern_extraimage.cpp | 6 +- plugins/Clist_modern/modern_framesmenu.cpp | 10 +- plugins/Clist_modern/modern_image_array.cpp | 16 +- plugins/Clist_modern/modern_newrowopts.cpp | 27 +- plugins/Clist_modern/modern_row.cpp | 5 +- plugins/Clist_modern/modern_skinbutton.cpp | 75 +- plugins/Clist_modern/modern_skineditor.cpp | 288 +- plugins/Clist_modern/modern_skinengine.cpp | 351 +- plugins/Clist_modern/modern_skinopt.cpp | 8 +- plugins/Clist_modern/modern_skinselector.cpp | 17 +- plugins/Clist_modern/modern_statusbar.cpp | 56 +- plugins/Clist_modern/modern_viewmodebar.cpp | 30 +- plugins/Clist_modern/resource.rc | 17 +- 33 files changed, 3118 insertions(+), 3484 deletions(-) diff --git a/plugins/Clist_modern/clist_modern_10.vcxproj b/plugins/Clist_modern/clist_modern_10.vcxproj index b9dfd884df..0d551cafe7 100644 --- a/plugins/Clist_modern/clist_modern_10.vcxproj +++ b/plugins/Clist_modern/clist_modern_10.vcxproj @@ -250,6 +250,7 @@ + diff --git a/plugins/Clist_modern/clist_modern_10.vcxproj.filters b/plugins/Clist_modern/clist_modern_10.vcxproj.filters index 5d1d16e8a8..4cd0989330 100644 --- a/plugins/Clist_modern/clist_modern_10.vcxproj.filters +++ b/plugins/Clist_modern/clist_modern_10.vcxproj.filters @@ -16,9 +16,6 @@ {98ef713e-45a0-4ca0-929b-636ed86d9478} - - {23cad96b-3c17-441a-a67d-d3053a53961b} - @@ -176,17 +173,20 @@ Resource Files + + Header Files + + + Header Files + - hdr + Header Files - hdr + Header Files - hdr - - - hdr + Header Files diff --git a/plugins/Clist_modern/hdr/modern_commonheaders.h b/plugins/Clist_modern/hdr/modern_commonheaders.h index cb1685337a..86f649df78 100644 --- a/plugins/Clist_modern/hdr/modern_commonheaders.h +++ b/plugins/Clist_modern/hdr/modern_commonheaders.h @@ -141,7 +141,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern char *g_szMetaModuleName; //macros to free data and set it pointer to NULL -#define mir_free_and_nill(x) {mir_free((void*)x); x=NULL;} +#define mir_free_and_nil(x) {mir_free((void*)x); x=NULL;} // shared vars #define CLUI_FRAME_AUTOHIDENOTIFY 512 diff --git a/plugins/Clist_modern/modern_cachefuncs.cpp b/plugins/Clist_modern/modern_cachefuncs.cpp index 343321d503..011290186c 100644 --- a/plugins/Clist_modern/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/modern_cachefuncs.cpp @@ -107,10 +107,8 @@ void CSmileyString::AddListeningToIcon(struct SHORTDATA *dat, PDNCE pdnce, TCHAR piece->smiley_width = 16; piece->smiley_height = 16; - if (GetIconInfo(piece->smiley, &icon)) - { - if (GetObject(icon.hbmColor,sizeof(BITMAP),&bm)) - { + if (GetIconInfo(piece->smiley, &icon)) { + if (GetObject(icon.hbmColor,sizeof(BITMAP),&bm)) { piece->smiley_width = bm.bmWidth; piece->smiley_height = bm.bmHeight; } @@ -428,11 +426,10 @@ int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR * DBVARIANT dbv = {0}; // Try to get XStatusMsg - if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { + if ( !DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) { - TCHAR *tmp = mir_tstrdup(text); - mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal); - mir_free_and_nill(tmp); + TCHAR *tmp = NEWTSTR_ALLOCA(text); + mir_sntprintf(text, text_size, _T("%s: %s"), tmp, dbv.ptszVal); CopySkipUnprintableChars(text, text, text_size-1); } db_free(&dbv); @@ -460,10 +457,8 @@ int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR * // Try to get XStatusName if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) { - TCHAR *tmp = mir_tstrdup(text); - - mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp); - mir_free_and_nill(tmp); + TCHAR *tmp = NEWTSTR_ALLOCA(text); + mir_sntprintf(text, text_size, _T("%s: %s"), dbv.pszVal, tmp); } CopySkipUnprintableChars(text, text, text_size-1); db_free(&dbv); @@ -474,7 +469,7 @@ int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR * // Try to get XStatusName if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) - mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal); + mir_sntprintf(text, text_size, _T("%s"), dbv.pszVal); CopySkipUnprintableChars(text, text, text_size-1); db_free(&dbv); } @@ -705,38 +700,26 @@ static BOOL ExecuteOnAllContacts(struct ClcData *dat, ExecuteOnAllContactsFuncPt static BOOL ExecuteOnAllContactsOfGroup(struct ClcGroup *group, ExecuteOnAllContactsFuncPtr func, void *param) { - int scanIndex, i; - if (group) - for(scanIndex = 0 ; scanIndex < group->cl.count ; scanIndex++) - { - if (group->cl.items[scanIndex]->type == CLCIT_CONTACT) - { - if (!func(group->cl.items[scanIndex], FALSE, param)) - { - return FALSE; - } + if (!group) + return TRUE; - if (group->cl.items[scanIndex]->SubAllocated > 0) - { - for (i=0 ; i < group->cl.items[scanIndex]->SubAllocated ; i++) - { - if (!func(&group->cl.items[scanIndex]->subcontacts[i], TRUE, param)) - { - return FALSE; - } - } - } - } - else if (group->cl.items[scanIndex]->type == CLCIT_GROUP) - { - if (!ExecuteOnAllContactsOfGroup(group->cl.items[scanIndex]->group, func, param)) - { - return FALSE; - } + for (int scanIndex = 0 ; scanIndex < group->cl.count ; scanIndex++) { + if (group->cl.items[scanIndex]->type == CLCIT_CONTACT) { + if (!func(group->cl.items[scanIndex], FALSE, param)) + return FALSE; + + if (group->cl.items[scanIndex]->SubAllocated > 0) { + for (int i=0 ; i < group->cl.items[scanIndex]->SubAllocated ; i++) + if (!func(&group->cl.items[scanIndex]->subcontacts[i], TRUE, param)) + return FALSE; } } + else if (group->cl.items[scanIndex]->type == CLCIT_GROUP) + if (!ExecuteOnAllContactsOfGroup(group->cl.items[scanIndex]->group, func, param)) + return FALSE; + } - return TRUE; + return TRUE; } @@ -757,9 +740,7 @@ void UpdateAllAvatars(struct ClcData *dat) BOOL ReduceAvatarPosition(struct ClcContact *contact, BOOL subcontact, void *param) { if (contact->avatar_pos >= *((int *)param)) - { contact->avatar_pos--; - } return TRUE; } @@ -770,13 +751,9 @@ void Cache_ProceedAvatarInList(struct ClcData *dat, struct ClcContact *contact) struct avatarCacheEntry * ace = contact->avatar_data; int old_pos = contact->avatar_pos; - if ( ace == NULL - || ace->dwFlags == AVS_BITMAP_EXPIRED - || ace->hbmPic == NULL) - { + if (ace == NULL || ace->dwFlags == AVS_BITMAP_EXPIRED || ace->hbmPic == NULL) { //Avatar was not ready or removed - need to remove it from cache - if (old_pos >= 0) - { + if (old_pos >= 0) { ImageArray_RemoveImage(&dat->avatar_cache, old_pos); // Update all items ExecuteOnAllContacts(dat, ReduceAvatarPosition, (void *)&old_pos); @@ -786,10 +763,6 @@ void Cache_ProceedAvatarInList(struct ClcData *dat, struct ClcContact *contact) } else if (contact->avatar_data->hbmPic != NULL) //Lets Add it { - HDC hdc; - HBITMAP hDrawBmp,oldBmp; - void * pt; - // Make bounds -> keep aspect radio LONG width_clip; LONG height_clip; @@ -800,114 +773,83 @@ void Cache_ProceedAvatarInList(struct ClcData *dat, struct ClcContact *contact) height_clip = dat->avatars_maxheight_size; if (height_clip * ace->bmWidth / ace->bmHeight <= width_clip) - { width_clip = height_clip * ace->bmWidth / ace->bmHeight; - } else - { height_clip = width_clip * ace->bmHeight / ace->bmWidth; - } - if (wildcmpi(contact->avatar_data->szFilename,_T("*.gif"))) - { - int res; + + if (wildcmpi(contact->avatar_data->szFilename,_T("*.gif"))) { if (old_pos == AVATAR_POS_ANIMATED) AniAva_RemoveAvatar(contact->hContact); - res = AniAva_AddAvatar(contact->hContact, contact->avatar_data->szFilename, width_clip, height_clip); - if (res) - { + int res = AniAva_AddAvatar(contact->hContact, contact->avatar_data->szFilename, width_clip, height_clip); + if (res) { contact->avatar_pos = AVATAR_POS_ANIMATED; contact->avatar_size.cy = HIWORD(res); contact->avatar_size.cx = LOWORD(res); return; } } + // Create objs - hdc = CreateCompatibleDC(dat->avatar_cache.hdc); - hDrawBmp = ske_CreateDIB32Point(width_clip, height_clip,&pt); - oldBmp = (HBITMAP)SelectObject(hdc, hDrawBmp); + void * pt; + HDC hdc = CreateCompatibleDC(dat->avatar_cache.hdc); + HBITMAP hDrawBmp = ske_CreateDIB32Point(width_clip, height_clip,&pt); + HBITMAP oldBmp = (HBITMAP)SelectObject(hdc, hDrawBmp); //need to draw avatar bitmap here { RECT real_rc = {0,0,width_clip, height_clip}; - /* - if (ServiceExists(MS_AV_BLENDDRAWAVATAR)) - { - AVATARDRAWREQUEST adr; - - adr.cbSize = sizeof(AVATARDRAWREQUEST); - adr.hContact = contact->hContact; - adr.hTargetDC = hdc; - adr.rcDraw = real_rc; - adr.dwFlags = 0; - adr.alpha = 255; - CallService(MS_AV_BLENDDRAWAVATAR, 0, (LPARAM) &adr); - } - else - */ - { - int w = width_clip; - int h = height_clip; - if (!g_CluiData.fGDIPlusFail) //Use gdi+ engine - { - DrawAvatarImageWithGDIp(hdc, 0, 0, w, h,ace->hbmPic,0,0,ace->bmWidth,ace->bmHeight,ace->dwFlags,255); + + int w = width_clip; + int h = height_clip; + if (!g_CluiData.fGDIPlusFail) //Use gdi+ engine + DrawAvatarImageWithGDIp(hdc, 0, 0, w, h,ace->hbmPic,0,0,ace->bmWidth,ace->bmHeight,ace->dwFlags,255); + else { + if ( !(ace->dwFlags & AVS_PREMULTIPLIED)) { + HDC hdcTmp = CreateCompatibleDC(hdc); + RECT r = {0,0,w,h}; + HDC hdcTmp2 = CreateCompatibleDC(hdc); + HBITMAP bmo = (HBITMAP)SelectObject(hdcTmp,ace->hbmPic); + HBITMAP b2 = ske_CreateDIB32(w,h); + HBITMAP bmo2 = (HBITMAP)SelectObject(hdcTmp2,b2); + SetStretchBltMode(hdcTmp, HALFTONE); + SetStretchBltMode(hdcTmp2, HALFTONE); + StretchBlt(hdcTmp2, 0, 0, w, h, + hdcTmp, 0, 0, ace->bmWidth, ace->bmHeight, + SRCCOPY); + + ske_SetRectOpaque(hdcTmp2,&r); + BitBlt(hdc, rc.left, rc.top, w, h,hdcTmp2,0,0,SRCCOPY); + SelectObject(hdcTmp2,bmo2); + SelectObject(hdcTmp,bmo); + mod_DeleteDC(hdcTmp); + mod_DeleteDC(hdcTmp2); + DeleteObject(b2); } - else - { - if (!(ace->dwFlags&AVS_PREMULTIPLIED)) - { - HDC hdcTmp = CreateCompatibleDC(hdc); - RECT r = {0,0,w,h}; - HDC hdcTmp2 = CreateCompatibleDC(hdc); - HBITMAP bmo = (HBITMAP)SelectObject(hdcTmp,ace->hbmPic); - HBITMAP b2 = ske_CreateDIB32(w,h); - HBITMAP bmo2 = (HBITMAP)SelectObject(hdcTmp2,b2); - SetStretchBltMode(hdcTmp, HALFTONE); - SetStretchBltMode(hdcTmp2, HALFTONE); - StretchBlt(hdcTmp2, 0, 0, w, h, - hdcTmp, 0, 0, ace->bmWidth, ace->bmHeight, - SRCCOPY); - - ske_SetRectOpaque(hdcTmp2,&r); - BitBlt(hdc, rc.left, rc.top, w, h,hdcTmp2,0,0,SRCCOPY); - SelectObject(hdcTmp2,bmo2); - SelectObject(hdcTmp,bmo); - mod_DeleteDC(hdcTmp); - mod_DeleteDC(hdcTmp2); - DeleteObject(b2); - } - else { - BLENDFUNCTION bf = {AC_SRC_OVER, 0,255, AC_SRC_ALPHA }; - HDC hdcTempAv = CreateCompatibleDC(hdc); - HBITMAP hbmTempAvOld; - hbmTempAvOld = (HBITMAP)SelectObject(hdcTempAv,ace->hbmPic); - ske_AlphaBlend(hdc, rc.left, rc.top, w, h, hdcTempAv, 0, 0,ace->bmWidth,ace->bmHeight, bf); - SelectObject(hdcTempAv, hbmTempAvOld); - mod_DeleteDC(hdcTempAv); - } + else { + BLENDFUNCTION bf = {AC_SRC_OVER, 0,255, AC_SRC_ALPHA }; + HDC hdcTempAv = CreateCompatibleDC(hdc); + HBITMAP hbmTempAvOld; + hbmTempAvOld = (HBITMAP)SelectObject(hdcTempAv,ace->hbmPic); + ske_AlphaBlend(hdc, rc.left, rc.top, w, h, hdcTempAv, 0, 0,ace->bmWidth,ace->bmHeight, bf); + SelectObject(hdcTempAv, hbmTempAvOld); + mod_DeleteDC(hdcTempAv); } } } SelectObject(hdc,oldBmp); DeleteDC(hdc); // Add to list - if (old_pos >= 0) - { + if (old_pos >= 0) { ImageArray_ChangeImage(&dat->avatar_cache, hDrawBmp, old_pos); contact->avatar_pos = old_pos; } - else - { - contact->avatar_pos = ImageArray_AddImage(&dat->avatar_cache, hDrawBmp, -1); - } + else contact->avatar_pos = ImageArray_AddImage(&dat->avatar_cache, hDrawBmp, -1); + if (old_pos == AVATAR_POS_ANIMATED && contact->avatar_pos != AVATAR_POS_ANIMATED) - { AniAva_RemoveAvatar(contact->hContact); - } DeleteObject(hDrawBmp); - } - } void Cache_GetAvatar(struct ClcData *dat, struct ClcContact *contact) diff --git a/plugins/Clist_modern/modern_clc.cpp b/plugins/Clist_modern/modern_clc.cpp index 21b252abce..0e2d875b4b 100644 --- a/plugins/Clist_modern/modern_clc.cpp +++ b/plugins/Clist_modern/modern_clc.cpp @@ -1575,8 +1575,7 @@ static LRESULT clcOnLButtonUp(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w TCHAR * groupName = mir_tstrdup(pcli->pfnGetGroupName(contact->groupId,0)); TCHAR * shortGroup = NULL; TCHAR * sourceGrName = mir_tstrdup(pcli->pfnGetGroupName(destgroup->groupId,0)); - if (groupName) - { + if (groupName) { int len = (int)_tcslen(groupName); do {len--;}while(len >= 0 && groupName[len] != '\\'); if (len >= 0) shortGroup = groupName+len+1; @@ -1590,8 +1589,8 @@ static LRESULT clcOnLButtonUp(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM w else mir_sntprintf(newName,SIZEOF(newName),_T("%s"),shortGroup); } - if (groupName) mir_free_and_nill(groupName); - if (sourceGrName) mir_free_and_nill(sourceGrName); + mir_free(groupName); + mir_free(sourceGrName); } newIndex = CallService(MS_CLIST_GROUPMOVEBEFORE, contact->groupId, (destcontact && i != -1)?destcontact->groupId:0); newIndex = newIndex?newIndex:contact->groupId; @@ -1623,7 +1622,7 @@ static LRESULT clcOnDestroy(struct ClcData *dat, HWND hwnd, UINT msg, WPARAM wPa { int i=0; - for(i=0;i <= FONTID_MODERN_MAX;i++) + for (i=0;i <= FONTID_MODERN_MAX;i++) { if (dat->fontModernInfo[i].hFont) DeleteObject(dat->fontModernInfo[i].hFont); dat->fontModernInfo[i].hFont = NULL; @@ -2048,13 +2047,12 @@ int ClcDoProtoAck(HANDLE wParam,ACKDATA * ack) if (ack->hContact) { char * val = db_get_sa(ack->hContact,"CList","StatusMsg"); - if (val) - { + if (val) { if (!mir_bool_strcmpi(val,"")) db_set_s(ack->hContact,"CList","StatusMsg",""); else gtaRenewText(ack->hContact); - mir_free_and_nill(val); + mir_free(val); } } //pcli->pfnClcBroadcast( INTM_STATUSMSGCHANGED,(WPARAM)ack->hContact,&a); @@ -2134,14 +2132,12 @@ LRESULT CALLBACK cli_ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wPara #define CASE_MSG_RET(msg, handler) case msg: return handler(dat, hwnd, msg, wParam, lParam); - struct ClcData *dat; - dat = (struct ClcData*)GetWindowLongPtr(hwnd,0); + struct ClcData *dat = (struct ClcData*)GetWindowLongPtr(hwnd,0); if (msg >= CLM_FIRST && msg < CLM_LAST) return cli_ProcessExternalMessages(hwnd,dat,msg,wParam,lParam); - switch (msg) - { + switch (msg) { CASE_MSG_RET( INTM_GROUPCHANGED, clcOnIntmGroupChanged ); CASE_MSG_RET( INTM_ICONCHANGED, clcOnIntmIconChanged ); CASE_MSG_RET( INTM_AVATARCHANGED, clcOnIntmAvatarChanged ); diff --git a/plugins/Clist_modern/modern_clcidents.cpp b/plugins/Clist_modern/modern_clcidents.cpp index 5da5d16ab3..67374a01a5 100644 --- a/plugins/Clist_modern/modern_clcidents.cpp +++ b/plugins/Clist_modern/modern_clcidents.cpp @@ -125,7 +125,7 @@ int FindItem(HWND hwnd,struct ClcData *dat,HANDLE hItem,struct ClcContact **cont group = group->parent; if (group == NULL) break; nowVisible = 1; - for(tgroup = group;tgroup;tgroup = tgroup->parent) + for (tgroup = group;tgroup;tgroup = tgroup->parent) { if (!tgroup->expanded) { diff --git a/plugins/Clist_modern/modern_clcitems.cpp b/plugins/Clist_modern/modern_clcitems.cpp index a2d2e2b50c..41da3057fe 100644 --- a/plugins/Clist_modern/modern_clcitems.cpp +++ b/plugins/Clist_modern/modern_clcitems.cpp @@ -100,7 +100,8 @@ void AddSubcontacts(struct ClcData *dat, struct ClcContact * cont, BOOL showOffl } } cont->SubAllocated = i; - if (!i && cont->subcontacts != NULL) mir_free_and_nill(cont->subcontacts); + if (!i && cont->subcontacts != NULL) + mir_free_and_nil(cont->subcontacts); } int cli_AddItemToGroup(struct ClcGroup *group,int iAboveItem) @@ -144,7 +145,7 @@ void cli_FreeContact(struct ClcContact *p) AniAva_RemoveAvatar( p->subcontacts[i].hContact ); p->subcontacts[i].avatar_pos = AVATAR_POS_DONT_HAVE; } - mir_free_and_nill(p->subcontacts); + mir_free_and_nil(p->subcontacts); } } p->ssText.DestroySmileyList(); @@ -240,7 +241,7 @@ static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup if (dat == NULL) return NULL; hContact = cacheEntry->m_cache_hContact; dat->NeedResort = 1; - for(i = group->cl.count-1;i >= 0;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); @@ -256,16 +257,11 @@ void * AddTempGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flag int f = 0; TCHAR * szGroupName; DWORD groupFlags; - char *mbuf = mir_u2a((TCHAR *)szName); - if (wildcmp(mbuf,"-@-HIDDEN-GROUP-@-",0)) - { - mir_free_and_nill(mbuf); + if ( wildcmp( _T2A(szName), "-@-HIDDEN-GROUP-@-",0)) return NULL; - } - mir_free_and_nill(mbuf); - for(i = 1;;i++) - { + + for (i = 1;;i++) { szGroupName = pcli->pfnGetGroupName(i,&groupFlags); if (szGroupName == NULL) break; if (!mir_tstrcmpi(szGroupName,szName)) f = 1; @@ -389,7 +385,7 @@ void cliRebuildEntireList(HWND hwnd,struct ClcData *dat) TCHAR *szGroupName; DWORD groupFlags; - for(i = 1;;i++) { + for (i = 1;;i++) { szGroupName = pcli->pfnGetGroupName(i,&groupFlags); //UNICODE if (szGroupName == NULL) break; cli_AddGroup(hwnd,dat,szGroupName,groupFlags,i,0); diff --git a/plugins/Clist_modern/modern_clcopts.cpp b/plugins/Clist_modern/modern_clcopts.cpp index 077fe882e5..76e5f368d7 100644 --- a/plugins/Clist_modern/modern_clcopts.cpp +++ b/plugins/Clist_modern/modern_clcopts.cpp @@ -368,7 +368,7 @@ static void FillCheckBoxTree(HWND hwndTree,const struct CheckBoxValues_t *values tvis.hParent = NULL; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE|TVIF_IMAGE; - for(i=0;i < nValues;i++) { + for (i=0;i < nValues;i++) { tvis.item.lParam = values[i].style; tvis.item.pszText = TranslateTS(values[i].szDescr); tvis.item.stateMask = TVIS_STATEIMAGEMASK; @@ -506,7 +506,7 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar } { DWORD exStyle = db_get_dw(NULL,"CLC","ExStyle",GetDefaultExStyle()); - for(int i=0;i < SIZEOF(checkBoxToStyleEx);i++) + for (int i=0;i < SIZEOF(checkBoxToStyleEx);i++) CheckDlgButton(hwndDlg,checkBoxToStyleEx[i].id,(exStyle&checkBoxToStyleEx[i].flag)^(checkBoxToStyleEx[i].flag*checkBoxToStyleEx[i].neg)?BST_CHECKED:BST_UNCHECKED); } { @@ -566,7 +566,7 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar case PSN_APPLY: { DWORD exStyle = 0; - for(int i=0;i < SIZEOF(checkBoxToStyleEx);i++) + for (int i=0;i < SIZEOF(checkBoxToStyleEx);i++) if ((IsDlgButtonChecked(hwndDlg,checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].neg) exStyle |= checkBoxToStyleEx[i].flag; db_set_dw(NULL,"CLC","ExStyle",exStyle); @@ -647,7 +647,7 @@ static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM w } { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD); - MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandle(TEXT("shlwapi")),"SHAutoComplete"); + MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandle(_T("shlwapi")),"SHAutoComplete"); if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); } return TRUE; @@ -753,7 +753,7 @@ static int _GetNetVisibleProtoCount() int i,count,netProtoCount; PROTOACCOUNT **accs; ProtoEnumAccounts( &count, &accs ); - for(i=0,netProtoCount = 0;i < count;i++) + for (i=0,netProtoCount = 0;i < count;i++) { if ( pcli->pfnGetProtocolVisibility(accs[i]->szModuleName) == 0 ) continue; netProtoCount++; @@ -923,7 +923,7 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L ProtoEnumAccounts( &count, &accs ); item = SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_ADDSTRING,0,(LPARAM)TranslateT("Global")); SendDlgItemMessage(hwndDlg,IDC_PRIMARYSTATUS,CB_SETITEMDATA,item,(LPARAM)0); - for(i=0;i < count;i++) { + for (i=0;i < count;i++) { if ( !IsAccountEnabled( accs[i] ) || CallProtoService(accs[i]->szModuleName,PS_GETCAPS,PFLAGNUM_2,0) == 0) continue; @@ -1280,36 +1280,32 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP { DBVARIANT dbv = {0}; - TCHAR *s = NULL; - char szUin[20]; + TCHAR *s; if (!DBGetContactSettingTString(NULL,"CList","TitleText",&dbv)) - s = mir_tstrdup(dbv.ptszVal); + s = dbv.ptszVal; else - s = mir_tstrdup(_T(MIRANDANAME)); - //dbv.pszVal = s; - SetDlgItemText(hwndDlg,IDC_TITLETEXT,s); - if (s) mir_free_and_nill(s); + s = _T(MIRANDANAME); + SetDlgItemText(hwndDlg, IDC_TITLETEXT, s); db_free(&dbv); - //if (s) mir_free_and_nill(s); + SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)MIRANDANAME); + + char szUin[20]; sprintf(szUin,"%u",db_get_dw(NULL,"ICQ","UIN",0)); SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)szUin); if (!DBGetContactSettingString(NULL,"ICQ","Nick",&dbv)) { SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal); - //mir_free_and_nill(dbv.pszVal); db_free(&dbv); dbv.pszVal = NULL; } if (!DBGetContactSettingString(NULL,"ICQ","FirstName",&dbv)) { SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal); - //mir_free_and_nill(dbv.pszVal); db_free(&dbv); dbv.pszVal = NULL; } if (!DBGetContactSettingString(NULL,"ICQ","e-mail",&dbv)) { SendDlgItemMessage(hwndDlg,IDC_TITLETEXT,CB_ADDSTRING,0,(LPARAM)dbv.pszVal); - //mir_free_and_nill(dbv.pszVal); db_free(&dbv); dbv.pszVal = NULL; } @@ -1452,7 +1448,7 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP if (IsDlgButtonChecked(hwndDlg,IDC_ONDESKTOP)) { - HWND hProgMan = FindWindow(TEXT("Progman"),NULL); + HWND hProgMan = FindWindow(_T("Progman"),NULL); if (IsWindow(hProgMan)) { SetParent(pcli->hwndContactList,hProgMan); @@ -1564,7 +1560,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, dat->count = bkgrCount; dat->item = (struct BkgrItem*)mir_alloc(sizeof(struct BkgrItem)*dat->count); dat->indx = CB_ERR; - for(indx = 0; indx < dat->count; indx++) + for (indx = 0; indx < dat->count; indx++) { char *module = bkgrList[indx] + strlen(bkgrList[indx]) + 1; int jndx; @@ -1709,7 +1705,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { int isChecked = IsDlgButtonChecked(hwndDlg,IDC_BITMAP); int indx; - for(indx = 0; indx < SIZEOF(bitmapRelatedControls); indx++) + for (indx = 0; indx < SIZEOF(bitmapRelatedControls); indx++) EnableWindow(GetDlgItem(hwndDlg, bitmapRelatedControls[indx]),isChecked); break; } @@ -1775,7 +1771,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { int indx; SendMessage(hwndDlg, M_BKGR_GETSTATE, SendDlgItemMessage(hwndDlg, IDC_BKGRLIST, CB_GETCURSEL, 0,0), 0); - for(indx = 0; indx < dat->count; indx++) + for (indx = 0; indx < dat->count; indx++) if (dat->item[indx].changed) { char *module = bkgrList[indx] + strlen(bkgrList[indx]) + 1; @@ -1852,7 +1848,7 @@ HRESULT BackgroundsLoadModule() int BackgroundsUnloadModule(void) { if (bkgrList != NULL) { - for(int indx = 0; indx < bkgrCount; indx++) + for (int indx = 0; indx < bkgrCount; indx++) if (bkgrList[indx] != NULL) mir_free(bkgrList[indx]); mir_free(bkgrList); diff --git a/plugins/Clist_modern/modern_clcpaint.cpp b/plugins/Clist_modern/modern_clcpaint.cpp index 72445c2b39..c1dee212ee 100644 --- a/plugins/Clist_modern/modern_clcpaint.cpp +++ b/plugins/Clist_modern/modern_clcpaint.cpp @@ -119,39 +119,36 @@ void CLCPaint::cliPaintClc( HWND hwnd, struct ClcData *dat, HDC hdc, RECT *rcPa BOOL CLCPaint::IsForegroundWindow( HWND hWnd ) { - HWND hWindow; - hWindow = hWnd; - while ( hWindow ) - { - if ( GetForegroundWindow() == hWindow ) return TRUE; - hWindow = GetParent( hWindow ); - } - return FALSE; + HWND hWindow; + hWindow = hWnd; + while ( hWindow ) { + if ( GetForegroundWindow() == hWindow ) return TRUE; + hWindow = GetParent( hWindow ); + } + return FALSE; } HFONT CLCPaint::ChangeToFont( HDC hdc, struct ClcData *dat, int id, int *fontHeight ) { - HFONT res; - if ( !dat ) - dat = ( struct ClcData* )GetWindowLongPtr( pcli->hwndContactTree, 0 ); + dat = ( struct ClcData* )GetWindowLongPtr( pcli->hwndContactTree, 0 ); if ( !dat ) return NULL; - res = ( HFONT )SelectObject( hdc, dat->fontModernInfo[id].hFont ); - SetTextColor( hdc, dat->fontModernInfo[id].colour ); - + HFONT res = ( HFONT )SelectObject( hdc, dat->fontModernInfo[id].hFont ); + SetTextColor( hdc, dat->fontModernInfo[id].colour ); + if ( fontHeight ) *fontHeight = dat->fontModernInfo[id].fontHeight; - ske_ResetTextEffect( hdc ); + ske_ResetTextEffect( hdc ); - if ( dat->hWnd == pcli->hwndContactTree && dat->fontModernInfo[id].effect != 0 ) - ske_SelectTextEffect( hdc, dat->fontModernInfo[id].effect-1, dat->fontModernInfo[id].effectColour1, dat->fontModernInfo[id].effectColour2 ); - else + if ( dat->hWnd == pcli->hwndContactTree && dat->fontModernInfo[id].effect != 0 ) + ske_SelectTextEffect( hdc, dat->fontModernInfo[id].effect-1, dat->fontModernInfo[id].effectColour1, dat->fontModernInfo[id].effectColour2 ); + else ske_ResetTextEffect( hdc ); - return res; + return res; } int CLCPaint::GetBasicFontID( struct ClcContact * contact ) @@ -181,10 +178,10 @@ int CLCPaint::GetBasicFontID( struct ClcContact * contact ) if ( contact->flags & CONTACTF_NOTONLIST ) return FONTID_NOTONLIST; else if ( ( contact->flags&CONTACTF_INVISTO - && _GetRealStatus( contact, ID_STATUS_OFFLINE ) != ID_STATUS_INVISIBLE ) - || + && _GetRealStatus( contact, ID_STATUS_OFFLINE ) != ID_STATUS_INVISIBLE ) + || ( contact->flags&CONTACTF_VISTO - && _GetRealStatus( contact, ID_STATUS_OFFLINE ) == ID_STATUS_INVISIBLE )) + && _GetRealStatus( contact, ID_STATUS_OFFLINE ) == ID_STATUS_INVISIBLE )) { // the contact is in the always visible list and the proto is invisible // the contact is in the always invisible and the proto is in any other mode @@ -284,9 +281,9 @@ void CLCPaint::AddParam( MODERNMASK * mpModernMask, DWORD dwParamHash, const ch BOOL CLCPaint::CheckMiniMode( struct ClcData *dat, BOOL selected, BOOL hot ) { if ( ( !dat->bCompactMode /* not mini*/ ) - || ( ( dat->bCompactMode&0x01 ) && selected /*mini on selected*/ ) + || ( ( dat->bCompactMode&0x01 ) && selected /*mini on selected*/ ) /* || ( TRUE && hot )*/ ) return FALSE; - return TRUE; + return TRUE; } tPaintCallbackProc CLCPaint::PaintCallbackProc( HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData ) @@ -306,1369 +303,1369 @@ void CLCPaint::_FillQuickHash() void CLCPaint::_SetHotTrackColour( HDC hdc, struct ClcData *dat ) { - if ( dat->gammaCorrection ) { - COLORREF oldCol, newCol; - int oldLum, newLum; - - oldCol = GetTextColor( hdc ); - oldLum = ( GetRValue( oldCol )*30+GetGValue( oldCol )*59+GetBValue( oldCol )*11 )/100; - newLum = ( GetRValue( dat->hotTextColour )*30+GetGValue( dat->hotTextColour )*59+GetBValue( dat->hotTextColour )*11 )/100; - if ( newLum == 0 ) { - SetTextColor( hdc, dat->hotTextColour ); - return; - } - if ( newLum >= oldLum+20 ) { - oldLum += 20; - newCol = RGB( GetRValue( dat->hotTextColour )*oldLum/newLum, GetGValue( dat->hotTextColour )*oldLum/newLum, GetBValue( dat->hotTextColour )*oldLum/newLum ); - } - else if ( newLum <= oldLum ) { - int r, g, b; - r = GetRValue( dat->hotTextColour )*oldLum/newLum; - g = GetGValue( dat->hotTextColour )*oldLum/newLum; - b = GetBValue( dat->hotTextColour )*oldLum/newLum; - if ( r>255 ) { - g += ( r-255 )*3/7; - b += ( r-255 )*3/7; - r = 255; - } - if ( g>255 ) { - r += ( g-255 )*59/41; - if ( r>255 ) r = 255; - b += ( g-255 )*59/41; - g = 255; - } - if ( b>255 ) { - r += ( b-255 )*11/89; - if ( r>255 ) r = 255; - g += ( b-255 )*11/89; - if ( g>255 ) g = 255; - b = 255; - } - newCol = RGB( r, g, b ); - } - else newCol = dat->hotTextColour; - SetTextColor( hdc, newCol ); - } - else - SetTextColor( hdc, dat->hotTextColour ); + if ( dat->gammaCorrection ) { + COLORREF oldCol, newCol; + int oldLum, newLum; + + oldCol = GetTextColor( hdc ); + oldLum = ( GetRValue( oldCol )*30+GetGValue( oldCol )*59+GetBValue( oldCol )*11 )/100; + newLum = ( GetRValue( dat->hotTextColour )*30+GetGValue( dat->hotTextColour )*59+GetBValue( dat->hotTextColour )*11 )/100; + if ( newLum == 0 ) { + SetTextColor( hdc, dat->hotTextColour ); + return; + } + if ( newLum >= oldLum+20 ) { + oldLum += 20; + newCol = RGB( GetRValue( dat->hotTextColour )*oldLum/newLum, GetGValue( dat->hotTextColour )*oldLum/newLum, GetBValue( dat->hotTextColour )*oldLum/newLum ); + } + else if ( newLum <= oldLum ) { + int r, g, b; + r = GetRValue( dat->hotTextColour )*oldLum/newLum; + g = GetGValue( dat->hotTextColour )*oldLum/newLum; + b = GetBValue( dat->hotTextColour )*oldLum/newLum; + if ( r>255 ) { + g += ( r-255 )*3/7; + b += ( r-255 )*3/7; + r = 255; + } + if ( g>255 ) { + r += ( g-255 )*59/41; + if ( r>255 ) r = 255; + b += ( g-255 )*59/41; + g = 255; + } + if ( b>255 ) { + r += ( b-255 )*11/89; + if ( r>255 ) r = 255; + g += ( b-255 )*11/89; + if ( g>255 ) g = 255; + b = 255; + } + newCol = RGB( r, g, b ); + } + else newCol = dat->hotTextColour; + SetTextColor( hdc, newCol ); + } + else + SetTextColor( hdc, dat->hotTextColour ); } int CLCPaint::_GetStatusOnlineness( int status ) { - switch( status ) - { - case ID_STATUS_FREECHAT: return 110; - case ID_STATUS_ONLINE: return 100; - case ID_STATUS_OCCUPIED: return 60; - case ID_STATUS_ONTHEPHONE: return 50; - case ID_STATUS_DND: return 40; - case ID_STATUS_AWAY: return 30; - case ID_STATUS_OUTTOLUNCH: return 20; - case ID_STATUS_NA: return 10; - case ID_STATUS_INVISIBLE: return 5; - } - return 0; + switch( status ) + { + case ID_STATUS_FREECHAT: return 110; + case ID_STATUS_ONLINE: return 100; + case ID_STATUS_OCCUPIED: return 60; + case ID_STATUS_ONTHEPHONE: return 50; + case ID_STATUS_DND: return 40; + case ID_STATUS_AWAY: return 30; + case ID_STATUS_OUTTOLUNCH: return 20; + case ID_STATUS_NA: return 10; + case ID_STATUS_INVISIBLE: return 5; + } + return 0; } int CLCPaint::_GetGeneralisedStatus() { - int status = ID_STATUS_OFFLINE; - int statusOnlineness = 0; + int status = ID_STATUS_OFFLINE; + int statusOnlineness = 0; - for ( int i=0; i < pcli->hClcProtoCount; i++ ) + for ( int i=0; i < pcli->hClcProtoCount; i++ ) { - int thisStatus = pcli->clcProto[i].dwStatus; - if ( thisStatus == ID_STATUS_INVISIBLE ) + int thisStatus = pcli->clcProto[i].dwStatus; + if ( thisStatus == ID_STATUS_INVISIBLE ) return ID_STATUS_INVISIBLE; - int thisOnlineness = _GetStatusOnlineness( thisStatus ); - if ( thisOnlineness > statusOnlineness ) + int thisOnlineness = _GetStatusOnlineness( thisStatus ); + if ( thisOnlineness > statusOnlineness ) { - status = thisStatus; - statusOnlineness = thisOnlineness; - } - } - return status; + status = thisStatus; + statusOnlineness = thisOnlineness; + } + } + return status; } int CLCPaint::_GetRealStatus( struct ClcContact * pContact, int nStatus ) { if ( !pContact->proto ) return nStatus; - + for ( int i=0; i < pcli->hClcProtoCount; i++ ) { - if ( !lstrcmpA( pcli->clcProto[i].szProto, pContact->proto )) - return pcli->clcProto[i].dwStatus; + if ( !lstrcmpA( pcli->clcProto[i].szProto, pContact->proto )) + return pcli->clcProto[i].dwStatus; } - return nStatus; + return nStatus; } RECT CLCPaint::_GetRectangle( struct ClcData *dat, RECT *row_rc, RECT *free_row_rc, int *left_pos, int *right_pos, BOOL left, int real_width, int width, int height, int horizontal_space ) { - RECT rc = *free_row_rc; - int width_tmp = width; - if ( left ) - { - if ( dat->row_align_left_items_to_left ) - width_tmp = real_width; - - rc.left += ( width_tmp - real_width ) >> 1; - rc.right = rc.left + real_width; - rc.top += ( rc.bottom - rc.top - height ) >> 1; - rc.bottom = rc.top + height; - *left_pos += width_tmp + horizontal_space; - free_row_rc->left = row_rc->left + *left_pos; - } - else // if ( !left ) - { - if ( dat->row_align_right_items_to_right ) - width_tmp = real_width; - - if ( width_tmp > rc.right - rc.left ) - { - rc.left = rc.right + 1; - } - else - { - rc.left = max( rc.left + horizontal_space, rc.right - width_tmp ) + ( ( width_tmp - real_width ) >> 1 ); - rc.right = min( rc.left + real_width, rc.right ); - rc.top += max( 0, ( rc.bottom - rc.top - height ) >> 1 ); - rc.bottom = min( rc.top + height, rc.bottom ); - - *right_pos += min( width_tmp + horizontal_space, free_row_rc->right - free_row_rc->left ); - free_row_rc->right = row_rc->right - *right_pos; - } - } - - return rc; + RECT rc = *free_row_rc; + int width_tmp = width; + if ( left ) + { + if ( dat->row_align_left_items_to_left ) + width_tmp = real_width; + + rc.left += ( width_tmp - real_width ) >> 1; + rc.right = rc.left + real_width; + rc.top += ( rc.bottom - rc.top - height ) >> 1; + rc.bottom = rc.top + height; + *left_pos += width_tmp + horizontal_space; + free_row_rc->left = row_rc->left + *left_pos; + } + else // if ( !left ) + { + if ( dat->row_align_right_items_to_right ) + width_tmp = real_width; + + if ( width_tmp > rc.right - rc.left ) + { + rc.left = rc.right + 1; + } + else + { + rc.left = max( rc.left + horizontal_space, rc.right - width_tmp ) + ( ( width_tmp - real_width ) >> 1 ); + rc.right = min( rc.left + real_width, rc.right ); + rc.top += max( 0, ( rc.bottom - rc.top - height ) >> 1 ); + rc.bottom = min( rc.top + height, rc.bottom ); + + *right_pos += min( width_tmp + horizontal_space, free_row_rc->right - free_row_rc->left ); + free_row_rc->right = row_rc->right - *right_pos; + } + } + + return rc; } void CLCPaint::_DrawTextSmiley( HDC hdcMem, RECT * free_rc, SIZE * text_size, TCHAR *szText, int len, SortedList *plText, UINT uTextFormat, BOOL ResizeSizeSmiley ) { - if ( szText == NULL )return; - uTextFormat &= ~DT_RIGHT; - if ( plText == NULL ) - ske_DrawText( hdcMem, szText, len, free_rc, uTextFormat ); - else - { - // Draw list - int i; - int pos_x = 0; - int row_height; - RECT tmp_rc = *free_rc; - if ( len == -1 ) len = (int)_tcslen( szText ); - if ( uTextFormat & DT_RTLREADING ) - i = plText->realCount - 1; - else - i=0; - - // Get real height of the line - row_height = ske_DrawText( hdcMem, TEXT( "A" ), 1, &tmp_rc, DT_CALCRECT | uTextFormat ); - - // Just draw ellipsis - if ( free_rc->right <= free_rc->left ) - { - if ( gl_TrimText ) ske_DrawText( hdcMem, TEXT( "..." ), 3, free_rc, uTextFormat & ~DT_END_ELLIPSIS ); - } - else - { - // Draw text and smileys - for ( ; i < plText->realCount && i >= 0 && pos_x < text_size->cx && len > 0; i += ( uTextFormat & DT_RTLREADING ? -1 : 1 )) - { - ClcContactTextPiece *piece = ( ClcContactTextPiece * ) plText->items[i]; - RECT text_rc = *free_rc; - - if ( uTextFormat & DT_RTLREADING ) - text_rc.right -= pos_x; - else - text_rc.left += pos_x; - - if ( piece->type == TEXT_PIECE_TYPE_TEXT ) - { - tmp_rc = text_rc; - tmp_rc.right += 50; - ske_DrawText( hdcMem, &szText[piece->start_pos], min( len, piece->len ), &tmp_rc, DT_CALCRECT | ( uTextFormat & ~DT_END_ELLIPSIS )); - pos_x += tmp_rc.right - tmp_rc.left + 2; - - if ( uTextFormat & DT_RTLREADING ) - text_rc.left = max( text_rc.left, text_rc.right - ( tmp_rc.right - tmp_rc.left )); - - ske_DrawText( hdcMem, &szText[piece->start_pos], min( len, piece->len ), &text_rc, uTextFormat ); - len -= piece->len; - } - else - { - float factor = 0; - - if ( len < piece->len ) - { - len = 0; - } - else - { - LONG fac_width, fac_height; - len -= piece->len; - - if ( piece->smiley_height > row_height && ResizeSizeSmiley ) - { - factor = row_height / ( float ) piece->smiley_height; - } - else - { - factor = 1; - } - - fac_width = ( LONG )( piece->smiley_width * factor ); - fac_height = ( LONG )( piece->smiley_height * factor ); - - if ( uTextFormat & DT_RTLREADING ) - text_rc.left = max( text_rc.right - fac_width, text_rc.left ); - - if ( fac_width <= text_rc.right - text_rc.left ) - { - text_rc.top += ( row_height - fac_height ) >> 1; - - ske_DrawIconEx( hdcMem, text_rc.left, text_rc.top, piece->smiley, - fac_width, fac_height, 0, NULL, DI_NORMAL|( ( factor < 1 )?128:0 )); //TO DO enchance drawing quality - } - else - { - ske_DrawText( hdcMem, TEXT( "..." ), 3, &text_rc, uTextFormat ); - } - - pos_x += fac_width; - } - } - } - } - } + if ( szText == NULL )return; + uTextFormat &= ~DT_RIGHT; + if ( plText == NULL ) + ske_DrawText( hdcMem, szText, len, free_rc, uTextFormat ); + else + { + // Draw list + int i; + int pos_x = 0; + int row_height; + RECT tmp_rc = *free_rc; + if ( len == -1 ) len = (int)_tcslen( szText ); + if ( uTextFormat & DT_RTLREADING ) + i = plText->realCount - 1; + else + i=0; + + // Get real height of the line + row_height = ske_DrawText( hdcMem, _T( "A" ), 1, &tmp_rc, DT_CALCRECT | uTextFormat ); + + // Just draw ellipsis + if ( free_rc->right <= free_rc->left ) + { + if ( gl_TrimText ) ske_DrawText( hdcMem, _T( "..." ), 3, free_rc, uTextFormat & ~DT_END_ELLIPSIS ); + } + else + { + // Draw text and smileys + for ( ; i < plText->realCount && i >= 0 && pos_x < text_size->cx && len > 0; i += ( uTextFormat & DT_RTLREADING ? -1 : 1 )) + { + ClcContactTextPiece *piece = ( ClcContactTextPiece * ) plText->items[i]; + RECT text_rc = *free_rc; + + if ( uTextFormat & DT_RTLREADING ) + text_rc.right -= pos_x; + else + text_rc.left += pos_x; + + if ( piece->type == TEXT_PIECE_TYPE_TEXT ) + { + tmp_rc = text_rc; + tmp_rc.right += 50; + ske_DrawText( hdcMem, &szText[piece->start_pos], min( len, piece->len ), &tmp_rc, DT_CALCRECT | ( uTextFormat & ~DT_END_ELLIPSIS )); + pos_x += tmp_rc.right - tmp_rc.left + 2; + + if ( uTextFormat & DT_RTLREADING ) + text_rc.left = max( text_rc.left, text_rc.right - ( tmp_rc.right - tmp_rc.left )); + + ske_DrawText( hdcMem, &szText[piece->start_pos], min( len, piece->len ), &text_rc, uTextFormat ); + len -= piece->len; + } + else + { + float factor = 0; + + if ( len < piece->len ) + { + len = 0; + } + else + { + LONG fac_width, fac_height; + len -= piece->len; + + if ( piece->smiley_height > row_height && ResizeSizeSmiley ) + { + factor = row_height / ( float ) piece->smiley_height; + } + else + { + factor = 1; + } + + fac_width = ( LONG )( piece->smiley_width * factor ); + fac_height = ( LONG )( piece->smiley_height * factor ); + + if ( uTextFormat & DT_RTLREADING ) + text_rc.left = max( text_rc.right - fac_width, text_rc.left ); + + if ( fac_width <= text_rc.right - text_rc.left ) + { + text_rc.top += ( row_height - fac_height ) >> 1; + + ske_DrawIconEx( hdcMem, text_rc.left, text_rc.top, piece->smiley, + fac_width, fac_height, 0, NULL, DI_NORMAL|( ( factor < 1 )?128:0 )); //TO DO enchance drawing quality + } + else + { + ske_DrawText( hdcMem, _T( "..." ), 3, &text_rc, uTextFormat ); + } + + pos_x += fac_width; + } + } + } + } + } } void CLCPaint::_AddParameter( MODERNMASK * mpModernMask, MASKPARAM * lpParam ) { - mpModernMask->pl_Params = ( MASKPARAM * )realloc( mpModernMask->pl_Params, ( mpModernMask->dwParamCnt+1 )*sizeof( MASKPARAM )); - memmove( &( mpModernMask->pl_Params[mpModernMask->dwParamCnt] ), lpParam, sizeof( MASKPARAM )); - mpModernMask->dwParamCnt++; - memset( lpParam, 0, sizeof( MASKPARAM )); + mpModernMask->pl_Params = ( MASKPARAM * )realloc( mpModernMask->pl_Params, ( mpModernMask->dwParamCnt+1 )*sizeof( MASKPARAM )); + memmove( &( mpModernMask->pl_Params[mpModernMask->dwParamCnt] ), lpParam, sizeof( MASKPARAM )); + mpModernMask->dwParamCnt++; + memset( lpParam, 0, sizeof( MASKPARAM )); } void CLCPaint::_FillParam( MASKPARAM * lpParam, DWORD dwParamHash, const char* const szValue, DWORD dwValueHash ) { - lpParam->bMaskParamFlag = MPF_EQUAL|MPF_HASHED; - lpParam->dwId = dwParamHash; - if ( !dwValueHash && szValue && szValue[0] ) lpParam->dwValueHash = mod_CalcHash( szValue ); - else lpParam->dwValueHash = dwValueHash; - if ( szValue ) lpParam->szValue = strdupn( szValue, strlen( szValue )); - else lpParam->szValue = NULL; + lpParam->bMaskParamFlag = MPF_EQUAL|MPF_HASHED; + lpParam->dwId = dwParamHash; + if ( !dwValueHash && szValue && szValue[0] ) lpParam->dwValueHash = mod_CalcHash( szValue ); + else lpParam->dwValueHash = dwValueHash; + if ( szValue ) lpParam->szValue = strdupn( szValue, strlen( szValue )); + else lpParam->szValue = NULL; } void CLCPaint::_AddParamShort( MODERNMASK * mpModernMask, DWORD dwParamIndex, DWORD dwValueIndex ) { - AddParam( mpModernMask, HASH[dwParamIndex], HASHTEXT[dwValueIndex], HASH[dwValueIndex] ); + AddParam( mpModernMask, HASH[dwParamIndex], HASHTEXT[dwValueIndex], HASH[dwValueIndex] ); } MODERNMASK * CLCPaint::_GetCLCContactRowBackModernMask( struct ClcGroup * group, struct ClcContact * Drawing, int indent, int index, BOOL selected, BOOL hottrack, struct ClcData * dat ) { - MODERNMASK * mpModernMask = NULL; - char buf[BUF2SIZE] = {0}; - mpModernMask = ( MODERNMASK* )mir_calloc( sizeof( MODERNMASK )); - - _AddParamShort( mpModernMask, hi_Module, hi_CL ); - _AddParamShort( mpModernMask, hi_ID, hi_Row ); - switch ( Drawing->type ) - { - case CLCIT_GROUP: - { - _AddParamShort( mpModernMask, hi_Type, hi_Group ); - _AddParamShort( mpModernMask, hi_Open, ( Drawing && Drawing->group && Drawing->group->expanded )?hi_True:hi_False ); - _AddParamShort( mpModernMask, hi_IsEmpty, ( Drawing->group->cl.count == 0 )?hi_True:hi_False ); - } - break; - case CLCIT_CONTACT: - { - struct ClcContact * mCont = Drawing; - if ( Drawing->isSubcontact ) - { - _AddParamShort( mpModernMask, hi_Type, hi_SubContact ); - if ( Drawing->isSubcontact == 1 && Drawing->subcontacts->SubAllocated == 1 ) - _AddParamShort( mpModernMask, hi_SubPos, hi_First_Single ); - else if ( Drawing->isSubcontact == 1 ) - _AddParamShort( mpModernMask, hi_SubPos, hi_First ); - else if ( Drawing->isSubcontact == Drawing->subcontacts->SubAllocated ) - _AddParamShort( mpModernMask, hi_SubPos, hi_Last ); - else - _AddParamShort( mpModernMask, hi_SubPos, hi_Middle ); - mCont = Drawing->subcontacts; - } - else if ( Drawing->SubAllocated ) - { - _AddParamShort( mpModernMask, hi_Type, hi_MetaContact ); - _AddParamShort( mpModernMask, hi_Open, ( Drawing->SubExpanded )?hi_True:hi_False ); - } - else - _AddParamShort( mpModernMask, hi_Type, hi_Contact ); - AddParam( mpModernMask, HASH[hi_Protocol], Drawing->proto, 0 ); - _AddParamShort( mpModernMask, hi_RootGroup, ( group && group->parent == NULL )?hi_True:hi_False ); - switch( GetContactCachedStatus( Drawing->hContact )) - { - // case ID_STATUS_CONNECTING: AppendChar( buf, BUFSIZE, "CONNECTING" ); break; - case ID_STATUS_ONLINE: _AddParamShort( mpModernMask, hi_Status, hi_ONLINE ); break; - case ID_STATUS_AWAY: _AddParamShort( mpModernMask, hi_Status, hi_AWAY ); break; - case ID_STATUS_DND: _AddParamShort( mpModernMask, hi_Status, hi_DND ); break; - case ID_STATUS_NA: _AddParamShort( mpModernMask, hi_Status, hi_NA ); break; - case ID_STATUS_OCCUPIED: _AddParamShort( mpModernMask, hi_Status, hi_OCCUPIED ); break; - case ID_STATUS_FREECHAT: _AddParamShort( mpModernMask, hi_Status, hi_FREECHAT ); break; - case ID_STATUS_INVISIBLE: _AddParamShort( mpModernMask, hi_Status, hi_INVISIBLE ); break; - case ID_STATUS_OUTTOLUNCH: _AddParamShort( mpModernMask, hi_Status, hi_OUTTOLUNCH );break; - case ID_STATUS_ONTHEPHONE: _AddParamShort( mpModernMask, hi_Status, hi_ONTHEPHONE );break; - case ID_STATUS_IDLE: _AddParamShort( mpModernMask, hi_Status, hi_IDLE ); break; - default: _AddParamShort( mpModernMask, hi_Status, hi_OFFLINE ); - } - _AddParamShort( mpModernMask, hi_HasAvatar, ( dat->avatars_show && Drawing->avatar_data != NULL )?hi_True:hi_False ); - _AddParamShort( mpModernMask, hi_Rate, hi_None + Drawing->bContactRate ); - break; - } - case CLCIT_DIVIDER: - { - _AddParamShort( mpModernMask, hi_Type, hi_Divider ); - } - break; - case CLCIT_INFO: - { - _AddParamShort( mpModernMask, hi_Type, hi_Info ); - } - break; - } - if ( group->scanIndex == 0 && group->cl.count == 1 ) - _AddParamShort( mpModernMask, hi_GroupPos, hi_First_Single ); - else if ( group->scanIndex == 0 ) - _AddParamShort( mpModernMask, hi_GroupPos, hi_First ); - else if ( group->scanIndex+1 == group->cl.count ) - _AddParamShort( mpModernMask, hi_GroupPos, hi_Last ); - else - _AddParamShort( mpModernMask, hi_GroupPos, hi_Mid ); - - _AddParamShort( mpModernMask, hi_Selected, ( selected )?hi_True:hi_False ); - _AddParamShort( mpModernMask, hi_Hot, ( hottrack )?hi_True:hi_False ); - _AddParamShort( mpModernMask, hi_Odd, ( index&1 )?hi_True:hi_False ); - - _itoa( indent, buf, BUF2SIZE ); - AddParam( mpModernMask, HASH[hi_Indent], buf, 0 ); - _itoa( index, buf, BUF2SIZE ); - AddParam( mpModernMask, HASH[hi_Index], buf, 0 ); - { - TCHAR * b2 = mir_tstrdup( Drawing->szText ); - int i, m; - m = lstrlen( b2 ); - for ( i=0; i < m;i++ ) - if ( b2[i] == TEXT( ',' )) b2[i] = TEXT( '.' ); + MODERNMASK * mpModernMask = NULL; + char buf[BUF2SIZE] = {0}; + mpModernMask = ( MODERNMASK* )mir_calloc( sizeof( MODERNMASK )); + + _AddParamShort( mpModernMask, hi_Module, hi_CL ); + _AddParamShort( mpModernMask, hi_ID, hi_Row ); + switch ( Drawing->type ) + { + case CLCIT_GROUP: + { + _AddParamShort( mpModernMask, hi_Type, hi_Group ); + _AddParamShort( mpModernMask, hi_Open, ( Drawing && Drawing->group && Drawing->group->expanded )?hi_True:hi_False ); + _AddParamShort( mpModernMask, hi_IsEmpty, ( Drawing->group->cl.count == 0 )?hi_True:hi_False ); + } + break; + case CLCIT_CONTACT: + { + struct ClcContact * mCont = Drawing; + if ( Drawing->isSubcontact ) + { + _AddParamShort( mpModernMask, hi_Type, hi_SubContact ); + if ( Drawing->isSubcontact == 1 && Drawing->subcontacts->SubAllocated == 1 ) + _AddParamShort( mpModernMask, hi_SubPos, hi_First_Single ); + else if ( Drawing->isSubcontact == 1 ) + _AddParamShort( mpModernMask, hi_SubPos, hi_First ); + else if ( Drawing->isSubcontact == Drawing->subcontacts->SubAllocated ) + _AddParamShort( mpModernMask, hi_SubPos, hi_Last ); + else + _AddParamShort( mpModernMask, hi_SubPos, hi_Middle ); + mCont = Drawing->subcontacts; + } + else if ( Drawing->SubAllocated ) + { + _AddParamShort( mpModernMask, hi_Type, hi_MetaContact ); + _AddParamShort( mpModernMask, hi_Open, ( Drawing->SubExpanded )?hi_True:hi_False ); + } + else + _AddParamShort( mpModernMask, hi_Type, hi_Contact ); + AddParam( mpModernMask, HASH[hi_Protocol], Drawing->proto, 0 ); + _AddParamShort( mpModernMask, hi_RootGroup, ( group && group->parent == NULL )?hi_True:hi_False ); + switch( GetContactCachedStatus( Drawing->hContact )) + { + // case ID_STATUS_CONNECTING: AppendChar( buf, BUFSIZE, "CONNECTING" ); break; + case ID_STATUS_ONLINE: _AddParamShort( mpModernMask, hi_Status, hi_ONLINE ); break; + case ID_STATUS_AWAY: _AddParamShort( mpModernMask, hi_Status, hi_AWAY ); break; + case ID_STATUS_DND: _AddParamShort( mpModernMask, hi_Status, hi_DND ); break; + case ID_STATUS_NA: _AddParamShort( mpModernMask, hi_Status, hi_NA ); break; + case ID_STATUS_OCCUPIED: _AddParamShort( mpModernMask, hi_Status, hi_OCCUPIED ); break; + case ID_STATUS_FREECHAT: _AddParamShort( mpModernMask, hi_Status, hi_FREECHAT ); break; + case ID_STATUS_INVISIBLE: _AddParamShort( mpModernMask, hi_Status, hi_INVISIBLE ); break; + case ID_STATUS_OUTTOLUNCH: _AddParamShort( mpModernMask, hi_Status, hi_OUTTOLUNCH );break; + case ID_STATUS_ONTHEPHONE: _AddParamShort( mpModernMask, hi_Status, hi_ONTHEPHONE );break; + case ID_STATUS_IDLE: _AddParamShort( mpModernMask, hi_Status, hi_IDLE ); break; + default: _AddParamShort( mpModernMask, hi_Status, hi_OFFLINE ); + } + _AddParamShort( mpModernMask, hi_HasAvatar, ( dat->avatars_show && Drawing->avatar_data != NULL )?hi_True:hi_False ); + _AddParamShort( mpModernMask, hi_Rate, hi_None + Drawing->bContactRate ); + break; + } + case CLCIT_DIVIDER: { - char* b3 = mir_utf8encodeT( b2 ); - AddParam( mpModernMask, HASH[hi_Name], b3, 0 ); - mir_free( b3 ); - } - - mir_free_and_nill( b2 ); - } - if ( group->parent ) - { - TCHAR * b2 = mir_tstrdup( group->parent->cl.items[0]->szText ); - int i, m; - m = lstrlen( b2 ); - for ( i=0; i < m;i++ ) - if ( b2[i] == TEXT( ',' )) b2[i] = TEXT( '.' ); + _AddParamShort( mpModernMask, hi_Type, hi_Divider ); + } + break; + case CLCIT_INFO: + { + _AddParamShort( mpModernMask, hi_Type, hi_Info ); + } + break; + } + if ( group->scanIndex == 0 && group->cl.count == 1 ) + _AddParamShort( mpModernMask, hi_GroupPos, hi_First_Single ); + else if ( group->scanIndex == 0 ) + _AddParamShort( mpModernMask, hi_GroupPos, hi_First ); + else if ( group->scanIndex+1 == group->cl.count ) + _AddParamShort( mpModernMask, hi_GroupPos, hi_Last ); + else + _AddParamShort( mpModernMask, hi_GroupPos, hi_Mid ); + + _AddParamShort( mpModernMask, hi_Selected, ( selected )?hi_True:hi_False ); + _AddParamShort( mpModernMask, hi_Hot, ( hottrack )?hi_True:hi_False ); + _AddParamShort( mpModernMask, hi_Odd, ( index&1 )?hi_True:hi_False ); + + _itoa( indent, buf, BUF2SIZE ); + AddParam( mpModernMask, HASH[hi_Indent], buf, 0 ); + _itoa( index, buf, BUF2SIZE ); + AddParam( mpModernMask, HASH[hi_Index], buf, 0 ); + { + TCHAR * b2 = mir_tstrdup( Drawing->szText ); + int i, m; + m = lstrlen( b2 ); + for ( i=0; i < m;i++ ) + if ( b2[i] == _T( ',' )) b2[i] = _T( '.' ); + { + char* b3 = mir_utf8encodeT( b2 ); + AddParam( mpModernMask, HASH[hi_Name], b3, 0 ); + mir_free( b3 ); + } + + mir_free( b2 ); + } + if ( group->parent ) + { + TCHAR * b2 = mir_tstrdup( group->parent->cl.items[0]->szText ); + int i, m; + m = lstrlen( b2 ); + for ( i=0; i < m;i++ ) + if ( b2[i] == _T( ',' )) b2[i] = _T( '.' ); { - char * b3 = mir_utf8encodeT( b2 ); - AddParam( mpModernMask, HASH[hi_Group], b3, 0 ); - mir_free( b3 ); - } - - mir_free_and_nill( b2 ); - } - return mpModernMask; + char * b3 = mir_utf8encodeT( b2 ); + AddParam( mpModernMask, HASH[hi_Group], b3, 0 ); + mir_free( b3 ); + } + + mir_free( b2 ); + } + return mpModernMask; } void CLCPaint::_RTLRect( RECT *rect, int width, int offset ) { - int left, right; - if ( !rect ) return; - left = ( width )-rect->right; - right = ( width )-rect->left; - rect->left = left;//-offset; - rect->right = right;//-offset; - return; + int left, right; + if ( !rect ) return; + left = ( width )-rect->right; + right = ( width )-rect->left; + rect->left = left;//-offset; + rect->right = right;//-offset; + return; } void CLCPaint::_PaintRowItemsEx( HWND hwnd, HDC hdcMem, struct ClcData *dat, struct ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint ) { - int i=0; - int dx = free_row_rc.left; - int dy = row_rc.top+dat->row_border; - int dg = 0; - - - // Let calc placeholder - int minheight = dat->row_min_heigh; - int mode2 = -1; - COLORREF colourFg = RGB( 0, 0, 0 ); - BOOL InClistWindow = ( dat->hWnd == pcli->hwndContactTree ); - PDNCE pdnce = NULL; - int height = RowHeight_CalcRowHeight( dat, hwnd, Drawing, -1 ); - + int i=0; + int dx = free_row_rc.left; + int dy = row_rc.top+dat->row_border; + int dg = 0; + + + // Let calc placeholder + int minheight = dat->row_min_heigh; + int mode2 = -1; + COLORREF colourFg = RGB( 0, 0, 0 ); + BOOL InClistWindow = ( dat->hWnd == pcli->hwndContactTree ); + PDNCE pdnce = NULL; + int height = RowHeight_CalcRowHeight( dat, hwnd, Drawing, -1 ); + // TO DO DEPRECATE OLD ROW LAYOUT - if ( Drawing->type == CLCIT_CONTACT ) - pdnce = ( PDNCE )pcli->pfnGetCacheEntry( Drawing->hContact ); - - if ( Drawing->type == CLCIT_GROUP && - Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing ) - { - dg = dat->row_before_group_space; - free_row_rc.top += dg; - height -= dg; - } - if ( !InClistWindow || !gl_RowRoot || Drawing->type == CLCIT_GROUP ) - { - // to do paint simple - RECT fr_rc = free_row_rc; - - //1 draw icon - if ( !( Drawing->type == CLCIT_GROUP && InClistWindow && dat->row_hide_group_icon )) - { - int iImage = -1; - // Get image - if ( Drawing->type == CLCIT_GROUP ) - { - iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; - } - else if ( Drawing->type == CLCIT_CONTACT ) - iImage = Drawing->iImage; - if ( iImage != -1 ) - { - COLORREF colourFg; - int mode; - RECT p_rect = {0}; - p_rect.top = fr_rc.top+( ( fr_rc.bottom-fr_rc.top-ICON_HEIGHT )>>1 ); - p_rect.left = fr_rc.left; - p_rect.right = p_rect.left+ICON_HEIGHT; - p_rect.bottom = p_rect.top+ICON_HEIGHT; - // Store pos - if ( dat->text_rtl != 0 ) _RTLRect( &p_rect, free_row_rc.right, dx ); - Drawing->pos_icon = p_rect; - if ( hottrack ) - { - colourFg = dat->hotTextColour; - mode = ILD_NORMAL; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = ILD_BLEND50; - } - else - { - colourFg = dat->selBkColour; - mode = ILD_NORMAL; - } - - if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && - _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) - { - mode = ILD_SELECTED; - } - _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); - - } - fr_rc.left += ICON_HEIGHT+2; - } - //2 draw extra - { - RECT p_rect = {0}; - p_rect.top = fr_rc.top+( ( fr_rc.bottom-fr_rc.top-ICON_HEIGHT )>>1 ); - //p_rect.left = fr_rc.left; - //p_rect.right = p_rect.left+ICON_HEIGHT; - p_rect.bottom = p_rect.top+ICON_HEIGHT; - - if ( ( Drawing->type == CLCIT_GROUP || Drawing->type == CLCIT_CONTACT || Drawing->type == CLCIT_INFO ) - && dat->extraColumnsCount > 0 && ( !InClistWindow || Drawing->type == CLCIT_CONTACT )) - { - int BlendedInActiveState = dat->dbbBlendInActiveState; - int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; - int iImage; - int count = 0; - RECT rc; - int x = 0; - for ( iImage = dat->extraColumnsCount-1; iImage >= 0 ; iImage-- ) - { - COLORREF colourFg = dat->selBkColour; - int mode = BlendedInActiveState?BlendValue:ILD_NORMAL; - if ( Drawing->iExtraImage[iImage] == 0xFF && Drawing->iWideExtraImage[iImage] == 0xFFFF ) - { - { - x += ( x>0 )?dat->extraColumnSpacing:ICON_HEIGHT; - SetRect( &rc, fr_rc.right-x, p_rect.top, fr_rc.right-x+ICON_HEIGHT, p_rect.bottom ); - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); - Drawing->pos_extra[iImage] = rc; - count++; - } - continue; - } - - if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; - else if ( hottrack ) - { - mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; - colourFg = dat->hotTextColour; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = BlendValue; - } - - x += ( x>0 )?dat->extraColumnSpacing:ICON_HEIGHT; - SetRect( &rc, fr_rc.right-x, p_rect.top, fr_rc.right-x+ICON_HEIGHT, p_rect.bottom ); - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); - Drawing->pos_extra[iImage] = rc; - Drawing->pos_extra[iImage] = rc; + if ( Drawing->type == CLCIT_CONTACT ) + pdnce = ( PDNCE )pcli->pfnGetCacheEntry( Drawing->hContact ); + + if ( Drawing->type == CLCIT_GROUP && + Drawing->group->parent->groupId == 0 && + Drawing->group->parent->cl.items[0] != Drawing ) + { + dg = dat->row_before_group_space; + free_row_rc.top += dg; + height -= dg; + } + if ( !InClistWindow || !gl_RowRoot || Drawing->type == CLCIT_GROUP ) + { + // to do paint simple + RECT fr_rc = free_row_rc; + + //1 draw icon + if ( !( Drawing->type == CLCIT_GROUP && InClistWindow && dat->row_hide_group_icon )) + { + int iImage = -1; + // Get image + if ( Drawing->type == CLCIT_GROUP ) + { + iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; + } + else if ( Drawing->type == CLCIT_CONTACT ) + iImage = Drawing->iImage; + if ( iImage != -1 ) + { + COLORREF colourFg; + int mode; + RECT p_rect = {0}; + p_rect.top = fr_rc.top+( ( fr_rc.bottom-fr_rc.top-ICON_HEIGHT )>>1 ); + p_rect.left = fr_rc.left; + p_rect.right = p_rect.left+ICON_HEIGHT; + p_rect.bottom = p_rect.top+ICON_HEIGHT; + // Store pos + if ( dat->text_rtl != 0 ) _RTLRect( &p_rect, free_row_rc.right, dx ); + Drawing->pos_icon = p_rect; + if ( hottrack ) + { + colourFg = dat->hotTextColour; + mode = ILD_NORMAL; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = ILD_BLEND50; + } + else + { + colourFg = dat->selBkColour; + mode = ILD_NORMAL; + } + + if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && + _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) + { + mode = ILD_SELECTED; + } + _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); + + } + fr_rc.left += ICON_HEIGHT+2; + } + //2 draw extra + { + RECT p_rect = {0}; + p_rect.top = fr_rc.top+( ( fr_rc.bottom-fr_rc.top-ICON_HEIGHT )>>1 ); + //p_rect.left = fr_rc.left; + //p_rect.right = p_rect.left+ICON_HEIGHT; + p_rect.bottom = p_rect.top+ICON_HEIGHT; + + if ( ( Drawing->type == CLCIT_GROUP || Drawing->type == CLCIT_CONTACT || Drawing->type == CLCIT_INFO ) + && dat->extraColumnsCount > 0 && ( !InClistWindow || Drawing->type == CLCIT_CONTACT )) + { + int BlendedInActiveState = dat->dbbBlendInActiveState; + int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; + int iImage; + int count = 0; + RECT rc; + int x = 0; + for ( iImage = dat->extraColumnsCount-1; iImage >= 0 ; iImage-- ) + { + COLORREF colourFg = dat->selBkColour; + int mode = BlendedInActiveState?BlendValue:ILD_NORMAL; + if ( Drawing->iExtraImage[iImage] == 0xFF && Drawing->iWideExtraImage[iImage] == 0xFFFF ) + { + { + x += ( x>0 )?dat->extraColumnSpacing:ICON_HEIGHT; + SetRect( &rc, fr_rc.right-x, p_rect.top, fr_rc.right-x+ICON_HEIGHT, p_rect.bottom ); + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); + Drawing->pos_extra[iImage] = rc; + count++; + } + continue; + } + + if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; + else if ( hottrack ) + { + mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; + colourFg = dat->hotTextColour; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = BlendValue; + } + + x += ( x>0 )?dat->extraColumnSpacing:ICON_HEIGHT; + SetRect( &rc, fr_rc.right-x, p_rect.top, fr_rc.right-x+ICON_HEIGHT, p_rect.bottom ); + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); + Drawing->pos_extra[iImage] = rc; + Drawing->pos_extra[iImage] = rc; if ( Drawing->iExtraImage[iImage] != 0xFF ) ske_ImageList_DrawEx( dat->himlExtraColumns, Drawing->iExtraImage[iImage], hdcMem, - rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); + rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); else if ( Drawing->iWideExtraImage[iImage] != 0xFFFF ) ske_ImageList_DrawEx( dat->himlWideExtraColumns, Drawing->iWideExtraImage[iImage], hdcMem, - rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); - - } - fr_rc.right -= x; - } - } - //3 draw text - { - SIZE text_size = {0}; - char * szCounts = NULL; - RECT text_rect = fr_rc; - RECT counts_rc = {0}; - UINT uTextFormat = DT_LEFT|DT_VCENTER|( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; - uTextFormat |= dat->text_rtl?DT_RTLREADING:0; - // Select font - ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); - - // Get text size - GetTextSize( &text_size, hdcMem, fr_rc, Drawing->szText, Drawing->ssText.plText, uTextFormat, - dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); - // counters - if ( Drawing->type == CLCIT_GROUP && InClistWindow ) - { - RECT nameRect = fr_rc; - RECT countRect = {0}; - RECT count_rc = {0}; - SIZE count_size = {0}; - int space_width = 0; - char * szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); - // Has to draw the count? - if ( szCounts && strlen( szCounts )>0 ) - { - // calc width and height - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - ske_DrawText( hdcMem, _T( " " ), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX ); - count_size.cx = count_rc.right-count_rc.left; - space_width = count_size.cx; - count_rc.right = 0; - count_rc.left = 0; - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &count_rc, DT_CALCRECT ); - count_size.cx += count_rc.right-count_rc.left; - count_size.cy = count_rc.bottom-count_rc.top; - } - // modify text rect - //if ( !RTL ) - { - SIZE text_size = {0}; - int wid = fr_rc.right-fr_rc.left; - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); - GetTextSize( &text_size, hdcMem, fr_rc, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); - - if ( wid-count_size.cx > text_size.cx ) - { - - if ( dat->row_align_group_mode != 2 ) //center or left - { - int x = ( dat->row_align_group_mode == 1 )?( wid-( text_size.cx+count_size.cx ))>>1:0; - nameRect.left += x; - nameRect.right = nameRect.left+text_size.cx; - countRect.left = nameRect.right+space_width; - countRect.right = countRect.left+count_size.cx-space_width; - } - else - { - countRect.right = nameRect.right; - countRect.left = countRect.right-( ( count_size.cx>0 )?( count_size.cx-space_width ):0 ); - nameRect.right = countRect.left-( ( count_size.cx>0 )?space_width:0 ); - nameRect.left = nameRect.right-text_size.cx; - } - - } - - else - { - countRect.right = nameRect.right; - nameRect.right -= count_size.cx; - countRect.left = nameRect.right+space_width; - } - countRect.bottom = nameRect.bottom; - countRect.top = nameRect.top; - } - - - - //if ( !( szCounts && strlen( szCounts )>0 )) - //uTextFormat |= ( dat->row_align_group_mode == 2 )?DT_RIGHT:( dat->row_align_group_mode == 1 )?DT_CENTER:DT_LEFT; - - uTextFormat |= DT_VCENTER; - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - if ( dat->text_rtl != 0 ) _RTLRect( &nameRect, free_row_rc.right, dx ); - _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - if ( selected && dat->szQuickSearch[0] != '\0' ) - { - SetTextColor( hdcMem, dat->quickSearchColour ); - _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - } - if ( szCounts && strlen( szCounts )>0 ) - { - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - if ( dat->text_rtl != 0 ) _RTLRect( &countRect, free_row_rc.right, dx ); - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &countRect, uTextFormat ); - } - { - RECT rc = fr_rc; - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); - Drawing->pos_rename_rect = rc; - } - Drawing->pos_label = nameRect; - return; - } - else if ( Drawing->type == CLCIT_GROUP ) - { - - szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); - // Has to draw the count? - if ( szCounts && szCounts[0] ) - { - RECT space_rc = fr_rc; - - int text_width = 0; - SIZE space_size = {0}; - SIZE counts_size = {0}; - // Get widths - counts_rc = fr_rc; - DrawText( hdcMem, _T( " " ), 1, &space_rc, DT_CALCRECT | DT_NOPREFIX ); - - space_size.cx = space_rc.right - space_rc.left; - space_size.cy = min( space_rc.bottom - space_rc.top, fr_rc.bottom-fr_rc.top ); - - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, DT_CALCRECT ); - - counts_size.cx = counts_rc.right - counts_rc.left; - counts_size.cy = min( counts_rc.bottom - counts_rc.top, fr_rc.bottom-fr_rc.top ); - - text_width = fr_rc.right - fr_rc.left - space_size.cx - counts_size.cx; - - if ( text_width > 4 ) - { - text_size.cx = min( text_width, text_size.cx ); - text_width = text_size.cx + space_size.cx + counts_size.cx; - } - else - { - text_width = text_size.cx; - space_size.cx = 0; - counts_size.cx = 0; - } - text_rect.right = text_rect.left+text_size.cx; - counts_rc = text_rect; - counts_rc.left = text_rect.right+space_size.cx; - counts_rc.right = counts_rc.left+counts_size.cx; - } - } - ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); - - // Set color - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - if ( dat->text_rtl != 0 ) _RTLRect( &text_rect, free_row_rc.right, dx ); - _DrawTextSmiley( hdcMem, &text_rect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - if ( selected && dat->szQuickSearch[0] != '\0' ) - { - SetTextColor( hdcMem, dat->quickSearchColour ); - _DrawTextSmiley( hdcMem, &text_rect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - } - if ( Drawing->type == CLCIT_GROUP && szCounts && szCounts[0] && counts_rc.right-counts_rc.left>0 ) - { - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - if ( dat->text_rtl != 0 ) _RTLRect( &counts_rc, free_row_rc.right, dx ); - if ( InClistWindow && g_CluiData.fLayered ) - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, uTextFormat ); - else - //88 - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, uTextFormat ); - if ( dat->text_rtl == 0 ) - text_rect.right = counts_rc.right; - else - text_rect.left = counts_rc.left; - } - Drawing->pos_label = text_rect; - { - RECT rc = fr_rc; - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); - Drawing->pos_rename_rect = rc; - } - - if ( ( !InClistWindow || !g_CluiData.fLayered ) && ( ( Drawing->type == CLCIT_DIVIDER ) || ( Drawing->type == CLCIT_GROUP && dat->exStyle&CLS_EX_LINEWITHGROUPS )) ) - { - //??? - RECT rc = fr_rc; - if ( dat->text_rtl != 0 ) - { - rc.left = Drawing->pos_rename_rect.left; - rc.right = text_rect.left-3; - } - else - rc.left = text_rect.right+3; - if ( rc.right-rc.left>4 ) - { - rc.top += ( ( rc.bottom-rc.top )>>1 )-1; - rc.bottom = rc.top+2; - DrawEdge( hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT ); - ske_SetRectOpaque( hdcMem, &rc ); - } - } - - } - return; - } - minheight = max( minheight, height ); - dy += ( minheight>height )?( ( minheight-height )>>1 ):0; - // Call Placement - cppCalculateRowItemsPos( gl_RowRoot, free_row_rc.right-free_row_rc.left ); - // Now paint - while ( ( gl_RowTabAccess[i] != NULL || ( i < 2 && Drawing->type == CLCIT_GROUP )) && !( i >= 2 && Drawing->type == CLCIT_GROUP )) - { - - if ( gl_RowTabAccess[i]->r.right-gl_RowTabAccess[i]->r.left>0 - && gl_RowTabAccess[i]->r.bottom-gl_RowTabAccess[i]->r.top>0 ) - { - RECT p_rect = gl_RowTabAccess[i]->r; - OffsetRect( &p_rect, dx, dy ); - if ( dat->text_rtl != 0 && gl_RowTabAccess[i]->type != TC_EXTRA /*each extra icon modified separately*/ ) _RTLRect( &p_rect, free_row_rc.right, 0 ); - switch ( gl_RowTabAccess[i]->type ) - { - case TC_TEXT1: - { - //paint text 1 - SIZE text_size; - UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; - text_size.cx = p_rect.right-p_rect.left; - text_size.cy = p_rect.bottom-p_rect.top; - ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); - - uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; - uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; - - uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; - if ( Drawing->type == CLCIT_CONTACT ) - { - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - _DrawTextSmiley( hdcMem, &p_rect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - if ( selected && dat->szQuickSearch[0] != '\0' ) - { - SetTextColor( hdcMem, dat->quickSearchColour ); - _DrawTextSmiley( hdcMem, &p_rect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - } - Drawing->pos_rename_rect = p_rect; - { - SIZE size; - GetTextSize( &size, hdcMem, p_rect, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); - Drawing->pos_label = p_rect; - Drawing->pos_label.right = min( Drawing->pos_label.right, Drawing->pos_label.left+size.cx ); - } - - } - else if ( Drawing->type == CLCIT_GROUP ) - { - RECT nameRect = p_rect; - RECT countRect = {0}; - RECT count_rc = {0}; - SIZE count_size = {0}; - int space_width = 0; - char * szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); - // Has to draw the count? - if ( szCounts && strlen( szCounts )>0 ) - { - - - // calc width and height - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - ske_DrawText( hdcMem, _T( " " ), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX ); - count_size.cx = count_rc.right-count_rc.left; - space_width = count_size.cx; - count_rc.right = 0; - count_rc.left = 0; - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &count_rc, DT_CALCRECT ); - count_size.cx += count_rc.right-count_rc.left; - count_size.cy = count_rc.bottom-count_rc.top; - } - // modify text rect - //if ( !RTL ) - { - SIZE text_size = {0}; - int wid = p_rect.right-p_rect.left; - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); - GetTextSize( &text_size, hdcMem, p_rect, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); - - if ( wid-count_size.cx > text_size.cx ) - { - - if ( dat->row_align_group_mode != 2 ) //center or left - { - int x = ( dat->row_align_group_mode == 1 )?( wid-( text_size.cx+count_size.cx ))>>1:0; - nameRect.left += x; - nameRect.right = nameRect.left+text_size.cx; - countRect.left = nameRect.right+space_width; - countRect.right = countRect.left+count_size.cx-space_width; - } - else - { - countRect.right = nameRect.right; - countRect.left = countRect.right-( ( count_size.cx>0 )?( count_size.cx-space_width ):0 ); - nameRect.right = countRect.left-( ( count_size.cx>0 )?space_width:0 ); - nameRect.left = nameRect.right-text_size.cx; - } - - } - - else - { - countRect.right = nameRect.right; - nameRect.right -= count_size.cx; - countRect.left = nameRect.right+space_width; - } - countRect.bottom = nameRect.bottom; - countRect.top = nameRect.top; - } - - - - //if ( !( szCounts && strlen( szCounts )>0 )) - //uTextFormat |= ( dat->row_align_group_mode == 2 )?DT_RIGHT:( dat->row_align_group_mode == 1 )?DT_CENTER:DT_LEFT; - - uTextFormat |= DT_VCENTER; - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - if ( selected && dat->szQuickSearch[0] != '\0' ) - { - SetTextColor( hdcMem, dat->quickSearchColour ); - _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); - } - if ( szCounts && strlen( szCounts )>0 ) - { - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - if ( selected ) - SetTextColor( hdcMem, dat->selTextColour ); - else if ( hottrack ) - _SetHotTrackColour( hdcMem, dat ); - ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &countRect, uTextFormat ); - } - Drawing->pos_rename_rect = p_rect; - Drawing->pos_label = nameRect; - } - break; - } - case TC_TEXT2: - { - // paint text 2 - // - // Select font - SIZE text_size; - UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; - { - if ( dat->second_line_show && dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) - { - // Get contact time - TCHAR buf[70] = _T(""); - mir_free_and_nill( pdnce->szSecondLineText ); + rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); + + } + fr_rc.right -= x; + } + } + //3 draw text + { + SIZE text_size = {0}; + char * szCounts = NULL; + RECT text_rect = fr_rc; + RECT counts_rc = {0}; + UINT uTextFormat = DT_LEFT|DT_VCENTER|( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; + uTextFormat |= dat->text_rtl?DT_RTLREADING:0; + // Select font + ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); + + // Get text size + GetTextSize( &text_size, hdcMem, fr_rc, Drawing->szText, Drawing->ssText.plText, uTextFormat, + dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); + // counters + if ( Drawing->type == CLCIT_GROUP && InClistWindow ) + { + RECT nameRect = fr_rc; + RECT countRect = {0}; + RECT count_rc = {0}; + SIZE count_size = {0}; + int space_width = 0; + char * szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); + // Has to draw the count? + if ( szCounts && strlen( szCounts )>0 ) + { + // calc width and height + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + ske_DrawText( hdcMem, _T( " " ), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX ); + count_size.cx = count_rc.right-count_rc.left; + space_width = count_size.cx; + count_rc.right = 0; + count_rc.left = 0; + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &count_rc, DT_CALCRECT ); + count_size.cx += count_rc.right-count_rc.left; + count_size.cy = count_rc.bottom-count_rc.top; + } + // modify text rect + //if ( !RTL ) + { + SIZE text_size = {0}; + int wid = fr_rc.right-fr_rc.left; + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); + GetTextSize( &text_size, hdcMem, fr_rc, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); + + if ( wid-count_size.cx > text_size.cx ) + { + + if ( dat->row_align_group_mode != 2 ) //center or left + { + int x = ( dat->row_align_group_mode == 1 )?( wid-( text_size.cx+count_size.cx ))>>1:0; + nameRect.left += x; + nameRect.right = nameRect.left+text_size.cx; + countRect.left = nameRect.right+space_width; + countRect.right = countRect.left+count_size.cx-space_width; + } + else + { + countRect.right = nameRect.right; + countRect.left = countRect.right-( ( count_size.cx>0 )?( count_size.cx-space_width ):0 ); + nameRect.right = countRect.left-( ( count_size.cx>0 )?space_width:0 ); + nameRect.left = nameRect.right-text_size.cx; + } + + } + + else + { + countRect.right = nameRect.right; + nameRect.right -= count_size.cx; + countRect.left = nameRect.right+space_width; + } + countRect.bottom = nameRect.bottom; + countRect.top = nameRect.top; + } + + + + //if ( !( szCounts && strlen( szCounts )>0 )) + //uTextFormat |= ( dat->row_align_group_mode == 2 )?DT_RIGHT:( dat->row_align_group_mode == 1 )?DT_CENTER:DT_LEFT; + + uTextFormat |= DT_VCENTER; + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + if ( dat->text_rtl != 0 ) _RTLRect( &nameRect, free_row_rc.right, dx ); + _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + if ( selected && dat->szQuickSearch[0] != '\0' ) + { + SetTextColor( hdcMem, dat->quickSearchColour ); + _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + } + if ( szCounts && strlen( szCounts )>0 ) + { + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + if ( dat->text_rtl != 0 ) _RTLRect( &countRect, free_row_rc.right, dx ); + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &countRect, uTextFormat ); + } + { + RECT rc = fr_rc; + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); + Drawing->pos_rename_rect = rc; + } + Drawing->pos_label = nameRect; + return; + } + else if ( Drawing->type == CLCIT_GROUP ) + { + + szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); + // Has to draw the count? + if ( szCounts && szCounts[0] ) + { + RECT space_rc = fr_rc; + + int text_width = 0; + SIZE space_size = {0}; + SIZE counts_size = {0}; + // Get widths + counts_rc = fr_rc; + DrawText( hdcMem, _T( " " ), 1, &space_rc, DT_CALCRECT | DT_NOPREFIX ); + + space_size.cx = space_rc.right - space_rc.left; + space_size.cy = min( space_rc.bottom - space_rc.top, fr_rc.bottom-fr_rc.top ); + + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, DT_CALCRECT ); + + counts_size.cx = counts_rc.right - counts_rc.left; + counts_size.cy = min( counts_rc.bottom - counts_rc.top, fr_rc.bottom-fr_rc.top ); + + text_width = fr_rc.right - fr_rc.left - space_size.cx - counts_size.cx; + + if ( text_width > 4 ) + { + text_size.cx = min( text_width, text_size.cx ); + text_width = text_size.cx + space_size.cx + counts_size.cx; + } + else + { + text_width = text_size.cx; + space_size.cx = 0; + counts_size.cx = 0; + } + text_rect.right = text_rect.left+text_size.cx; + counts_rc = text_rect; + counts_rc.left = text_rect.right+space_size.cx; + counts_rc.right = counts_rc.left+counts_size.cx; + } + } + ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); + + // Set color + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + if ( dat->text_rtl != 0 ) _RTLRect( &text_rect, free_row_rc.right, dx ); + _DrawTextSmiley( hdcMem, &text_rect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + if ( selected && dat->szQuickSearch[0] != '\0' ) + { + SetTextColor( hdcMem, dat->quickSearchColour ); + _DrawTextSmiley( hdcMem, &text_rect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + } + if ( Drawing->type == CLCIT_GROUP && szCounts && szCounts[0] && counts_rc.right-counts_rc.left>0 ) + { + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + if ( dat->text_rtl != 0 ) _RTLRect( &counts_rc, free_row_rc.right, dx ); + if ( InClistWindow && g_CluiData.fLayered ) + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, uTextFormat ); + else + //88 + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, uTextFormat ); + if ( dat->text_rtl == 0 ) + text_rect.right = counts_rc.right; + else + text_rect.left = counts_rc.left; + } + Drawing->pos_label = text_rect; + { + RECT rc = fr_rc; + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, dx ); + Drawing->pos_rename_rect = rc; + } + + if ( ( !InClistWindow || !g_CluiData.fLayered ) && ( ( Drawing->type == CLCIT_DIVIDER ) || ( Drawing->type == CLCIT_GROUP && dat->exStyle&CLS_EX_LINEWITHGROUPS )) ) + { + //??? + RECT rc = fr_rc; + if ( dat->text_rtl != 0 ) + { + rc.left = Drawing->pos_rename_rect.left; + rc.right = text_rect.left-3; + } + else + rc.left = text_rect.right+3; + if ( rc.right-rc.left>4 ) + { + rc.top += ( ( rc.bottom-rc.top )>>1 )-1; + rc.bottom = rc.top+2; + DrawEdge( hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT ); + ske_SetRectOpaque( hdcMem, &rc ); + } + } + + } + return; + } + minheight = max( minheight, height ); + dy += ( minheight>height )?( ( minheight-height )>>1 ):0; + // Call Placement + cppCalculateRowItemsPos( gl_RowRoot, free_row_rc.right-free_row_rc.left ); + // Now paint + while ( ( gl_RowTabAccess[i] != NULL || ( i < 2 && Drawing->type == CLCIT_GROUP )) && !( i >= 2 && Drawing->type == CLCIT_GROUP )) + { + + if ( gl_RowTabAccess[i]->r.right-gl_RowTabAccess[i]->r.left>0 + && gl_RowTabAccess[i]->r.bottom-gl_RowTabAccess[i]->r.top>0 ) + { + RECT p_rect = gl_RowTabAccess[i]->r; + OffsetRect( &p_rect, dx, dy ); + if ( dat->text_rtl != 0 && gl_RowTabAccess[i]->type != TC_EXTRA /*each extra icon modified separately*/ ) _RTLRect( &p_rect, free_row_rc.right, 0 ); + switch ( gl_RowTabAccess[i]->type ) + { + case TC_TEXT1: + { + //paint text 1 + SIZE text_size; + UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; + text_size.cx = p_rect.right-p_rect.left; + text_size.cy = p_rect.bottom-p_rect.top; + ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); + + uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; + uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; + + uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; + if ( Drawing->type == CLCIT_CONTACT ) + { + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + _DrawTextSmiley( hdcMem, &p_rect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + if ( selected && dat->szQuickSearch[0] != '\0' ) + { + SetTextColor( hdcMem, dat->quickSearchColour ); + _DrawTextSmiley( hdcMem, &p_rect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + } + Drawing->pos_rename_rect = p_rect; + { + SIZE size; + GetTextSize( &size, hdcMem, p_rect, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); + Drawing->pos_label = p_rect; + Drawing->pos_label.right = min( Drawing->pos_label.right, Drawing->pos_label.left+size.cx ); + } + + } + else if ( Drawing->type == CLCIT_GROUP ) + { + RECT nameRect = p_rect; + RECT countRect = {0}; + RECT count_rc = {0}; + SIZE count_size = {0}; + int space_width = 0; + char * szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); + // Has to draw the count? + if ( szCounts && strlen( szCounts )>0 ) + { + + + // calc width and height + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + ske_DrawText( hdcMem, _T( " " ), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX ); + count_size.cx = count_rc.right-count_rc.left; + space_width = count_size.cx; + count_rc.right = 0; + count_rc.left = 0; + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &count_rc, DT_CALCRECT ); + count_size.cx += count_rc.right-count_rc.left; + count_size.cy = count_rc.bottom-count_rc.top; + } + // modify text rect + //if ( !RTL ) + { + SIZE text_size = {0}; + int wid = p_rect.right-p_rect.left; + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); + GetTextSize( &text_size, hdcMem, p_rect, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); + + if ( wid-count_size.cx > text_size.cx ) + { + + if ( dat->row_align_group_mode != 2 ) //center or left + { + int x = ( dat->row_align_group_mode == 1 )?( wid-( text_size.cx+count_size.cx ))>>1:0; + nameRect.left += x; + nameRect.right = nameRect.left+text_size.cx; + countRect.left = nameRect.right+space_width; + countRect.right = countRect.left+count_size.cx-space_width; + } + else + { + countRect.right = nameRect.right; + countRect.left = countRect.right-( ( count_size.cx>0 )?( count_size.cx-space_width ):0 ); + nameRect.right = countRect.left-( ( count_size.cx>0 )?space_width:0 ); + nameRect.left = nameRect.right-text_size.cx; + } + + } + + else + { + countRect.right = nameRect.right; + nameRect.right -= count_size.cx; + countRect.left = nameRect.right+space_width; + } + countRect.bottom = nameRect.bottom; + countRect.top = nameRect.top; + } + + + + //if ( !( szCounts && strlen( szCounts )>0 )) + //uTextFormat |= ( dat->row_align_group_mode == 2 )?DT_RIGHT:( dat->row_align_group_mode == 1 )?DT_CENTER:DT_LEFT; + + uTextFormat |= DT_VCENTER; + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( Drawing->szText ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + if ( selected && dat->szQuickSearch[0] != '\0' ) + { + SetTextColor( hdcMem, dat->quickSearchColour ); + _DrawTextSmiley( hdcMem, &nameRect, &text_size, Drawing->szText, lstrlen( dat->szQuickSearch ), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ); + } + if ( szCounts && strlen( szCounts )>0 ) + { + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + if ( selected ) + SetTextColor( hdcMem, dat->selTextColour ); + else if ( hottrack ) + _SetHotTrackColour( hdcMem, dat ); + ske_DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &countRect, uTextFormat ); + } + Drawing->pos_rename_rect = p_rect; + Drawing->pos_label = nameRect; + } + break; + } + case TC_TEXT2: + { + // paint text 2 + // + // Select font + SIZE text_size; + UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; + { + if ( dat->second_line_show && dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) + { + // Get contact time + TCHAR buf[70] = _T(""); + mir_free_and_nil( pdnce->szSecondLineText ); tmi.printDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); pdnce->szSecondLineText = mir_tstrdup( buf ); - } - } - uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; - uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; - - text_size.cx = p_rect.right-p_rect.left; - text_size.cy = p_rect.bottom-p_rect.top; - - ChangeToFont( hdcMem, dat, FONTID_SECONDLINE, NULL ); - uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; - if ( Drawing->type == CLCIT_CONTACT ) - _DrawTextSmiley( hdcMem, &p_rect, &text_size, pdnce->szSecondLineText, lstrlen( pdnce->szSecondLineText ), pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys ); - break; - } - case TC_TEXT3: - { - //paint text 3 - // Select font - SIZE text_size; - UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; - { - if ( dat->third_line_show && dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) - { - // Get contact time - TCHAR buf[70] = _T(""); - mir_free_and_nill( pdnce->szThirdLineText ); + } + } + uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; + uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; + + text_size.cx = p_rect.right-p_rect.left; + text_size.cy = p_rect.bottom-p_rect.top; + + ChangeToFont( hdcMem, dat, FONTID_SECONDLINE, NULL ); + uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; + if ( Drawing->type == CLCIT_CONTACT ) + _DrawTextSmiley( hdcMem, &p_rect, &text_size, pdnce->szSecondLineText, lstrlen( pdnce->szSecondLineText ), pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys ); + break; + } + case TC_TEXT3: + { + //paint text 3 + // Select font + SIZE text_size; + UINT uTextFormat = ( dat->text_rtl ? DT_RTLREADING : 0 ) ; + { + if ( dat->third_line_show && dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) + { + // Get contact time + TCHAR buf[70] = _T(""); + mir_free( pdnce->szThirdLineText ); tmi.printDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); - pdnce->szThirdLineText = mir_tstrdup( buf ); - } - } - uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; - uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; - - text_size.cx = p_rect.right-p_rect.left; - text_size.cy = p_rect.bottom-p_rect.top; - - ChangeToFont( hdcMem, dat, FONTID_THIRDLINE, NULL ); - uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; - if ( Drawing->type == CLCIT_CONTACT ) - _DrawTextSmiley( hdcMem, &p_rect, &text_size, pdnce->szThirdLineText, lstrlen( pdnce->szThirdLineText ), pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys ); - break; - } - case TC_STATUS: - { - - if ( ( Drawing->type == CLCIT_GROUP && !dat->row_hide_group_icon ) - || ( Drawing->type == CLCIT_CONTACT && Drawing->iImage != -1 - && !( dat->icon_hide_on_avatar && dat->avatars_show - && ( ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || - ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE ) - ) - && !Drawing->image_is_special )) ) - { - int iImage = -1; - // Get image - if ( Drawing->type == CLCIT_GROUP ) - { - if ( !dat->row_hide_group_icon ) iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; - else iImage = -1; - } - else if ( Drawing->type == CLCIT_CONTACT ) - iImage = Drawing->iImage; - if ( iImage != -1 ) - { - COLORREF colourFg; - int mode; - // Store pos - Drawing->pos_icon = p_rect; - if ( hottrack ) - { - colourFg = dat->hotTextColour; - mode = ILD_NORMAL; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = ILD_BLEND50; - } - else - { - colourFg = dat->selBkColour; - mode = ILD_NORMAL; - } - - if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && - _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) - { - mode = ILD_SELECTED; - } - - _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); - - } - } - - break; - } - case TC_AVATAR: - { - BOOL hasAvatar = ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE ); - BYTE blendmode = 255; - if ( hottrack ) - blendmode = 255; - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - blendmode = 128; - if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && - _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) - blendmode = 128; - if ( !hasAvatar ) //if no avatar then paint icon image - { - int iImage = Drawing->iImage; - if ( iImage != -1 ) - { - COLORREF colourFg; - int mode; - // Store pos - Drawing->pos_icon = p_rect; - if ( hottrack ) - { - colourFg = dat->hotTextColour; - mode = ILD_NORMAL; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = ILD_BLEND50; - } - else - { - colourFg = dat->selBkColour; - mode = ILD_NORMAL; - } - - if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && - _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) - { - mode = ILD_SELECTED; - } - - _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); - - } - } - else - { - HRGN rgn = NULL; - HRGN oldrgn; - int round_radius = 0; - int width = p_rect.right-p_rect.left; - int height = p_rect.bottom-p_rect.top; - // Store pos - Drawing->pos_avatar = p_rect; - oldrgn = CreateRectRgn( 0, 0, 0, 0 ); - GetClipRgn( hdcMem, oldrgn ); - - // Round corners - if ( dat->avatars_round_corners ) - { - if ( dat->avatars_use_custom_corner_size ) - round_radius = dat->avatars_custom_corner_size; - else - round_radius = min( width, height ) / 5; - } - else - { - round_radius = 0; - } - if ( dat->avatars_draw_border ) - { - HBRUSH hBrush = CreateSolidBrush( dat->avatars_border_color ); - HBRUSH hOldBrush = ( HBRUSH )SelectObject( hdcMem, hBrush ); - HRGN rgn2; - rgn = CreateRoundRectRgn( p_rect.left, p_rect.top, p_rect.right+1, p_rect.bottom+1, round_radius << 1, round_radius << 1 ); - rgn2 = CreateRoundRectRgn( p_rect.left+1, p_rect.top+1, p_rect.right, p_rect.bottom, round_radius << 1, round_radius << 1 ); - CombineRgn( rgn2, rgn, rgn2, RGN_DIFF ); - // FrameRgn( hdcMem, rgn, hBrush, 1, 1 ); - FillRgn( hdcMem, rgn2, hBrush ); - ske_SetRgnOpaque( hdcMem, rgn2 ); - SelectObject( hdcMem, hOldBrush ); - DeleteObject( hBrush ); - DeleteObject( rgn ); - DeleteObject( rgn2 ); - } - if ( dat->avatars_round_corners || dat->avatars_draw_border ) - { - int k = dat->avatars_draw_border?1:0; - rgn = CreateRoundRectRgn( p_rect.left+k, p_rect.top+k, p_rect.right+1-k, p_rect.bottom+1-k, round_radius * 2, round_radius * 2 ); - ExtSelectClipRgn( hdcMem, rgn, RGN_AND ); - } - - // Draw avatar - if ( dat->use_avatar_service ) - /*if ( ServiceExists( MS_AV_BLENDDRAWAVATAR )) - { - AVATARDRAWREQUEST adr; - - adr.cbSize = sizeof( AVATARDRAWREQUEST ); - adr.hContact = Drawing->hContact; - adr.hTargetDC = hdcMem; - adr.rcDraw = p_rect; - adr.dwFlags = ( dat->avatars_draw_border ? AVDRQ_DRAWBORDER : 0 ) | - ( dat->avatars_round_corners ? AVDRQ_ROUNDEDCORNER : 0 ) | - AVDRQ_HIDEBORDERONTRANSPARENCY; - adr.clrBorder = dat->avatars_border_color; - adr.radius = round_radius; - adr.alpha = blendmode; - - CallService( MS_AV_DRAWAVATAR, 0, ( LPARAM ) &adr ); - } - else + pdnce->szThirdLineText = mir_tstrdup( buf ); + } + } + uTextFormat |= ( gl_RowTabAccess[i]->valign == TC_VCENTER )?DT_VCENTER:( gl_RowTabAccess[i]->valign == TC_BOTTOM )?DT_BOTTOM:0; + uTextFormat |= ( gl_RowTabAccess[i]->halign == TC_HCENTER )?DT_CENTER:( gl_RowTabAccess[i]->halign == TC_RIGHT )?DT_RIGHT:0; + + text_size.cx = p_rect.right-p_rect.left; + text_size.cy = p_rect.bottom-p_rect.top; + + ChangeToFont( hdcMem, dat, FONTID_THIRDLINE, NULL ); + uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 )|DT_SINGLELINE; + if ( Drawing->type == CLCIT_CONTACT ) + _DrawTextSmiley( hdcMem, &p_rect, &text_size, pdnce->szThirdLineText, lstrlen( pdnce->szThirdLineText ), pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys ); + break; + } + case TC_STATUS: + { + + if ( ( Drawing->type == CLCIT_GROUP && !dat->row_hide_group_icon ) + || ( Drawing->type == CLCIT_CONTACT && Drawing->iImage != -1 + && !( dat->icon_hide_on_avatar && dat->avatars_show + && ( ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || + ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE ) + ) + && !Drawing->image_is_special )) ) + { + int iImage = -1; + // Get image + if ( Drawing->type == CLCIT_GROUP ) + { + if ( !dat->row_hide_group_icon ) iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; + else iImage = -1; + } + else if ( Drawing->type == CLCIT_CONTACT ) + iImage = Drawing->iImage; + if ( iImage != -1 ) + { + COLORREF colourFg; + int mode; + // Store pos + Drawing->pos_icon = p_rect; + if ( hottrack ) + { + colourFg = dat->hotTextColour; + mode = ILD_NORMAL; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = ILD_BLEND50; + } + else + { + colourFg = dat->selBkColour; + mode = ILD_NORMAL; + } + + if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && + _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) + { + mode = ILD_SELECTED; + } + + _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); + + } + } + + break; + } + case TC_AVATAR: + { + BOOL hasAvatar = ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE ); + BYTE blendmode = 255; + if ( hottrack ) + blendmode = 255; + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + blendmode = 128; + if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && + _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) + blendmode = 128; + if ( !hasAvatar ) //if no avatar then paint icon image + { + int iImage = Drawing->iImage; + if ( iImage != -1 ) + { + COLORREF colourFg; + int mode; + // Store pos + Drawing->pos_icon = p_rect; + if ( hottrack ) + { + colourFg = dat->hotTextColour; + mode = ILD_NORMAL; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = ILD_BLEND50; + } + else + { + colourFg = dat->selBkColour; + mode = ILD_NORMAL; + } + + if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && + _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) + { + mode = ILD_SELECTED; + } + + _DrawStatusIcon( Drawing, dat, iImage, hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); + + } + } + else + { + HRGN rgn = NULL; + HRGN oldrgn; + int round_radius = 0; + int width = p_rect.right-p_rect.left; + int height = p_rect.bottom-p_rect.top; + // Store pos + Drawing->pos_avatar = p_rect; + oldrgn = CreateRectRgn( 0, 0, 0, 0 ); + GetClipRgn( hdcMem, oldrgn ); + + // Round corners + if ( dat->avatars_round_corners ) + { + if ( dat->avatars_use_custom_corner_size ) + round_radius = dat->avatars_custom_corner_size; + else + round_radius = min( width, height ) / 5; + } + else + { + round_radius = 0; + } + if ( dat->avatars_draw_border ) + { + HBRUSH hBrush = CreateSolidBrush( dat->avatars_border_color ); + HBRUSH hOldBrush = ( HBRUSH )SelectObject( hdcMem, hBrush ); + HRGN rgn2; + rgn = CreateRoundRectRgn( p_rect.left, p_rect.top, p_rect.right+1, p_rect.bottom+1, round_radius << 1, round_radius << 1 ); + rgn2 = CreateRoundRectRgn( p_rect.left+1, p_rect.top+1, p_rect.right, p_rect.bottom, round_radius << 1, round_radius << 1 ); + CombineRgn( rgn2, rgn, rgn2, RGN_DIFF ); + // FrameRgn( hdcMem, rgn, hBrush, 1, 1 ); + FillRgn( hdcMem, rgn2, hBrush ); + ske_SetRgnOpaque( hdcMem, rgn2 ); + SelectObject( hdcMem, hOldBrush ); + DeleteObject( hBrush ); + DeleteObject( rgn ); + DeleteObject( rgn2 ); + } + if ( dat->avatars_round_corners || dat->avatars_draw_border ) + { + int k = dat->avatars_draw_border?1:0; + rgn = CreateRoundRectRgn( p_rect.left+k, p_rect.top+k, p_rect.right+1-k, p_rect.bottom+1-k, round_radius * 2, round_radius * 2 ); + ExtSelectClipRgn( hdcMem, rgn, RGN_AND ); + } + + // Draw avatar + if ( dat->use_avatar_service ) + /*if ( ServiceExists( MS_AV_BLENDDRAWAVATAR )) + { + AVATARDRAWREQUEST adr; + + adr.cbSize = sizeof( AVATARDRAWREQUEST ); + adr.hContact = Drawing->hContact; + adr.hTargetDC = hdcMem; + adr.rcDraw = p_rect; + adr.dwFlags = ( dat->avatars_draw_border ? AVDRQ_DRAWBORDER : 0 ) | + ( dat->avatars_round_corners ? AVDRQ_ROUNDEDCORNER : 0 ) | + AVDRQ_HIDEBORDERONTRANSPARENCY; + adr.clrBorder = dat->avatars_border_color; + adr.radius = round_radius; + adr.alpha = blendmode; + + CallService( MS_AV_DRAWAVATAR, 0, ( LPARAM ) &adr ); + } + else */ - { - int w = width; - int h = height; - if ( !g_CluiData.fGDIPlusFail ) //Use gdi+ engine - { - DrawAvatarImageWithGDIp( hdcMem, p_rect.left, p_rect.top, w, h, Drawing->avatar_data->hbmPic, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, Drawing->avatar_data->dwFlags, blendmode ); - } - else - { - if ( !( Drawing->avatar_data->dwFlags&AVS_PREMULTIPLIED )) - { - HDC hdcTmp = CreateCompatibleDC( hdcMem ); - RECT r = {0, 0, w, h}; - HDC hdcTmp2 = CreateCompatibleDC( hdcMem ); - HBITMAP bmo = ( HBITMAP )SelectObject( hdcTmp, Drawing->avatar_data->hbmPic ); - HBITMAP b2 = ske_CreateDIB32( w, h ); - HBITMAP bmo2 = ( HBITMAP )SelectObject( hdcTmp2, b2 ); - SetStretchBltMode( hdcTmp, HALFTONE ); - SetStretchBltMode( hdcTmp2, HALFTONE ); - StretchBlt( hdcTmp2, 0, 0, w, h, - hdcTmp, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, - SRCCOPY ); - - ske_SetRectOpaque( hdcTmp2, &r ); - BitBlt( hdcMem, p_rect.left, p_rect.top, w, h, hdcTmp2, 0, 0, SRCCOPY ); - SelectObject( hdcTmp2, bmo2 ); - SelectObject( hdcTmp, bmo ); - mod_DeleteDC( hdcTmp ); - mod_DeleteDC( hdcTmp2 ); - DeleteObject( b2 ); - } - else { - BLENDFUNCTION bf = {AC_SRC_OVER, 0, blendmode, AC_SRC_ALPHA }; - HDC hdcTempAv = CreateCompatibleDC( hdcMem ); - HBITMAP hbmTempAvOld; - hbmTempAvOld = ( HBITMAP )SelectObject( hdcTempAv, Drawing->avatar_data->hbmPic ); - ske_AlphaBlend( hdcMem, p_rect.left, p_rect.top, w, h, hdcTempAv, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, bf ); - SelectObject( hdcTempAv, hbmTempAvOld ); - mod_DeleteDC( hdcTempAv ); - } - } - } - else - { - ImageArray_DrawImage( &dat->avatar_cache, Drawing->avatar_pos, hdcMem, p_rect.left, p_rect.top, 255 ); - } - // Restore region - if ( dat->avatars_round_corners || dat->avatars_draw_border ) - { - DeleteObject( rgn ); - } - SelectClipRgn( hdcMem, oldrgn ); - DeleteObject( oldrgn ); - - - // Draw borders - - //TODO fix overlays - // Draw overlay - if ( dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) - && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) - { - p_rect.top = p_rect.bottom - ICON_HEIGHT; - p_rect.left = p_rect.right - ICON_HEIGHT; - - if ( dat->avatars_draw_border ) - { - p_rect.top--; - p_rect.left--; - } - - switch( dat->avatars_overlay_type ) - { - case SETTING_AVATAR_OVERLAY_TYPE_NORMAL: - { - UINT a = blendmode; - a = ( a << 24 ); - ske_ImageList_DrawEx( hAvatarOverlays, g_pAvatarOverlayIcons[GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE].listID, - hdcMem, - p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, - CLR_NONE, CLR_NONE, - ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); - - //ske_DrawIconEx( hdcMem, p_rect.left, p_rect.top, g_pAvatarOverlayIcons[GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE].icon, - // ICON_HEIGHT, ICON_HEIGHT, 0, NULL, DI_NORMAL|a ); - break; - } - case SETTING_AVATAR_OVERLAY_TYPE_PROTOCOL: - { - int item; - - item = ExtIconFromStatusMode( Drawing->hContact, Drawing->proto, - Drawing->proto == NULL ? ID_STATUS_OFFLINE : GetContactCachedStatus( Drawing->hContact )); - if ( item != -1 ) - _DrawStatusIcon( Drawing, dat, item, hdcMem, - p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, - CLR_NONE, CLR_NONE, ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); - break; - } - case SETTING_AVATAR_OVERLAY_TYPE_CONTACT: - { - if ( Drawing->iImage != -1 ) - _DrawStatusIcon( Drawing, dat, Drawing->iImage, hdcMem, - p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, - CLR_NONE, CLR_NONE, ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); - break; - } - } - } - } - - break; - } - case TC_EXTRA: - { - - if ( Drawing->type == CLCIT_CONTACT && - ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 )) - { - int BlendedInActiveState = dat->dbbBlendInActiveState; - int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; - int iImage; - int count = 0; - RECT rc; - int x = 0; - for ( iImage = 0; iImage < dat->extraColumnsCount ; iImage++ ) - { - COLORREF colourFg = dat->selBkColour; - int mode = BlendedInActiveState?BlendValue:ILD_NORMAL; - if ( Drawing->iExtraImage[iImage] == 0xFF && Drawing->iWideExtraImage[iImage] == 0xFFFF ) - { - if ( !dat->MetaIgnoreEmptyExtra ) - { - SetRect( &rc, p_rect.left+x, p_rect.top, p_rect.left+x+ICON_HEIGHT, p_rect.bottom ); - x += dat->extraColumnSpacing; - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); - Drawing->pos_extra[iImage] = rc; - count++; - } - continue; - } - - if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; - else if ( hottrack ) - { - mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; - colourFg = dat->hotTextColour; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = BlendValue; - } - - SetRect( &rc, p_rect.left+x, p_rect.top, p_rect.left+x+ICON_HEIGHT, p_rect.bottom ); - x += dat->extraColumnSpacing; - count++; - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); - Drawing->pos_extra[iImage] = rc; + { + int w = width; + int h = height; + if ( !g_CluiData.fGDIPlusFail ) //Use gdi+ engine + { + DrawAvatarImageWithGDIp( hdcMem, p_rect.left, p_rect.top, w, h, Drawing->avatar_data->hbmPic, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, Drawing->avatar_data->dwFlags, blendmode ); + } + else + { + if ( !( Drawing->avatar_data->dwFlags&AVS_PREMULTIPLIED )) + { + HDC hdcTmp = CreateCompatibleDC( hdcMem ); + RECT r = {0, 0, w, h}; + HDC hdcTmp2 = CreateCompatibleDC( hdcMem ); + HBITMAP bmo = ( HBITMAP )SelectObject( hdcTmp, Drawing->avatar_data->hbmPic ); + HBITMAP b2 = ske_CreateDIB32( w, h ); + HBITMAP bmo2 = ( HBITMAP )SelectObject( hdcTmp2, b2 ); + SetStretchBltMode( hdcTmp, HALFTONE ); + SetStretchBltMode( hdcTmp2, HALFTONE ); + StretchBlt( hdcTmp2, 0, 0, w, h, + hdcTmp, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, + SRCCOPY ); + + ske_SetRectOpaque( hdcTmp2, &r ); + BitBlt( hdcMem, p_rect.left, p_rect.top, w, h, hdcTmp2, 0, 0, SRCCOPY ); + SelectObject( hdcTmp2, bmo2 ); + SelectObject( hdcTmp, bmo ); + mod_DeleteDC( hdcTmp ); + mod_DeleteDC( hdcTmp2 ); + DeleteObject( b2 ); + } + else { + BLENDFUNCTION bf = {AC_SRC_OVER, 0, blendmode, AC_SRC_ALPHA }; + HDC hdcTempAv = CreateCompatibleDC( hdcMem ); + HBITMAP hbmTempAvOld; + hbmTempAvOld = ( HBITMAP )SelectObject( hdcTempAv, Drawing->avatar_data->hbmPic ); + ske_AlphaBlend( hdcMem, p_rect.left, p_rect.top, w, h, hdcTempAv, 0, 0, Drawing->avatar_data->bmWidth, Drawing->avatar_data->bmHeight, bf ); + SelectObject( hdcTempAv, hbmTempAvOld ); + mod_DeleteDC( hdcTempAv ); + } + } + } + else + { + ImageArray_DrawImage( &dat->avatar_cache, Drawing->avatar_pos, hdcMem, p_rect.left, p_rect.top, 255 ); + } + // Restore region + if ( dat->avatars_round_corners || dat->avatars_draw_border ) + { + DeleteObject( rgn ); + } + SelectClipRgn( hdcMem, oldrgn ); + DeleteObject( oldrgn ); + + + // Draw borders + + //TODO fix overlays + // Draw overlay + if ( dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) + && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) + { + p_rect.top = p_rect.bottom - ICON_HEIGHT; + p_rect.left = p_rect.right - ICON_HEIGHT; + + if ( dat->avatars_draw_border ) + { + p_rect.top--; + p_rect.left--; + } + + switch( dat->avatars_overlay_type ) + { + case SETTING_AVATAR_OVERLAY_TYPE_NORMAL: + { + UINT a = blendmode; + a = ( a << 24 ); + ske_ImageList_DrawEx( hAvatarOverlays, g_pAvatarOverlayIcons[GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE].listID, + hdcMem, + p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, + CLR_NONE, CLR_NONE, + ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); + + //ske_DrawIconEx( hdcMem, p_rect.left, p_rect.top, g_pAvatarOverlayIcons[GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE].icon, + // ICON_HEIGHT, ICON_HEIGHT, 0, NULL, DI_NORMAL|a ); + break; + } + case SETTING_AVATAR_OVERLAY_TYPE_PROTOCOL: + { + int item; + + item = ExtIconFromStatusMode( Drawing->hContact, Drawing->proto, + Drawing->proto == NULL ? ID_STATUS_OFFLINE : GetContactCachedStatus( Drawing->hContact )); + if ( item != -1 ) + _DrawStatusIcon( Drawing, dat, item, hdcMem, + p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, + CLR_NONE, CLR_NONE, ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); + break; + } + case SETTING_AVATAR_OVERLAY_TYPE_CONTACT: + { + if ( Drawing->iImage != -1 ) + _DrawStatusIcon( Drawing, dat, Drawing->iImage, hdcMem, + p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, + CLR_NONE, CLR_NONE, ( blendmode == 255 )?ILD_NORMAL:( blendmode == 128 )?ILD_BLEND50:ILD_BLEND25 ); + break; + } + } + } + } + + break; + } + case TC_EXTRA: + { + + if ( Drawing->type == CLCIT_CONTACT && + ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 )) + { + int BlendedInActiveState = dat->dbbBlendInActiveState; + int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; + int iImage; + int count = 0; + RECT rc; + int x = 0; + for ( iImage = 0; iImage < dat->extraColumnsCount ; iImage++ ) + { + COLORREF colourFg = dat->selBkColour; + int mode = BlendedInActiveState?BlendValue:ILD_NORMAL; + if ( Drawing->iExtraImage[iImage] == 0xFF && Drawing->iWideExtraImage[iImage] == 0xFFFF ) + { + if ( !dat->MetaIgnoreEmptyExtra ) + { + SetRect( &rc, p_rect.left+x, p_rect.top, p_rect.left+x+ICON_HEIGHT, p_rect.bottom ); + x += dat->extraColumnSpacing; + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); + Drawing->pos_extra[iImage] = rc; + count++; + } + continue; + } + + if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; + else if ( hottrack ) + { + mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; + colourFg = dat->hotTextColour; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = BlendValue; + } + + SetRect( &rc, p_rect.left+x, p_rect.top, p_rect.left+x+ICON_HEIGHT, p_rect.bottom ); + x += dat->extraColumnSpacing; + count++; + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); + Drawing->pos_extra[iImage] = rc; if ( Drawing->iExtraImage[iImage] != 0xFF ) ske_ImageList_DrawEx( dat->himlExtraColumns, Drawing->iExtraImage[iImage], hdcMem, rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); else if ( Drawing->iWideExtraImage[iImage] != 0xFFFF ) ske_ImageList_DrawEx( dat->himlWideExtraColumns, Drawing->iWideExtraImage[iImage], hdcMem, rc.left, rc.top, 0, 0, CLR_NONE, colourFg, mode ); - } - } - break; - } - case TC_EXTRA1: - case TC_EXTRA2: - case TC_EXTRA3: - case TC_EXTRA4: - case TC_EXTRA5: - case TC_EXTRA6: - case TC_EXTRA7: - case TC_EXTRA8: - case TC_EXTRA9: - { - if ( Drawing->type == CLCIT_CONTACT && - ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 )) - { - int eNum = gl_RowTabAccess[i]->type-TC_EXTRA1; - if ( eNum < dat->extraColumnsCount ) - if ( Drawing->iExtraImage[eNum] != 0xFF || Drawing->iWideExtraImage[eNum] != 0xFFFF ) - { - int mode = 0; - int BlendedInActiveState = dat->dbbBlendInActiveState; - int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; - if ( mode2 != -1 ) mode = mode2; - else - { - if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; - else if ( hottrack ) - { - mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; - colourFg = dat->hotTextColour; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = BlendValue; - } - mode2 = mode; - } - if ( dat->text_rtl != 0 ) _RTLRect( &p_rect, free_row_rc.right, 0 ); - Drawing->pos_extra[eNum] = p_rect; + } + } + break; + } + case TC_EXTRA1: + case TC_EXTRA2: + case TC_EXTRA3: + case TC_EXTRA4: + case TC_EXTRA5: + case TC_EXTRA6: + case TC_EXTRA7: + case TC_EXTRA8: + case TC_EXTRA9: + { + if ( Drawing->type == CLCIT_CONTACT && + ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 )) + { + int eNum = gl_RowTabAccess[i]->type-TC_EXTRA1; + if ( eNum < dat->extraColumnsCount ) + if ( Drawing->iExtraImage[eNum] != 0xFF || Drawing->iWideExtraImage[eNum] != 0xFFFF ) + { + int mode = 0; + int BlendedInActiveState = dat->dbbBlendInActiveState; + int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; + if ( mode2 != -1 ) mode = mode2; + else + { + if ( selected ) mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; + else if ( hottrack ) + { + mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; + colourFg = dat->hotTextColour; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST ) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = BlendValue; + } + mode2 = mode; + } + if ( dat->text_rtl != 0 ) _RTLRect( &p_rect, free_row_rc.right, 0 ); + Drawing->pos_extra[eNum] = p_rect; if ( Drawing->iExtraImage[eNum] != 0xFF ) ske_ImageList_DrawEx( dat->himlExtraColumns, Drawing->iExtraImage[eNum], hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); else if ( Drawing->iWideExtraImage[eNum] != 0xFFFF ) ske_ImageList_DrawEx( dat->himlWideExtraColumns, Drawing->iWideExtraImage[eNum], hdcMem, p_rect.left, p_rect.top, 0, 0, CLR_NONE, colourFg, mode ); - } - } - } - case TC_TIME: - { - TCHAR szResult[80]; - - if (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) - { - // Select font - ChangeToFont( hdcMem, dat, FONTID_CONTACT_TIME, NULL ); - ske_DrawText( hdcMem, szResult, lstrlen( szResult ), &p_rect, DT_NOPREFIX | DT_SINGLELINE|( dat->text_rtl ? DT_RTLREADING : 0 )); - } - break; - } - } - } - i++; - } - return; + } + } + } + case TC_TIME: + { + TCHAR szResult[80]; + + if (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) + { + // Select font + ChangeToFont( hdcMem, dat, FONTID_CONTACT_TIME, NULL ); + ske_DrawText( hdcMem, szResult, lstrlen( szResult ), &p_rect, DT_NOPREFIX | DT_SINGLELINE|( dat->text_rtl ? DT_RTLREADING : 0 )); + } + break; + } + } + } + i++; + } + return; } @@ -1676,629 +1673,620 @@ void CLCPaint::_PaintRowItemsEx( HWND hwnd, HDC hdcMem, struct ClcData *dat, str void CLCPaint::_DrawStatusIcon( struct ClcContact * Drawing, struct ClcData *dat, int iImage, HDC hdcMem, int x, int y, int cx, int cy, DWORD colorbg, DWORD colorfg, int mode ) { - if ( Drawing->type != CLCIT_CONTACT ) - { - ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, - x, y, cx, cy, colorbg, colorfg, mode ); - } - else if ( Drawing->image_is_special ) - { - ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, - x, y, cx, cy, colorbg, colorfg, mode ); - } - else if ( iImage != -1 && HIWORD( iImage ) && dat->drawOverlayedStatus ) - { - int status = GetContactCachedStatus( Drawing->hContact ); - if ( status < ID_STATUS_OFFLINE ) status = ID_STATUS_OFFLINE; - else if ( status>ID_STATUS_OUTTOLUNCH ) status = ID_STATUS_ONLINE; - ske_ImageList_DrawEx( g_himlCListClc, HIWORD( iImage ), hdcMem, - x, y, cx, cy, colorbg, colorfg, mode ); - if ( dat->drawOverlayedStatus&2 ) //draw overlay - ske_ImageList_DrawEx( hAvatarOverlays, g_pStatusOverlayIcons[status-ID_STATUS_OFFLINE].listID, hdcMem, - x, y, cx, cy, colorbg, colorfg, mode ); - } - else - { - ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, - x, y, cx, cy, colorbg, colorfg, mode ); - } + if ( Drawing->type != CLCIT_CONTACT ) + { + ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, + x, y, cx, cy, colorbg, colorfg, mode ); + } + else if ( Drawing->image_is_special ) + { + ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, + x, y, cx, cy, colorbg, colorfg, mode ); + } + else if ( iImage != -1 && HIWORD( iImage ) && dat->drawOverlayedStatus ) + { + int status = GetContactCachedStatus( Drawing->hContact ); + if ( status < ID_STATUS_OFFLINE ) status = ID_STATUS_OFFLINE; + else if ( status>ID_STATUS_OUTTOLUNCH ) status = ID_STATUS_ONLINE; + ske_ImageList_DrawEx( g_himlCListClc, HIWORD( iImage ), hdcMem, + x, y, cx, cy, colorbg, colorfg, mode ); + if ( dat->drawOverlayedStatus&2 ) //draw overlay + ske_ImageList_DrawEx( hAvatarOverlays, g_pStatusOverlayIcons[status-ID_STATUS_OFFLINE].listID, hdcMem, + x, y, cx, cy, colorbg, colorfg, mode ); + } + else + { + ske_ImageList_DrawEx( g_himlCListClc, LOWORD( iImage ), hdcMem, + x, y, cx, cy, colorbg, colorfg, mode ); + } } BOOL CLCPaint::_DrawNonEnginedBackground( HWND hwnd, HDC hdcMem, RECT * rcPaint, RECT clRect, struct ClcData * dat ) { - if ( dat->hBmpBackground ) + if ( dat->hBmpBackground ) { - BITMAP bmp; - HBITMAP oldbm; - HDC hdcBmp; - int x, y; - int maxx, maxy; - int destw, desth; - - // XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98. - SetStretchBltMode( hdcMem, HALFTONE ); - - - GetObject( dat->hBmpBackground, sizeof( bmp ), &bmp ); - hdcBmp = CreateCompatibleDC( hdcMem ); - oldbm = ( HBITMAP )SelectObject( hdcBmp, dat->hBmpBackground ); - y = dat->backgroundBmpUse&CLBF_SCROLL?-dat->yScroll:0; - maxx = dat->backgroundBmpUse&CLBF_TILEH?clRect.right:1; - maxy = dat->backgroundBmpUse&CLBF_TILEV?maxy = rcPaint->bottom:y+1; - switch( dat->backgroundBmpUse&CLBM_TYPE ) { - case CLB_STRETCH: - if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { - if ( clRect.right*bmp.bmHeight < clRect.bottom*bmp.bmWidth ) { - desth = clRect.bottom; - destw = desth*bmp.bmWidth/bmp.bmHeight; - } - else { - destw = clRect.right; - desth = destw*bmp.bmHeight/bmp.bmWidth; - } - } - else { - destw = clRect.right; - desth = clRect.bottom; - } - break; - case CLB_STRETCHH: - if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { - destw = clRect.right; - desth = destw*bmp.bmHeight/bmp.bmWidth; - } - else { - destw = clRect.right; - desth = bmp.bmHeight; - if ( dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT ) - { - desth = dat->row_min_heigh; - } - - } - break; - case CLB_STRETCHV: - if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { - desth = clRect.bottom; - destw = desth*bmp.bmWidth/bmp.bmHeight; - } - else { - destw = bmp.bmWidth; - desth = clRect.bottom; - } - break; - default: //clb_topleft - destw = bmp.bmWidth; - desth = bmp.bmHeight; - if ( dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT ) - { - desth = dat->row_min_heigh; - } - break; - } - for ( ;y < maxy;y += desth ) { - if ( y < rcPaint->top-desth ) continue; - for ( x = 0;x < maxx;x += destw ) - StretchBlt( hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY ); - } - SelectObject( hdcBmp, oldbm ); - DeleteDC( hdcBmp ); - return TRUE; - } - return FALSE; + BITMAP bmp; + HBITMAP oldbm; + HDC hdcBmp; + int x, y; + int maxx, maxy; + int destw, desth; + + // XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98. + SetStretchBltMode( hdcMem, HALFTONE ); + + + GetObject( dat->hBmpBackground, sizeof( bmp ), &bmp ); + hdcBmp = CreateCompatibleDC( hdcMem ); + oldbm = ( HBITMAP )SelectObject( hdcBmp, dat->hBmpBackground ); + y = dat->backgroundBmpUse&CLBF_SCROLL?-dat->yScroll:0; + maxx = dat->backgroundBmpUse&CLBF_TILEH?clRect.right:1; + maxy = dat->backgroundBmpUse&CLBF_TILEV?maxy = rcPaint->bottom:y+1; + switch( dat->backgroundBmpUse&CLBM_TYPE ) { + case CLB_STRETCH: + if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { + if ( clRect.right*bmp.bmHeight < clRect.bottom*bmp.bmWidth ) { + desth = clRect.bottom; + destw = desth*bmp.bmWidth/bmp.bmHeight; + } + else { + destw = clRect.right; + desth = destw*bmp.bmHeight/bmp.bmWidth; + } + } + else { + destw = clRect.right; + desth = clRect.bottom; + } + break; + case CLB_STRETCHH: + if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { + destw = clRect.right; + desth = destw*bmp.bmHeight/bmp.bmWidth; + } + else { + destw = clRect.right; + desth = bmp.bmHeight; + if ( dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT ) + { + desth = dat->row_min_heigh; + } + + } + break; + case CLB_STRETCHV: + if ( dat->backgroundBmpUse&CLBF_PROPORTIONAL ) { + desth = clRect.bottom; + destw = desth*bmp.bmWidth/bmp.bmHeight; + } + else { + destw = bmp.bmWidth; + desth = clRect.bottom; + } + break; + default: //clb_topleft + destw = bmp.bmWidth; + desth = bmp.bmHeight; + if ( dat->backgroundBmpUse&CLBF_TILEVTOROWHEIGHT ) + { + desth = dat->row_min_heigh; + } + break; + } + for ( ;y < maxy;y += desth ) { + if ( y < rcPaint->top-desth ) continue; + for ( x = 0;x < maxx;x += destw ) + StretchBlt( hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY ); + } + SelectObject( hdcBmp, oldbm ); + DeleteDC( hdcBmp ); + return TRUE; + } + return FALSE; } int CLCPaint::_DetermineDrawMode( HWND hWnd, struct ClcData *dat ) { - int paintMode = DM_LAYERED; // by default + int paintMode = DM_LAYERED; // by default + + if ( dat->force_in_dialog ) + paintMode = DM_CONTROL; + else if ( g_CluiData.fDisableSkinEngine ) + paintMode = DM_CLASSIC; + else if ( !g_CluiData.fLayered ) + paintMode = DM_NON_LAYERED; + + if ( !(paintMode&DM_CONTROL) && !CLUI_IsInMainWindow( hWnd )) + paintMode |= DM_FLOAT; + + LONG lStyle = GetWindowLongPtr( hWnd, GWL_STYLE ); + int nStatus = _GetGeneralisedStatus(); + if ( ( lStyle & WS_DISABLED ) + || ( dat->greyoutFlags & pcli->pfnClcStatusToPf2( nStatus )) + || ( ( dat->greyoutFlags & GREYF_UNFOCUS) && ( GetFocus() != hWnd )) ) + paintMode |= DM_GRAY; + + if ( lStyle&CLS_GREYALTERNATE ) + paintMode |= DM_GREYALTERNATE; + + return paintMode; +} + +void CLCPaint::_PreparePaintContext( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT& clRect, _PaintContext& pc ) +{ + if ( paintMode&DM_GRAY && !(paintMode&DM_LAYERED)) + { + pc.hdcMem2 = CreateCompatibleDC( hdc ); + if ( paintMode&DM_CLASSIC ) + pc.hBmpOsb2 = CreateBitmap( clRect.right, clRect.bottom, 1, GetDeviceCaps( hdc, BITSPIXEL ), NULL ); + else + pc.hBmpOsb2 = ske_CreateDIB32( clRect.right, clRect.bottom ); + pc.oldbmp2 = (HBITMAP) SelectObject( pc.hdcMem2, pc.hBmpOsb2 ); + pc.fRelease |= _PaintContext::release_hdcmem2; + } + + if ( paintMode&( DM_DRAW_OFFSCREEN | DM_GRAY ) ) + { + pc.hdcMem = CreateCompatibleDC( hdc ); + pc.fRelease |= _PaintContext::release_hdcmem; + pc.hBmpOsb = ske_CreateDIB32( clRect.right, clRect.bottom ); + pc.oldbmp = ( HBITMAP ) SelectObject( pc.hdcMem, pc.hBmpOsb ); + } + + if ( paintMode&DM_CONTROL && !dat->bkChanged ) + { + pc.tmpbkcolour = GetSysColor( COLOR_3DFACE ); + pc.tmpforecolour = GetSysColor( COLOR_BTNTEXT ); + } + else + { + pc.tmpbkcolour = (!(paintMode&DM_CONTROL) && dat->bkChanged ) ? dat->bkColour : ( !dat->useWindowsColours ? dat->bkColour : GetSysColor( COLOR_3DFACE )); + pc.tmpforecolour = /*(paintMode&DM_CONTROL) ? */dat->fontModernInfo[FONTID_CONTACTS].colour; + } - if ( dat->force_in_dialog ) - paintMode = DM_CONTROL; - else if ( g_CluiData.fDisableSkinEngine ) - paintMode = DM_CLASSIC; - else if ( !g_CluiData.fLayered ) - paintMode = DM_NON_LAYERED; + if ( paintMode&DM_GREYALTERNATE ) + { + int rDelta = ( GetRValue( pc.tmpbkcolour ) > GetRValue( pc.tmpforecolour )) ? -10 : 10; + int gDelta = ( GetGValue( pc.tmpbkcolour ) > GetGValue( pc.tmpforecolour )) ? -10 : 10; + int bDelta = ( GetBValue( pc.tmpbkcolour ) > GetBValue( pc.tmpforecolour )) ? -10 : 10; + int rValue = GetRValue( pc.tmpbkcolour ) + rDelta; + int gValue = GetRValue( pc.tmpbkcolour ) + gDelta; + int bValue = GetRValue( pc.tmpbkcolour ) + bDelta; + + BYTE brValue = ( rValue >255) ? 255 : rValue < 0 ? 0 : (BYTE)rValue; + BYTE bgValue = ( gValue >255) ? 255 : gValue < 0 ? 0 : (BYTE)gValue; + BYTE bbValue = ( bValue >255) ? 255 : bValue < 0 ? 0 : (BYTE)bValue; + + pc.hBrushAlternateGrey = CreateSolidBrush( GetNearestColor( pc.hdcMem, RGB( brValue, bgValue, bbValue )) ); + } + + // Set some draw states + SetBkMode( pc.hdcMem, TRANSPARENT ); + SetStretchBltMode( pc.hdcMem, HALFTONE ); + + POINT org; + GetBrushOrgEx( pc.hdcMem, &org ); + SetBrushOrgEx( pc.hdcMem, org.x, org.y, NULL ); +} + +void CLCPaint::_DrawBackground( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT * rcPaint, RECT& clRect, _PaintContext& pc ) +{ + if ( paintMode&(DM_FLOAT|DM_CONTROL)) + { + HBRUSH hBrush = CreateSolidBrush( pc.tmpbkcolour ); + FillRect( pc.hdcMem, rcPaint, hBrush ); + DeleteObject( hBrush ); + ske_SetRectOpaque( pc.hdcMem, rcPaint ); + if ( !( paintMode&DM_GREYALTERNATE )) + SkinDrawGlyph( pc.hdcMem, &clRect, rcPaint, "CL,ID = Background,Type = Control" ); + } + else if ( paintMode&DM_CLASSIC) + { + if ( !_DrawNonEnginedBackground( hWnd, pc.hdcMem, rcPaint, clRect, dat )) + { + HBRUSH hBrush = CreateSolidBrush( pc.tmpbkcolour ); + FillRect( pc.hdcMem, rcPaint, hBrush ); + DeleteObject( hBrush ); + } + } + else + { + if ( paintMode&DM_NON_LAYERED ) + ske_BltBackImage( hWnd, (paintMode&DM_GRAY) ? pc.hdcMem2 : pc.hdcMem, rcPaint ); + + SkinDrawGlyph( pc.hdcMem, &clRect, rcPaint, "CL,ID = Background" ); + } +} +void CLCPaint::_DrawLines( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT* rcPaint, RECT& clRect, _PaintContext& pc ) +{ + struct ClcContact *Drawing; + struct ClcGroup *group = &dat->list; + group->scanIndex = 0; + int indent = 0; + int subident = 0; + int subindex = -1; + int line_num = -1; + int y = -dat->yScroll; + BOOL is_foreground = IsForegroundWindow( hWnd ); + LONG lStyle = GetWindowLongPtr( hWnd, GWL_STYLE ); + + while( y < rcPaint->bottom ) + { + if ( subindex == -1 ) + { + if ( group->scanIndex >= group->cl.count ) + { + group = group->parent; + indent--; + if ( group == NULL ) break; // Finished list + group->scanIndex++; + continue; + } + } + + line_num++; + + // Draw line, if needed + if ( y > rcPaint->top - dat->row_heights[line_num] ) + { + int selected; + int hottrack; + int left_pos; + int right_pos; + int free_row_height; + RECT row_rc; + RECT free_row_rc; + MODERNMASK * mpRequest = NULL; + RECT rc; + + // Get item to draw + if ( group->scanIndex < group->cl.count ) + { + if ( subindex == -1 ) { + Drawing = group->cl.items[group->scanIndex]; + subident = 0; + } + else { + Drawing = &( group->cl.items[group->scanIndex]->subcontacts[subindex] ); + subident = dat->subIndent; + } + } + else Drawing = NULL; + + // Something to draw? + if ( Drawing ) { + + // Calc row height + if ( !gl_RowRoot ) + RowHeights_GetRowHeight( dat, hWnd, Drawing, line_num ); + else + RowHeight_CalcRowHeight( dat, hWnd, Drawing, line_num ); + + // Init settings + selected = ( ( line_num == dat->selection ) && ( dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || is_foreground ) && Drawing->type != CLCIT_DIVIDER ); + hottrack = dat->exStyle&CLS_EX_TRACKSELECT && Drawing->type != CLCIT_DIVIDER && dat->iHotTrack == line_num; + left_pos = clRect.left + dat->leftMargin + indent * dat->groupIndent + subident; + right_pos = dat->rightMargin; // Border + + SetRect( &row_rc, clRect.left, y, clRect.right, y + dat->row_heights[line_num] ); + free_row_rc = row_rc; + free_row_rc.left += left_pos; + free_row_rc.right -= right_pos; + free_row_rc.top += dat->row_border; + free_row_rc.bottom -= dat->row_border; + free_row_height = free_row_rc.bottom - free_row_rc.top; + + { + HRGN rgn = CreateRectRgn( row_rc.left, row_rc.top, row_rc.right, row_rc.bottom ); + SelectClipRgn( pc.hdcMem, rgn ); + DeleteObject( rgn ); + } + + // Store pos + Drawing->pos_indent = free_row_rc.left; + ZeroMemory( &Drawing->pos_check, sizeof( Drawing->pos_check )); + ZeroMemory( &Drawing->pos_avatar, sizeof( Drawing->pos_avatar )); + ZeroMemory( &Drawing->pos_icon, sizeof( Drawing->pos_icon )); + ZeroMemory( &Drawing->pos_label, sizeof( Drawing->pos_label )); + ZeroMemory( &Drawing->pos_rename_rect, sizeof( Drawing->pos_rename_rect )); + ZeroMemory( &Drawing->pos_extra, sizeof( Drawing->pos_extra )); + + + //**** Draw Background + + // Alternating grey + if ( paintMode&DM_GREYALTERNATE && line_num&1 ) + { + if ( paintMode&DM_CONTROL || dat->bkChanged ) + { + FillRect( pc.hdcMem, &row_rc, pc.hBrushAlternateGrey ); + } + else + SkinDrawGlyph( pc.hdcMem, &row_rc, rcPaint, "CL,ID = GreyAlternate" ); + } + if ( ! (paintMode&(DM_CLASSIC|DM_CONTROL)) ) + { + // Row background + if ( !(paintMode&DM_CONTROL)) + { //Build mpRequest string + mpRequest = _GetCLCContactRowBackModernMask( group, Drawing, indent, line_num, selected, hottrack, dat ); + { + RECT mrc = row_rc; + if ( group->parent == 0 + && group->scanIndex != 0 + && group->scanIndex < group->cl.count + && group->cl.items[group->scanIndex]->type == CLCIT_GROUP ) + { + mrc.top += dat->row_before_group_space; + } + SkinDrawGlyphMask( pc.hdcMem, &mrc, rcPaint, mpRequest ); + } + } + if ( selected || hottrack ) + { + RECT mrc = row_rc; + if ( Drawing->type == CLCIT_GROUP && + Drawing->group->parent->groupId == 0 && + Drawing->group->parent->cl.items[0] != Drawing ) + { + mrc.top += dat->row_before_group_space; + } + // Selection background ( only if hole line - full/less ) + if ( dat->HiLightMode == 1 ) // Full or default + { + if ( selected ) + SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL , ID = Selection " ); + if ( hottrack ) + SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = HotTracking" ); + } + else if ( dat->HiLightMode == 2 ) // Less + { + if ( selected ) + SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = Selection" ); //instead of free_row_rc + if ( hottrack ) + SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = HotTracking" ); + } + } + + } + else + { + int checkboxWidth; + if ( ( lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT ) || + ( lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP ) || + ( Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX )) + checkboxWidth = dat->checkboxSize+2; + else checkboxWidth = 0; + //background + if ( selected ) { + switch ( dat->HiLightMode ) + { + case 0: + case 1: + { + int i = y; + int row_height = row_rc.bottom-row_rc.top; + for ( i = y; i < y+row_height; i += max( dat->row_min_heigh, 1 )) + { + ImageList_DrawEx( dat->himlHighlight, 0, pc.hdcMem, 0, i, clRect.right, + min( y+row_height-i, max( dat->row_min_heigh, 1 )), CLR_NONE, CLR_NONE, + dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25 ); + } + SetTextColor( pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor( COLOR_HIGHLIGHTTEXT ) : dat->selTextColour ); + break; + } + + case 2: + { + int i; + int row_height = row_rc.bottom-row_rc.top-1; + for ( i = y+1; i < y+row_height; i += max( dat->row_min_heigh, 1 )) + { + ImageList_DrawEx( dat->himlHighlight, 0, pc.hdcMem, 1, i, clRect.right-2, + min( y+row_height-i, max( dat->row_min_heigh, 1 )), CLR_NONE, CLR_NONE, + dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25 ); + } + SetTextColor( pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor( COLOR_HIGHLIGHTTEXT ) : dat->selTextColour ); + break; + } + } + } - if ( !(paintMode&DM_CONTROL) && !CLUI_IsInMainWindow( hWnd )) - paintMode |= DM_FLOAT; + } + //**** Checkboxes + if ( ( lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT ) || + ( lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP ) || + ( Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX )) + { + //RECT rc; + rc = free_row_rc; + rc.right = rc.left + dat->checkboxSize; + rc.top += ( rc.bottom - rc.top - dat->checkboxSize ) >> 1; + rc.bottom = rc.top + dat->checkboxSize; - LONG lStyle = GetWindowLongPtr( hWnd, GWL_STYLE ); - int nStatus = _GetGeneralisedStatus(); - if ( ( lStyle & WS_DISABLED ) - || ( dat->greyoutFlags & pcli->pfnClcStatusToPf2( nStatus )) - || ( ( dat->greyoutFlags & GREYF_UNFOCUS) && ( GetFocus() != hWnd )) ) - paintMode |= DM_GRAY; + if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); - if ( lStyle&CLS_GREYALTERNATE ) - paintMode |= DM_GREYALTERNATE; + if ( xpt_IsThemed( dat->hCheckBoxTheme )) { + xpt_DrawThemeBackground( dat->hCheckBoxTheme, pc.hdcMem, BP_CHECKBOX, Drawing->flags&CONTACTF_CHECKED?( hottrack?CBS_CHECKEDHOT:CBS_CHECKEDNORMAL ):( hottrack?CBS_UNCHECKEDHOT:CBS_UNCHECKEDNORMAL ), &rc, &rc ); + } + else DrawFrameControl( pc.hdcMem, &rc, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_FLAT|( Drawing->flags&CONTACTF_CHECKED?DFCS_CHECKED:0 )|( hottrack?DFCS_HOT:0 )); - return paintMode; -} + left_pos += dat->checkboxSize + EXTRA_CHECKBOX_SPACE + HORIZONTAL_SPACE; + free_row_rc.left = row_rc.left + left_pos; -void CLCPaint::_PreparePaintContext( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT& clRect, _PaintContext& pc ) -{ - if ( paintMode&DM_GRAY && !(paintMode&DM_LAYERED)) - { - pc.hdcMem2 = CreateCompatibleDC( hdc ); - if ( paintMode&DM_CLASSIC ) - pc.hBmpOsb2 = CreateBitmap( clRect.right, clRect.bottom, 1, GetDeviceCaps( hdc, BITSPIXEL ), NULL ); - else - pc.hBmpOsb2 = ske_CreateDIB32( clRect.right, clRect.bottom ); - pc.oldbmp2 = (HBITMAP) SelectObject( pc.hdcMem2, pc.hBmpOsb2 ); - pc.fRelease |= _PaintContext::release_hdcmem2; - } - - if ( paintMode&( DM_DRAW_OFFSCREEN | DM_GRAY ) ) - { - pc.hdcMem = CreateCompatibleDC( hdc ); - pc.fRelease |= _PaintContext::release_hdcmem; - pc.hBmpOsb = ske_CreateDIB32( clRect.right, clRect.bottom ); - pc.oldbmp = ( HBITMAP ) SelectObject( pc.hdcMem, pc.hBmpOsb ); - } - - if ( paintMode&DM_CONTROL && !dat->bkChanged ) - { - pc.tmpbkcolour = GetSysColor( COLOR_3DFACE ); - pc.tmpforecolour = GetSysColor( COLOR_BTNTEXT ); - } - else - { - pc.tmpbkcolour = (!(paintMode&DM_CONTROL) && dat->bkChanged ) ? dat->bkColour : ( !dat->useWindowsColours ? dat->bkColour : GetSysColor( COLOR_3DFACE )); - pc.tmpforecolour = /*(paintMode&DM_CONTROL) ? */dat->fontModernInfo[FONTID_CONTACTS].colour; - } - - if ( paintMode&DM_GREYALTERNATE ) - { - int rDelta = ( GetRValue( pc.tmpbkcolour ) > GetRValue( pc.tmpforecolour )) ? -10 : 10; - int gDelta = ( GetGValue( pc.tmpbkcolour ) > GetGValue( pc.tmpforecolour )) ? -10 : 10; - int bDelta = ( GetBValue( pc.tmpbkcolour ) > GetBValue( pc.tmpforecolour )) ? -10 : 10; - int rValue = GetRValue( pc.tmpbkcolour ) + rDelta; - int gValue = GetRValue( pc.tmpbkcolour ) + gDelta; - int bValue = GetRValue( pc.tmpbkcolour ) + bDelta; - - BYTE brValue = ( rValue >255) ? 255 : rValue < 0 ? 0 : (BYTE)rValue; - BYTE bgValue = ( gValue >255) ? 255 : gValue < 0 ? 0 : (BYTE)gValue; - BYTE bbValue = ( bValue >255) ? 255 : bValue < 0 ? 0 : (BYTE)bValue; - - pc.hBrushAlternateGrey = CreateSolidBrush( GetNearestColor( pc.hdcMem, RGB( brValue, bgValue, bbValue )) ); - } - - // Set some draw states - SetBkMode( pc.hdcMem, TRANSPARENT ); - SetStretchBltMode( pc.hdcMem, HALFTONE ); - - POINT org; - GetBrushOrgEx( pc.hdcMem, &org ); - SetBrushOrgEx( pc.hdcMem, org.x, org.y, NULL ); -} + // Store pos + Drawing->pos_check = rc; + } + _PaintRowItems( hWnd, pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); + if ( mpRequest && !dat->force_in_dialog ) + { + if ( mpRequest->pl_Params[1].szValue ) + free( mpRequest->pl_Params[1].szValue ); + mpRequest->pl_Params[1].szValue = strdupn( "Ovl", 3 ); + mpRequest->pl_Params[1].dwValueHash = mod_CalcHash( "Ovl" ); + { + RECT mrc = row_rc; + if ( Drawing->type == CLCIT_GROUP && + Drawing->group->parent->groupId == 0 && + Drawing->group->parent->cl.items[0] != Drawing ) + { + mrc.top += dat->row_before_group_space; + } + SkinDrawGlyphMask( pc.hdcMem, &mrc, rcPaint, mpRequest ); + } + SkinSelector_DeleteMask( mpRequest ); + mir_free( mpRequest ); + } + } + } + y += dat->row_heights[line_num]; + //increment by subcontacts + if ( ( group->cl.items && group->scanIndex < group->cl.count && group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP ) + && ( group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta )) + { + if ( subindex < group->cl.items[group->scanIndex]->SubAllocated-1 ) + subindex++; + else + subindex = -1; + } -void CLCPaint::_DrawBackground( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT * rcPaint, RECT& clRect, _PaintContext& pc ) -{ - if ( paintMode&(DM_FLOAT|DM_CONTROL)) - { - HBRUSH hBrush = CreateSolidBrush( pc.tmpbkcolour ); - FillRect( pc.hdcMem, rcPaint, hBrush ); - DeleteObject( hBrush ); - ske_SetRectOpaque( pc.hdcMem, rcPaint ); - if ( !( paintMode&DM_GREYALTERNATE )) - SkinDrawGlyph( pc.hdcMem, &clRect, rcPaint, "CL,ID = Background,Type = Control" ); - } - else if ( paintMode&DM_CLASSIC) - { - if ( !_DrawNonEnginedBackground( hWnd, pc.hdcMem, rcPaint, clRect, dat )) - { - HBRUSH hBrush = CreateSolidBrush( pc.tmpbkcolour ); - FillRect( pc.hdcMem, rcPaint, hBrush ); - DeleteObject( hBrush ); - } - } - else - { - if ( paintMode&DM_NON_LAYERED ) - ske_BltBackImage( hWnd, (paintMode&DM_GRAY) ? pc.hdcMem2 : pc.hdcMem, rcPaint ); - - SkinDrawGlyph( pc.hdcMem, &clRect, rcPaint, "CL,ID = Background" ); - } -} -void CLCPaint::_DrawLines( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT* rcPaint, RECT& clRect, _PaintContext& pc ) -{ - struct ClcContact *Drawing; - struct ClcGroup *group = &dat->list; - group->scanIndex = 0; - int indent = 0; - int subident = 0; - int subindex = -1; - int line_num = -1; - int y = -dat->yScroll; - BOOL is_foreground = IsForegroundWindow( hWnd ); - LONG lStyle = GetWindowLongPtr( hWnd, GWL_STYLE ); - - while( y < rcPaint->bottom ) - { - if ( subindex == -1 ) - { - if ( group->scanIndex >= group->cl.count ) - { - group = group->parent; - indent--; - if ( group == NULL ) break; // Finished list - group->scanIndex++; - continue; - } - } - - line_num++; - - // Draw line, if needed - if ( y > rcPaint->top - dat->row_heights[line_num] ) - { - int selected; - int hottrack; - int left_pos; - int right_pos; - int free_row_height; - RECT row_rc; - RECT free_row_rc; - MODERNMASK * mpRequest = NULL; - RECT rc; - - // Get item to draw - if ( group->scanIndex < group->cl.count ) - { - if ( subindex == -1 ) - { - Drawing = group->cl.items[group->scanIndex]; - subident = 0; - } - else - { - Drawing = &( group->cl.items[group->scanIndex]->subcontacts[subindex] ); - subident = dat->subIndent; - } - } - else - Drawing = NULL; - if ( mpRequest ) - { - SkinSelector_DeleteMask( mpRequest ); - mir_free_and_nill( mpRequest ); - } - - // Something to draw? - if ( Drawing ) - { - - // Calc row height - - if ( !gl_RowRoot ) RowHeights_GetRowHeight( dat, hWnd, Drawing, line_num ); - else RowHeight_CalcRowHeight( dat, hWnd, Drawing, line_num ); - - // Init settings - selected = ( ( line_num == dat->selection ) && ( dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || is_foreground ) && Drawing->type != CLCIT_DIVIDER ); - hottrack = dat->exStyle&CLS_EX_TRACKSELECT && Drawing->type != CLCIT_DIVIDER && dat->iHotTrack == line_num; - left_pos = clRect.left + dat->leftMargin + indent * dat->groupIndent + subident; - right_pos = dat->rightMargin; // Border - - SetRect( &row_rc, clRect.left, y, clRect.right, y + dat->row_heights[line_num] ); - free_row_rc = row_rc; - free_row_rc.left += left_pos; - free_row_rc.right -= right_pos; - free_row_rc.top += dat->row_border; - free_row_rc.bottom -= dat->row_border; - free_row_height = free_row_rc.bottom - free_row_rc.top; - - { - HRGN rgn = CreateRectRgn( row_rc.left, row_rc.top, row_rc.right, row_rc.bottom ); - SelectClipRgn( pc.hdcMem, rgn ); - DeleteObject( rgn ); - } - - // Store pos - Drawing->pos_indent = free_row_rc.left; - ZeroMemory( &Drawing->pos_check, sizeof( Drawing->pos_check )); - ZeroMemory( &Drawing->pos_avatar, sizeof( Drawing->pos_avatar )); - ZeroMemory( &Drawing->pos_icon, sizeof( Drawing->pos_icon )); - ZeroMemory( &Drawing->pos_label, sizeof( Drawing->pos_label )); - ZeroMemory( &Drawing->pos_rename_rect, sizeof( Drawing->pos_rename_rect )); - ZeroMemory( &Drawing->pos_extra, sizeof( Drawing->pos_extra )); - - - //**** Draw Background - - // Alternating grey - if ( paintMode&DM_GREYALTERNATE && line_num&1 ) - { - if ( paintMode&DM_CONTROL || dat->bkChanged ) - { - FillRect( pc.hdcMem, &row_rc, pc.hBrushAlternateGrey ); - } - else - SkinDrawGlyph( pc.hdcMem, &row_rc, rcPaint, "CL,ID = GreyAlternate" ); - } - if ( ! (paintMode&(DM_CLASSIC|DM_CONTROL)) ) - { - // Row background - if ( !(paintMode&DM_CONTROL)) - { //Build mpRequest string - mpRequest = _GetCLCContactRowBackModernMask( group, Drawing, indent, line_num, selected, hottrack, dat ); - { - RECT mrc = row_rc; - if ( group->parent == 0 - && group->scanIndex != 0 - && group->scanIndex < group->cl.count - && group->cl.items[group->scanIndex]->type == CLCIT_GROUP ) - { - mrc.top += dat->row_before_group_space; - } - SkinDrawGlyphMask( pc.hdcMem, &mrc, rcPaint, mpRequest ); - } - } - if ( selected || hottrack ) - { - RECT mrc = row_rc; - if ( Drawing->type == CLCIT_GROUP && - Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing ) - { - mrc.top += dat->row_before_group_space; - } - // Selection background ( only if hole line - full/less ) - if ( dat->HiLightMode == 1 ) // Full or default - { - if ( selected ) - SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL , ID = Selection " ); - if ( hottrack ) - SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = HotTracking" ); - } - else if ( dat->HiLightMode == 2 ) // Less - { - if ( selected ) - SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = Selection" ); //instead of free_row_rc - if ( hottrack ) - SkinDrawGlyph( pc.hdcMem, &mrc, rcPaint, "CL,ID = HotTracking" ); - } - } - - } - else - { - int checkboxWidth; - if ( ( lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT ) || - ( lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP ) || - ( Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX )) - checkboxWidth = dat->checkboxSize+2; - else checkboxWidth = 0; - //background - if ( selected ) { - switch ( dat->HiLightMode ) - { - case 0: - case 1: - { - int i = y; - int row_height = row_rc.bottom-row_rc.top; - for ( i = y; i < y+row_height; i += max( dat->row_min_heigh, 1 )) - { - ImageList_DrawEx( dat->himlHighlight, 0, pc.hdcMem, 0, i, clRect.right, - min( y+row_height-i, max( dat->row_min_heigh, 1 )), CLR_NONE, CLR_NONE, - dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25 ); - } - SetTextColor( pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor( COLOR_HIGHLIGHTTEXT ) : dat->selTextColour ); - break; - } - - case 2: - { - int i; - int row_height = row_rc.bottom-row_rc.top-1; - for ( i = y+1; i < y+row_height; i += max( dat->row_min_heigh, 1 )) - { - ImageList_DrawEx( dat->himlHighlight, 0, pc.hdcMem, 1, i, clRect.right-2, - min( y+row_height-i, max( dat->row_min_heigh, 1 )), CLR_NONE, CLR_NONE, - dat->exStyle&CLS_EX_NOTRANSLUCENTSEL?ILD_NORMAL:ILD_BLEND25 ); - } - SetTextColor( pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor( COLOR_HIGHLIGHTTEXT ) : dat->selTextColour ); - break; - } - } - } - - } - //**** Checkboxes - if ( ( lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT ) || - ( lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP ) || - ( Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX )) - { - //RECT rc; - rc = free_row_rc; - rc.right = rc.left + dat->checkboxSize; - rc.top += ( rc.bottom - rc.top - dat->checkboxSize ) >> 1; - rc.bottom = rc.top + dat->checkboxSize; - - if ( dat->text_rtl != 0 ) _RTLRect( &rc, free_row_rc.right, 0 ); - - if ( xpt_IsThemed( dat->hCheckBoxTheme )) { - xpt_DrawThemeBackground( dat->hCheckBoxTheme, pc.hdcMem, BP_CHECKBOX, Drawing->flags&CONTACTF_CHECKED?( hottrack?CBS_CHECKEDHOT:CBS_CHECKEDNORMAL ):( hottrack?CBS_UNCHECKEDHOT:CBS_UNCHECKEDNORMAL ), &rc, &rc ); - } - else DrawFrameControl( pc.hdcMem, &rc, DFC_BUTTON, DFCS_BUTTONCHECK|DFCS_FLAT|( Drawing->flags&CONTACTF_CHECKED?DFCS_CHECKED:0 )|( hottrack?DFCS_HOT:0 )); - - left_pos += dat->checkboxSize + EXTRA_CHECKBOX_SPACE + HORIZONTAL_SPACE; - free_row_rc.left = row_rc.left + left_pos; - - // Store pos - Drawing->pos_check = rc; - } - _PaintRowItems( hWnd, pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); - if ( mpRequest && !dat->force_in_dialog ) - { - if ( mpRequest->pl_Params[1].szValue ) - free( mpRequest->pl_Params[1].szValue ); - mpRequest->pl_Params[1].szValue = strdupn( "Ovl", 3 ); - mpRequest->pl_Params[1].dwValueHash = mod_CalcHash( "Ovl" ); - { - RECT mrc = row_rc; - if ( Drawing->type == CLCIT_GROUP && - Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing ) - { - mrc.top += dat->row_before_group_space; - } - SkinDrawGlyphMask( pc.hdcMem, &mrc, rcPaint, mpRequest ); - } - SkinSelector_DeleteMask( mpRequest ); - mir_free_and_nill( mpRequest ); - mpRequest = NULL; - } - } - } - y += dat->row_heights[line_num]; - //increment by subcontacts - if ( ( group->cl.items && group->scanIndex < group->cl.count && group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP ) - && ( group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta )) - { - if ( subindex < group->cl.items[group->scanIndex]->SubAllocated-1 ) - subindex++; - else - subindex = -1; - } - - if ( subindex == -1 && group->scanIndex < group->cl.count ) - { - if ( group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded ) - { - group = group->cl.items[group->scanIndex]->group; - indent++; - group->scanIndex = 0; - subindex = -1; - continue; - } - group->scanIndex++; - } - else if ( group->scanIndex >= group->cl.count ) - { - subindex = -1; - } - } - SelectClipRgn( pc.hdcMem, NULL ); + if ( subindex == -1 && group->scanIndex < group->cl.count ) + { + if ( group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded ) + { + group = group->cl.items[group->scanIndex]->group; + indent++; + group->scanIndex = 0; + subindex = -1; + continue; + } + group->scanIndex++; + } + else if ( group->scanIndex >= group->cl.count ) + { + subindex = -1; + } + } + SelectClipRgn( pc.hdcMem, NULL ); } void CLCPaint::_DrawInsertionMark( struct ClcData * dat, RECT& clRect, _PaintContext& pc ) { - HBRUSH hBrush, hoBrush; - POINT pts[8]; - HRGN hRgn; - int identation = dat->nInsertionLevel*dat->groupIndent; - int yt = cliGetRowTopY( dat, dat->iInsertionMark ); - - pts[0].y = yt - dat->yScroll - 4; - if ( pts[0].y < -3 ) pts[0].y = -3; - pts[0].x = 1+identation*( dat->text_rtl?0:1 ); - - pts[1].x = pts[0].x+2; - pts[1].y = pts[0].y+3; - - pts[2].x = clRect.right-identation*( dat->text_rtl?1:0 )-4; - pts[2].y = pts[1].y; - - pts[3].x = clRect.right-1-identation*( dat->text_rtl?1:0 ); - pts[3].y = pts[0].y-1; - - pts[4].x = pts[3].x; pts[4].y = pts[0].y+7; - pts[5].x = pts[2].x+1; pts[5].y = pts[1].y+2; - pts[6].x = pts[1].x; pts[6].y = pts[5].y; - pts[7].x = pts[0].x; pts[7].y = pts[4].y; - hRgn = CreatePolygonRgn( pts, sizeof( pts )/sizeof( pts[0] ), ALTERNATE ); - hBrush = CreateSolidBrush( dat->fontModernInfo[FONTID_CONTACTS].colour ); - hoBrush = ( HBRUSH )SelectObject( pc.hdcMem, hBrush ); - FillRgn( pc.hdcMem, hRgn, hBrush ); - ske_SetRgnOpaque( pc.hdcMem, hRgn ); - SelectObject( pc.hdcMem, hoBrush ); - DeleteObject( hBrush ); + HBRUSH hBrush, hoBrush; + POINT pts[8]; + HRGN hRgn; + int identation = dat->nInsertionLevel*dat->groupIndent; + int yt = cliGetRowTopY( dat, dat->iInsertionMark ); + + pts[0].y = yt - dat->yScroll - 4; + if ( pts[0].y < -3 ) pts[0].y = -3; + pts[0].x = 1+identation*( dat->text_rtl?0:1 ); + + pts[1].x = pts[0].x+2; + pts[1].y = pts[0].y+3; + + pts[2].x = clRect.right-identation*( dat->text_rtl?1:0 )-4; + pts[2].y = pts[1].y; + + pts[3].x = clRect.right-1-identation*( dat->text_rtl?1:0 ); + pts[3].y = pts[0].y-1; + + pts[4].x = pts[3].x; pts[4].y = pts[0].y+7; + pts[5].x = pts[2].x+1; pts[5].y = pts[1].y+2; + pts[6].x = pts[1].x; pts[6].y = pts[5].y; + pts[7].x = pts[0].x; pts[7].y = pts[4].y; + hRgn = CreatePolygonRgn( pts, sizeof( pts )/sizeof( pts[0] ), ALTERNATE ); + hBrush = CreateSolidBrush( dat->fontModernInfo[FONTID_CONTACTS].colour ); + hoBrush = ( HBRUSH )SelectObject( pc.hdcMem, hBrush ); + FillRgn( pc.hdcMem, hRgn, hBrush ); + ske_SetRgnOpaque( pc.hdcMem, hRgn ); + SelectObject( pc.hdcMem, hoBrush ); + DeleteObject( hBrush ); } void CLCPaint::_CopyPaintToDest( HWND hWnd, struct ClcData * dat, HDC hdc, int paintMode, RECT* rcPaint, RECT& clRect, _PaintContext& pc ) { - if ( !( paintMode&DM_GRAY ) && ( paintMode & DM_DRAW_OFFSCREEN )) - { - BitBlt( hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem, rcPaint->left, rcPaint->top, SRCCOPY ); - } - - if ( ( paintMode&DM_GRAY ) && hdc && hdc != pc.hdcMem ) - { - BLENDFUNCTION bf = {AC_SRC_OVER, 0, 80, AC_SRC_ALPHA }; - BOOL a = ( ( paintMode&DM_GRAY ) && ( ( paintMode&DM_NON_LAYERED)) ); - ske_AlphaBlend( a ? pc.hdcMem2 : hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, bf ); - if ( a ) - BitBlt( hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem2, rcPaint->left, rcPaint->top, SRCCOPY ); - } + if ( !( paintMode&DM_GRAY ) && ( paintMode & DM_DRAW_OFFSCREEN )) + { + BitBlt( hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem, rcPaint->left, rcPaint->top, SRCCOPY ); + } + + if ( ( paintMode&DM_GRAY ) && hdc && hdc != pc.hdcMem ) + { + BLENDFUNCTION bf = {AC_SRC_OVER, 0, 80, AC_SRC_ALPHA }; + BOOL a = ( ( paintMode&DM_GRAY ) && ( ( paintMode&DM_NON_LAYERED)) ); + ske_AlphaBlend( a ? pc.hdcMem2 : hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, bf ); + if ( a ) + BitBlt( hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, pc.hdcMem2, rcPaint->left, rcPaint->top, SRCCOPY ); + } } void CLCPaint::_FreePaintContext( _PaintContext& pc ) { - if ( pc.hBrushAlternateGrey ) DeleteObject( pc.hBrushAlternateGrey ); - SelectObject( pc.hdcMem, (HFONT) GetStockObject( DEFAULT_GUI_FONT )); - if ( pc.fRelease&_PaintContext::release_hdcmem ) - { - SelectObject( pc.hdcMem, pc.oldbmp ); - DeleteObject( pc.hBmpOsb ); - DeleteDC( pc.hdcMem ); - } - if ( pc.fRelease&_PaintContext::release_hdcmem2) - { - SelectObject( pc.hdcMem2, pc.oldbmp2 ); - DeleteObject( pc.hBmpOsb2 ); - DeleteDC( pc.hdcMem2 ); - } + if ( pc.hBrushAlternateGrey ) DeleteObject( pc.hBrushAlternateGrey ); + SelectObject( pc.hdcMem, (HFONT) GetStockObject( DEFAULT_GUI_FONT )); + if ( pc.fRelease&_PaintContext::release_hdcmem ) + { + SelectObject( pc.hdcMem, pc.oldbmp ); + DeleteObject( pc.hBmpOsb ); + DeleteDC( pc.hdcMem ); + } + if ( pc.fRelease&_PaintContext::release_hdcmem2) + { + SelectObject( pc.hdcMem2, pc.oldbmp2 ); + DeleteObject( pc.hBmpOsb2 ); + DeleteDC( pc.hdcMem2 ); + } } void CLCPaint::_PaintClc( HWND hwnd, struct ClcData *dat, HDC hdc, RECT *_rcPaint ) { - g_CluiData.t_now = time( NULL ); + g_CluiData.t_now = time( NULL ); + + if ( _rcPaint && IsRectEmpty( _rcPaint )) return; // check if draw area is not empty + if ( !IsWindowVisible( hwnd )) return; // and window is visible + + RECT clRect; + GetClientRect( hwnd, &clRect ); - if ( _rcPaint && IsRectEmpty( _rcPaint )) return; // check if draw area is not empty - if ( !IsWindowVisible( hwnd )) return; // and window is visible + RECT * rcPaint = _rcPaint ? _rcPaint : &clRect; // if null is transmitted - use whole client area - RECT clRect; - GetClientRect( hwnd, &clRect ); + // Invalidate ani avatars, avatars have to be validated in row paint routine below + if ( rcPaint->top == 0 && rcPaint->bottom == clRect.bottom && dat->avatars_show ) + AniAva_InvalidateAvatarPositions( NULL ); - RECT * rcPaint = _rcPaint ? _rcPaint : &clRect; // if null is transmitted - use whole client area + // Now determine paint mode + int paintMode = _DetermineDrawMode( hwnd, dat ); - // Invalidate ani avatars, avatars have to be validated in row paint routine below - if ( rcPaint->top == 0 && rcPaint->bottom == clRect.bottom && dat->avatars_show ) - AniAva_InvalidateAvatarPositions( NULL ); + // Preparing drawing contexts + _PaintContext pc( hdc ); + _PreparePaintContext( hwnd, dat, hdc, paintMode, clRect, pc ); - // Now determine paint mode - int paintMode = _DetermineDrawMode( hwnd, dat ); + // Draw background + _DrawBackground( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); + // Draw lines + if ( dat->row_heights ) + _DrawLines( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); - // Preparing drawing contexts - _PaintContext pc( hdc ); - _PreparePaintContext( hwnd, dat, hdc, paintMode, clRect, pc ); - - // Draw background - _DrawBackground( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); - // Draw lines - if ( dat->row_heights ) - _DrawLines( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); + //insertion mark + if ( dat->iInsertionMark != -1 ) + _DrawInsertionMark( dat, clRect, pc ); - //insertion mark - if ( dat->iInsertionMark != -1 ) - _DrawInsertionMark( dat, clRect, pc ); - - // BitBlt from memory to destination - _CopyPaintToDest( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); + // BitBlt from memory to destination + _CopyPaintToDest( hwnd, dat, hdc, paintMode, rcPaint, clRect, pc ); - // Free - _FreePaintContext( pc ); + // Free + _FreePaintContext( pc ); - // all still non-validated animated avatars have to be removed - AniAva_RemoveInvalidatedAvatars(); + // all still non-validated animated avatars have to be removed + AniAva_RemoveInvalidatedAvatars(); } void CLCPaint::_StoreItemPos( struct ClcContact *contact, int ItemType, RECT * rc ) { - contact->ext_mpItemsDesc[contact->ext_nItemsNum].itemType = ItemType; - contact->ext_mpItemsDesc[contact->ext_nItemsNum].itemRect = *rc; - contact->ext_nItemsNum++; + contact->ext_mpItemsDesc[contact->ext_nItemsNum].itemType = ItemType; + contact->ext_mpItemsDesc[contact->ext_nItemsNum].itemRect = *rc; + contact->ext_nItemsNum++; switch ( ItemType ) { case CIT_AVATAR: @@ -2329,668 +2317,666 @@ void CLCPaint::_StoreItemPos( struct ClcContact *contact, int ItemType, RECT * r void CLCPaint::_CalcItemsPos( HWND hwnd, HDC hdcMem, struct ClcData *dat, struct ClcContact *Drawing, RECT *in_row_rc, RECT *in_free_row_rc, int left_pos, int right_pos, int selected, int hottrack ) { - int item_iterator, item, item_text, text_left_pos; - BOOL left = TRUE; //TODO remove - RECT free_row_rc = *in_free_row_rc; - RECT row_rc = *in_row_rc; - Drawing->ext_nItemsNum = 0; - text_left_pos = row_rc.right; - // Now let's check what we have to draw - for ( item_iterator = 0 ; item_iterator < NUM_ITEM_TYPE && free_row_rc.left < free_row_rc.right ; item_iterator++ ) - { - if ( Drawing->ext_nItemsNum >= SIZEOF( Drawing->ext_mpItemsDesc )) break; - if ( left ) - item = item_iterator; - else - item = NUM_ITEM_TYPE - ( item_iterator - item_text ); - - switch( dat->row_items[item] ) - { - case ITEM_AVATAR: /////////////////////////////////////////////////////////////////////////////////////////////////// - { - RECT rc; - int max_width; - int width; - int height; - BOOL miniMode; - if ( !dat->avatars_show || Drawing->type != CLCIT_CONTACT ) - break; - miniMode = CheckMiniMode( dat, selected, hottrack ); - AniAva_InvalidateAvatarPositions( Drawing->hContact ); - if ( dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space ) - max_width = max( dat->iconXSpace, dat->avatars_maxheight_size ); - else - max_width = dat->avatars_maxheight_size; - - // Has to draw? - if ( ( dat->use_avatar_service && Drawing->avatar_data == NULL ) - || ( !dat->use_avatar_service && Drawing->avatar_pos == AVATAR_POS_DONT_HAVE ) - || miniMode ) - { - // Don't have to draw avatar - - // Has to draw icon instead? - if ( dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && Drawing->iImage != -1 ) - { - RECT rc; - - // Make rectangle - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, dat->iconXSpace, max_width, ICON_HEIGHT, HORIZONTAL_SPACE ); - - if ( rc.left < rc.right ) - { - /* center icon in avatar place */ - if ( rc.right-rc.left>16 ) rc.left += ( ( ( rc.right-rc.left )-16 )>>1 ); - if ( rc.bottom-rc.top>16 ) rc.top += ( ( ( rc.bottom-rc.top )-16 )>>1 ); - - // Store position - _StoreItemPos( Drawing, CIT_ICON, &rc ); - } - } - else - { - // Has to keep the empty space?? - if ( ( left && !dat->row_align_left_items_to_left ) || ( !left && !dat->row_align_right_items_to_right )) - { - // Make rectangle - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, max_width, max_width, dat->avatars_maxheight_size, HORIZONTAL_SPACE ); - - // Store position - //StoreItemPos( Drawing, CIT_AVATAR, &rc ); - //Drawing->pos_avatar = rc; - } - } - break; - } - - // Has to draw avatar - if ( dat->avatar_cache.nodes && Drawing->avatar_pos > AVATAR_POS_DONT_HAVE ) { - width = dat->avatar_cache.nodes[Drawing->avatar_pos].width; - height = dat->avatar_cache.nodes[Drawing->avatar_pos].height; - }else if ( Drawing->avatar_pos == AVATAR_POS_ANIMATED ) { - width = Drawing->avatar_size.cx; - height = Drawing->avatar_size.cy; - }else { - width = 0; - height = 0; - } - - // Make rectangle - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, width, max_width, height, HORIZONTAL_SPACE ); - - rc.top = max( free_row_rc.top, rc.top ); - rc.bottom = min( free_row_rc.bottom, rc.bottom ); - - if ( rc.left < rc.right ) { - // Store position - _StoreItemPos( Drawing, CIT_AVATAR, &rc ); - } - //TO DO: CALC avatar overlays - break; - } - case ITEM_ICON: ///////////////////////////////////////////////////////////////////////////////////////////////////// - { - RECT rc; - int iImage = -1; - BOOL has_avatar = ( ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || - ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE )) - && !( CheckMiniMode( dat, selected, hottrack )); - - if ( Drawing->type == CLCIT_CONTACT - && dat->icon_hide_on_avatar - && !dat->icon_draw_on_avatar_space - && has_avatar - && !Drawing->image_is_special ) - { - // Don't have to draw, but has to keep the empty space? - if ( ( left && !dat->row_align_left_items_to_left ) || ( !left && !dat->row_align_right_items_to_right )) - { - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, dat->iconXSpace, dat->iconXSpace, ICON_HEIGHT, HORIZONTAL_SPACE ); - - if ( rc.left < rc.right ) { - // Store position - _StoreItemPos( Drawing, CIT_ICON, &rc ); - } - } - break; - } - if ( Drawing->type == CLCIT_CONTACT - && dat->icon_hide_on_avatar - && dat->icon_draw_on_avatar_space - && ( !Drawing->image_is_special || !has_avatar || - ( - dat->avatars_draw_overlay - && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) - && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons ) - && dat->avatars_overlay_type == SETTING_AVATAR_OVERLAY_TYPE_CONTACT - )) ) - { - // Don't have to draw and don't have to keep the empty space - break; - } - - // Get image - iImage = -1; - if ( Drawing->type == CLCIT_GROUP && !dat->row_hide_group_icon ) - iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; - else if ( Drawing->type == CLCIT_CONTACT ) - iImage = Drawing->iImage; - - // Has image to draw? - if ( iImage != -1 ) - { - // Make rectangle - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, dat->iconXSpace, dat->iconXSpace, ICON_HEIGHT, HORIZONTAL_SPACE ); - - if ( rc.left < rc.right ) - { - // Store position - _StoreItemPos( Drawing, CIT_ICON, &rc ); - } - } - break; - } - case ITEM_CONTACT_TIME: ///////////////////////////////////////////////////////////////////////////////////////////////////// - { - PDNCE pdnce = ( PDNCE )( ( Drawing->type == CLCIT_CONTACT )?pcli->pfnGetCacheEntry( Drawing->hContact ):NULL ); - if ( Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone ) - { - TCHAR szResult[80]; + int item_iterator, item, item_text, text_left_pos; + BOOL left = TRUE; //TODO remove + RECT free_row_rc = *in_free_row_rc; + RECT row_rc = *in_row_rc; + Drawing->ext_nItemsNum = 0; + text_left_pos = row_rc.right; + // Now let's check what we have to draw + for ( item_iterator = 0 ; item_iterator < NUM_ITEM_TYPE && free_row_rc.left < free_row_rc.right ; item_iterator++ ) + { + if ( Drawing->ext_nItemsNum >= SIZEOF( Drawing->ext_mpItemsDesc )) break; + if ( left ) + item = item_iterator; + else + item = NUM_ITEM_TYPE - ( item_iterator - item_text ); + + switch( dat->row_items[item] ) + { + case ITEM_AVATAR: /////////////////////////////////////////////////////////////////////////////////////////////////// + { + RECT rc; + int max_width; + int width; + int height; + BOOL miniMode; + if ( !dat->avatars_show || Drawing->type != CLCIT_CONTACT ) + break; + miniMode = CheckMiniMode( dat, selected, hottrack ); + AniAva_InvalidateAvatarPositions( Drawing->hContact ); + if ( dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space ) + max_width = max( dat->iconXSpace, dat->avatars_maxheight_size ); + else + max_width = dat->avatars_maxheight_size; + + // Has to draw? + if ( ( dat->use_avatar_service && Drawing->avatar_data == NULL ) + || ( !dat->use_avatar_service && Drawing->avatar_pos == AVATAR_POS_DONT_HAVE ) + || miniMode ) + { + // Don't have to draw avatar + + // Has to draw icon instead? + if ( dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && Drawing->iImage != -1 ) + { + RECT rc; + + // Make rectangle + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, dat->iconXSpace, max_width, ICON_HEIGHT, HORIZONTAL_SPACE ); + + if ( rc.left < rc.right ) + { + /* center icon in avatar place */ + if ( rc.right-rc.left>16 ) rc.left += ( ( ( rc.right-rc.left )-16 )>>1 ); + if ( rc.bottom-rc.top>16 ) rc.top += ( ( ( rc.bottom-rc.top )-16 )>>1 ); + + // Store position + _StoreItemPos( Drawing, CIT_ICON, &rc ); + } + } + else + { + // Has to keep the empty space?? + if ( ( left && !dat->row_align_left_items_to_left ) || ( !left && !dat->row_align_right_items_to_right )) + { + // Make rectangle + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, max_width, max_width, dat->avatars_maxheight_size, HORIZONTAL_SPACE ); + + // Store position + //StoreItemPos( Drawing, CIT_AVATAR, &rc ); + //Drawing->pos_avatar = rc; + } + } + break; + } + + // Has to draw avatar + if ( dat->avatar_cache.nodes && Drawing->avatar_pos > AVATAR_POS_DONT_HAVE ) { + width = dat->avatar_cache.nodes[Drawing->avatar_pos].width; + height = dat->avatar_cache.nodes[Drawing->avatar_pos].height; + }else if ( Drawing->avatar_pos == AVATAR_POS_ANIMATED ) { + width = Drawing->avatar_size.cx; + height = Drawing->avatar_size.cy; + }else { + width = 0; + height = 0; + } + + // Make rectangle + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, width, max_width, height, HORIZONTAL_SPACE ); + + rc.top = max( free_row_rc.top, rc.top ); + rc.bottom = min( free_row_rc.bottom, rc.bottom ); + + if ( rc.left < rc.right ) { + // Store position + _StoreItemPos( Drawing, CIT_AVATAR, &rc ); + } + //TO DO: CALC avatar overlays + break; + } + case ITEM_ICON: ///////////////////////////////////////////////////////////////////////////////////////////////////// + { + RECT rc; + int iImage = -1; + BOOL has_avatar = ( ( dat->use_avatar_service && Drawing->avatar_data != NULL ) || + ( !dat->use_avatar_service && Drawing->avatar_pos != AVATAR_POS_DONT_HAVE )) + && !( CheckMiniMode( dat, selected, hottrack )); + + if ( Drawing->type == CLCIT_CONTACT + && dat->icon_hide_on_avatar + && !dat->icon_draw_on_avatar_space + && has_avatar + && !Drawing->image_is_special ) + { + // Don't have to draw, but has to keep the empty space? + if ( ( left && !dat->row_align_left_items_to_left ) || ( !left && !dat->row_align_right_items_to_right )) + { + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, dat->iconXSpace, dat->iconXSpace, ICON_HEIGHT, HORIZONTAL_SPACE ); + + if ( rc.left < rc.right ) { + // Store position + _StoreItemPos( Drawing, CIT_ICON, &rc ); + } + } + break; + } + if ( Drawing->type == CLCIT_CONTACT + && dat->icon_hide_on_avatar + && dat->icon_draw_on_avatar_space + && ( !Drawing->image_is_special || !has_avatar || + ( + dat->avatars_draw_overlay + && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) + && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons ) + && dat->avatars_overlay_type == SETTING_AVATAR_OVERLAY_TYPE_CONTACT + )) ) + { + // Don't have to draw and don't have to keep the empty space + break; + } + + // Get image + iImage = -1; + if ( Drawing->type == CLCIT_GROUP && !dat->row_hide_group_icon ) + iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT; + else if ( Drawing->type == CLCIT_CONTACT ) + iImage = Drawing->iImage; + + // Has image to draw? + if ( iImage != -1 ) + { + // Make rectangle + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, dat->iconXSpace, dat->iconXSpace, ICON_HEIGHT, HORIZONTAL_SPACE ); + + if ( rc.left < rc.right ) + { + // Store position + _StoreItemPos( Drawing, CIT_ICON, &rc ); + } + } + break; + } + case ITEM_CONTACT_TIME: ///////////////////////////////////////////////////////////////////////////////////////////////////// + { + PDNCE pdnce = ( 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 (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) - { - SIZE text_size; - RECT rc; - - // Select font - ChangeToFont( hdcMem, dat, FONTID_CONTACT_TIME, NULL ); - - // Get text size - text_size.cy = ske_DrawText( hdcMem, szResult, lstrlen( 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 ); - } - } - } - break; - } - case ITEM_TEXT: ///////////////////////////////////////////////////////////////////////////////////////////////////// - { - // Store init text position: - text_left_pos = left_pos; - - left_pos += MIN_TEXT_WIDTH; - free_row_rc.left = row_rc.left + left_pos; - - item_text = item; - left = FALSE; - break; - } - case ITEM_EXTRA_ICONS: ////////////////////////////////////////////////////////////////////////////////////////////// - { - // Draw extra icons - if ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 ) - { - int iImage; - int count = 0; - RECT rc; - - for ( iImage = dat->extraColumnsCount-1 ; iImage >= 0 ; iImage -- ) - { - if ( Drawing->iExtraImage[iImage] != 0xFF || Drawing->iWideExtraImage[iImage] != 0xFFFF || !dat->MetaIgnoreEmptyExtra ) - { - rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, dat->extraColumnSpacing, dat->extraColumnSpacing, ICON_HEIGHT, 0 ); - if ( rc.left < rc.right ) - { - // Store position - _StoreItemPos( Drawing, CIT_EXTRA|( iImage&0x3F ), &rc ); - //Drawing->pos_extra[iImage] = rc; - count++; - } - } - } - // Add extra space - if ( count ) - { - _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, - left, HORIZONTAL_SPACE, HORIZONTAL_SPACE, ICON_HEIGHT, 0 ); - } - } - break; - } - } - } - if ( text_left_pos < free_row_rc.right ) - { - // Draw text - RECT text_rc; - RECT selection_text_rc; - SIZE text_size = {0}; - SIZE second_line_text_size = {0}; - SIZE third_line_text_size = {0}; - SIZE space_size = {0}; - SIZE counts_size = {0}; - char *szCounts = NULL;//mir_tstrdup( TEXT( "" )); - int free_width; - int free_height; - int max_bottom_selection_border = SELECTION_BORDER; - UINT uTextFormat = DT_NOPREFIX| /*DT_VCENTER |*/ DT_SINGLELINE | ( dat->text_rtl ? DT_RTLREADING : 0 ) | ( dat->text_align_right ? DT_RIGHT : 0 ); - - free_row_rc.left = text_left_pos; - free_width = free_row_rc.right - free_row_rc.left; - free_height = free_row_rc.bottom - free_row_rc.top; - - // Select font - ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); - - // Get text size - GetTextSize( &text_size, hdcMem, free_row_rc, Drawing->szText, Drawing->ssText.plText, uTextFormat, - dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); - - // Get rect - text_rc = free_row_rc; - - free_height -= text_size.cy; - text_rc.top += free_height >> 1; - text_rc.bottom = text_rc.top + text_size.cy; - - if ( dat->text_align_right ) - text_rc.left = max( free_row_rc.left, free_row_rc.right - text_size.cx ); - else - text_rc.right = min( free_row_rc.right, free_row_rc.left + text_size.cx ); - - selection_text_rc = text_rc; - - // If group, can have the size of count - if ( Drawing->type == CLCIT_GROUP ) - { - int full_text_width = text_size.cx; - // Group conts? - szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); - - // Has to draw the count? - if ( szCounts && szCounts[0] ) - { - RECT space_rc = free_row_rc; - RECT counts_rc = free_row_rc; - int text_width; - - free_height = free_row_rc.bottom - free_row_rc.top; - - // Get widths - ske_DrawText( hdcMem, _T( " " ), 1, &space_rc, DT_CALCRECT | DT_NOPREFIX ); - space_size.cx = space_rc.right - space_rc.left; - space_size.cy = min( space_rc.bottom - space_rc.top, free_height ); - - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); - DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, DT_CALCRECT ); - - //Store position - //StoreItemPos( Drawing, CIT_SUBTEXT1, &counts_rc ); // Or not to comment? - - counts_size.cx = counts_rc.right - counts_rc.left; - counts_size.cy = min( counts_rc.bottom - counts_rc.top, free_height ); - - text_width = free_row_rc.right - free_row_rc.left - space_size.cx - counts_size.cx; - - if ( text_width > 4 ) - { - text_size.cx = min( text_width, text_size.cx ); - text_width = text_size.cx + space_size.cx + counts_size.cx; - } - else - { - text_width = text_size.cx; - space_size.cx = 0; - space_size.cy = 0; - counts_size.cx = 0; - counts_size.cy = 0; - } - - // Get rect - free_height -= max( text_size.cy, counts_size.cy ); - text_rc.top = free_row_rc.top + ( free_height >> 1 ); - text_rc.bottom = text_rc.top + max( text_size.cy, counts_size.cy ); - - if ( dat->text_align_right ) - text_rc.left = free_row_rc.right - text_width; - else - text_rc.right = free_row_rc.left + text_width; - - selection_text_rc = text_rc; - full_text_width = text_width; - ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); - } - - if ( dat->row_align_group_mode == 1 ) //center - { - int x; - x = free_row_rc.left+( ( free_row_rc.right-free_row_rc.left-full_text_width )>>1 ); - //int l = dat->leftMargin; - //int r = dat->rightMargin; - //x = l+row_rc.left+( ( row_rc.right-row_rc.left-full_text_width-l-r )>>1 ); - text_rc.left = x; - text_rc.right = x+full_text_width; - } - else if ( dat->row_align_group_mode == 2 ) //right - { - text_rc.left = free_row_rc.right-full_text_width; - text_rc.right = free_row_rc.right; - } - else //left - { - text_rc.left = free_row_rc.left; - text_rc.right = free_row_rc.left+full_text_width; - } - - } - else if ( Drawing->type == CLCIT_CONTACT && !CheckMiniMode( dat, selected, hottrack )) - { - int tmp; - PDNCE pdnce = ( PDNCE )( ( Drawing->type == CLCIT_CONTACT )?pcli->pfnGetCacheEntry( Drawing->hContact ):NULL ); - if ( dat->second_line_show && dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) - { - // Get contact time - TCHAR buf[70] = _T(""); - mir_free_and_nill( pdnce->szThirdLineText ); + { + SIZE text_size; + RECT rc; + + // Select font + ChangeToFont( hdcMem, dat, FONTID_CONTACT_TIME, NULL ); + + // Get text size + text_size.cy = ske_DrawText( hdcMem, szResult, lstrlen( 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 ); + } + } + } + break; + } + case ITEM_TEXT: ///////////////////////////////////////////////////////////////////////////////////////////////////// + { + // Store init text position: + text_left_pos = left_pos; - tmi.printDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); - pdnce->szSecondLineText = mir_tstrdup( buf ); - } + left_pos += MIN_TEXT_WIDTH; + free_row_rc.left = row_rc.left + left_pos; + + item_text = item; + left = FALSE; + break; + } + case ITEM_EXTRA_ICONS: ////////////////////////////////////////////////////////////////////////////////////////////// + { + // Draw extra icons + if ( !Drawing->isSubcontact || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0 ) + { + int iImage; + int count = 0; + RECT rc; + + for ( iImage = dat->extraColumnsCount-1 ; iImage >= 0 ; iImage -- ) + { + if ( Drawing->iExtraImage[iImage] != 0xFF || Drawing->iWideExtraImage[iImage] != 0xFFFF || !dat->MetaIgnoreEmptyExtra ) + { + rc = _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, dat->extraColumnSpacing, dat->extraColumnSpacing, ICON_HEIGHT, 0 ); + if ( rc.left < rc.right ) + { + // Store position + _StoreItemPos( Drawing, CIT_EXTRA|( iImage&0x3F ), &rc ); + //Drawing->pos_extra[iImage] = rc; + count++; + } + } + } + // Add extra space + if ( count ) + { + _GetRectangle( dat, &row_rc, &free_row_rc, &left_pos, &right_pos, + left, HORIZONTAL_SPACE, HORIZONTAL_SPACE, ICON_HEIGHT, 0 ); + } + } + break; + } + } + } + if ( text_left_pos < free_row_rc.right ) + { + // Draw text + RECT text_rc; + RECT selection_text_rc; + SIZE text_size = {0}; + SIZE second_line_text_size = {0}; + SIZE third_line_text_size = {0}; + SIZE space_size = {0}; + SIZE counts_size = {0}; + char *szCounts = NULL;//mir_tstrdup( _T( "" )); + int free_width; + int free_height; + int max_bottom_selection_border = SELECTION_BORDER; + UINT uTextFormat = DT_NOPREFIX| /*DT_VCENTER |*/ DT_SINGLELINE | ( dat->text_rtl ? DT_RTLREADING : 0 ) | ( dat->text_align_right ? DT_RIGHT : 0 ); + + free_row_rc.left = text_left_pos; + free_width = free_row_rc.right - free_row_rc.left; + free_height = free_row_rc.bottom - free_row_rc.top; + + // Select font + ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); + + // Get text size + GetTextSize( &text_size, hdcMem, free_row_rc, Drawing->szText, Drawing->ssText.plText, uTextFormat, + dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight ); + + // Get rect + text_rc = free_row_rc; + + free_height -= text_size.cy; + text_rc.top += free_height >> 1; + text_rc.bottom = text_rc.top + text_size.cy; + + if ( dat->text_align_right ) + text_rc.left = max( free_row_rc.left, free_row_rc.right - text_size.cx ); + else + text_rc.right = min( free_row_rc.right, free_row_rc.left + text_size.cx ); + + selection_text_rc = text_rc; + + // If group, can have the size of count + if ( Drawing->type == CLCIT_GROUP ) + { + int full_text_width = text_size.cx; + // Group conts? + szCounts = pcli->pfnGetGroupCountsText( dat, Drawing ); + + // Has to draw the count? + if ( szCounts && szCounts[0] ) + { + RECT space_rc = free_row_rc; + RECT counts_rc = free_row_rc; + int text_width; + + free_height = free_row_rc.bottom - free_row_rc.top; - if ( dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0] - && free_height > dat->second_line_top_space ) - { - //RECT rc_tmp = free_row_rc; + // Get widths + ske_DrawText( hdcMem, _T( " " ), 1, &space_rc, DT_CALCRECT | DT_NOPREFIX ); + space_size.cx = space_rc.right - space_rc.left; + space_size.cy = min( space_rc.bottom - space_rc.top, free_height ); - ChangeToFont( hdcMem, dat, FONTID_SECONDLINE, NULL ); + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPCOUNTS:FONTID_CLOSEDGROUPCOUNTS, NULL ); + DrawTextA( hdcMem, szCounts, lstrlenA( szCounts ), &counts_rc, DT_CALCRECT ); - // Get sizes - GetTextSize( &second_line_text_size, hdcMem, free_row_rc, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, - uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight ); + //Store position + //StoreItemPos( Drawing, CIT_SUBTEXT1, &counts_rc ); // Or not to comment? - // Get rect - tmp = min( free_height, dat->second_line_top_space + second_line_text_size.cy ); + counts_size.cx = counts_rc.right - counts_rc.left; + counts_size.cy = min( counts_rc.bottom - counts_rc.top, free_height ); - free_height -= tmp; - text_rc.top = free_row_rc.top + ( free_height >> 1 ); - text_rc.bottom = text_rc.top + free_row_rc.bottom - free_row_rc.top - free_height; + text_width = free_row_rc.right - free_row_rc.left - space_size.cx - counts_size.cx; - if ( dat->text_align_right ) - text_rc.left = max( free_row_rc.left, min( text_rc.left, free_row_rc.right - second_line_text_size.cx )); - else - text_rc.right = min( free_row_rc.right, max( text_rc.right, free_row_rc.left + second_line_text_size.cx )); + if ( text_width > 4 ) + { + text_size.cx = min( text_width, text_size.cx ); + text_width = text_size.cx + space_size.cx + counts_size.cx; + } + else + { + text_width = text_size.cx; + space_size.cx = 0; + space_size.cy = 0; + counts_size.cx = 0; + counts_size.cy = 0; + } + + // Get rect + free_height -= max( text_size.cy, counts_size.cy ); + text_rc.top = free_row_rc.top + ( free_height >> 1 ); + text_rc.bottom = text_rc.top + max( text_size.cy, counts_size.cy ); + + if ( dat->text_align_right ) + text_rc.left = free_row_rc.right - text_width; + else + text_rc.right = free_row_rc.left + text_width; + + selection_text_rc = text_rc; + full_text_width = text_width; + ChangeToFont( hdcMem, dat, Drawing->group->expanded?FONTID_OPENGROUPS:FONTID_CLOSEDGROUPS, NULL ); + } + + if ( dat->row_align_group_mode == 1 ) //center + { + int x; + x = free_row_rc.left+( ( free_row_rc.right-free_row_rc.left-full_text_width )>>1 ); + //int l = dat->leftMargin; + //int r = dat->rightMargin; + //x = l+row_rc.left+( ( row_rc.right-row_rc.left-full_text_width-l-r )>>1 ); + text_rc.left = x; + text_rc.right = x+full_text_width; + } + else if ( dat->row_align_group_mode == 2 ) //right + { + text_rc.left = free_row_rc.right-full_text_width; + text_rc.right = free_row_rc.right; + } + else //left + { + text_rc.left = free_row_rc.left; + text_rc.right = free_row_rc.left+full_text_width; + } + + } + else if ( Drawing->type == CLCIT_CONTACT && !CheckMiniMode( dat, selected, hottrack )) + { + int tmp; + PDNCE pdnce = ( PDNCE )( ( Drawing->type == CLCIT_CONTACT )?pcli->pfnGetCacheEntry( Drawing->hContact ):NULL ); + if ( dat->second_line_show && dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) + { + // Get contact time + TCHAR buf[70] = _T(""); + tmi.printDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); + mir_free( pdnce->szThirdLineText ); + pdnce->szSecondLineText = mir_tstrdup( buf ); + } + + if ( dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0] + && free_height > dat->second_line_top_space ) + { + //RECT rc_tmp = free_row_rc; + + ChangeToFont( hdcMem, dat, FONTID_SECONDLINE, NULL ); + + // Get sizes + GetTextSize( &second_line_text_size, hdcMem, free_row_rc, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, + uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight ); + + // Get rect + tmp = min( free_height, dat->second_line_top_space + second_line_text_size.cy ); - selection_text_rc.top = text_rc.top; - selection_text_rc.bottom = min( selection_text_rc.bottom, selection_text_rc.top + text_size.cy ); + free_height -= tmp; + text_rc.top = free_row_rc.top + ( free_height >> 1 ); + text_rc.bottom = text_rc.top + free_row_rc.bottom - free_row_rc.top - free_height; - max_bottom_selection_border = min( max_bottom_selection_border, dat->second_line_top_space / 2 ); - } - if ( dat->third_line_show && dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) - { - // Get contact time - TCHAR buf[70] = _T(""); - mir_free_and_nill( pdnce->szThirdLineText ); + if ( dat->text_align_right ) + text_rc.left = max( free_row_rc.left, min( text_rc.left, free_row_rc.right - second_line_text_size.cx )); + else + text_rc.right = min( free_row_rc.right, max( text_rc.right, free_row_rc.left + second_line_text_size.cx )); + + selection_text_rc.top = text_rc.top; + selection_text_rc.bottom = min( selection_text_rc.bottom, selection_text_rc.top + text_size.cy ); + max_bottom_selection_border = min( max_bottom_selection_border, dat->second_line_top_space / 2 ); + } + if ( dat->third_line_show && dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone ) + { + // Get contact time + TCHAR buf[70] = _T(""); tmi.printDateTime(pdnce->hTimeZone, _T("t"), buf, SIZEOF(buf), 0); - pdnce->szThirdLineText = mir_tstrdup( buf ); - } - if ( dat->third_line_show && pdnce->szThirdLineText != NULL && pdnce->szThirdLineText[0] - && free_height > dat->third_line_top_space ) - { - //RECT rc_tmp = free_row_rc; - - ChangeToFont( hdcMem, dat, FONTID_THIRDLINE, NULL ); - - // Get sizes - GetTextSize( &third_line_text_size, hdcMem, free_row_rc, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, - uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight ); - - // Get rect - tmp = min( free_height, dat->third_line_top_space + third_line_text_size.cy ); - - free_height -= tmp; - text_rc.top = free_row_rc.top + ( free_height >> 1 ); - text_rc.bottom = text_rc.top + free_row_rc.bottom - free_row_rc.top - free_height; - - if ( dat->text_align_right ) - text_rc.left = max( free_row_rc.left, min( text_rc.left, free_row_rc.right - third_line_text_size.cx )); - else - text_rc.right = min( free_row_rc.right, max( text_rc.right, free_row_rc.left + third_line_text_size.cx )); - - selection_text_rc.top = text_rc.top; - selection_text_rc.bottom = min( selection_text_rc.bottom, selection_text_rc.top + text_size.cy ); - - max_bottom_selection_border = min( max_bottom_selection_border, dat->third_line_top_space / 2 ); - } - - ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); - } - - - selection_text_rc.left = text_rc.left; - selection_text_rc.right = text_rc.right; - - Drawing->pos_label = text_rc; - - selection_text_rc.top = max( selection_text_rc.top - SELECTION_BORDER, row_rc.top ); - selection_text_rc.bottom = min( selection_text_rc.bottom + max_bottom_selection_border, row_rc.bottom ); - - if ( dat->text_align_right ) - selection_text_rc.left = max( selection_text_rc.left - SELECTION_BORDER, free_row_rc.left ); - else - selection_text_rc.right = min( selection_text_rc.right + SELECTION_BORDER, free_row_rc.right ); - _StoreItemPos( Drawing, CIT_SELECTION, &selection_text_rc ); - - Drawing->pos_rename_rect = free_row_rc; - - { - // Draw text - uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 ); - - switch ( Drawing->type ) - { - case CLCIT_DIVIDER: - { - //devider - RECT trc = free_row_rc; - RECT rc = free_row_rc; - rc.top += ( rc.bottom - rc.top ) >> 1; - rc.bottom = rc.top + 2; - rc.right = rc.left + ( ( rc.right - rc.left - text_size.cx )>>1 ) - 3; - trc.left = rc.right + 3; - trc.right = trc.left + text_size.cx + 6; - if ( text_size.cy < trc.bottom - trc.top ) - { - trc.top += ( trc.bottom - trc.top - text_size.cy ) >> 1; - trc.bottom = trc.top + text_size.cy; - } - _StoreItemPos( Drawing, CIT_TEXT, &trc ); - rc.left = rc.right + 6 + text_size.cx; - rc.right = free_row_rc.right; - break; - } - case CLCIT_GROUP: - { - RECT rc = text_rc; - - // Get text rectangle - if ( dat->text_align_right ) - rc.left = rc.right - text_size.cx; - else - rc.right = rc.left + text_size.cx; - - - if ( text_size.cy < rc.bottom - rc.top ) - { - rc.top += ( rc.bottom - rc.top - text_size.cy ) >> 1; - rc.bottom = rc.top + text_size.cy; - } - - // Draw text - _StoreItemPos( Drawing, CIT_TEXT, &rc ); - - // Has to draw the count? - if ( counts_size.cx > 0 ) - { - RECT counts_rc = text_rc; - //counts_size.cx; - if ( dat->text_align_right ) - counts_rc.right = text_rc.left + counts_size.cx; - else - counts_rc.left = text_rc.right - counts_size.cx; - - if ( counts_size.cy < counts_rc.bottom - counts_rc.top ) - { - counts_rc.top += ( counts_rc.bottom - counts_rc.top - counts_size.cy + 1 ) >> 1; - counts_rc.bottom = counts_rc.top + counts_size.cy; - } - // Draw counts - _StoreItemPos( Drawing, CIT_SUBTEXT1, &counts_rc ); - } - break; - } - case CLCIT_CONTACT: - { - - RECT free_rc = text_rc; - PDNCE pdnce = ( PDNCE )pcli->pfnGetCacheEntry( Drawing->hContact ); - if ( text_size.cx > 0 && free_rc.bottom > free_rc.top ) - { - RECT rc = free_rc; - rc.bottom = min( rc.bottom, rc.top + text_size.cy ); - - if ( text_size.cx < rc.right - rc.left ) - { - if ( dat->text_align_right ) - rc.left = rc.right - text_size.cx; - else - rc.right = rc.left + text_size.cx; - } - uTextFormat |= DT_VCENTER; - _StoreItemPos( Drawing, CIT_TEXT, &rc ); - free_rc.top = rc.bottom; - } - uTextFormat &= ~DT_VCENTER; - if ( second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top ) - { - free_rc.top += dat->second_line_top_space; - - if ( free_rc.bottom > free_rc.top ) - { - RECT rc = free_rc; - rc.bottom = min( rc.bottom, rc.top + second_line_text_size.cy ); - - if ( second_line_text_size.cx < rc.right - rc.left ) - { - if ( dat->text_align_right ) - rc.left = rc.right - second_line_text_size.cx; - else - rc.right = rc.left + second_line_text_size.cx; - } - _StoreItemPos( Drawing, CIT_SUBTEXT1, &rc ); - free_rc.top = rc.bottom; - } - } - - if ( third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top ) - { - free_rc.top += dat->third_line_top_space; - - if ( free_rc.bottom > free_rc.top ) - { - RECT rc = free_rc; - rc.bottom = min( rc.bottom, rc.top + third_line_text_size.cy ); - - if ( third_line_text_size.cx < rc.right - rc.left ) - { - if ( dat->text_align_right ) - rc.left = rc.right - third_line_text_size.cx; - else - rc.right = rc.left + third_line_text_size.cx; - } - _StoreItemPos( Drawing, CIT_SUBTEXT2, &rc ); - free_rc.top = rc.bottom; - } - } - break; - } - default: // CLCIT_INFO - { - _StoreItemPos( Drawing, CIT_TEXT, &text_rc ); - } - } - } - } - - *in_free_row_rc = free_row_rc; - *in_row_rc = row_rc; - Drawing->ext_fItemsValid = FALSE; /*TO DO: correctly implement placement recalculation*/ + mir_free( pdnce->szThirdLineText ); + pdnce->szThirdLineText = mir_tstrdup( buf ); + } + if ( dat->third_line_show && pdnce->szThirdLineText != NULL && pdnce->szThirdLineText[0] + && free_height > dat->third_line_top_space ) + { + //RECT rc_tmp = free_row_rc; + + ChangeToFont( hdcMem, dat, FONTID_THIRDLINE, NULL ); + + // Get sizes + GetTextSize( &third_line_text_size, hdcMem, free_row_rc, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, + uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight ); + + // Get rect + tmp = min( free_height, dat->third_line_top_space + third_line_text_size.cy ); + + free_height -= tmp; + text_rc.top = free_row_rc.top + ( free_height >> 1 ); + text_rc.bottom = text_rc.top + free_row_rc.bottom - free_row_rc.top - free_height; + + if ( dat->text_align_right ) + text_rc.left = max( free_row_rc.left, min( text_rc.left, free_row_rc.right - third_line_text_size.cx )); + else + text_rc.right = min( free_row_rc.right, max( text_rc.right, free_row_rc.left + third_line_text_size.cx )); + + selection_text_rc.top = text_rc.top; + selection_text_rc.bottom = min( selection_text_rc.bottom, selection_text_rc.top + text_size.cy ); + + max_bottom_selection_border = min( max_bottom_selection_border, dat->third_line_top_space / 2 ); + } + + ChangeToFont( hdcMem, dat, GetBasicFontID( Drawing ), NULL ); + } + + + selection_text_rc.left = text_rc.left; + selection_text_rc.right = text_rc.right; + + Drawing->pos_label = text_rc; + + selection_text_rc.top = max( selection_text_rc.top - SELECTION_BORDER, row_rc.top ); + selection_text_rc.bottom = min( selection_text_rc.bottom + max_bottom_selection_border, row_rc.bottom ); + + if ( dat->text_align_right ) + selection_text_rc.left = max( selection_text_rc.left - SELECTION_BORDER, free_row_rc.left ); + else + selection_text_rc.right = min( selection_text_rc.right + SELECTION_BORDER, free_row_rc.right ); + _StoreItemPos( Drawing, CIT_SELECTION, &selection_text_rc ); + + Drawing->pos_rename_rect = free_row_rc; + + { + // Draw text + uTextFormat = uTextFormat | ( gl_TrimText?DT_END_ELLIPSIS:0 ); + + switch ( Drawing->type ) + { + case CLCIT_DIVIDER: + { + //devider + RECT trc = free_row_rc; + RECT rc = free_row_rc; + rc.top += ( rc.bottom - rc.top ) >> 1; + rc.bottom = rc.top + 2; + rc.right = rc.left + ( ( rc.right - rc.left - text_size.cx )>>1 ) - 3; + trc.left = rc.right + 3; + trc.right = trc.left + text_size.cx + 6; + if ( text_size.cy < trc.bottom - trc.top ) + { + trc.top += ( trc.bottom - trc.top - text_size.cy ) >> 1; + trc.bottom = trc.top + text_size.cy; + } + _StoreItemPos( Drawing, CIT_TEXT, &trc ); + rc.left = rc.right + 6 + text_size.cx; + rc.right = free_row_rc.right; + break; + } + case CLCIT_GROUP: + { + RECT rc = text_rc; + + // Get text rectangle + if ( dat->text_align_right ) + rc.left = rc.right - text_size.cx; + else + rc.right = rc.left + text_size.cx; + + + if ( text_size.cy < rc.bottom - rc.top ) + { + rc.top += ( rc.bottom - rc.top - text_size.cy ) >> 1; + rc.bottom = rc.top + text_size.cy; + } + + // Draw text + _StoreItemPos( Drawing, CIT_TEXT, &rc ); + + // Has to draw the count? + if ( counts_size.cx > 0 ) + { + RECT counts_rc = text_rc; + //counts_size.cx; + if ( dat->text_align_right ) + counts_rc.right = text_rc.left + counts_size.cx; + else + counts_rc.left = text_rc.right - counts_size.cx; + + if ( counts_size.cy < counts_rc.bottom - counts_rc.top ) + { + counts_rc.top += ( counts_rc.bottom - counts_rc.top - counts_size.cy + 1 ) >> 1; + counts_rc.bottom = counts_rc.top + counts_size.cy; + } + // Draw counts + _StoreItemPos( Drawing, CIT_SUBTEXT1, &counts_rc ); + } + break; + } + case CLCIT_CONTACT: + { + + RECT free_rc = text_rc; + PDNCE pdnce = ( PDNCE )pcli->pfnGetCacheEntry( Drawing->hContact ); + if ( text_size.cx > 0 && free_rc.bottom > free_rc.top ) + { + RECT rc = free_rc; + rc.bottom = min( rc.bottom, rc.top + text_size.cy ); + + if ( text_size.cx < rc.right - rc.left ) + { + if ( dat->text_align_right ) + rc.left = rc.right - text_size.cx; + else + rc.right = rc.left + text_size.cx; + } + uTextFormat |= DT_VCENTER; + _StoreItemPos( Drawing, CIT_TEXT, &rc ); + free_rc.top = rc.bottom; + } + uTextFormat &= ~DT_VCENTER; + if ( second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top ) + { + free_rc.top += dat->second_line_top_space; + + if ( free_rc.bottom > free_rc.top ) + { + RECT rc = free_rc; + rc.bottom = min( rc.bottom, rc.top + second_line_text_size.cy ); + + if ( second_line_text_size.cx < rc.right - rc.left ) + { + if ( dat->text_align_right ) + rc.left = rc.right - second_line_text_size.cx; + else + rc.right = rc.left + second_line_text_size.cx; + } + _StoreItemPos( Drawing, CIT_SUBTEXT1, &rc ); + free_rc.top = rc.bottom; + } + } + + if ( third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top ) + { + free_rc.top += dat->third_line_top_space; + + if ( free_rc.bottom > free_rc.top ) + { + RECT rc = free_rc; + rc.bottom = min( rc.bottom, rc.top + third_line_text_size.cy ); + + if ( third_line_text_size.cx < rc.right - rc.left ) + { + if ( dat->text_align_right ) + rc.left = rc.right - third_line_text_size.cx; + else + rc.right = rc.left + third_line_text_size.cx; + } + _StoreItemPos( Drawing, CIT_SUBTEXT2, &rc ); + free_rc.top = rc.bottom; + } + } + break; + } + default: // CLCIT_INFO + { + _StoreItemPos( Drawing, CIT_TEXT, &text_rc ); + } + } + } + } + + *in_free_row_rc = free_row_rc; + *in_row_rc = row_rc; + Drawing->ext_fItemsValid = FALSE; /*TO DO: correctly implement placement recalculation*/ } BOOL CLCPaint::__IsVisible( RECT * firtRect, RECT * secondRect ) { - RECT res; - IntersectRect( &res, firtRect, secondRect ); - return !IsRectEmpty( &res ); + RECT res; + IntersectRect( &res, firtRect, secondRect ); + return !IsRectEmpty( &res ); } void CLCPaint::_GetBlendMode( IN struct ClcData *dat, IN struct ClcContact * Drawing, IN BOOL selected, IN BOOL hottrack, IN BOOL bFlag, OUT COLORREF * OutColourFg, OUT int * OutMode ) { - COLORREF colourFg; - int mode; - int BlendedInActiveState = ( dat->dbbBlendInActiveState ); - int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; - if ( selected && ( bFlag&GIM_SELECTED_AFFECT )) - { - colourFg = dat->selBkColour; - mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; - } - else if ( hottrack && ( bFlag&GIM_HOT_AFFECT )) - { - mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; - colourFg = dat->hotTextColour; - } - else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST && ( bFlag&GIM_TEMP_AFFECT )) - { - colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; - mode = BlendValue; - } - else - { - colourFg = dat->selBkColour; - mode = ILD_NORMAL; - } - if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && - _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE && - ( bFlag&GIM_IDLE_AFFECT ) - ) - mode = ILD_SELECTED; - if ( OutColourFg ) *OutColourFg = colourFg; - if ( OutMode ) - { - if ( OutColourFg ) *OutMode = mode; //return ILD_MODE if color requested - else *OutMode = - ( mode == ILD_BLEND50 )?128 : - ( mode == ILD_BLEND25 )?64 : - 255; //return alpha otherwise - } + COLORREF colourFg; + int mode; + int BlendedInActiveState = ( dat->dbbBlendInActiveState ); + int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50; + if ( selected && ( bFlag&GIM_SELECTED_AFFECT )) + { + colourFg = dat->selBkColour; + mode = BlendedInActiveState?ILD_NORMAL:ILD_SELECTED; + } + else if ( hottrack && ( bFlag&GIM_HOT_AFFECT )) + { + mode = BlendedInActiveState?ILD_NORMAL:ILD_FOCUS; + colourFg = dat->hotTextColour; + } + else if ( Drawing->type == CLCIT_CONTACT && Drawing->flags&CONTACTF_NOTONLIST && ( bFlag&GIM_TEMP_AFFECT )) + { + colourFg = dat->fontModernInfo[FONTID_NOTONLIST].colour; + mode = BlendValue; + } + else + { + colourFg = dat->selBkColour; + mode = ILD_NORMAL; + } + if ( Drawing->type == CLCIT_CONTACT && dat->showIdle && ( Drawing->flags&CONTACTF_IDLE ) && + _GetRealStatus( Drawing, ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE && + ( bFlag&GIM_IDLE_AFFECT ) + ) + mode = ILD_SELECTED; + if ( OutColourFg ) *OutColourFg = colourFg; + if ( OutMode ) + { + if ( OutColourFg ) *OutMode = mode; //return ILD_MODE if color requested + else *OutMode = + ( mode == ILD_BLEND50 )?128 : + ( mode == ILD_BLEND25 )?64 : + 255; //return alpha otherwise + } } void CLCPaint::_DrawContactAvatar( HDC hdcMem, struct ClcData *dat, struct ClcContact *Drawing, RECT *row_rc, int& selected, int& hottrack, RECT& text_rc, RECT * prcItem ) @@ -3000,7 +2986,7 @@ void CLCPaint::_DrawContactAvatar( HDC hdcMem, struct ClcData *dat, struct ClcCo int overlayIdx = -1; int blendmode = 255; if ( dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) - && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) + && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) { switch( dat->avatars_overlay_type ) { @@ -3072,7 +3058,7 @@ void CLCPaint::_DrawContactAvatar( HDC hdcMem, struct ClcData *dat, struct ClcCo DeleteObject( rgn ); // Draw overlays if ( dat->avatars_draw_overlay && dat->avatars_maxheight_size >= ICON_HEIGHT + ( dat->avatars_draw_border ? 2 : 0 ) - && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) + && GetContactCachedStatus( Drawing->hContact ) - ID_STATUS_OFFLINE < MAX_REGS( g_pAvatarOverlayIcons )) { POINT ptOverlay = { prcItem->right-ICON_HEIGHT, prcItem->bottom-ICON_HEIGHT }; if ( dat->avatars_draw_border ) @@ -3226,7 +3212,7 @@ void CLCPaint::_DrawContactTime( HDC hdcMem, struct ClcData *dat, struct ClcCont if ( !pdnce ) return; - if (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) + if (!tmi.printDateTime(pdnce->hTimeZone, _T("t"), szResult, SIZEOF(szResult), 0)) { // Select font ChangeToFont( hdcMem, dat, FONTID_CONTACT_TIME, NULL ); @@ -3304,74 +3290,74 @@ void CLCPaint::_DrawContactLine( HDC hdcMem, struct ClcData *dat, struct ClcCont void CLCPaint::_DrawContactItems( HWND hwnd, HDC hdcMem, struct ClcData *dat, struct ClcContact *Drawing, RECT *row_rc, RECT *free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint ) { - int i; - RECT text_rc = {0}; - UINT uTextFormat = DT_NOPREFIX | - /*DT_VCENTER |*/ - DT_SINGLELINE | - ( dat->text_rtl ? DT_RTLREADING : 0 ) | - ( dat->text_align_right ? DT_RIGHT : 0 )| - ( gl_TrimText?DT_END_ELLIPSIS:0 )| - ( ( dat->force_in_dialog || dat->bkChanged ) ? DT_FORCENATIVERENDER:0 ); - - text_rc = *row_rc; - - text_rc.right = row_rc->left; - text_rc.left = row_rc->right; - - for ( i=0; i < Drawing->ext_nItemsNum; i++ ) - { - RECT * prcItem = &( Drawing->ext_mpItemsDesc[i].itemRect ); - if ( __IsVisible( rcPaint, prcItem ) || ( Drawing->ext_mpItemsDesc[i].itemType == CIT_AVATAR && Drawing->avatar_pos == AVATAR_POS_ANIMATED )) + int i; + RECT text_rc = {0}; + UINT uTextFormat = DT_NOPREFIX | + /*DT_VCENTER |*/ + DT_SINGLELINE | + ( dat->text_rtl ? DT_RTLREADING : 0 ) | + ( dat->text_align_right ? DT_RIGHT : 0 )| + ( gl_TrimText?DT_END_ELLIPSIS:0 )| + ( ( dat->force_in_dialog || dat->bkChanged ) ? DT_FORCENATIVERENDER:0 ); + + text_rc = *row_rc; + + text_rc.right = row_rc->left; + text_rc.left = row_rc->right; + + for ( i=0; i < Drawing->ext_nItemsNum; i++ ) + { + RECT * prcItem = &( Drawing->ext_mpItemsDesc[i].itemRect ); + if ( __IsVisible( rcPaint, prcItem ) || ( Drawing->ext_mpItemsDesc[i].itemType == CIT_AVATAR && Drawing->avatar_pos == AVATAR_POS_ANIMATED )) { - switch( Drawing->ext_mpItemsDesc[i].itemType ) + switch( Drawing->ext_mpItemsDesc[i].itemType ) { - case CIT_AVATAR: - _DrawContactAvatar( hdcMem, dat, Drawing, row_rc, selected, hottrack, text_rc, prcItem ); - break; - case CIT_ICON: - _DrawContactIcon( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem ); - break; - case CIT_TEXT: - _DrawContactText( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, uTextFormat ); - break; - case CIT_SUBTEXT1: - case CIT_SUBTEXT2: - _DrawContactSubText( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, uTextFormat, Drawing->ext_mpItemsDesc[i].itemType ); - break; - case CIT_TIME: - _DrawContactTime( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem ); - break; - case CIT_CHECKBOX: - //_DrawNothing no check boxes in skinned mode - break; - //other here - case CIT_SELECTION: - _DrawContactSelection( hdcMem, dat, Drawing, selected, hottrack, rcPaint, prcItem ); - break; - default: - if ( Drawing->ext_mpItemsDesc[i].itemType&CIT_EXTRA ) - _DrawContactExtraIcon( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, Drawing->ext_mpItemsDesc[i].itemType&0x3F ); - break; + case CIT_AVATAR: + _DrawContactAvatar( hdcMem, dat, Drawing, row_rc, selected, hottrack, text_rc, prcItem ); + break; + case CIT_ICON: + _DrawContactIcon( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem ); + break; + case CIT_TEXT: + _DrawContactText( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, uTextFormat ); + break; + case CIT_SUBTEXT1: + case CIT_SUBTEXT2: + _DrawContactSubText( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, uTextFormat, Drawing->ext_mpItemsDesc[i].itemType ); + break; + case CIT_TIME: + _DrawContactTime( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem ); + break; + case CIT_CHECKBOX: + //_DrawNothing no check boxes in skinned mode + break; + //other here + case CIT_SELECTION: + _DrawContactSelection( hdcMem, dat, Drawing, selected, hottrack, rcPaint, prcItem ); + break; + default: + if ( Drawing->ext_mpItemsDesc[i].itemType&CIT_EXTRA ) + _DrawContactExtraIcon( hdcMem, dat, Drawing, selected, hottrack, text_rc, prcItem, Drawing->ext_mpItemsDesc[i].itemType&0x3F ); + break; } } - } - if ( ( Drawing->type == CLCIT_GROUP && dat->exStyle&CLS_EX_LINEWITHGROUPS ) - || ( Drawing->type == CLCIT_DIVIDER )) + } + if ( ( Drawing->type == CLCIT_GROUP && dat->exStyle&CLS_EX_LINEWITHGROUPS ) + || ( Drawing->type == CLCIT_DIVIDER )) _DrawContactLine( hdcMem, dat, Drawing, free_row_rc, rcPaint, text_rc ); } void CLCPaint::_PaintRowItems ( HWND hwnd, HDC hdcMem, struct ClcData *dat, struct ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint ) { //Extended LAYOUT if ( gl_RowRoot && ( dat->hWnd == pcli->hwndContactTree )) - { - _PaintRowItemsEx( hwnd, hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); + { + _PaintRowItemsEx( hwnd, hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); ske_ResetTextEffect( hdcMem ); - return; - } + return; + } //END OFF Extended LAYOUT if ( !Drawing->ext_fItemsValid ) _CalcItemsPos( hwnd, hdcMem, dat, Drawing, &row_rc, &free_row_rc, left_pos, right_pos, selected, hottrack ); - _DrawContactItems( hwnd, hdcMem, dat, Drawing, &row_rc, &free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); + _DrawContactItems( hwnd, hdcMem, dat, Drawing, &row_rc, &free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint ); ske_ResetTextEffect( hdcMem ); } diff --git a/plugins/Clist_modern/modern_clcutils.cpp b/plugins/Clist_modern/modern_clcutils.cpp index 38ce06fcee..c38788fd23 100644 --- a/plugins/Clist_modern/modern_clcutils.cpp +++ b/plugins/Clist_modern/modern_clcutils.cpp @@ -104,7 +104,7 @@ int cliHitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcConta { // int c = -1; int i; - for(i=0; i < dat->extraColumnsCount; i++) + for (i=0; i < dat->extraColumnsCount; i++) { if (RectHitTest(&hitcontact->pos_extra[i], testx, testy)) { @@ -287,7 +287,7 @@ void cliBeginRenameSelection(HWND hwnd,struct ClcData *dat) else subident = 0; - for(indent = 0;group->parent;indent++,group = group->parent); + for (indent = 0;group->parent;indent++,group = group->parent); GetClientRect(hwnd,&clRect); x = indent*dat->groupIndent+dat->iconXSpace-2+subident; w = clRect.right-x; @@ -329,9 +329,9 @@ void cliBeginRenameSelection(HWND hwnd,struct ClcData *dat) } if (dat->text_rtl) a |= EN_ALIGN_RTL_EC; if (contact->type == CLCIT_GROUP) - dat->hwndRenameEdit = CreateWindow(TEXT("EDIT"),contact->szText,WS_POPUP|WS_BORDER|ES_AUTOHSCROLL|a,x,y,w,h,hwnd,NULL,g_hInst,NULL); + dat->hwndRenameEdit = CreateWindow(_T("EDIT"),contact->szText,WS_POPUP|WS_BORDER|ES_AUTOHSCROLL|a,x,y,w,h,hwnd,NULL,g_hInst,NULL); else - dat->hwndRenameEdit = CreateWindow(TEXT("EDIT"),pcli->pfnGetContactDisplayName(contact->hContact,0),WS_POPUP|WS_BORDER|ES_AUTOHSCROLL|a,x,y,w,h,hwnd,NULL,g_hInst,NULL); + dat->hwndRenameEdit = CreateWindow(_T("EDIT"),pcli->pfnGetContactDisplayName(contact->hContact,0),WS_POPUP|WS_BORDER|ES_AUTOHSCROLL|a,x,y,w,h,hwnd,NULL,g_hInst,NULL); } SetWindowLongPtr(dat->hwndRenameEdit,GWL_STYLE,GetWindowLongPtr(dat->hwndRenameEdit,GWL_STYLE)&(~WS_CAPTION)|WS_BORDER); SetWindowLongPtr(dat->hwndRenameEdit,GWLP_USERDATA,(LONG_PTR)dat); @@ -742,7 +742,6 @@ void LoadCLCOptions(HWND hwnd, struct ClcData *dat ) if (db_get_b(NULL,"Menu","UseBitmap",CLCDEFAULT_USEBITMAP)) { if (!DBGetContactSettingString(NULL,"Menu","BkBitmap",&dbv)) { dat->hMenuBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal); - //mir_free_and_nill(dbv.pszVal); db_free(&dbv); } } diff --git a/plugins/Clist_modern/modern_clistevents.cpp b/plugins/Clist_modern/modern_clistevents.cpp index 5000929294..adc2d55de0 100644 --- a/plugins/Clist_modern/modern_clistevents.cpp +++ b/plugins/Clist_modern/modern_clistevents.cpp @@ -424,7 +424,7 @@ int EventArea_Create(HWND hCluiWnd) ehhEventAreaBackgroundSettingsChanged(0,0); WNDCLASS wndclass = {0}; - TCHAR pluginname[] = TEXT("EventArea"); + TCHAR pluginname[] = _T("EventArea"); int h = GetSystemMetrics(SM_CYSMICON)+2; if (GetClassInfo(g_hInst,pluginname,&wndclass) == 0) { diff --git a/plugins/Clist_modern/modern_clistmod.cpp b/plugins/Clist_modern/modern_clistmod.cpp index 9837c2aeac..118c1325f2 100644 --- a/plugins/Clist_modern/modern_clistmod.cpp +++ b/plugins/Clist_modern/modern_clistmod.cpp @@ -302,7 +302,7 @@ HRESULT CluiLoadModule() CreateServiceFunction(MS_CLIST_GETCONTACTICON,GetContactIcon); - MySetProcessWorkingSetSize = (BOOL (WINAPI*)(HANDLE,SIZE_T,SIZE_T))GetProcAddress(GetModuleHandle(TEXT("kernel32")),"SetProcessWorkingSetSize"); + MySetProcessWorkingSetSize = (BOOL (WINAPI*)(HANDLE,SIZE_T,SIZE_T))GetProcAddress(GetModuleHandle(_T("kernel32")),"SetProcessWorkingSetSize"); hCListImages = ImageList_Create(16, 16, ILC_MASK|ILC_COLOR32, 32, 0); InitCustomMenus(); InitTray(); diff --git a/plugins/Clist_modern/modern_clistopts.cpp b/plugins/Clist_modern/modern_clistopts.cpp index 28a3cbe975..42dfc18cab 100644 --- a/plugins/Clist_modern/modern_clistopts.cpp +++ b/plugins/Clist_modern/modern_clistopts.cpp @@ -119,7 +119,7 @@ static INT_PTR CALLBACK DlgProcItemRowOpts(HWND hwndDlg, UINT msg, WPARAM wParam // Listbox hwndList = GetDlgItem(hwndDlg, IDC_LIST_ORDER); - for(i=0 ; i < NUM_ITEM_TYPE ; i++) + for (i=0 ; i < NUM_ITEM_TYPE ; i++) { char tmp[128]; int type; @@ -326,7 +326,7 @@ static INT_PTR CALLBACK DlgProcItemRowOpts(HWND hwndDlg, UINT msg, WPARAM wParam db_set_b(NULL,"CLC","RightMargin",(BYTE)SendDlgItemMessage(hwndDlg,IDC_RIGHTMARGINSPIN,UDM_GETPOS,0,0)); hwndList = GetDlgItem(hwndDlg, IDC_LIST_ORDER); - for(i=0 ; i < NUM_ITEM_TYPE ; i++) + for (i=0 ; i < NUM_ITEM_TYPE ; i++) { char tmp[128]; mir_snprintf(tmp, SIZEOF(tmp), "RowPos%d", i); diff --git a/plugins/Clist_modern/modern_clistsettings.cpp b/plugins/Clist_modern/modern_clistsettings.cpp index a39982c385..af5921e15b 100644 --- a/plugins/Clist_modern/modern_clistsettings.cpp +++ b/plugins/Clist_modern/modern_clistsettings.cpp @@ -79,11 +79,11 @@ void FreeDisplayNameCache() int i; for ( i=0; i < clistCache->realCount; i++) { pcli->pfnFreeCacheItem(( ClcCacheEntryBase* )clistCache->items[i] ); - mir_free_and_nill( clistCache->items[i] ); + mir_free_and_nil( clistCache->items[i] ); } List_Destroy( clistCache ); - mir_free_and_nill(clistCache); + mir_free(clistCache); clistCache = NULL; } } @@ -107,7 +107,7 @@ ClcCacheEntryBase* cliGetCacheEntry(HANDLE hContact) static void free_and_nil_tcsName(TCHAR* &p) { if (p && p != UnknownConctactTranslatedName) - mir_free_and_nill(p); + mir_free_and_nil(p); } void CListSettings_FreeCacheItemData(pdisplayNameCacheEntry pDst) @@ -121,15 +121,15 @@ void CListSettings_FreeCacheItemDataOption( pdisplayNameCacheEntry pDst, DWORD f if ( flag & CCI_NAME) { if (!pDst->isUnknown) free_and_nil_tcsName(pDst->m_cache_tcsName); - if (pDst->m_cache_szName) mir_free_and_nill(pDst->m_cache_szName); + mir_free_and_nil(pDst->m_cache_szName); } if ( flag & CCI_GROUP ) - if (pDst->m_cache_tcsGroup) mir_free_and_nill(pDst->m_cache_tcsGroup); + mir_free_and_nil(pDst->m_cache_tcsGroup); if ( flag & CCI_LINES ) { - if (pDst->szSecondLineText) mir_free_and_nill(pDst->szSecondLineText); - if (pDst->szThirdLineText) mir_free_and_nill(pDst->szThirdLineText); + mir_free_and_nil(pDst->szSecondLineText); + mir_free_and_nil(pDst->szThirdLineText); pDst->ssSecondLine.DestroySmileyList(); pDst->ssThirdLine.DestroySmileyList(); } @@ -219,27 +219,14 @@ void cliFreeCacheItem( pdisplayNameCacheEntry p ) if ( !p->isUnknown) free_and_nil_tcsName(p->m_cache_tcsName); p->m_cache_tcsName = NULL; - if ( p->m_cache_szName) { mir_free_and_nill(p->m_cache_szName); p->m_cache_szName = NULL; } - if ( p->m_cache_tcsGroup) { mir_free_and_nill(p->m_cache_tcsGroup); p->m_cache_tcsGroup = NULL; } - if ( p->szSecondLineText) mir_free_and_nill(p->szSecondLineText); - if ( p->szThirdLineText) mir_free_and_nill(p->szThirdLineText); + mir_free_and_nil(p->m_cache_szName); + mir_free_and_nil(p->m_cache_tcsGroup); + mir_free_and_nil(p->szSecondLineText); + mir_free_and_nil(p->szThirdLineText); p->ssSecondLine.DestroySmileyList(); p->ssThirdLine.DestroySmileyList(); } - -/* -void FreeDisplayNameCache(SortedList *list) -{ - int i; - for ( i=0; i < list->realCount; i++) { - FreeDisplayNameCacheItem(( pdisplayNameCacheEntry )list->items[i] ); - mir_free_and_nill(list->items[i]); - } - List_Destroy(list); - -} -*/ void cliCheckCacheItem(pdisplayNameCacheEntry pdnce) { if (pdnce == NULL) @@ -281,7 +268,7 @@ void cliCheckCacheItem(pdisplayNameCacheEntry pdnce) else pdnce->m_cache_tcsName = GetNameForContact(pdnce->m_cache_hContact,0,&pdnce->isUnknown); //TODO UNICODE } - if (pdnce->m_cache_szName) mir_free_and_nill(pdnce->m_cache_szName); + mir_free_and_nil(pdnce->m_cache_szName); } else { @@ -302,10 +289,9 @@ void cliCheckCacheItem(pdisplayNameCacheEntry pdnce) DBVARIANT dbv = {0}; if (!DBGetContactSettingTString(pdnce->m_cache_hContact,"CList","Group",&dbv)) { pdnce->m_cache_tcsGroup = mir_tstrdup(dbv.ptszVal); - //mir_free_and_nill(dbv.ptszVal); db_free(&dbv); } - else pdnce->m_cache_tcsGroup = mir_tstrdup(TEXT("")); + else pdnce->m_cache_tcsGroup = mir_tstrdup(_T("")); } if (pdnce->m_cache_nHidden == -1) @@ -364,9 +350,9 @@ void InvalidateDNCEbyPointer(HANDLE hContact,pdisplayNameCacheEntry pdnce,int Se if (SettingType == 16) { pdnce->ssSecondLine.DestroySmileyList(); - if (pdnce->szSecondLineText) mir_free_and_nill(pdnce->szSecondLineText); + mir_free_and_nil(pdnce->szSecondLineText); pdnce->ssThirdLine.DestroySmileyList(); - if (pdnce->szThirdLineText) mir_free_and_nill(pdnce->szThirdLineText); + mir_free_and_nil(pdnce->szThirdLineText); pdnce->ssSecondLine.iMaxSmileyHeight = 0; pdnce->ssThirdLine.iMaxSmileyHeight = 0; pdnce->hTimeZone = NULL; @@ -380,8 +366,7 @@ void InvalidateDNCEbyPointer(HANDLE hContact,pdisplayNameCacheEntry pdnce,int Se if (!pdnce->isUnknown) free_and_nil_tcsName(pdnce->m_cache_tcsName); pdnce->m_cache_tcsName = NULL; - if (pdnce->m_cache_tcsGroup) mir_free_and_nill(pdnce->m_cache_tcsGroup); - // if (pdnce->szProto) mir_free_and_nill(pdnce->szProto); //free proto + mir_free_and_nil(pdnce->m_cache_tcsGroup); pdnce->m_cache_tcsGroup = NULL; pdnce->m_cache_nHidden = -1; @@ -400,8 +385,7 @@ void InvalidateDNCEbyPointer(HANDLE hContact,pdisplayNameCacheEntry pdnce,int Se if (SettingType >= DBVT_WCHAR) { if (!pdnce->isUnknown) free_and_nil_tcsName(pdnce->m_cache_tcsName); - if (pdnce->m_cache_tcsGroup) mir_free_and_nill(pdnce->m_cache_tcsGroup); - //if (pdnce->szProto) mir_free_and_nill(pdnce->szProto); + mir_free_and_nil(pdnce->m_cache_tcsGroup); pdnce->m_cache_tcsName = NULL; pdnce->m_cache_tcsGroup = NULL; pdnce->m_cache_cszProto = NULL; @@ -505,7 +489,6 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) if (pdnce == NULL) { TRACE("!!! Very bad pdnce not found."); - //if (dbv.pszVal) mir_free_and_nill(dbv.pszVal); return 0; } if (pdnce->m_cache_bProtoNotExists == FALSE && pdnce->m_cache_cszProto) @@ -613,10 +596,9 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) cli_ChangeContactIcon((HANDLE)wParam,ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:db_get_w((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE)),0); //by FYR } } + // Clean up db_free(&dbv); - //if (dbv.pszVal) - // mir_free_and_nill(dbv.pszVal); } return 0; diff --git a/plugins/Clist_modern/modern_clisttray.cpp b/plugins/Clist_modern/modern_clisttray.cpp index 7385ab6754..741294f878 100644 --- a/plugins/Clist_modern/modern_clisttray.cpp +++ b/plugins/Clist_modern/modern_clisttray.cpp @@ -60,7 +60,7 @@ typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *); void mir_strset(TCHAR ** dest, TCHAR *source) { - if (*dest) mir_free_and_nill(*dest); + if (*dest) mir_free_and_nil(*dest); if (source) *dest = mir_tstrdup(source); } @@ -75,7 +75,7 @@ int GetStatusVal(int status) case ID_STATUS_FREECHAT: return 110; case ID_STATUS_INVISIBLE: return 120; case ID_STATUS_AWAY: return 200; - case ID_STATUS_DND: return 210; + case ID_STATUS_DND: return 210; case ID_STATUS_NA: return 220; case ID_STATUS_OCCUPIED: return 230; case ID_STATUS_ONTHEPHONE: return 400; @@ -126,7 +126,7 @@ int GetAverageMode() int averageMode = 0; PROTOACCOUNT **accs; ProtoEnumAccounts( &count, &accs ); - for(i=0,netProtoCount = 0;i < count;i++) { + for (i=0,netProtoCount = 0;i < count;i++) { if ( pcli->pfnGetProtocolVisibility(accs[i]->szModuleName) == 0 ) continue; pcli->cycleStep = i; netProtoCount++; @@ -172,7 +172,7 @@ void cliTrayIconUpdateBase(const char *szChangedProto) pcli->cycleTimerId = 0; } ProtoEnumAccounts( &count, &accs ); - for(i=0,netProtoCount = 0;i < count;i++) { + for (i=0,netProtoCount = 0;i < count;i++) { if ( pcli->pfnGetProtocolVisibility(accs[i]->szModuleName) == 0 ) continue; netProtoCount++; if (!lstrcmpA(szChangedProto,accs[i]->szModuleName)) pcli->cycleStep = i; @@ -202,7 +202,7 @@ void cliTrayIconUpdateBase(const char *szChangedProto) if (DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv)) szProto = NULL; else szProto = dbv.pszVal; changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szProto,averageMode),NULL); - if (szProto) mir_free_and_nill(szProto); + mir_free(szProto); } else changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,NULL,averageMode),NULL); @@ -342,8 +342,7 @@ void cliTrayIconUpdateBase(const char *szChangedProto) else szProto = dbv.pszVal; changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szProto,status),NULL); - if (szProto) - mir_free_and_nill(szProto); + mir_free(szProto); } } diff --git a/plugins/Clist_modern/modern_clui.cpp b/plugins/Clist_modern/modern_clui.cpp index b1f9018f1a..f1b1b9416f 100644 --- a/plugins/Clist_modern/modern_clui.cpp +++ b/plugins/Clist_modern/modern_clui.cpp @@ -297,7 +297,7 @@ CLUI::~CLUI() HRESULT CLUI::LoadDllsRuntime() { - m_hUserDll = LoadLibrary(TEXT("user32.dll")); + m_hUserDll = LoadLibrary(_T("user32.dll")); if (m_hUserDll) { g_proc_UpdateLayeredWindow = (BOOL (WINAPI *)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD))GetProcAddress(m_hUserDll, "UpdateLayeredWindow"); @@ -311,7 +311,7 @@ HRESULT CLUI::LoadDllsRuntime() if (IsWinVerVistaPlus()) { - m_hDwmapiDll = LoadLibrary(TEXT("dwmapi.dll")); + m_hDwmapiDll = LoadLibrary(_T("dwmapi.dll")); if (m_hDwmapiDll) { g_proc_DWMEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))GetProcAddress(m_hDwmapiDll, "DwmEnableBlurBehindWindow"); @@ -351,7 +351,7 @@ HRESULT CLUI::RegisterAvatarMenu() } HRESULT CLUI::CreateCLCWindow(const HWND hwndClui) { - ClcWnd() = CreateWindow(CLISTCONTROL_CLASS,TEXT(""), + ClcWnd() = CreateWindow(CLISTCONTROL_CLASS,_T(""), WS_CHILD|WS_CLIPCHILDREN|CLS_CONTACTLIST |(db_get_b(NULL,"CList","UseGroups",SETTING_USEGROUPS_DEFAULT)?CLS_USEGROUPS:0) |(db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT)?CLS_HIDEOFFLINE:0) @@ -714,7 +714,7 @@ void CLUI_ChangeWindowMode() TCHAR titleText[255] = {0}; DBVARIANT dbv = {0}; if (DBGetContactSettingTString(NULL,"CList","TitleText",&dbv)) - lstrcpyn(titleText,TEXT(MIRANDANAME),SIZEOF(titleText)); + lstrcpyn(titleText,_T(MIRANDANAME),SIZEOF(titleText)); else { lstrcpyn(titleText,dbv.ptszVal,SIZEOF(titleText)); @@ -768,7 +768,7 @@ void CLUI_ChangeWindowMode() //6- Pin to desktop mode if (db_get_b(NULL,"CList","OnDesktop", SETTING_ONDESKTOP_DEFAULT)) { - HWND hProgMan = FindWindow(TEXT("Progman"),NULL); + HWND hProgMan = FindWindow(_T("Progman"),NULL); if (IsWindow(hProgMan)) { SetParent(pcli->hwndContactList,hProgMan); @@ -779,7 +779,7 @@ void CLUI_ChangeWindowMode() else { // HWND parent = GetParent(pcli->hwndContactList); - // HWND progman = FindWindow(TEXT("Progman"),NULL); + // HWND progman = FindWindow(_T("Progman"),NULL); // if (parent == progman) { SetParent(pcli->hwndContactList,NULL); @@ -1415,8 +1415,8 @@ static int CLUI_DrawMenuBackGround(HWND hwnd, HDC hdc, int item, int state) break; } if (desth && destw) - for(y = clRect.top;y < maxy;y += desth) { - for(x = clRect.left;x < maxx;x += destw) + for (y = clRect.top;y < maxy;y += desth) { + for (x = clRect.left;x < maxx;x += destw) StretchBlt(hdc,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY); } SelectObject(hdcBmp,oldbm); @@ -2286,7 +2286,7 @@ LRESULT CLUI::OnCreate( UINT msg, WPARAM wParam, LPARAM lParam ) } //PostMessage(m_hWnd, M_CREATECLC, 0, 0); //pcli->hwndContactList = m_hWnd; - uMsgGetProfile = RegisterWindowMessage(TEXT("Miranda::GetProfile")); // don't localise + uMsgGetProfile = RegisterWindowMessage(_T("Miranda::GetProfile")); // don't localise bTransparentFocus = 1; return FALSE; } @@ -2846,26 +2846,24 @@ LRESULT CLUI::OnClickNotify( NMCLISTCONTROL * pnmc ) }; if (pnmc->iColumn == e) { - char *email,buf[4096]; - email = db_get_sa(pnmc->hItem,"UserInfo", "Mye-mail0"); + char *email = db_get_sa(pnmc->hItem,"UserInfo", "Mye-mail0"); if (!email) email = db_get_sa(pnmc->hItem, pdnce->m_cache_cszProto, "e-mail"); - if (email) - { + if (email) { + char buf[4096]; sprintf(buf,"mailto:%s",email); - mir_free_and_nill(email); + mir_free(email); ShellExecuteA(m_hWnd,"open",buf,NULL,NULL,SW_SHOW); } }; if (pnmc->iColumn == w) { - char *homepage; - homepage = db_get_sa(pdnce->m_cache_hContact,"UserInfo", "Homepage"); + char *homepage = db_get_sa(pdnce->m_cache_hContact,"UserInfo", "Homepage"); if (!homepage) homepage = db_get_sa(pdnce->m_cache_hContact,pdnce->m_cache_cszProto, "Homepage"); if (homepage != NULL) { CallService(MS_UTILS_OPENURL, 1, (LPARAM)homepage); - mir_free_and_nill(homepage); + mir_free(homepage); } } } @@ -3066,9 +3064,9 @@ LRESULT CLUI::OnDestroy( UINT msg, WPARAM wParam, LPARAM lParam ) while (CLUI_WaitThreadsCompletion(m_hWnd)); //stop all my threads TRACE("CLUI.c: WM_DESTROY - WaitThreadsCompletion DONE\n"); { - int i=0; - for(i=0; i < 64; i++) - if (CycleStartTick[i].szProto) mir_free_and_nill(CycleStartTick[i].szProto); + for (int i=0; i < 64; i++) + if (CycleStartTick[i].szProto) + mir_free_and_nil(CycleStartTick[i].szProto); } if (state == SETTING_STATE_NORMAL){CLUI_ShowWindowMod(m_hWnd,SW_HIDE);}; diff --git a/plugins/Clist_modern/modern_cluiframes.cpp b/plugins/Clist_modern/modern_cluiframes.cpp index 605ef0faf5..782ffcff16 100644 --- a/plugins/Clist_modern/modern_cluiframes.cpp +++ b/plugins/Clist_modern/modern_cluiframes.cpp @@ -121,7 +121,7 @@ int CLUIFrames_OnMoving( HWND hwnd, RECT * r) { int i; g_CluiData.mutexPreventDockMoving = 0; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if (!g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != NULL && g_pfwFrames[i].OwnerWindow != (HWND)-2) { @@ -151,7 +151,7 @@ int SetAlpha(BYTE Alpha) { int i; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if (!g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != NULL && g_pfwFrames[i].OwnerWindow != (HWND)-2 && g_pfwFrames[i].visible && !g_pfwFrames[i].needhide ) { @@ -165,7 +165,7 @@ int SetAlpha(BYTE Alpha) HWND parent = NULL; if (g_CluiData.fOnDesktop) { - HWND hProgMan = FindWindow(TEXT("Progman"),NULL); + HWND hProgMan = FindWindow(_T("Progman"),NULL); if (IsWindow(hProgMan)) parent = hProgMan; } @@ -188,7 +188,7 @@ int SetAlpha(BYTE Alpha) int CLUIFrames_RepaintSubContainers() { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (!g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != (HWND)0 && g_pfwFrames[i].OwnerWindow != (HWND)-2 && g_pfwFrames[i].visible && !g_pfwFrames[i].needhide ) { RedrawWindow(g_pfwFrames[i].hWnd,NULL,NULL,RDW_ALLCHILDREN|RDW_UPDATENOW|RDW_INVALIDATE|RDW_FRAME); @@ -199,7 +199,7 @@ int CLUIFrames_RepaintSubContainers() int CLUIFrames_ActivateSubContainers( BOOL active) { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (active && !g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != (HWND)0 && g_pfwFrames[i].OwnerWindow != (HWND)-2 && g_pfwFrames[i].visible && !g_pfwFrames[i].needhide ) { HWND hwnd = g_pfwFrames[i].OwnerWindow; @@ -220,7 +220,7 @@ int CLUIFrames_SetParentForContainers( HWND parent ) g_CluiData.fOnDesktop = 1; else g_CluiData.fOnDesktop = 0; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if (!g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != (HWND)0 && g_pfwFrames[i].OwnerWindow != (HWND)-2 && g_pfwFrames[i].visible && !g_pfwFrames[i].needhide ) { HWND hwnd = g_pfwFrames[i].OwnerWindow; @@ -234,7 +234,7 @@ int CLUIFrames_OnShowHide( HWND hwnd, int mode ) { int i; int prevFrameCount; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if (!g_pfwFrames[i].floating && g_pfwFrames[i].OwnerWindow != (HWND)0 && g_pfwFrames[i].OwnerWindow != (HWND)-2) { { @@ -295,7 +295,7 @@ static FRAMEWND* FindFrameByWnd( HWND hwnd ) if ( hwnd == NULL ) return( NULL ); - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if ((g_pfwFrames[i].floating) && (g_pfwFrames[i].ContainerWnd == hwnd)) return(&g_pfwFrames[i]); @@ -306,7 +306,7 @@ static FRAMEWND* FindFrameByWnd( HWND hwnd ) int QueueAllFramesUpdating(BYTE queue) { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if (!g_CluiData.fLayered) { @@ -342,7 +342,7 @@ FRAMEWND * FindFrameByItsHWND(HWND FrameHwnd) { int i; if ( FrameHwnd == NULL ) return( NULL ); - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if (g_pfwFrames[i].hWnd == FrameHwnd){return(&g_pfwFrames[i]);}; }; @@ -803,7 +803,7 @@ static int CLUIFramesStoreAllFrames() { int i; if (_fCluiFramesModuleNotStarted) return -1; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) CLUIFramesStoreFrameSettings(i); return 0; } @@ -823,7 +823,7 @@ static int CLUIFramesGetalClientFrame(void) } } - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (g_pfwFrames[i].align == alClient) { _nClientFrameId = i; return i; @@ -1332,8 +1332,8 @@ static int _us_DoSetFrameOptions(WPARAM wParam,LPARAM lParam) case FO_TBTIPNAME: if (lParam == (LPARAM)NULL) { return(-1);} - if (g_pfwFrames[pos].TitleBar.tooltip != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.tooltip); - if (g_pfwFrames[pos].TitleBar.sztooltip != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.sztooltip); + if (g_pfwFrames[pos].TitleBar.tooltip != NULL) mir_free_and_nil(g_pfwFrames[pos].TitleBar.tooltip); + if (g_pfwFrames[pos].TitleBar.sztooltip != NULL) mir_free_and_nil(g_pfwFrames[pos].TitleBar.sztooltip); if (bUnicodeText) { g_pfwFrames[pos].TitleBar.tooltip = mir_tstrdup((LPTSTR)lParam); @@ -1427,7 +1427,7 @@ static int _us_DoShowAllFrames(WPARAM wParam,LPARAM lParam) if (_fCluiFramesModuleNotStarted) return -1; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) g_pfwFrames[i].visible = TRUE; CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0); return 0; @@ -1440,7 +1440,7 @@ static int _us_DoShowTitles(WPARAM wParam,LPARAM lParam) if (_fCluiFramesModuleNotStarted) return -1; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) g_pfwFrames[i].TitleBar.ShowTitleBar = TRUE; CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0); return 0; @@ -1453,7 +1453,7 @@ static int _us_DoHideTitles(WPARAM wParam,LPARAM lParam) if (_fCluiFramesModuleNotStarted) return -1; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) g_pfwFrames[i].TitleBar.ShowTitleBar = FALSE; CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList,(LPARAM)0); return 0; @@ -1751,7 +1751,7 @@ static int _us_DoCollapseFrame(WPARAM wParam,LPARAM lParam) }else { int i,sumheight = 0; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if ((g_pfwFrames[i].align != alClient) && (!g_pfwFrames[i].floating) && (g_pfwFrames[i].visible) && (!g_pfwFrames[i].needhide)) { sumheight += (g_pfwFrames[i].height)+(g_nTitleBarHeight*btoint(g_pfwFrames[i].TitleBar.ShowTitleBar))+2; return FALSE; @@ -1895,20 +1895,6 @@ static int _us_DoAddFrame(WPARAM wParam,LPARAM lParam) g_pfwFrames = (FRAMEWND*)realloc(g_pfwFrames,sizeof(FRAMEWND)*(g_nFramesCount+1)); memset(&g_pfwFrames[g_nFramesCount],0,sizeof(FRAMEWND)); - /* //removed buggy code - if (clfrm->name && 0 ) - { - CustomName = ModernDBGetStringA(NULL,"CUSTOM_CLUI_FRAMES",AS(buff,"CustomName_",clfrm->name)); - Frames[nFramescount].TitleBar.BackColour = (COLORREF)DBGetContactSettingDword(NULL,"CUSTOM_CLUI_FRAMES",AS(buff,"CustomBackColor_",clfrm->name),GetSysColor(COLOR_3DFACE)); - Frames[nFramescount].TitleBar.TextColour = (COLORREF)DBGetContactSettingDword(NULL,"CUSTOM_CLUI_FRAMES",AS(buff,"CustomTextColor_",clfrm->name),GetSysColor(COLOR_WINDOWTEXT)); - if (CustomName) - { - if (clfrm->name) mir_free_and_nill(clfrm->name); - clfrm->name = mir_strdup(CustomName); - mir_free_and_nill(CustomName); - } - } - */ g_pfwFrames[g_nFramesCount].id = _iNextFrameId++; g_pfwFrames[g_nFramesCount].align = clfrm->align; g_pfwFrames[g_nFramesCount].hWnd = clfrm->hWnd; @@ -2077,12 +2063,12 @@ static int _us_DoRemoveFrame(WPARAM wParam,LPARAM lParam) if (pos < 0 || pos>g_nFramesCount){return(-1);}; - if (g_pfwFrames[pos].Name != NULL) mir_free_and_nill(g_pfwFrames[pos].Name); - if (g_pfwFrames[pos].szName != NULL) mir_free_and_nill(g_pfwFrames[pos].szName); - if (g_pfwFrames[pos].TitleBar.tbname != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.tbname); - if (g_pfwFrames[pos].TitleBar.sztbname != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.sztbname); - if (g_pfwFrames[pos].TitleBar.tooltip != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.tooltip); - if (g_pfwFrames[pos].TitleBar.sztooltip != NULL) mir_free_and_nill(g_pfwFrames[pos].TitleBar.sztooltip); + mir_free_and_nil(g_pfwFrames[pos].Name); + mir_free_and_nil(g_pfwFrames[pos].szName); + mir_free_and_nil(g_pfwFrames[pos].TitleBar.tbname); + mir_free_and_nil(g_pfwFrames[pos].TitleBar.sztbname); + mir_free_and_nil(g_pfwFrames[pos].TitleBar.tooltip); + mir_free_and_nil(g_pfwFrames[pos].TitleBar.sztooltip); DestroyWindow(g_pfwFrames[pos].hWnd); g_pfwFrames[pos].hWnd = (HWND)-1; DestroyWindow(g_pfwFrames[pos].TitleBar.hwnd); @@ -2218,7 +2204,7 @@ static BOOL CLUIFramesFitInSize(void) if (clientfrm != -1) tbh = g_nTitleBarHeight*btoint(g_pfwFrames[clientfrm].TitleBar.ShowTitleBar); - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if ((g_pfwFrames[i].align != alClient) && (!g_pfwFrames[i].floating) && (g_pfwFrames[i].visible) && (!g_pfwFrames[i].needhide)) { sumheight += (g_pfwFrames[i].height)+(g_nTitleBarHeight*btoint(g_pfwFrames[i].TitleBar.ShowTitleBar))+2/*+btoint(Frames[i].UseBorder)*2*/; if (sumheight>_nContactListHeight-tbh-2) @@ -2240,7 +2226,7 @@ int CLUIFrames_GetTotalHeight() RECT border; if (pcli->hwndContactList == NULL) return 0; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if ((g_pfwFrames[i].visible) && (!g_pfwFrames[i].needhide) && (!g_pfwFrames[i].floating) && (pcli->hwndContactTree) && (g_pfwFrames[i].hWnd != pcli->hwndContactTree)) sumheight += (g_pfwFrames[i].height)+(g_nTitleBarHeight*btoint(g_pfwFrames[i].TitleBar.ShowTitleBar)); @@ -2275,7 +2261,7 @@ int CLUIFramesGetMinHeight() if (clientfrm != -1) tbh = g_nTitleBarHeight*btoint(g_pfwFrames[clientfrm].TitleBar.ShowTitleBar); - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if ((g_pfwFrames[i].align != alClient) && (g_pfwFrames[i].visible) && (!g_pfwFrames[i].needhide) && (!g_pfwFrames[i].floating)) { @@ -2331,7 +2317,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) if (clientfrm != -1) tbh = (g_nTitleBarHeight+g_CluiData.nGapBetweenTitlebar)*btoint(g_pfwFrames[clientfrm].TitleBar.ShowTitleBar); - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if (!g_pfwFrames[i].floating) { @@ -2345,7 +2331,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) //sorting stuff sdarray = (SortData*)malloc(sizeof(SortData)*g_nFramesCount); if (sdarray == NULL){return(-1);}; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) {sdarray[i].order = g_pfwFrames[i].order; sdarray[i].realpos = i; }; @@ -2358,7 +2344,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) while(sumheight>(newheight-tbh) && drawitems>0) { sumheight = 0; drawitems = 0; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if (((g_pfwFrames[i].align != alClient)) && (!g_pfwFrames[i].floating) && (g_pfwFrames[i].visible) && (!g_pfwFrames[i].needhide)) { drawitems++; curfrmtbh = (g_nTitleBarHeight+g_CluiData.nGapBetweenTitlebar)*btoint(g_pfwFrames[i].TitleBar.ShowTitleBar); @@ -2375,7 +2361,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) prevframe = -1; prevframebottomline = topBorder; - for(j = 0;j < g_nFramesCount;j++) { + for (j = 0;j < g_nFramesCount;j++) { //move all alTop frames i = sdarray[j].realpos; if ((!g_pfwFrames[i].needhide) && (!g_pfwFrames[i].floating) && (g_pfwFrames[i].visible) && (g_pfwFrames[i].align == alTop)) { @@ -2393,7 +2379,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) } if (sumheight < newheight) { - for(j = 0;j < g_nFramesCount;j++) { + for (j = 0;j < g_nFramesCount;j++) { //move alClient frame i = sdarray[j].realpos; if ((!g_pfwFrames[i].needhide) && (!g_pfwFrames[i].floating) && (g_pfwFrames[i].visible) && (g_pfwFrames[i].align == alClient)) { @@ -2418,7 +2404,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) //newheight prevframebottomline = newheight+sepw+topBorder; //prevframe = -1; - for(j = g_nFramesCount-1;j >= 0;j--) { + for (j = g_nFramesCount-1;j >= 0;j--) { //move all alBottom frames i = sdarray[j].realpos; if ((g_pfwFrames[i].visible) && (!g_pfwFrames[i].floating) && (!g_pfwFrames[i].needhide) && (g_pfwFrames[i].align == alBottom)) { @@ -2434,7 +2420,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) } } } - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (g_pfwFrames[i].TitleBar.ShowTitleBar) SetRect(&g_pfwFrames[i].TitleBar.wndSize,g_pfwFrames[i].wndSize.left,g_pfwFrames[i].wndSize.top-g_nTitleBarHeight-g_CluiData.nGapBetweenTitlebar,g_pfwFrames[i].wndSize.right,g_pfwFrames[i].wndSize.top-g_CluiData.nGapBetweenTitlebar); if (sdarray != NULL){free(sdarray);sdarray = NULL;}; @@ -2447,7 +2433,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) static int SizeMoveNewSizes() { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if (g_pfwFrames[i].floating){ @@ -2471,7 +2457,7 @@ int CLUIFrames_ApplyNewSizes(int mode) { int i; g_CluiData.mutexPreventDockMoving = 0; - for(i=0;i < g_nFramesCount;i++) { + for (i=0;i < g_nFramesCount;i++) { if ( (mode == 1 && g_pfwFrames[i].OwnerWindow != (HWND)-2 && g_pfwFrames[i].OwnerWindow) || (mode == 2 && g_pfwFrames[i].OwnerWindow == (HWND)-2) || (mode == 3)) @@ -2551,7 +2537,7 @@ int SizeFramesByWindowRect(RECT *r, HDWP * PosBatch, int mode) CLUIFramesResizeFrames(nRect); { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { int dx; int dy; @@ -2628,7 +2614,7 @@ int CheckFramesPos(RECT *wr) g_CluiData.nGapBetweenTitlebar = (int)db_get_dw(NULL,"CLUIFrames","GapBetweenTitleBar",SETTING_GAPTITLEBAR_DEFAULT); GapBetweenFrames = db_get_dw(NULL,"CLUIFrames","GapBetweenFrames",SETTING_GAPFRAMES_DEFAULT); - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { int dx; int dy; @@ -2780,7 +2766,6 @@ int OnFrameTitleBarBackgroundChange(WPARAM wParam,LPARAM lParam) if (db_get_b(NULL,"FrameTitleBar","UseBitmap",CLCDEFAULT_USEBITMAP)) { if (!DBGetContactSettingString(NULL,"FrameTitleBar","BkBitmap",&dbv)) { hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP,0,(LPARAM)dbv.pszVal); - //mir_free_and_nill(dbv.pszVal); db_free(&dbv); } } @@ -2899,7 +2884,7 @@ void DrawBackGround(HWND hwnd,HDC mhdc, HBITMAP hBmpBackground, COLORREF bkColou desth = clRect.bottom -clRect.top; for (;y < maxy;y += desth) { if (y < rcPaint->top-desth) continue; - for(x = 0;x < maxx;x += destw) + for (x = 0;x < maxx;x += destw) StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY); } DeleteDC(hdcBmp); @@ -3651,11 +3636,11 @@ static LRESULT CALLBACK CLUIFrameSubContainerProc(HWND hwnd, UINT msg, WPARAM wP static HWND CreateSubContainerWindow(HWND parent,int x,int y,int width,int height) { HWND hwnd; - hwnd = CreateWindowEx(g_proc_SetLayeredWindowAttributesNew ? WS_EX_LAYERED:0,CLUIFrameSubContainerClassName,TEXT("SubContainerWindow"),WS_POPUP|(!g_CluiData.fLayered ? WS_BORDER : 0),x,y,width,height,parent,0,g_hInst,0); + hwnd = CreateWindowEx(g_proc_SetLayeredWindowAttributesNew ? WS_EX_LAYERED:0,CLUIFrameSubContainerClassName,_T("SubContainerWindow"),WS_POPUP|(!g_CluiData.fLayered ? WS_BORDER : 0),x,y,width,height,parent,0,g_hInst,0); SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)&~(WS_CAPTION|WS_BORDER)); if (g_CluiData.fOnDesktop) { - HWND hProgMan = FindWindow(TEXT("Progman"),NULL); + HWND hProgMan = FindWindow(_T("Progman"),NULL); if (IsWindow(hProgMan)) SetParent(hwnd,hProgMan); } @@ -3885,7 +3870,7 @@ static LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wP }; static HWND CreateContainerWindow(HWND parent,int x,int y,int width,int height) { - return(CreateWindow(TEXT("FramesContainer"),TEXT("FramesContainer"),WS_POPUP|WS_THICKFRAME,x,y,width,height,parent,0,g_hInst,0)); + return(CreateWindow(_T("FramesContainer"),_T("FramesContainer"),WS_POPUP|WS_THICKFRAME,x,y,width,height,parent,0,g_hInst,0)); }; @@ -4092,7 +4077,7 @@ int LoadCLUIFramesModule(void) cntclass.hCursor = LoadCursor(NULL, IDC_ARROW); cntclass.hbrBackground = NULL; cntclass.lpszMenuName = NULL; - cntclass.lpszClassName = TEXT("FramesContainer"); + cntclass.lpszClassName = _T("FramesContainer"); RegisterClass(&cntclass); //end container helper @@ -4110,7 +4095,7 @@ int LoadCLUIFramesModule(void) CreateCluiFramesServices(); - hWndExplorerToolBar = FindWindowEx(0,0,TEXT("Shell_TrayWnd"),NULL); + hWndExplorerToolBar = FindWindowEx(0,0,_T("Shell_TrayWnd"),NULL); OnFrameTitleBarBackgroundChange(0,0); _fCluiFramesModuleNotStarted = FALSE; return 0; @@ -4156,12 +4141,12 @@ int UnLoadCLUIFramesModule(void) g_pfwFrames[i].OwnerWindow = (HWND)-2; if (g_pfwFrames[i].UpdateRgn) DeleteObject(g_pfwFrames[i].UpdateRgn); - if (g_pfwFrames[i].Name != NULL) mir_free_and_nill(g_pfwFrames[i].Name); - if (g_pfwFrames[i].szName != NULL) mir_free_and_nill(g_pfwFrames[i].szName); - if (g_pfwFrames[i].TitleBar.tbname != NULL) mir_free_and_nill(g_pfwFrames[i].TitleBar.tbname); - if (g_pfwFrames[i].TitleBar.sztbname != NULL) mir_free_and_nill(g_pfwFrames[i].TitleBar.sztbname); - if (g_pfwFrames[i].TitleBar.tooltip != NULL) mir_free_and_nill(g_pfwFrames[i].TitleBar.tooltip); - if (g_pfwFrames[i].TitleBar.sztooltip != NULL) mir_free_and_nill(g_pfwFrames[i].TitleBar.sztooltip); + mir_free_and_nil(g_pfwFrames[i].Name); + mir_free_and_nil(g_pfwFrames[i].szName); + mir_free_and_nil(g_pfwFrames[i].TitleBar.tbname); + mir_free_and_nil(g_pfwFrames[i].TitleBar.sztbname); + mir_free_and_nil(g_pfwFrames[i].TitleBar.tooltip); + mir_free_and_nil(g_pfwFrames[i].TitleBar.sztooltip); } if (g_pfwFrames) free(g_pfwFrames); @@ -4192,7 +4177,7 @@ static int _us_DoSetFramePaintProc(WPARAM wParam, LPARAM lParam) int CLUIFrames_SetLayeredMode( BOOL fLayeredMode, HWND hwnd ) { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) { if (fLayeredMode) { diff --git a/plugins/Clist_modern/modern_commonheaders.cpp b/plugins/Clist_modern/modern_commonheaders.cpp index c5d9a7408e..03e8f26487 100644 --- a/plugins/Clist_modern/modern_commonheaders.cpp +++ b/plugins/Clist_modern/modern_commonheaders.cpp @@ -33,7 +33,7 @@ int __cdecl mir_strcmpi(const char *a, const char *b) int __cdecl mir_tstrcmpi(const TCHAR *a, const TCHAR *b) { if (a == NULL && b == NULL) return 0; - if (a == NULL || b == NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT("")); + if (a == NULL || b == NULL) return _tcsicmp(a?a:_T(""),b?b:_T("")); return _tcsicmp(a,b); } BOOL __cdecl mir_bool_strcmpi(const char *a, const char *b) @@ -46,7 +46,7 @@ BOOL __cdecl mir_bool_strcmpi(const char *a, const char *b) BOOL __cdecl mir_bool_tstrcmpi(const TCHAR *a, const TCHAR *b) { if (a == NULL && b == NULL) return 1; - if (a == NULL || b == NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT("")) == 0; + if (a == NULL || b == NULL) return _tcsicmp(a?a:_T(""),b?b:_T("")) == 0; return _tcsicmp(a,b) == 0; } @@ -315,7 +315,7 @@ int UnhookAll() hooksrec[i].hHook = NULL; } } - mir_free_and_nill(hooksrec); + mir_free_and_nil(hooksrec); hooksRecAlloced = 0; return 1; } diff --git a/plugins/Clist_modern/modern_contact.cpp b/plugins/Clist_modern/modern_contact.cpp index fa85d337bb..7142b6dcc2 100644 --- a/plugins/Clist_modern/modern_contact.cpp +++ b/plugins/Clist_modern/modern_contact.cpp @@ -54,7 +54,7 @@ void cli_ChangeContactIcon(HANDLE hContact,int iIcon,int add) static int GetStatusModeOrdering(int statusMode) { int i; - for(i=0;i < SIZEOF(statusModeOrder);i++) + for (i=0;i < SIZEOF(statusModeOrder);i++) if (statusModeOrder[i].m_cache_nStatus == statusMode) return statusModeOrder[i].order; return 1000; } diff --git a/plugins/Clist_modern/modern_docking.cpp b/plugins/Clist_modern/modern_docking.cpp index eda88ce4fc..885c53b9db 100644 --- a/plugins/Clist_modern/modern_docking.cpp +++ b/plugins/Clist_modern/modern_docking.cpp @@ -42,7 +42,7 @@ static int dock_drag_dy = 0; static void Docking_GetMonitorRectFromPoint(POINT pt,RECT *rc) { - HMODULE hUserInstance = GetModuleHandle(TEXT("user32")); + HMODULE hUserInstance = GetModuleHandle(_T("user32")); if ( MyMonitorFromPoint ) { diff --git a/plugins/Clist_modern/modern_extraimage.cpp b/plugins/Clist_modern/modern_extraimage.cpp index f0a5799355..cc27494d61 100644 --- a/plugins/Clist_modern/modern_extraimage.cpp +++ b/plugins/Clist_modern/modern_extraimage.cpp @@ -203,7 +203,7 @@ void ExtraImage_ReloadExtraIcons() //calc only needed protocols //adding protocol icons ProtoEnumAccounts( &count, &accs ); - for(i=0;i < count;i++) + for (i=0;i < count;i++) { if (!IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS,PFLAGNUM_2, 0 ) == 0) continue; @@ -303,7 +303,7 @@ void ExtraImage_SetAllExtraIcons(HWND hwndList,HANDLE hContact) ProtoEnumAccounts( &count, &accs ); maxpr = 0; //calc only needed protocols - for(i=0;i < count;i++) { + for (i=0;i < count;i++) { if ( !IsAccountEnabled( accs[i] ) || CallProtoService(accs[i]->szModuleName,PS_GETCAPS,PFLAGNUM_2,0) == 0) continue; ImgIndex[maxpr] = accs[i]->szModuleName; maxpr++; @@ -343,7 +343,7 @@ void ExtraImage_SetAllExtraIcons(HWND hwndList,HANDLE hContact) if (homepage != NULL) { showweb = TRUE; - mir_free_and_nill(homepage); + mir_free(homepage); } } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_WEB),(showweb)?2:0xFF)); diff --git a/plugins/Clist_modern/modern_framesmenu.cpp b/plugins/Clist_modern/modern_framesmenu.cpp index 27ec830d9f..9fc07f5e07 100644 --- a/plugins/Clist_modern/modern_framesmenu.cpp +++ b/plugins/Clist_modern/modern_framesmenu.cpp @@ -47,13 +47,11 @@ static INT_PTR AddContextFrameMenuItem(WPARAM wParam,LPARAM lParam) static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam,LPARAM lParam) { - lpFrameMenuExecParam fmep; - fmep = (lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA,wParam,lParam); + lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA,wParam,lParam); if (fmep != NULL){ - if (fmep->szServiceName != NULL){ - mir_free_and_nill(fmep->szServiceName); - }; - mir_free_and_nill(fmep); + if (fmep->szServiceName != NULL) + mir_free(fmep->szServiceName); + mir_free(fmep); } if (lParam != 1) diff --git a/plugins/Clist_modern/modern_image_array.cpp b/plugins/Clist_modern/modern_image_array.cpp index 7d0dbd5106..b1dae7be0c 100644 --- a/plugins/Clist_modern/modern_image_array.cpp +++ b/plugins/Clist_modern/modern_image_array.cpp @@ -273,7 +273,7 @@ int ImageArray_AddImage(LP_IMAGE_ARRAY_DATA iad, HBITMAP hBmp, int pos) { w = iad->width; h = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { h += iad->nodes[i].height; } @@ -282,7 +282,7 @@ int ImageArray_AddImage(LP_IMAGE_ARRAY_DATA iad, HBITMAP hBmp, int pos) { h = iad->height; w = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { w += iad->nodes[i].width; } @@ -434,7 +434,7 @@ BOOL ImageArray_ChangeImage(LP_IMAGE_ARRAY_DATA iad, HBITMAP hBmp, int pos) { w = iad->width; h = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { h += iad->nodes[i].height; } @@ -443,7 +443,7 @@ BOOL ImageArray_ChangeImage(LP_IMAGE_ARRAY_DATA iad, HBITMAP hBmp, int pos) { h = iad->height; w = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { w += iad->nodes[i].width; } @@ -578,7 +578,7 @@ BOOL ImageArray_RemoveImage(LP_IMAGE_ARRAY_DATA iad, int pos) { w = iad->width; h = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { h += iad->nodes[i].height; } @@ -587,7 +587,7 @@ BOOL ImageArray_RemoveImage(LP_IMAGE_ARRAY_DATA iad, int pos) { h = iad->height; w = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { w += iad->nodes[i].width; } @@ -667,7 +667,7 @@ BOOL ImageArray_DrawImage(LP_IMAGE_ARRAY_DATA iad, int pos, HDC hdcDest, int nXD { w = 0; h = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { h += iad->nodes[i].height; } @@ -676,7 +676,7 @@ BOOL ImageArray_DrawImage(LP_IMAGE_ARRAY_DATA iad, int pos, HDC hdcDest, int nXD { h = 0; w = 0; - for(i=0; i < pos; i++) + for (i=0; i < pos; i++) { w += iad->nodes[i].width; } diff --git a/plugins/Clist_modern/modern_newrowopts.cpp b/plugins/Clist_modern/modern_newrowopts.cpp index fac4015bad..669fad8fa7 100644 --- a/plugins/Clist_modern/modern_newrowopts.cpp +++ b/plugins/Clist_modern/modern_newrowopts.cpp @@ -69,28 +69,22 @@ NodeList * AddNode(NodeList * Parent) BOOL RemoveChildNode(NodeList * FromList, DWORD index) { - DWORD i; - NodeList * work; if (!FromList) return FALSE; if (FromList->AllocatedChilds <= index) return FALSE; - work = &(FromList->childNodes[index]); - for(i=0; i < work->AllocatedChilds; i++) - { + NodeList *work = &(FromList->childNodes[index]); + for (size_t i=0; i < work->AllocatedChilds; i++) if (work->childNodes[i].AllocatedChilds) RemoveChildNode(work->childNodes,i); - } - if (work->AllocatedChilds) - { - mir_free_and_nill(work->childNodes); + + if (work->AllocatedChilds) { + mir_free_and_nil(work->childNodes); work->AllocatedChilds = 0; } - //mir_free_and_nill(work); memmove(FromList->childNodes+index,FromList->childNodes+index+1,sizeof(NodeList)*(FromList->AllocatedChilds-index-1)); FromList->AllocatedChilds--; return TRUE; } - BOOL RemoveNode(NodeList * FromList) { if (!FromList) return FALSE; @@ -107,9 +101,10 @@ BOOL RemoveNode(NodeList * FromList) do { RemoveChildNode(FromList,0); - }while (FromList->AllocatedChilds>0); - mir_free_and_nill(FromList->childNodes); - mir_free_and_nill(FromList); + } + while (FromList->AllocatedChilds>0); + mir_free_and_nil(FromList->childNodes); + mir_free_and_nil(FromList); return TRUE; } int ident = 0; @@ -131,7 +126,7 @@ void TraceTreeLevel(NodeList * node) TRACE(buf); } ident += 5; - for(i=0; i < node->AllocatedChilds;i++) + for (i=0; i < node->AllocatedChilds;i++) { if (node->childNodes[i].AllocatedChilds>0) @@ -179,7 +174,7 @@ BOOL CALLBACK DlgProcItemNewRowOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA TRACE("*********** Nodes DUMP 2 ***********\n"); TraceTreeLevel(RootNode); //CheckDlgButton(hwndDlg, IDC_HIDE_ICON_ON_AVATAR, DBGetContactSettingByte(NULL,"CList","IconHideOnAvatar",SETTING_HIDEICONONAVATAR_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED ); - MessageBox(hwndDlg,TEXT("Init NewRow Dialog"),TEXT("Notify"),MB_OK); + MessageBox(hwndDlg,_T("Init NewRow Dialog"),_T("Notify"),MB_OK); break; } case WM_NOTIFY: diff --git a/plugins/Clist_modern/modern_row.cpp b/plugins/Clist_modern/modern_row.cpp index e1b9a9d81a..202247e02f 100644 --- a/plugins/Clist_modern/modern_row.cpp +++ b/plugins/Clist_modern/modern_row.cpp @@ -72,10 +72,9 @@ ROWCELL *cppInitModernRow(ROWCELL ** tabAccess) tmplbuf = NULL; if (db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT) == 1) tmplbuf = db_get_sa(NULL,"ModernData","RowTemplate"); - if (tmplbuf) - { + if (tmplbuf) { rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess); - mir_free_and_nill(tmplbuf); + mir_free(tmplbuf); return RowRoot; } if (hFile = fopen("template.txt", "rb")) diff --git a/plugins/Clist_modern/modern_skinbutton.cpp b/plugins/Clist_modern/modern_skinbutton.cpp index b87cd7eaf5..4dfd16484c 100644 --- a/plugins/Clist_modern/modern_skinbutton.cpp +++ b/plugins/Clist_modern/modern_skinbutton.cpp @@ -163,7 +163,7 @@ static int ModernSkinButtonPaintWorker(HWND hwnd, HDC whdc) Value = mir_strdup(_ltoa(defval,buf,SIZEOF(buf))); break; } - mir_free_and_nill(section); + mir_free(section); } } @@ -172,10 +172,9 @@ static int ModernSkinButtonPaintWorker(HWND hwnd, HDC whdc) g_clcPainter.AddParam(&Request,mod_CalcHash("Down"),bct->down?"1":"0",0); g_clcPainter.AddParam(&Request,mod_CalcHash("Focused"),bct->focus?"1":"0",0); g_clcPainter.AddParam(&Request,mod_CalcHash("Hovered"),bct->hover?"1":"0",0); - if (Value) - { + if (Value) { g_clcPainter.AddParam(&Request,mod_CalcHash("Value"),Value,0); - mir_free_and_nill(Value); + mir_free(Value); } SkinDrawGlyphMask(hdc,&rc,&rc,&Request); SkinSelector_DeleteMask(&Request); @@ -241,37 +240,37 @@ static int ModernSkinButtonToggleDBValue(char * ValueDBSection,char *ValueTypeDe l2 = (DWORD)atol(val2); } - switch (ValueTypeDef[0]) - { + switch (ValueTypeDef[0]) { case 's': - { - Value = db_get_sa(NULL,section,key); - if (!Value || (Value && mir_bool_strcmpi(Value,val2))) - Value = mir_strdup(val); - else - Value = mir_strdup(val2); - db_set_s(NULL,section,key,Value); - mir_free_and_nill(Value); - break; - } + Value = db_get_sa(NULL,section,key); + if (!Value || (Value && mir_bool_strcmpi(Value,val2))) + Value = mir_strdup(val); + else + Value = mir_strdup(val2); + db_set_s(NULL,section,key,Value); + mir_free(Value); + break; + case 'd': curval = db_get_dw(NULL,section,key,l2); curval = (curval == l2)?l1:l2; db_set_dw(NULL,section,key,(DWORD)curval); break; + case 'w': curval = db_get_w(NULL,section,key,l2); curval = (curval == l2)?l1:l2; db_set_w(NULL,section,key,(WORD)curval); break; + case 'b': curval = db_get_b(NULL,section,key,l2); curval = (curval == l2)?l1:l2; db_set_b(NULL,section,key,(BYTE)curval); break; } - mir_free_and_nill(section); - mir_free_and_nill(val); + mir_free(section); + mir_free(val); } return 0; } @@ -404,15 +403,14 @@ static LRESULT CALLBACK ModernSkinButtonWndProc(HWND hwndDlg, UINT msg, WPARAM } } LeaveCriticalSection(&csTips); - if (bct->ID) mir_free_and_nill(bct->ID); - if (bct->CommandService) mir_free_and_nill(bct->CommandService); - if (bct->StateService) mir_free_and_nill (bct->StateService); - if (bct->HandleService) mir_free_and_nill(bct->HandleService); - if (bct->Hint) mir_free_and_nill(bct->Hint); - if (bct->ValueDBSection) mir_free_and_nill(bct->ValueDBSection); - if (bct->ValueTypeDef) mir_free_and_nill(bct->ValueTypeDef); - - mir_free_and_nill(bct); + mir_free(bct->ID); + mir_free(bct->CommandService); + mir_free(bct->StateService); + mir_free(bct->HandleService); + mir_free(bct->Hint); + mir_free(bct->ValueDBSection); + mir_free(bct->ValueTypeDef); + mir_free(bct); } SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); break; // DONT! fall thru @@ -541,7 +539,7 @@ HWND SetToolTip(HWND hwnd, TCHAR * tip) if (!tip) return 0; EnterCriticalSection(&csTips); if (!hwndToolTips) { - // hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, TEXT(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); + // hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); hwndToolTips = CreateWindowEx(0, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, @@ -670,7 +668,7 @@ static int ModernSkinButtonErase(int l,int t,int r, int b) if (!g_pCachedWindow->hImageDC || !g_pCachedWindow->hBackDC) return 0; if (!(l || r || t || b)) { - for(i=0; i < ButtonsCount; i++) + for (i=0; i < ButtonsCount; i++) { if (pcli->hwndContactList && Buttons[i].hwnd != NULL) { @@ -710,7 +708,7 @@ int ModernSkinButtonRedrawAll(HDC hdc) DWORD i; if (!ModernSkinButtonModuleIsLoaded) return 0; g_mutex_bLockUpdating++; - for(i=0; i < ButtonsCount; i++) + for (i=0; i < ButtonsCount; i++) { if (pcli->hwndContactList && Buttons[i].hwnd == NULL) Buttons[i].hwnd = ModernSkinButtonCreateWindow(Buttons[i].bct,pcli->hwndContactList); @@ -719,13 +717,17 @@ int ModernSkinButtonRedrawAll(HDC hdc) g_mutex_bLockUpdating--; return 0; } + int ModernSkinButtonDeleteAll() { - DWORD i; - if (!ModernSkinButtonModuleIsLoaded) return 0; - for(i=0; i < ButtonsCount; i++) - if (Buttons[i].hwnd) DestroyWindow(Buttons[i].hwnd); - if (Buttons) mir_free_and_nill(Buttons); + if (!ModernSkinButtonModuleIsLoaded) + return 0; + + for (size_t i=0; i < ButtonsCount; i++) + if (Buttons[i].hwnd) + DestroyWindow(Buttons[i].hwnd); + + mir_free_and_nil(Buttons); ButtonsCount = 0; return 0; } @@ -756,11 +758,10 @@ int ModernSkinButton_ReposButtons(HWND parent, BYTE draw, RECT * r) oldWndSize.cy = sy; } - OffsetRect(&rc,-rc.left,-rc.top); rc.right = rc.left+(clr.right-clr.left); rc.bottom = rc.top+(clr.bottom-clr.top); - for(i=0; i < ButtonsCount; i++) + for (i=0; i < ButtonsCount; i++) { int l,r,b,t; RECT oldRect = {0}; diff --git a/plugins/Clist_modern/modern_skineditor.cpp b/plugins/Clist_modern/modern_skineditor.cpp index 38c9e8bc98..d3ca995c1f 100644 --- a/plugins/Clist_modern/modern_skineditor.cpp +++ b/plugins/Clist_modern/modern_skineditor.cpp @@ -76,8 +76,7 @@ int TreeAddObject(HWND hwndDlg, int ID, OPT_OBJECT_DATA * data) char buf[255]; BOOL ext = FALSE; path = data->szPath?mir_strdup(data->szPath):(data->szName[1] == '$')?mir_strdup((data->szName)+2):NULL; - if (!path) - { + if (!path) { mir_snprintf(buf,SIZEOF(buf),"$(other)/%s",(data->szName)+1); path = mir_strdup(buf); } @@ -112,6 +111,7 @@ int TreeAddObject(HWND hwndDlg, int ID, OPT_OBJECT_DATA * data) } else ext = TRUE; }while (!ext); + //Insert item node { TVINSERTSTRUCTA tvis; @@ -122,7 +122,7 @@ int TreeAddObject(HWND hwndDlg, int ID, OPT_OBJECT_DATA * data) tvis.item.lParam = (LPARAM)data; TreeView_InsertItemA(GetDlgItem(hwndDlg,ID),&tvis); } - mir_free_and_nill(path); + mir_free(path); return 0; } @@ -146,12 +146,11 @@ int enumDB_SkinObjectsForEditorProc(const char *szSetting,LPARAM lParam) a->szTempValue = NULL; TreeAddObject(gl_Dlg,gl_controlID,a); } - else - { - if (value) mir_free_and_nill(value); - if (desc) mir_free_and_nill(desc); + else { + mir_free(value); + mir_free(desc); } - mir_free_and_nill(descKey); + mir_free(descKey); } return 0; } @@ -354,18 +353,17 @@ int GetShortFileName(char * FullFile) if (mir_bool_strcmpi(buf,FullFile)) { _snprintf(FullFile,MAX_PATH,"%s",file); - mir_free_and_nill(file); + mir_free(file); return 1; //skin folder relative } + + CallService(MS_UTILS_PATHTORELATIVE,(WPARAM)FullFile,(LPARAM)buf); + if (buf[0] != '\\' && buf[1] != ':') + _snprintf(FullFile,MAX_PATH,"\\%s",buf); else - { - CallService(MS_UTILS_PATHTORELATIVE,(WPARAM)FullFile,(LPARAM)buf); - if (buf[0] != '\\' && buf[1] != ':') - _snprintf(FullFile,MAX_PATH,"\\%s",buf); - else - _snprintf(FullFile,MAX_PATH,"%s",buf); - } - mir_free_and_nill(file); + _snprintf(FullFile,MAX_PATH,"%s",buf); + + mir_free(file); return 2; //mirand folder relative } @@ -462,12 +460,12 @@ void UpdateInfo(HWND hwndDlg) sd = (OPT_OBJECT_DATA*)(tvi.lParam); if (sd) { - if (sd->szValue) mir_free_and_nill(sd->szValue); + mir_free(sd->szValue); sd->szValue = mir_strdup(b); } } } - mir_free_and_nill(b); + mir_free(b); glSkinWasModified = 1; } @@ -529,15 +527,10 @@ int GetFileSizes(HWND hwndDlg) SendDlgItemMessageA(hwndDlg,IDC_S_SIZE,WM_SETTEXT,0,(LPARAM)buf); return 0; } + INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_DESTROY: - { - if (object_clipboard) mir_free_and_nill(object_clipboard); - break; - } + switch (msg) { case WM_WINDOWPOSCHANGED: { WINDOWPOS * wp = (WINDOWPOS *)lParam; @@ -553,46 +546,45 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } break; } + case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*"); - { //Fill types combo - int i=0; - for (i=0; i < SIZEOF(TYPES); i++) - SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_ADDSTRING,0,(LPARAM)TranslateTS(TYPES[i])); - } - { //Fill fit combo - int i=0; - for (i=0; i < SIZEOF(FITMODES); i++) - SendDlgItemMessage(hwndDlg,IDC_FIT,CB_ADDSTRING,0,(LPARAM)TranslateTS(FITMODES[i])); - } - //SPIN Ranges - { - SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETRANGE,0,MAKELONG(255,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS,0,MAKELONG(255,0)); - - SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETRANGE,0,MAKELONG(900,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETRANGE,0,MAKELONG(900,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETRANGE,0,MAKELONG(900,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETRANGE,0,MAKELONG(900,0)); - - SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_SETRANGE,0,MAKELONG(1000,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_SETRANGE,0,MAKELONG(1000,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_SETRANGE,0,MAKELONG(1000,0)); - SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_SETRANGE,0,MAKELONG(1000,0)); - } - EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),FALSE); - EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE); - EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE); - EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE); - EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE); - glSkinWasModified = 0; - glOtherSkinWasLoaded = FALSE; - break; + TranslateDialogDefault(hwndDlg); + FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*"); + { //Fill types combo + int i=0; + for (i=0; i < SIZEOF(TYPES); i++) + SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_ADDSTRING,0,(LPARAM)TranslateTS(TYPES[i])); + } + { //Fill fit combo + int i=0; + for (i=0; i < SIZEOF(FITMODES); i++) + SendDlgItemMessage(hwndDlg,IDC_FIT,CB_ADDSTRING,0,(LPARAM)TranslateTS(FITMODES[i])); } + //SPIN Ranges + { + SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETRANGE,0,MAKELONG(255,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS,0,MAKELONG(255,0)); + + SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETRANGE,0,MAKELONG(900,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETRANGE,0,MAKELONG(900,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETRANGE,0,MAKELONG(900,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETRANGE,0,MAKELONG(900,0)); + + SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_SETRANGE,0,MAKELONG(1000,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_SETRANGE,0,MAKELONG(1000,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_SETRANGE,0,MAKELONG(1000,0)); + SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_SETRANGE,0,MAKELONG(1000,0)); + } + EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),FALSE); + EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE); + EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE); + EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE); + EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE); + glSkinWasModified = 0; + glOtherSkinWasLoaded = FALSE; + break; case WM_COMMAND: { @@ -602,7 +594,7 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { int i = SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_GETCURSEL,(WPARAM)0,(LPARAM)0); //if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_TYPE))) - SetAppropriateGroups(hwndDlg,i); + SetAppropriateGroups(hwndDlg,i); if (GetFocus() == GetDlgItem(hwndDlg,IDC_TYPE)) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); UpdateInfo(hwndDlg); @@ -613,26 +605,24 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { if (HIWORD(wParam) == BN_CLICKED) { - if (object_clipboard) mir_free_and_nill(object_clipboard); - object_clipboard = NULL; + mir_free_and_nil(object_clipboard); + + OPT_OBJECT_DATA *sd = NULL; + HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE)); + if (hti != 0) { - OPT_OBJECT_DATA *sd = NULL; - HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE)); - if (hti != 0) - { - TVITEM tvi = {0}; - tvi.hItem = hti; - tvi.mask = TVIF_HANDLE|TVIF_PARAM; - TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi); - sd = (OPT_OBJECT_DATA*)(tvi.lParam); - } - if (sd && sd->szValue) - object_clipboard = mir_strdup(sd->szValue); + TVITEM tvi = {0}; + tvi.hItem = hti; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi); + sd = (OPT_OBJECT_DATA*)(tvi.lParam); } + if (sd && sd->szValue) + object_clipboard = mir_strdup(sd->szValue); + EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard != NULL); return 0; } - } else if (LOWORD(wParam) == IDC_PASTE) { @@ -675,23 +665,12 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ske_GetFullFilename(str,str,(char*)0,TRUE); } ofn.lpstrFile = str; - + ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = "*.*"; -// { -// DWORD tick = GetTickCount(); - res = GetOpenFileNameA(&ofn); -// if (!res) -// if (GetTickCount()-tick < 100) -// { -// res = GetOpenFileNameA(&ofn); -// if (!res) break; -// } -// else break; - //} - if (res) - { + res = GetOpenFileNameA(&ofn); + if (res) { GetShortFileName(ofn.lpstrFile); SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_SETTEXT,(WPARAM)0,(LPARAM)ofn.lpstrFile); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -722,16 +701,16 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } else if (( (LOWORD(wParam) == IDC_E_TOP - || LOWORD(wParam) == IDC_E_BOTTOM - || LOWORD(wParam) == IDC_E_LEFT - || LOWORD(wParam) == IDC_E_RIGHT - || LOWORD(wParam) == IDC_E_X - || LOWORD(wParam) == IDC_E_Y - || LOWORD(wParam) == IDC_E_W - || LOWORD(wParam) == IDC_E_H - || LOWORD(wParam) == IDC_EDIT_ALPHA - ) - && HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) + || LOWORD(wParam) == IDC_E_BOTTOM + || LOWORD(wParam) == IDC_E_LEFT + || LOWORD(wParam) == IDC_E_RIGHT + || LOWORD(wParam) == IDC_E_X + || LOWORD(wParam) == IDC_E_Y + || LOWORD(wParam) == IDC_E_W + || LOWORD(wParam) == IDC_E_H + || LOWORD(wParam) == IDC_EDIT_ALPHA + ) + && HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) { return 0; } @@ -745,59 +724,55 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; } case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) - { + switch (((LPNMHDR)lParam)->idFrom) { case IDC_OBJECT_TREE: + { + //Save existed object + //Change to new object + NMTREEVIEWA * nmtv = (NMTREEVIEWA *) lParam; + if (!nmtv) return 0; + if (nmtv->hdr.code == TVN_SELCHANGEDA || nmtv->hdr.code == TVN_SELCHANGEDW) { - //Save existed object - //Change to new object - NMTREEVIEWA * nmtv = (NMTREEVIEWA *) lParam; - if (!nmtv) return 0; - if (nmtv->hdr.code == TVN_SELCHANGEDA || nmtv->hdr.code == TVN_SELCHANGEDW) + if (nmtv->itemOld.lParam) { - if (nmtv->itemOld.lParam) - { - OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam; - if (dataOld->szValue) - { - mir_free_and_nill(dataOld->szValue); - dataOld->szValue = MadeString(hwndDlg); - } - } - if (nmtv->itemNew.lParam) - { - - OPT_OBJECT_DATA * data = (OPT_OBJECT_DATA*)nmtv->itemNew.lParam; - char buf[255]; - - mir_snprintf(buf,SIZEOF(buf),"%s = %s",data->szName, data->szValue); - SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)buf); - SetControls(hwndDlg,data->szValue); - EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),TRUE); - EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard != NULL); - } - else - { - SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)""); - SetControls(hwndDlg,NULL); - EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE); + OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam; + if (dataOld->szValue) { + mir_free(dataOld->szValue); + dataOld->szValue = MadeString(hwndDlg); } - } - else if (nmtv->hdr.code == TVN_DELETEITEMA) + if (nmtv->itemNew.lParam) { - OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam; - if (dataOld) - { - if (dataOld->szName) mir_free_and_nill(dataOld->szName); - if (dataOld->szPath) mir_free_and_nill(dataOld->szPath); - if (dataOld->szTempValue) mir_free_and_nill(dataOld->szTempValue); - if (dataOld->szValue) mir_free_and_nill(dataOld->szValue); - } + OPT_OBJECT_DATA * data = (OPT_OBJECT_DATA*)nmtv->itemNew.lParam; + char buf[255]; + + mir_snprintf(buf,SIZEOF(buf),"%s = %s",data->szName, data->szValue); + SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)buf); + SetControls(hwndDlg,data->szValue); + EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),TRUE); + EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard != NULL); } - return 0; + else + { + SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)""); + SetControls(hwndDlg,NULL); + EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE); + EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE); + } + } + else if (nmtv->hdr.code == TVN_DELETEITEMA) + { + OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam; + if (dataOld) { + mir_free_and_nil(dataOld->szName); + mir_free_and_nil(dataOld->szPath); + mir_free_and_nil(dataOld->szTempValue); + mir_free_and_nil(dataOld->szValue); + } + } + return 0; + } case 0: switch (((LPNMHDR)lParam)->code) @@ -825,6 +800,11 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } break; } + + case WM_DESTROY: + mir_free(object_clipboard); + break; + } return FALSE; } @@ -834,12 +814,13 @@ int EnableGroup(HWND hwndDlg, HWND first, BOOL bEnable) HWND hwnd = first; BOOL exit = FALSE; if (!hwnd) return 0; - do + do { EnableWindow(hwnd,bEnable); hwnd = GetWindow(hwnd,GW_HWNDNEXT); if (!hwnd || GetWindowLongPtr(hwnd,GWL_STYLE)&WS_GROUP) exit = TRUE; - }while (!exit); + } + while (!exit); return 0; } @@ -848,12 +829,13 @@ int ShowGroup(HWND hwndDlg, HWND first, BOOL bEnable) HWND hwnd = first; BOOL exit = FALSE; if (!hwnd) return 0; - do + do { ShowWindow(hwnd,bEnable?SW_SHOW:SW_HIDE); hwnd = GetWindow(hwnd,GW_HWNDNEXT); if (!hwnd || GetWindowLongPtr(hwnd,GWL_STYLE)&WS_GROUP) exit = TRUE; - }while (!exit); + } + while (!exit); return 0; } diff --git a/plugins/Clist_modern/modern_skinengine.cpp b/plugins/Clist_modern/modern_skinengine.cpp index 81db118868..8f2911c8e9 100644 --- a/plugins/Clist_modern/modern_skinengine.cpp +++ b/plugins/Clist_modern/modern_skinengine.cpp @@ -264,11 +264,11 @@ int IniParser::GetSkinFolder( IN const TCHAR * szFileName, OUT TCHAR * pszFolder if ( cus && _tcslen(cus)>0) _sntprintf(pszFolderName,MAX_PATH,_T("%s\\%s"),custom_folder,cus); - mir_free_and_nill(szBuff); + mir_free(szBuff); CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)pszFolderName, (LPARAM)pszFolderName); - return 0; } + void IniParser::_DoInit() { _isValid = false; @@ -463,7 +463,7 @@ HRESULT SkinEngineLoadModule() hImageDecoderModule = NULL; if (g_CluiData.fGDIPlusFail) { - hImageDecoderModule = LoadLibrary(TEXT("ImgDecoder.dll")); + hImageDecoderModule = LoadLibrary(_T("ImgDecoder.dll")); if (hImageDecoderModule == NULL) { char tDllPath[ MAX_PATH ]; @@ -510,26 +510,22 @@ int SkinEngineUnloadModule() ModernUnhookEvent(hSkinLoadedEvent); ModernSkinButtonUnloadModule(0,0); ske_UnloadSkin(&g_SkinObjectList); - if (g_SkinObjectList.pObjects) - mir_free_and_nill(g_SkinObjectList.pObjects); - if (g_SkinObjectList.pMaskList) - mir_free_and_nill(g_SkinObjectList.pMaskList); - if (MainModernMaskList) - mir_free_and_nill(MainModernMaskList); + + mir_free_and_nil(g_SkinObjectList.pObjects); + mir_free_and_nil(g_SkinObjectList.pMaskList); + mir_free_and_nil(MainModernMaskList); + if (pEffectStack) { - int i; - for (i=0; i < pEffectStack->realCount; i++) - if (pEffectStack->items[i]) - { + for (int i=0; i < pEffectStack->realCount; i++) + if (pEffectStack->items[i]) { EFFECTSSTACKITEM * effect = (EFFECTSSTACKITEM*)(pEffectStack->items[i]); - mir_free_and_nill(effect); + mir_free(effect); } - List_Destroy(pEffectStack); - mir_free_and_nill(pEffectStack); + List_Destroy(pEffectStack); + mir_free_and_nil(pEffectStack); } - if (g_pCachedWindow) - { + if (g_pCachedWindow) { SelectObject(g_pCachedWindow->hBackDC,g_pCachedWindow->hBackOld); SelectObject(g_pCachedWindow->hImageDC,g_pCachedWindow->hImageOld); DeleteObject(g_pCachedWindow->hBackDIB); @@ -537,8 +533,7 @@ int SkinEngineUnloadModule() mod_DeleteDC(g_pCachedWindow->hBackDC); mod_DeleteDC(g_pCachedWindow->hImageDC); ReleaseDC(NULL,g_pCachedWindow->hScreenDC); - mir_free_and_nill(g_pCachedWindow); - g_pCachedWindow = NULL; + mir_free_and_nil(g_pCachedWindow); } DeleteCriticalSection(&cs_SkinChanging); GdiFlush(); @@ -552,8 +547,6 @@ int SkinEngineUnloadModule() return 1; } - - 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) { if (g_CluiData.fDisableSkinEngine && !(!g_CluiData.fGDIPlusFail && blendFunction.BlendFlags&128)) @@ -574,12 +567,12 @@ BOOL ske_AlphaBlend(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest return AlphaBlend(hdcDest,nXOriginDest,nYOriginDest,nWidthDest,nHeightDest,hdcSrc,nXOriginSrc,nYOriginSrc,nWidthSrc,nHeightSrc,blendFunction); } - static int ske_LockSkin() { EnterCriticalSection(&cs_SkinChanging); return 0; } + static int ske_UnlockSkin() { LeaveCriticalSection(&cs_SkinChanging); @@ -714,7 +707,7 @@ BOOL ske_SetRgnOpaque(HDC memdc,HRGN hrgn, BOOL force) { ske_SetRectOpaque(memdc,&rect[d], force); } - mir_free_and_nill(rdata); + mir_free(rdata); return TRUE; } @@ -1633,10 +1626,10 @@ int ske_AddDescriptorToSkinObjectList (LPSKINOBJECTDESCRIPTOR lpDescr, SKINOBJEC if (gl->szFileName != NULL) { obdat->szFileName = mir_strdup(gl->szFileName); - mir_free_and_nill(gl->szFileName); + mir_free_and_nil(gl->szFileName); } - else - obdat->szFileName = NULL; + else obdat->szFileName = NULL; + obdat->hGlyph = NULL; break; } @@ -1797,7 +1790,7 @@ int ske_GetFullFilename(char * buf, char *file, char * skinfolder,BOOL madeAbsol else memcpy(buf,b2,MAX_PATH); - if (SkinPlace) mir_free_and_nill(SkinPlace); + mir_free(SkinPlace); return 0; } @@ -2141,6 +2134,7 @@ HBITMAP ske_LoadGlyphImage(char * szFileName) ske_UnlockSkin(); return hbmp; } + int ske_UnloadGlyphImage(HBITMAP hbmp) { DWORD i; @@ -2152,14 +2146,14 @@ int ske_UnloadGlyphImage(HBITMAP hbmp) if (pLoadedImages[i].dwLoadedTimes == 0) { LPGLYPHIMAGE gl = &(pLoadedImages[i]); - if (gl->szFileName) mir_free_and_nill(gl->szFileName); + mir_free_and_nil(gl->szFileName); memmove(&(pLoadedImages[i]),&(pLoadedImages[i+1]),sizeof(GLYPHIMAGE)*(dwLoadedImagesCount-i-1)); dwLoadedImagesCount--; DeleteObject(hbmp); if (pLoadedImages && dwLoadedImagesCount == 0) { dwLoadedImagesAlocated = 0; - mir_free_and_nill(pLoadedImages); + mir_free_and_nil(pLoadedImages); } } return 0; @@ -2172,32 +2166,27 @@ int ske_UnloadGlyphImage(HBITMAP hbmp) int ske_UnloadSkin(SKINOBJECTSLIST * Skin) { - DWORD i; ske_LockSkin(); ClearMaskList(Skin->pMaskList); - {//clear font list - int i; - if (gl_plSkinFonts && gl_plSkinFonts->realCount>0) - { - for (i=0; i < gl_plSkinFonts->realCount; i++) - { - SKINFONT * sf = (SKINFONT *)gl_plSkinFonts->items[i]; - if (sf) - { - if (sf->szFontID) mir_free_and_nill(sf->szFontID); - DeleteObject(sf->hFont); - mir_free_and_nill(sf); - } + + //clear font list + if (gl_plSkinFonts && gl_plSkinFonts->realCount > 0) { + for (int i=0; i < gl_plSkinFonts->realCount; i++) { + SKINFONT * sf = (SKINFONT *)gl_plSkinFonts->items[i]; + if (sf) { + mir_free(sf->szFontID); + DeleteObject(sf->hFont); + mir_free(sf); } - List_Destroy(gl_plSkinFonts); - mir_free_and_nill(gl_plSkinFonts); } + List_Destroy(gl_plSkinFonts); + mir_free_and_nil(gl_plSkinFonts); } - if (Skin->szSkinPlace) mir_free_and_nill(Skin->szSkinPlace); + mir_free_and_nil(Skin->szSkinPlace); if (Skin->pTextList) List_Destroy(Skin->pTextList); - mir_free_and_nill(Skin->pTextList); + mir_free_and_nil(Skin->pTextList); ModernSkinButtonDeleteAll(); if (Skin->dwObjLPAlocated == 0) { ske_UnlockSkin(); return 0;} for (i=0; i < Skin->dwObjLPAlocated; i++) @@ -2211,7 +2200,7 @@ int ske_UnloadSkin(SKINOBJECTSLIST * Skin) if (dt->hGlyph && dt->hGlyph != (HBITMAP)-1) ske_UnloadGlyphImage(dt->hGlyph); dt->hGlyph = NULL; - if (dt->szFileName) mir_free_and_nill(dt->szFileName); + mir_free_and_nil(dt->szFileName); {// delete texts int i; if (dt->plTextList && dt->plTextList->realCount>0) @@ -2219,27 +2208,26 @@ int ske_UnloadSkin(SKINOBJECTSLIST * Skin) for (i=0; i < dt->plTextList->realCount; i++) { GLYPHTEXT * gt = (GLYPHTEXT *)dt->plTextList->items[i]; - if (gt) - { - if (gt->stText) mir_free_and_nill(gt->stText); - if (gt->stValueText) mir_free_and_nill(gt->stValueText); - if (gt->szFontID) mir_free_and_nill(gt->szFontID); - if (gt->szGlyphTextID)mir_free_and_nill(gt->szGlyphTextID); - mir_free_and_nill(gt); + if (gt) { + mir_free(gt->stText); + mir_free(gt->stValueText); + mir_free(gt->szFontID); + mir_free(gt->szGlyphTextID); + mir_free(gt); } } List_Destroy(dt->plTextList); - mir_free_and_nill(dt->plTextList); + mir_free(dt->plTextList); } } - mir_free_and_nill(dt); + mir_free(dt); } break; } - if (Skin->pObjects[i].szObjectID) mir_free_and_nill(Skin->pObjects[i].szObjectID); + mir_free_and_nil(Skin->pObjects[i].szObjectID); } - mir_free_and_nill(Skin->pObjects); + mir_free_and_nil(Skin->pObjects); Skin->pTextList = NULL; Skin->dwObjLPAlocated = 0; Skin->dwObjLPReserved = 0; @@ -2261,7 +2249,7 @@ static void RegisterMaskByParce(const char * szSetting, char * szValue, SKINOBJE strncpy(Obj,szValue,i); Obj[i] = '\0'; res = AddStrModernMaskToList(ID,Mask,Obj,pSkin->pMaskList,pSkin); - mir_free_and_nill(Obj); + mir_free(Obj); } } @@ -2286,7 +2274,7 @@ static int ske_enumdb_SkinObjectsProc (const char *szSetting,LPARAM lParam) char *value; value = db_get_sa(NULL,SKIN,szSetting); ske_ProcessLoadindString(szSetting,value); - mir_free_and_nill(value); + mir_free_and_nil(value); return 0; } @@ -2304,7 +2292,7 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList) { MODERNMASK *mm = &(pObjectList->pMaskList->pl_Masks[i]); void * pObject = (void*) ske_FindObjectByName(mm->szObjectName, OT_ANY, (SKINOBJECTSLIST*) pObjectList); - mir_free_and_nill(mm->szObjectName); + mir_free_and_nil(mm->szObjectName); mm->bObjectFound = TRUE; mm->pObject = pObject; } @@ -2320,7 +2308,7 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList) SKINOBJECTDESCRIPTOR * lpobj; glText = (GLYPHTEXT *)pObjectList->pTextList->items[i]; lpobj = ske_FindObjectByName(glText->szObjectName,OT_GLYPHOBJECT, pObjectList); - mir_free_and_nill(glText->szObjectName); + mir_free_and_nil(glText->szObjectName); if (lpobj) globj = (GLYPHOBJECT*)lpobj->Data; if (globj) @@ -2336,19 +2324,18 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList) } else { - GLYPHTEXT * gt = glText; - if (gt) - { - if (gt->stText) mir_free_and_nill(gt->stText); - if (gt->stValueText) mir_free_and_nill(gt->stValueText); - if (gt->szFontID) mir_free_and_nill(gt->szFontID); - if (gt->szGlyphTextID)mir_free_and_nill(gt->szGlyphTextID); - mir_free_and_nill(gt); + GLYPHTEXT *gt = glText; + if (gt) { + mir_free(gt->stText); + mir_free(gt->stValueText); + mir_free(gt->szFontID); + mir_free(gt->szGlyphTextID); + mir_free(gt); } } } List_Destroy(pObjectList->pTextList); - mir_free_and_nill(pObjectList->pTextList); + mir_free_and_nil(pObjectList->pTextList); } } // Getting skin objects and masks from DB @@ -2408,203 +2395,7 @@ void ske_LoadSkinFromDB(void) g_CluiData.dwKeyColor = db_get_dw(NULL,"ModernSettings","KeyColor",(DWORD)SETTING_KEYCOLOR_DEFAULT); } - - -// - - -/* -static BOOL ske_ParseLineOfIniFile(char * Line, BOOL bOnlyObjects) -{ - DWORD i=0; - DWORD len = strlen(Line); - while (i < len && (Line[i] == ' ' || Line[i] == '\t')) i++; //skip spaces&tabs - if (i >= len) return FALSE; //only spaces (or tabs) - if (len>0 && Line[len-1] == 10) Line[len-1] = '\0'; - switch(Line[i]) - { - case ';': - return FALSE; // start of comment is found - case '[': - //New section start here - if (iniCurrentSection) mir_free_and_nill(iniCurrentSection); - { - char *tbuf = Line+i+1; - DWORD len2 = strlen(tbuf); - DWORD k = len2; - while (k>0 && tbuf[k] != ']') k--; //searching close bracket - tbuf[k] = '\0'; //closing string - if (k == 0) return FALSE; - iniCurrentSection = mir_strdup(tbuf); - } - return TRUE; - default: - if (!iniCurrentSection) return FALSE; //param found out of section - { - char *keyName = Line+i; - char *keyValue = Line+i; - - DWORD eqPlace = 0; - DWORD len2 = strlen(keyName); - while (eqPlace < len2 && keyName[eqPlace] != '=') eqPlace++; //find '=' - if (eqPlace == 0 || eqPlace == len2) return FALSE; // = not found or no key name - keyName[eqPlace] = '\0'; - keyValue = keyName+eqPlace+1; - //remove tail spaces in Name - { - DWORD len3 = strlen(keyName); - int j = len3-1; - while (j>0 && (keyName[j] == ' ' || keyName[j] == '\t')) j--; - if (j >= 0) keyName[j+1] = '\0'; - } - //remove start spaces in Value - { - DWORD len3 = strlen(keyValue); - DWORD j = 0; - while (j < len3 && (keyValue[j] == ' ' || keyValue[j] == '\t')) j++; - if (j < len3) keyValue += j; - } - //remove tail spaces in Value - { - DWORD len3 = strlen(keyValue); - int j = len3-1; - while (j>0 && (keyValue[j] == ' ' || keyValue[j] == '\t')) j--; - if (j >= 0) keyValue[j+1] = '\0'; - } - ske_WriteParamToDatabase(iniCurrentSection,keyName,keyValue,TRUE); - } - } - return FALSE; -} -*/ -//Load data from ini file - - - -//int ske_OldLoadSkinFromIniFile(char * szFileName) -//{ -// char bsn[MAXSN_BUFF_SIZE]; -// char * Buff; -// -// int i=0; -// int f = 0; -// int ReadingSection = 0; -// char AllowedSection[260]; -// int AllowedAll = 0; -// char t2[MAX_PATH]; -// char t3[MAX_PATH]; -// -// DWORD retu = GetPrivateProfileSectionNamesA(bsn,MAXSN_BUFF_SIZE,szFileName); -// ske_DeleteAllSettingInSection("ModernSkin"); -// ske_GetSkinFolder(szFileName,t2); -// db_set_s(NULL,SKIN,"SkinFolder",t2); -// CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)szFileName, (LPARAM)t3); -// db_set_s(NULL,SKIN,"SkinFile",t3); -// Buff = bsn; -// AllowedSection[0] = 0; -// do -// { -// f = mir_strlen(Buff); -// if (f>0 && !mir_bool_strcmpi(Buff,"Skin_Description_Section")) -// { -// char b3[MAX_BUFF_SIZE]; -// DWORD ret = 0; -// ret = GetPrivateProfileSectionA(Buff,b3,MAX_BUFF_SIZE,szFileName); -// if (ret>MAX_BUFF_SIZE-3) continue; -// if (ret == 0) continue; -// { -// DWORD p = 0; -// char *s1; -// char *s2; -// char *s3; -// { -// DWORD t; -// BOOL LOCK = FALSE; -// for (t = 0; t < ret-1;t++) -// { -// if (b3[t] == '\0') LOCK = FALSE; -// if (b3[t] == '=' && !LOCK) -// { -// b3[t] = '\0'; -// LOCK = TRUE; -// } -// } -// } -// do -// { -// s1 = b3+p; -// -// s2 = s1+mir_strlen(s1)+1; -// switch (s2[0]) -// { -// case 'b': -// { -// BYTE P; -// // char ba[255]; -// s3 = s2+1; -// P = (BYTE)atoi(s3); -// db_set_b(NULL,Buff,s1,P); -// } -// break; -// case 'w': -// { -// WORD P; -// // char ba[255]; -// s3 = s2+1; -// P = (WORD)atoi(s3); -// db_set_w(NULL,Buff,s1,P); -// }break; -// case 'd': -// { -// DWORD P; // -// s3 = s2+1; -// P = (DWORD)atoi(s3); -// db_set_dw(NULL,Buff,s1,P); -// }break; -// case 's': -// { -// // char ba[255]; -// char bb[255]; -// s3 = s2+1; -// strncpy(bb,s3,sizeof(bb)); -// db_set_s(NULL,Buff,s1,s3); -// }break; -// case 'f': //file -// { -// // char ba[255]; -// char bb[255]; -// -// s3 = s2+1; -// { -// char fn[MAX_PATH]; -// int pp, i; -// pp = -1; -// CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)szFileName, (LPARAM)fn); -// { -// for (i=0; i < mir_strlen(fn); i++) if (fn[i] == '.') pp = i; -// if (pp != -1) -// { -// fn[pp] = '\0'; -// } -// } -// sprintf(bb,"%s\\%s",fn,s3); -// db_set_s(NULL,Buff,s1,bb); -// } -// }break; -// } -// p = p+mir_strlen(s1)+mir_strlen(s2)+2; -// } while (p < ret); -// -// } -// } -// Buff += mir_strlen(Buff)+1; -// }while (((DWORD)Buff-(DWORD)bsn) < retu); -// return 0; -//} -// - - static int ske_LoadSkinFromResource(BOOL bOnlyObjects) { @@ -2686,7 +2477,7 @@ BOOL ske_TextOutA(HDC hdc, int x, int y, char * lpString, int nCount) BOOL res; MultiByteToWideChar(CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 ), 0, lpString, -1, buf, (2+nCount)*sizeof(TCHAR)); res = ske_TextOut(hdc,x,y,buf,nCount); - mir_free_and_nill(buf); + mir_free(buf); return res; } @@ -2752,7 +2543,7 @@ BOOL ske_ResetTextEffect(HDC hdc) if (pEffectStack->items[i] && ((EFFECTSSTACKITEM*)(pEffectStack->items[i]))->hdc == hdc) { EFFECTSSTACKITEM * effect = (EFFECTSSTACKITEM*)(pEffectStack->items[i]); - mir_free_and_nill(effect); + mir_free(effect); List_Remove(pEffectStack,i); return TRUE; } @@ -3656,7 +3447,7 @@ static INT_PTR ske_Service_UpdateFrameImage(WPARAM wParam, LPARAM lParam) { int i; frm->bQueued = 0; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (IsAnyQueued |= g_pfwFrames[i].bQueued) break; } } @@ -4018,7 +3809,7 @@ int ske_DrawNonFramedObjects(BOOL Erase,RECT *r) //--Draw frames captions { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (g_pfwFrames[i].TitleBar.ShowTitleBar && g_pfwFrames[i].visible && !g_pfwFrames[i].floating) { RECT rc; @@ -4093,7 +3884,7 @@ int ske_ValidateFrameImageProc(RECT * r) // Calli //-- Validating frames { int i; - for(i=0;i < g_nFramesCount;i++) + for (i=0;i < g_nFramesCount;i++) if (g_pfwFrames[i].PaintCallbackProc && g_pfwFrames[i].visible && !g_pfwFrames[i].floating ) if (g_pfwFrames[i].bQueued || IsForceAllPainting) ske_ValidateSingleFrameImage(&g_pfwFrames[i],IsForceAllPainting); @@ -4266,7 +4057,7 @@ static TCHAR *ske_ReAppend(TCHAR *lfirst, TCHAR * lsecond, int len) TCHAR* ske_ReplaceVar(TCHAR *var) { if (!var) return mir_tstrdup(_T("")); - if (!lstrcmpi(var,TEXT("Profile"))) + if (!lstrcmpi(var,_T("Profile"))) { char buf[MAX_PATH] = {0}; CallService(MS_DB_GETPROFILENAME,(WPARAM)MAX_PATH,(LPARAM)buf); @@ -4275,11 +4066,11 @@ TCHAR* ske_ReplaceVar(TCHAR *var) while (buf[i] != '.' && i>0) i--; buf[i] = '\0'; } - mir_free_and_nill(var); + mir_free(var); return mir_a2u(buf); } - mir_free_and_nill(var); + mir_free(var); return mir_tstrdup(_T("")); } TCHAR *ske_ParseText(TCHAR *stzText) @@ -4310,10 +4101,10 @@ TCHAR *ske_ParseText(TCHAR *stzText) var[curpos-stpos] = (TCHAR)'\0'; var = ske_ReplaceVar(var); result = ske_ReAppend(result,var,0); - mir_free_and_nill(var); + mir_free(var); } - else - result = ske_ReAppend(result,_T("%"),0); + else result = ske_ReAppend(result,_T("%"),0); + curpos++; stpos = curpos; } diff --git a/plugins/Clist_modern/modern_skinopt.cpp b/plugins/Clist_modern/modern_skinopt.cpp index 9cdc929fc7..ef4b1532b8 100644 --- a/plugins/Clist_modern/modern_skinopt.cpp +++ b/plugins/Clist_modern/modern_skinopt.cpp @@ -412,7 +412,7 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara else if ( nmtv->hdr.code == TVN_DELETEITEMA || nmtv->hdr.code == TVN_DELETEITEMW ) { if ( nmtv->itemOld.lParam ) - mir_free_and_nill( nmtv->itemOld.lParam ); + mir_free_and_nil( nmtv->itemOld.lParam ); return 0; } break; @@ -480,7 +480,7 @@ HTREEITEM FillAvailableSkinList( HWND hwndDlg ) if ( !SkinsFolder ) SkinsFolder = mir_tstrdup( _T("Skins")); CallService( MS_UTILS_PATHTOABSOLUTET, ( WPARAM )SkinsFolder, ( LPARAM )path ); - mir_free_and_nill( SkinsFolder ); + mir_free_and_nil( SkinsFolder ); AddSkinToList( hwndDlg, TranslateT( "Default Skin" ), _T("%Default Skin%")); attrib = GetFileAttributes( path ); @@ -495,7 +495,7 @@ HTREEITEM FillAvailableSkinList( HWND hwndDlg ) CallService( MS_UTILS_PATHTOABSOLUTET, ( WPARAM )skinfile, ( LPARAM )skinfull ); res = AddSkinToListFullName( hwndDlg, skinfull ); - mir_free_and_nill( skinfile ); + mir_free_and_nil( skinfile ); } } return res; @@ -658,7 +658,7 @@ HTREEITEM AddItemToTree( HWND hTree, TCHAR * folder, TCHAR * itemName, void * da } else { - mir_free_and_nill( data ); //need to free otherwise memory leak + mir_free_and_nil( data ); //need to free otherwise memory leak return cItem; } return 0; diff --git a/plugins/Clist_modern/modern_skinselector.cpp b/plugins/Clist_modern/modern_skinselector.cpp index 3b4f00ba23..45f66d51bb 100644 --- a/plugins/Clist_modern/modern_skinselector.cpp +++ b/plugins/Clist_modern/modern_skinselector.cpp @@ -186,7 +186,7 @@ lph_top: //only 4 of 9 instructions in here don't use AL, so optimal pipe use i DWORD hash = 0; int i; int shift = 0; - for(i=0;szStr[i];i++) { + for (i=0;szStr[i];i++) { hash ^= szStr[i] << shift; if (shift>24) hash ^= (szStr[i]>>(32-shift))&0x7F; shift = (shift+5)&0x1F; @@ -225,10 +225,9 @@ int ClearMaskList(LISTMODERNMASK * mmTemplateList) int i; if (!mmTemplateList) return -1; if (!mmTemplateList->pl_Masks) return -1; - for(i=0; i < (int)mmTemplateList->dwMaskCnt; i++) + for (i=0; i < (int)mmTemplateList->dwMaskCnt; i++) SkinSelector_DeleteMask(&(mmTemplateList->pl_Masks[i])); - mir_free_and_nill(mmTemplateList->pl_Masks); - mmTemplateList->pl_Masks = NULL; + mir_free_and_nil(mmTemplateList->pl_Masks); mmTemplateList->dwMaskCnt = 0; return 0; } @@ -239,7 +238,7 @@ int DeleteMaskByItID(DWORD mID,LISTMODERNMASK * mmTemplateList) if (mmTemplateList->dwMaskCnt == 1) { SkinSelector_DeleteMask(&(mmTemplateList->pl_Masks[0])); - mir_free_and_nill(mmTemplateList->pl_Masks); + mir_free_and_nil(mmTemplateList->pl_Masks); mmTemplateList->pl_Masks = NULL; mmTemplateList->dwMaskCnt; } @@ -255,7 +254,7 @@ int DeleteMaskByItID(DWORD mID,LISTMODERNMASK * mmTemplateList) newAlocation[i] = mmTemplateList->pl_Masks[i+1]; newAlocation[i].dwMaskId = i; } - mir_free_and_nill(mmTemplateList->pl_Masks); + mir_free_and_nil(mmTemplateList->pl_Masks); mmTemplateList->pl_Masks = newAlocation; mmTemplateList->dwMaskCnt--; } @@ -575,7 +574,7 @@ TCHAR * GetParamNT(char * string, TCHAR * buf, int buflen, BYTE paramN, char Del char *ansibuf = (char*)mir_alloc(buflen/sizeof(TCHAR)); GetParamN(string, ansibuf, buflen/sizeof(TCHAR), paramN, Delim, SkipSpaces); MultiByteToWideChar(CP_UTF8,0,ansibuf,-1,buf,buflen); - mir_free_and_nill(ansibuf); + mir_free(ansibuf); return buf; } @@ -746,8 +745,8 @@ int RegisterObjectByParce(char * ObjectName, char * Params) } obj.Data = ≷ res = ske_AddDescriptorToSkinObjectList(&obj,NULL); - mir_free_and_nill(obj.szObjectID); - if (gl.szFileName) mir_free_and_nill(gl.szFileName); + mir_free_and_nil(obj.szObjectID); + mir_free_and_nil(gl.szFileName); return res; } break; diff --git a/plugins/Clist_modern/modern_statusbar.cpp b/plugins/Clist_modern/modern_statusbar.cpp index a147d1b955..2a641ccca5 100644 --- a/plugins/Clist_modern/modern_statusbar.cpp +++ b/plugins/Clist_modern/modern_statusbar.cpp @@ -205,21 +205,16 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) { ProtoEnumAccounts( &protoCount, &accs ); - if (allocedItemData && ProtosData) - { - int k; - - for (k = 0; k < allocedItemData; k++) - { - if (ProtosData[k].ProtoXStatus) mir_free_and_nill (ProtosData[k].ProtoXStatus); - if (ProtosData[k].ProtoName) mir_free_and_nill (ProtosData[k].ProtoName); - if (ProtosData[k].AccountName) mir_free_and_nill (ProtosData[k].AccountName); - if (ProtosData[k].ProtoHumanName) mir_free_and_nill (ProtosData[k].ProtoHumanName); - if (ProtosData[k].ProtoEMailCount) mir_free_and_nill (ProtosData[k].ProtoEMailCount); - if (ProtosData[k].ProtoStatusText) mir_free_and_nill (ProtosData[k].ProtoStatusText); + if (allocedItemData && ProtosData) { + for (int k = 0; k < allocedItemData; k++) { + mir_free(ProtosData[k].ProtoXStatus); + mir_free(ProtosData[k].ProtoName); + mir_free(ProtosData[k].AccountName); + mir_free(ProtosData[k].ProtoHumanName); + mir_free(ProtosData[k].ProtoEMailCount); + mir_free(ProtosData[k].ProtoStatusText); } - mir_free_and_nill(ProtosData); - ProtosData = NULL; + mir_free_and_nil(ProtosData); allocedItemData = 0; } if ( protoCount == 0 ) @@ -399,7 +394,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) rectwidth = rc.right-rc.left-g_StatusBarData.rectBorders.left-g_StatusBarData.rectBorders.right; if (visProtoCount>1) sw = (rectwidth-(g_StatusBarData.extraspace*(visProtoCount-1)))/visProtoCount; else sw = rectwidth; - if (ProtoWidth) mir_free_and_nill(ProtoWidth); + mir_free(ProtoWidth); ProtoWidth = (int*)mir_alloc(sizeof(int)*visProtoCount); for (i=0; i < visProtoCount; i++) { @@ -430,7 +425,6 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) if (!DBGetContactSettingTString(NULL,ProtosData[i].AccountName,dbTitle,&dbv)) { ProtosData[i].ProtoXStatus = mir_tstrdup(dbv.ptszVal); - //mir_free_and_nill(dbv.ptszVal); db_free(&dbv); } } @@ -495,7 +489,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) } // Reposition rects - for(i=0; i < visProtoCount; i++) + for (i=0; i < visProtoCount; i++) if (ProtoWidth[i]>maxwidth) maxwidth = ProtoWidth[i]; if (g_StatusBarData.sameWidth) @@ -700,7 +694,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) } } - if (ProtoWidth) mir_free_and_nill(ProtoWidth); + mir_free_and_nil(ProtoWidth); } //code for each line ProtosData = orig_ProtosData; } @@ -766,21 +760,17 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam break; case WM_DESTROY: xpt_FreeThemeForWindow(hwnd); - if (allocedItemData && ProtosData) - { - int k; - - for (k = 0; k < allocedItemData; k++) - { - if (ProtosData[k].AccountName) mir_free_and_nill (ProtosData[k].AccountName); - if (ProtosData[k].ProtoName) mir_free_and_nill (ProtosData[k].ProtoName); - if (ProtosData[k].ProtoEMailCount) mir_free_and_nill (ProtosData[k].ProtoEMailCount); - if (ProtosData[k].ProtoHumanName) mir_free_and_nill (ProtosData[k].ProtoHumanName); - if (ProtosData[k].ProtoStatusText) mir_free_and_nill (ProtosData[k].ProtoStatusText); - if (ProtosData[k].ProtoEMailCount) mir_free_and_nill (ProtosData[k].ProtoEMailCount); - if (ProtosData[k].ProtoXStatus) mir_free_and_nill (ProtosData[k].ProtoXStatus); + if (allocedItemData && ProtosData) { + for (int k = 0; k < allocedItemData; k++) { + mir_free(ProtosData[k].AccountName); + mir_free(ProtosData[k].ProtoName); + mir_free(ProtosData[k].ProtoEMailCount); + mir_free(ProtosData[k].ProtoHumanName); + mir_free(ProtosData[k].ProtoStatusText); + mir_free(ProtosData[k].ProtoEMailCount); + mir_free(ProtosData[k].ProtoXStatus); } - mir_free_and_nill(ProtosData); + mir_free_and_nil(ProtosData); ProtosData = NULL; allocedItemData = 0; } @@ -1111,7 +1101,7 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam HWND StatusBar_Create(HWND parent) { WNDCLASS wndclass = {0}; - TCHAR pluginname[] = TEXT("ModernStatusBar"); + TCHAR pluginname[] = _T("ModernStatusBar"); int h = GetSystemMetrics(SM_CYSMICON)+2; if (GetClassInfo(g_hInst,pluginname,&wndclass) == 0) { diff --git a/plugins/Clist_modern/modern_viewmodebar.cpp b/plugins/Clist_modern/modern_viewmodebar.cpp index 13221b057d..37fa5e9297 100644 --- a/plugins/Clist_modern/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/modern_viewmodebar.cpp @@ -165,7 +165,7 @@ static void ShowPage(HWND hwnd, int page) static int UpdateClistItem(HANDLE hContact, DWORD mask) { - for(int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hContact, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & mask ? i - ID_STATUS_OFFLINE : nullImage)); @@ -176,7 +176,7 @@ static DWORD GetMaskForItem(HANDLE hItem) { DWORD dwMask = 0; - for(int i=0; i <= ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE; i++) + for (int i=0; i <= ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE; i++) dwMask |= (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == nullImage ? 0 : 1 << i); return dwMask; @@ -199,13 +199,13 @@ static void UpdateStickies() hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hInfoItem, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & stickyStatusMask ? i - ID_STATUS_OFFLINE : ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1)); hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETNEXTITEM,CLGN_ROOT,0); hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP, (LPARAM)hItem); while(hItem) { - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELONG(i - ID_STATUS_OFFLINE, nullImage)); hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); } @@ -231,7 +231,7 @@ static int FillDialog(HWND hwnd) item.mask = LVIF_TEXT; item.iItem = 1000; - for(i=0; i < protoCount; i++) + for (i=0; i < protoCount; i++) { item.pszText = accs[i]->szModuleName; newItem = SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item); @@ -259,7 +259,7 @@ static int FillDialog(HWND hwnd) item.pszText = TranslateT("Ungrouped contacts"); newItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item); - for(i=0;;i++) + for (i=0;;i++) { mir_snprintf(buf, 20, "%d", i); if (DBGetContactSettingTString(NULL, "CListGroups", buf, &dbv)) @@ -277,7 +277,7 @@ static int FillDialog(HWND hwnd) lvc.mask = LVCF_FMT; lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; ListView_InsertColumn(hwndList, 0, &lvc); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { LVITEM item = {0}; item.mask = LVIF_TEXT; @@ -414,7 +414,7 @@ void SaveState() char szTemp[256]; hwndList = GetDlgItem(clvmHwnd, IDC_PROTOCOLS); - for(i=0; i < ListView_GetItemCount(hwndList); i++) { + for (i=0; i < ListView_GetItemCount(hwndList); i++) { if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; item.pszText = szTemp; @@ -436,7 +436,7 @@ void SaveState() operators |= ListView_GetCheckState(hwndList, 0) ? CLVM_INCLUDED_UNGROUPED : 0; - for(i=0; i < ListView_GetItemCount(hwndList); i++) { + for (i=0; i < ListView_GetItemCount(hwndList); i++) { if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; item.pszText = szTemp; @@ -450,7 +450,7 @@ void SaveState() } } hwndList = GetDlgItem(clvmHwnd, IDC_STATUSMODES); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { if (ListView_GetCheckState(hwndList, i - ID_STATUS_OFFLINE)) statusMask |= (1 << (i - ID_STATUS_OFFLINE)); } @@ -585,7 +585,7 @@ static void UpdateFilters() item.pszText = szTemp; item.cchTextMax = 255; - for(i=0; i < ListView_GetItemCount(hwndList); i++) + for (i=0; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); @@ -609,7 +609,7 @@ static void UpdateFilters() ListView_SetCheckState(hwndList, 0, dwFlags & CLVM_INCLUDED_UNGROUPED ? TRUE : FALSE); - for(i = 1; i < ListView_GetItemCount(hwndList); i++) + for (i = 1; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; SendMessage(hwndList, LVM_GETITEM, 0, (LPARAM)&item); @@ -623,7 +623,7 @@ static void UpdateFilters() { HWND hwndList = GetDlgItem(clvmHwnd, IDC_STATUSMODES); - for(int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { if ((1 << (i - ID_STATUS_OFFLINE)) & statusMask) ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, TRUE) else @@ -715,7 +715,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP xpt_EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB); himlViewModes = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 12, 0); - for(i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { hIcon = LoadSkinnedProtoIcon(NULL, i); ImageList_AddIcon(himlViewModes, hIcon); CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); @@ -751,7 +751,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS,0,0); SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN,2,0); SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETINDENT,10,0); - for(i=0;i <= FONTID_MAX;i++) + for (i=0;i <= FONTID_MAX;i++) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETTEXTCOLOR,i,GetSysColor(COLOR_WINDOWTEXT)); cii.cbSize = sizeof(cii); cii.hParentGroup = 0; diff --git a/plugins/Clist_modern/resource.rc b/plugins/Clist_modern/resource.rc index db74c2a10b..aeb4af99c3 100644 --- a/plugins/Clist_modern/resource.rc +++ b/plugins/Clist_modern/resource.rc @@ -362,7 +362,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Toolbar settings",IDC_STATIC,7,5,290,204 CONTROL "",IDC_BTNORDER,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_TABSTOP,29,39,120,123 - LTEXT "Hints:\n* Use Drag && Drop feature to change buttons order.\n* You can change button icons at Customize->Icons Toolbar section",IDC_STATIC,18,174,278,29 + LTEXT "Hints:\n* Use Drag&&Drop feature to change buttons order.\n* You can change button icons at Customize->Icons Toolbar section",IDC_STATIC,18,174,278,29 CONTROL "Show Toolbar with next buttons:",IDC_TBSHOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,20,268,10 EDITTEXT IDC_TEXT_W,240,118,35,12,ES_NUMBER CONTROL "",IDC_SPIN_W,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,276,118,11,12 @@ -868,7 +868,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_OPT_SKINEDITOR, DIALOG BEGIN @@ -1139,7 +1139,7 @@ IDR_MSF_DEFAULT_SKIN MSF "res/skin.msf" // Menu // -IDR_CLISTMENU MENU +IDR_CLISTMENU MENU BEGIN POPUP "&¤" BEGIN @@ -1161,7 +1161,7 @@ BEGIN END END -IDR_CONTEXT MENU +IDR_CONTEXT MENU BEGIN POPUP "Tray" BEGIN @@ -1200,7 +1200,7 @@ END IDD_OPT_CLUI_2 DLGINIT BEGIN IDC_HIDEMETHOD, 0x403, 9, 0 -0x6f63, 0x706d, 0x656c, 0x6574, "\000" +0x6f63, 0x706d, 0x656c, 0x6574, "\000" 0 END @@ -1211,19 +1211,19 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include \r\n" "#include ""hdr/modern_statusmodes.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -1245,4 +1245,3 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED - -- cgit v1.2.3