From 35a9af527f9b7ec35e81455784cd0a795be910c5 Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Mon, 5 Nov 2012 20:08:43 +0000
Subject: - removed duplicate constants; - code cleaning

git-svn-id: http://svn.miranda-ng.org/main/trunk@2211 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 src/core/stdclist/src/clcpaint.cpp    | 8 ++++----
 src/modules/clist/clc.cpp             | 8 ++++----
 src/modules/clist/clcitems.cpp        | 5 +++--
 src/modules/clist/clcmsgs.cpp         | 1 +
 src/modules/clist/clcutils.cpp        | 4 ++--
 src/modules/clist/clui.cpp            | 8 +++++++-
 src/modules/extraicons/extraicons.cpp | 3 +--
 7 files changed, 22 insertions(+), 15 deletions(-)

(limited to 'src')

diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp
index 278e2e493b..690f0af8b6 100644
--- a/src/core/stdclist/src/clcpaint.cpp
+++ b/src/core/stdclist/src/clcpaint.cpp
@@ -497,10 +497,10 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
 			}
 
 			//extra icons
-			for (iImage = 0; iImage < dat->extraColumnsCount; iImage++) {
+			for (int i = dat->extraColumnsCount-1; i >= 0; i--) {
 				COLORREF colourFg = dat->selBkColour;
 				int mode = ILD_NORMAL;
-				if (group->cl.items[group->scanIndex]->iExtraImage[iImage] == 0xFFFF)
+				if (group->cl.items[group->scanIndex]->iExtraImage[i] == 0xFFFF)
 					continue;
 				if (selected)
 					mode = ILD_SELECTED;
@@ -512,8 +512,8 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
 					colourFg = dat->fontInfo[FONTID_NOTONLIST].colour;
 					mode = ILD_BLEND50;
 				}
-				ImageList_DrawEx(dat->himlExtraColumns, group->cl.items[group->scanIndex]->iExtraImage[iImage], hdcMem,
-					clRect.right - dat->extraColumnSpacing * (dat->extraColumnsCount - iImage), y + ((dat->rowHeight - 16) >> 1), 0, 0,
+				ImageList_DrawEx(dat->himlExtraColumns, group->cl.items[group->scanIndex]->iExtraImage[i], hdcMem,
+					clRect.right - dat->extraColumnSpacing * (dat->extraColumnsCount - i), y + ((dat->rowHeight - 16) >> 1), 0, 0,
 					CLR_NONE, colourFg, mode);
 			}
 		}
diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp
index 3f513f337a..20f966515b 100644
--- a/src/modules/clist/clc.cpp
+++ b/src/modules/clist/clc.cpp
@@ -699,7 +699,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam,
 			case SB_PAGEDOWN:   desty += clRect.bottom - dat->rowHeight; break;
 			case SB_BOTTOM:     desty = 0x7FFFFFFF;        break;
 			case SB_TOP:        desty = 0;                 break;
-			case SB_THUMBTRACK: desty = HIWORD(wParam); noSmooth = 1; break;      //noone has more than 4000 contacts, right?
+			case SB_THUMBTRACK: desty = HIWORD(wParam); noSmooth = 1; break; //noone has more than 4000 contacts, right?
 			default:            return 0;
 		}
 		cli.pfnScrollTo(hwnd, dat, desty, noSmooth);
@@ -802,7 +802,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam,
 		cli.pfnHideInfoTip(hwnd, dat);
 		KillTimer(hwnd, TIMERID_INFOTIP);
 		KillTimer(hwnd, TIMERID_RENAME);
-		if (wParam == 27)   //escape
+		if (wParam == 27) //escape
 			dat->szQuickSearch[0] = 0;
 		else if (wParam == '\b' && dat->szQuickSearch[0])
 			dat->szQuickSearch[lstrlen(dat->szQuickSearch) - 1] = '\0';
@@ -1203,10 +1203,10 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam,
 					ClcGroup *group;
 					ClcContact *contact;
 					cli.pfnGetRowByIndex(dat, dat->iDragItem, &contact, &group);
-					if (group->parent) {    //move to root
+					if (group->parent) { //move to root
 						if (contact->type == CLCIT_CONTACT) //dropee is a contact
 							CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)contact->hContact, 0);
-						else if (contact->type == CLCIT_GROUP) {    //dropee is a group
+						else if (contact->type == CLCIT_GROUP) { //dropee is a group
 							TCHAR szNewName[120];
 							lstrcpyn(szNewName, contact->szText, SIZEOF(szNewName));
 							cli.pfnRenameGroup(contact->groupId, szNewName);
diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp
index 94280f0bcf..c39f5cf5a6 100644
--- a/src/modules/clist/clcitems.cpp
+++ b/src/modules/clist/clcitems.cpp
@@ -244,7 +244,7 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int upd
 					if (szGroupName == NULL) {
 						mir_free(dbv.ptszVal);
 						return;
-					}           //never happens
+					}
 					if ( !lstrcmp(szGroupName, dbv.ptszVal))
 						break;
 				}
@@ -258,7 +258,7 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int upd
 				if (szGroupName == NULL) {
 					mir_free(dbv.ptszVal);
 					return;
-				}               //never happens
+				}
 				if ( !lstrcmp(szGroupName, dbv.ptszVal))
 					break;
 				len = lstrlen(szGroupName);
@@ -429,6 +429,7 @@ void fnRebuildEntireList(HWND hwnd, struct ClcData *dat)
 	}
 
 	cli.pfnSortCLC(hwnd, dat, 0);
+	cli.pfnSetAllExtraIcons(cli.hwndContactTree, 0);
 }
 
 int fnGetGroupContentsCount(ClcGroup *group, int visibleOnly)
diff --git a/src/modules/clist/clcmsgs.cpp b/src/modules/clist/clcmsgs.cpp
index 7d5664ec20..b35c7b0d64 100644
--- a/src/modules/clist/clcmsgs.cpp
+++ b/src/modules/clist/clcmsgs.cpp
@@ -396,6 +396,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPAR
 	case CLM_SETFONT:
 		if (HIWORD(lParam) < 0 || HIWORD(lParam) > FONTID_MAX)
 			return 0;
+
 		dat->fontInfo[HIWORD(lParam)].hFont = (HFONT) wParam;
 		dat->fontInfo[HIWORD(lParam)].changed = 1;
 		{
diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp
index fe2685ccbc..97b0db6abb 100644
--- a/src/modules/clist/clcutils.cpp
+++ b/src/modules/clist/clcutils.cpp
@@ -562,7 +562,7 @@ int fnGetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt)
 		}
 		if (ok) {
 			ok = 0;
-			if (bottomItem == -1 || bottomcontact->type != CLCIT_GROUP) {       //need to special-case moving to end
+			if (bottomItem == -1 || bottomcontact->type != CLCIT_GROUP) { //need to special-case moving to end
 				if (topItem != dat->iDragItem) {
 					for (; topgroup; topgroup = topgroup->parent) {
 						if (topgroup == movecontact->group)
@@ -589,7 +589,7 @@ int fnGetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt)
 	}
 	if (contact->type == CLCIT_GROUP) {
 		if (dat->iInsertionMark == -1) {
-			if (movecontact->type == CLCIT_GROUP) {     //check not moving onto its own subgroup
+			if (movecontact->type == CLCIT_GROUP) { //check not moving onto its own subgroup
 				for (; group; group = group->parent)
 					if (group == movecontact->group)
 						return DROPTARGET_ONSELF;
diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp
index 0e569f7ccb..b39dd5882c 100644
--- a/src/modules/clist/clui.cpp
+++ b/src/modules/clist/clui.cpp
@@ -449,7 +449,11 @@ void fnDrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, HICON eventIcon)
 	return;
 }
 
-#define M_CREATECLC  (WM_USER+1)
+static void CreateCLC()
+{
+	cli.pfnReloadExtraIcons();
+}
+
 LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	if (msg == uMsgProcessProfile)
@@ -532,6 +536,8 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
 			| (db_get_b(NULL, "CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) ?
 					CLS_HIDEEMPTYGROUPS : 0), 0, 0, 0, 0, hwnd, NULL, cli.hInst, NULL);
 		SendMessage(hwnd, WM_SIZE, 0, 0);
+
+		CreateCLC();
 		break;
 
 	case M_RESTORESTATUS:
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp
index 7a4f1a40e6..eef801f408 100644
--- a/src/modules/extraicons/extraicons.cpp
+++ b/src/modules/extraicons/extraicons.cpp
@@ -365,7 +365,6 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
 			return 0;
 
 		// Found one, now merge it
-
 		if ( _tcsicmp(extra->getDescription(), desc)) {
 			tstring newDesc = extra->getDescription();
 			newDesc += _T(" / ");
@@ -489,7 +488,7 @@ void LoadExtraIconsModule()
 
 	CreateServiceFunction(MS_CLIST_EXTRA_ADD_ICON, &svcExtraIcon_Add);
 
-	hEventExtraClick = CreateHookableEvent(ME_CLIST_EXTRA_CLICK);      
+	hEventExtraClick = CreateHookableEvent(ME_CLIST_EXTRA_CLICK);
 	hEventExtraImageApplying = CreateHookableEvent(ME_CLIST_EXTRA_IMAGE_APPLY);
 	hEventExtraImageListRebuilding = CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD);
 
-- 
cgit v1.2.3