summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-30 18:06:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-30 18:06:10 +0000
commit6e6e4a343442a774eb46e044a4b842b0033ed224 (patch)
tree6fe2cb0ce38f15956110b304d1d193dc0cfc80eb /plugins
parentf91816baec61992beaf8b85f65559f6cf55c8d64 (diff)
fix for drawing the root group in FavContacts
git-svn-id: http://svn.miranda-ng.org/main/trunk@6698 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/FavContacts/src/main.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp
index 98a10c53f0..feda5bbd0f 100644
--- a/plugins/FavContacts/src/main.cpp
+++ b/plugins/FavContacts/src/main.cpp
@@ -90,8 +90,23 @@ static __forceinline COLORREF sttShadeColor(COLORREF clLine1, COLORREF clBack)
return RGB(
(GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
(GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
- (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100
- );
+ (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
+}
+
+static bool sttIsGroup(int id)
+{
+ return (id == 1) ? true : (pcli->pfnGetGroupName(id-1, NULL) != NULL);
+}
+
+static TCHAR* sttGetGroupName(int id)
+{
+ if (id == 1) {
+ if (g_Options.bUseGroups)
+ return TranslateT("<No group>");
+ return TranslateT("Favourite Contacts");
+ }
+
+ return pcli->pfnGetGroupName(id-1, NULL);
}
int ProcessTBLoaded(WPARAM wParam, LPARAM lParam)
@@ -350,7 +365,7 @@ static BOOL sttMeasureItem_Group(LPMEASUREITEMSTRUCT lpmis, Options *options)
{
HDC hdc = GetDC(g_hwndMenuHost);
HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- TCHAR *name = pcli->pfnGetGroupName(lpmis->itemData-1, NULL);
+ TCHAR *name = sttGetGroupName(lpmis->itemData);
SIZE sz;
if (!options->bSysColors)
SelectObject(hdc, g_Options.hfntName);
@@ -445,7 +460,7 @@ static BOOL sttMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options=NULL)
return FALSE;
BOOL res = FALSE;
- if ( pcli->pfnGetGroupName(lpmis->itemData-1, 0))
+ if (sttIsGroup(lpmis->itemData))
res = sttMeasureItem_Group(lpmis, options);
else if (CallService(MS_DB_CONTACT_IS, lpmis->itemData, 0))
res = sttMeasureItem_Contact(lpmis, options);
@@ -474,12 +489,10 @@ static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
SetTextColor(lpdis->hDC, g_Options.clLine1Sel);
}
- if (true) {
- TCHAR *name = pcli->pfnGetGroupName(lpdis->itemData-1, NULL);
- if (!options->bSysColors)
- SelectObject(lpdis->hDC, g_Options.hfntName);
- DrawText(lpdis->hDC, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);
- }
+ TCHAR *name = sttGetGroupName(lpdis->itemData);
+ if (!options->bSysColors)
+ SelectObject(lpdis->hDC, g_Options.hfntName);
+ DrawText(lpdis->hDC, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);
SelectObject(lpdis->hDC, hfntSave);
@@ -673,7 +686,7 @@ static BOOL sttDrawItem(LPDRAWITEMSTRUCT lpdis, Options *options=NULL)
if (!lpdis->itemData)
return FALSE;
- if ( pcli->pfnGetGroupName(lpdis->itemData-1, NULL))
+ if (sttIsGroup(lpdis->itemData))
return sttDrawItem_Group(lpdis, options);
if (CallService(MS_DB_CONTACT_IS, lpdis->itemData, 0))