Print Page | Close Window

[solved] v17(final) - BUG Text clipped in Tooltips

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=22833
Printed Date: 08 May 2024 at 9:02am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] v17(final) - BUG Text clipped in Tooltips
Posted By: Marco1
Subject: [solved] v17(final) - BUG Text clipped in Tooltips
Date Posted: 13 January 2016 at 11:26am
Same with ribbon tooltips (tested with Office2007 and Office2010 themes).
Too much space on the right side, cut off at the bottom.

Have a look:



-------------
Product: XTP 18.3.0 on VS 2017
Platform: VS 2017 / Windows 10 (64bit)



Replies:
Posted By: JamesP
Date Posted: 23 February 2016 at 7:39am
In cases where the variable m_nMaxTipWidth is set using the function SetMaxTipWidth and an image is provided, the tooltip text can be quite badly clipped.

The size of the required rect is calculated in the CXTPToolTipContextToolTip::GetToolSize function. This function is giving results bigger than the m_nMaxTipWidth value.

In this function there is a line of code:

CRect rcText(0, 0, nMaxTipWidth - szMargin.cx, 0);

I suspect it should take into account the image size, making it something like:

CRect rcText(szImage.cx, 0, nMaxTipWidth - szMargin.cx, 0);


In order to avoid clipping the text, the first line of code in the CXTPToolTipContextToolTip::DrawEntry function:

rc.right = GetMaxTipWidth();

needs to be removed.

This line was added in 17.1 and wasn't present in the v17 Beta 3 that we have previously been using.


Posted By: rdhd
Date Posted: 25 February 2016 at 5:49pm
Are you running on a hi-res monitor? We are seeing clipping when running on one with the desktop DPI set to 200%.


Posted By: JamesP
Date Posted: 29 February 2016 at 6:52am
I am running on a high res monitor with the desktop dpi set to 200%. I was also getting the issue when running at 100%.

I think a large part of the problem could be down to the fact that we're providing extra large images to support high dpi and the tooltips always use the largest image they can find.


Posted By: olebed
Date Posted: 07 April 2016 at 10:44am
Hi all,

I found resolution for this issue.

For 125% and 150% DPI "XTP_DPI_X(nA) + XTP_DPI_X(nB)" always bigger for 1 than "XTP_DPI_X(nA + nB)". That is why difference in calculations between CXTPToolTipContextToolTip::GetToolSize and CXTPToolTipContextToolTip::DrawEntry.

Also "rc.right = GetMaxTipWidth();" in CXTPToolTipContextToolTip::DrawEntry() makes incorrect tooltips drawing even on 100% and 200% DPI. Thanks James!

Please check this solution. I have tested it with RibbonSample (Office2007 theme)  in 100-125-200% DPI.

CSize CXTPToolTipContextToolTip::GetToolSize(TOOLITEM* lpToolInfo)
{
CClientDC dc(this);

CFont* pOldFont = dc.SelectObject(&m_pContext->m_fnt);

CString str = GetToolText(lpToolInfo);

if (str.IsEmpty())
{
dc.SelectObject(pOldFont);
return CSize(0);
}

int nMaxTipWidth = GetMaxTipWidth();

CRect rcMargin = m_pContext->GetMargin();
CSize szMargin(XTP_DPI_X(3) + rcMargin.left + rcMargin.right + XTP_DPI_X(3),
XTP_DPI_Y(3) + rcMargin.top + rcMargin.bottom + XTP_DPI_Y(3));

DWORD dwFlags = DT_NOPREFIX | DT_EXPANDTABS;

BOOL bDrawImage = m_pIcon != NULL;
BOOL bDrawTitle = !m_strTitle.IsEmpty();
BOOL bDrawImageTop = TRUE;
CSize szImage(0, 0);
CSize szTitle(0, 0);

if (bDrawTitle)
{
CXTPFontDC fntTitle(&dc, &m_pContext->m_fntTitle);

CRect rcTitle(0, 0, 0, 0);
dc.DrawText(m_strTitle, rcTitle, dwFlags | DT_CALCRECT | DT_SINGLELINE);

szTitle = CSize(rcTitle.Width() + XTP_DPI_X(4), rcTitle.Height() + XTP_DPI_Y(10) + XTP_DPI_Y(10));
}

if (bDrawImage)
{
CSize szIcon(XTP_DPI_X(m_pIcon->GetWidth()), XTP_DPI_Y(m_pIcon->GetHeight()));
bDrawImageTop = (szIcon.cy <= XTP_DPI_Y(16));

if (bDrawImageTop)
{
if (!bDrawTitle)
{
szImage.cx = szIcon.cx + XTP_DPI_X(3);
}
else
{
szTitle.cx += szIcon.cx + XTP_DPI_X(1);
}
}
else
{
szImage.cx = szIcon.cx + XTP_DPI_X(5);
}
szImage.cy = szIcon.cy;
}

CRect rcText(0, 0, nMaxTipWidth - szMargin.cx, 0);

if (bDrawTitle)
rcText.right = max(szTitle.cx, nMaxTipWidth - szMargin.cx) - (XTP_DPI_X(10) + XTP_DPI_X(15));

dc.DrawText(str, rcText, dwFlags | DT_CALCRECT | DT_WORDBREAK);
dc.SelectObject(pOldFont);

CSize sz(0, 0);
sz.cy = max(szImage.cy, rcText.Height());
sz.cx = szImage.cx + rcText.Width();

if (bDrawTitle)
{
sz.cx = max(sz.cx + XTP_DPI_X(10) + XTP_DPI_X(15), szTitle.cx);
sz.cy += szTitle.cy;
}

sz += szMargin;

return sz;
}


Regards,
 Oleksandr Lebed


Posted By: scottp
Date Posted: 08 April 2016 at 1:10am
when will we see 17.2 released (or a beta) to try this and other recent bug fixes?


Posted By: olebed
Date Posted: 08 April 2016 at 5:38am

Scott, I don't sure that this fix will be available in 17.2. This and other recent fixes need to testing.

New version is preparing for release now. 

Note  I splited "clipped tooltips" and http://forum.codejock.com/forum_posts.asp?TID=22832" rel="nofollow - "clipped markup" to different forum topics.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net