Author: jimtabor
Date: Mon Jul 20 19:58:11 2015
New Revision: 68476
URL:
http://svn.reactos.org/svn/reactos?rev=68476&view=rev
Log:
[Win32k]
- Add ellipsis to the caption text if the window size is reduced. See CORE-9474, it can
use more tweaks.
- Also after all this, DefWndNCPaint can soon be moved into Win32k, draw.c in already in.
This could help with caption redrawing while moving the window.
Modified:
trunk/reactos/win32ss/user/ntuser/painting.c
Modified: trunk/reactos/win32ss/user/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/painti…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] Mon Jul 20 19:58:11 2015
@@ -2461,8 +2461,11 @@
END_CLEANUP;
}
+static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
+
BOOL
UserDrawCaptionText(
+ PWND pWnd,
HDC hDc,
const PUNICODE_STRING Text,
const RECTL *lpRc,
@@ -2475,12 +2478,14 @@
NTSTATUS Status;
BOOLEAN bDeleteFont = FALSE;
SIZE Size;
+ ULONG fit = 0, Length;
+ WCHAR szText[128];
+ RECTL r = *lpRc;
TRACE("UserDrawCaptionText: %wZ\n", Text);
nclm.cbSize = sizeof(nclm);
- if(!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
- sizeof(NONCLIENTMETRICS), &nclm, 0))
+ if(!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&nclm, 0))
{
ERR("UserSystemParametersInfo() failed!\n");
return FALSE;
@@ -2505,27 +2510,51 @@
IntGdiSetBkMode(hDc, TRANSPARENT);
hOldFont = NtGdiSelectFont(hDc, hFont);
- if(!hOldFont)
- {
- ERR("SelectFont() failed!\n");
- /* Don't fail */
- }
if(uFlags & DC_INBUTTON)
OldTextColor = IntGdiSetTextColor(hDc, IntGetSysColor(COLOR_BTNTEXT));
else
- OldTextColor = IntGdiSetTextColor(hDc, IntGetSysColor(uFlags & DC_ACTIVE
- ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT));
-
- // FIXME: If string doesn't fit to rc, truncate it and add ellipsis.
- GreGetTextExtentW(hDc, Text->Buffer, Text->Length/sizeof(WCHAR), &Size, 0);
- GreExtTextOutW(hDc,
- lpRc->left, (lpRc->top + lpRc->bottom)/2 - Size.cy/2,
- 0, NULL, Text->Buffer, Text->Length/sizeof(WCHAR), NULL, 0);
+ OldTextColor = IntGdiSetTextColor(hDc,
+ IntGetSysColor(uFlags & DC_ACTIVE ?
COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT));
+
+ // Adjust for system menu.
+ if (pWnd && pWnd->style & WS_SYSMENU)
+ {
+ r.right -= UserGetSystemMetrics(SM_CYCAPTION) - 1;
+ if ((pWnd->style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) &&
!(pWnd->ExStyle & WS_EX_TOOLWINDOW))
+ {
+ r.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
+ r.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
+ }
+ }
+
+ GreGetTextExtentExW(hDc, Text->Buffer, Text->Length/sizeof(WCHAR), r.right -
r.left, &fit, 0, &Size, 0);
+
+ Length = (Text->Length/sizeof(WCHAR) == fit ? fit : fit+1);
+
+ RtlZeroMemory(&szText, sizeof(szText));
+ RtlCopyMemory(&szText, Text->Buffer, Text->Length);
+
+ if (Text->Length/sizeof(WCHAR) > Length && Length > 3)
+ {
+ RtlCopyMemory(&szText[Length-3], ELLIPSISW, sizeof(ELLIPSISW));
+ }
+
+ GreExtTextOutW( hDc,
+ lpRc->left,
+ lpRc->top + (lpRc->bottom - lpRc->top) / 2 - Size.cy / 2, //
DT_SINGLELINE && DT_VCENTER
+ ETO_CLIPPED,
+ (RECTL *)lpRc,
+ (LPWSTR)&szText,
+ Length,
+ NULL,
+ 0 );
IntGdiSetTextColor(hDc, OldTextColor);
+
if (hOldFont)
NtGdiSelectFont(hDc, hOldFont);
+
if (bDeleteFont)
GreDeleteObject(hFont);
@@ -2657,14 +2686,14 @@
Rect.left += 2;
if (Str)
- UserDrawCaptionText(hDc, Str, &Rect, uFlags, hFont);
+ UserDrawCaptionText(pWnd, hDc, Str, &Rect, uFlags, hFont);
else if (pWnd != NULL) // FIXME: Windows does not do that
{
UNICODE_STRING ustr;
ustr.Buffer = pWnd->strName.Buffer; // FIXME: LARGE_STRING truncated!
ustr.Length = (USHORT)min(pWnd->strName.Length, MAXUSHORT);
ustr.MaximumLength = (USHORT)min(pWnd->strName.MaximumLength, MAXUSHORT);
- UserDrawCaptionText(hDc, &ustr, &Rect, uFlags, hFont);
+ UserDrawCaptionText(pWnd, hDc, &ustr, &Rect, uFlags, hFont);
}
}