show less text in panel if it overflows

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4858 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2011-11-15 09:58:33 +00:00
parent cc45121eea
commit 38e5743457
3 changed files with 24 additions and 1 deletions
+1
View File
@@ -815,6 +815,7 @@ typedef struct _PH_SYSINFO_DRAW_PANEL
// Parameters for default draw
PPH_STRING Title;
PPH_STRING SubTitle;
PPH_STRING SubTitleOverflow;
} PH_SYSINFO_DRAW_PANEL, *PPH_SYSINFO_DRAW_PANEL;
typedef struct _PH_SYSINFO_SECTION
+1
View File
@@ -828,6 +828,7 @@ typedef struct _PH_SYSINFO_DRAW_PANEL
// Parameters for default draw
PPH_STRING Title;
PPH_STRING SubTitle;
PPH_STRING SubTitleOverflow;
} PH_SYSINFO_DRAW_PANEL, *PPH_SYSINFO_DRAW_PANEL;
typedef struct _PH_SYSINFO_SECTION
+22 -1
View File
@@ -1128,6 +1128,7 @@ VOID PhSipDrawPanel(
sysInfoDrawPanel.Title = NULL;
sysInfoDrawPanel.SubTitle = NULL;
sysInfoDrawPanel.SubTitleOverflow = NULL;
Section->Callback(Section, SysInfoGraphDrawPanel, &sysInfoDrawPanel, NULL);
@@ -1252,9 +1253,24 @@ VOID PhSipDefaultDrawPanel(
if (DrawPanel->SubTitle)
{
RECT measureRect;
rect.top += CurrentParameters.MediumFontHeight + PH_SYSINFO_PANEL_PADDING;
SelectObject(hdc, CurrentParameters.Font);
DrawText(hdc, DrawPanel->SubTitle->Buffer, DrawPanel->SubTitle->Length / 2, &rect, flags);
measureRect = rect;
DrawText(hdc, DrawPanel->SubTitle->Buffer, DrawPanel->SubTitle->Length / 2, &measureRect, (flags & ~DT_END_ELLIPSIS) | DT_CALCRECT);
if (measureRect.right <= rect.right || !DrawPanel->SubTitleOverflow)
{
// Text fits; draw normally.
DrawText(hdc, DrawPanel->SubTitle->Buffer, DrawPanel->SubTitle->Length / 2, &rect, flags);
}
else
{
// Text doesn't fit; draw the alternative text.
DrawText(hdc, DrawPanel->SubTitleOverflow->Buffer, DrawPanel->SubTitleOverflow->Length / 2, &rect, flags);
}
}
}
@@ -2722,6 +2738,11 @@ BOOLEAN PhSipMemorySectionCallback(
PhSipFormatSizeWithPrecision(UInt32x32To64(usedPages, PAGE_SIZE), 1)->Buffer,
PhSipFormatSizeWithPrecision(UInt32x32To64(totalPages, PAGE_SIZE), 1)->Buffer
);
drawPanel->SubTitleOverflow = PhFormatString(
L"%.0f%%\n%s",
(FLOAT)usedPages * 100 / totalPages,
PhSipFormatSizeWithPrecision(UInt32x32To64(usedPages, PAGE_SIZE), 1)->Buffer
);
}
return TRUE;
}