void CLoginBarToolTipCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect (rect); CBCGPToolTipParams params; visualManagerMFC->GetToolTipParams (params); if (params.m_clrFill == (COLORREF)-1) { ::FillRect (dc.GetSafeHdc (), rect, ::GetSysColorBrush (COLOR_INFOBK)); } else { if (params.m_clrFillGradient == (COLORREF)-1) { CBrush br (params.m_clrFill); dc.FillRect (rect, &br); } else { CBCGPDrawManager dm (dc); dm.FillGradient2 (rect, params.m_clrFillGradient, params.m_clrFill, params.m_nGradientAngle == -1 ? 90 : params.m_nGradientAngle); } } COLORREF clrLine = params.m_clrBorder == (COLORREF)-1 ? ::GetSysColor (COLOR_INFOTEXT) : params.m_clrBorder; COLORREF clrText = params.m_clrText == (COLORREF)-1 ? ::GetSysColor (COLOR_INFOTEXT) : params.m_clrText; dc.Draw3dRect (rect, clrLine, clrLine); CFont* pPrevFont = m_pFont == NULL ? (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT) : dc.SelectObject (m_pFont); dc.SetBkMode (TRANSPARENT); dc.SetTextColor(clrText); if (m_strText.FindOneOf (_T("\n")) != -1) // multi-line tooltip { rect.DeflateRect (m_nTextMargin, m_nTextMargin); if (rect.Height () < m_rectLast.Height ()) { // center tooltip vertically //rect.top += (m_rectLast.Height () - rect.Height ()) / 2; } //dc.DrawText (m_strText, rect, DT_LEFT | DT_WORDBREAK); DrawTextML (dc, m_strText, rect); } else // single line tooltip { rect.DeflateRect (m_nTextMargin, 0); dc.DrawText (m_strText, rect, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); } if (pPrevFont != NULL) { dc.SelectObject (pPrevFont); } }
void TextBlockRender::DrawText() { if (!textBlock->isMultilineEnabled || textBlock->treatMultilineAsSingleLine) { WideString drawText = textBlock->text; //if((fittingType & FITTING_POINTS) && pointsStr.length()) if (textBlock->pointsStr.length()) { drawText = textBlock->pointsStr; } DrawTextSL(drawText, textBlock->cacheDx, textBlock->cacheDy, textBlock->cacheW); } else { uint32 yOffset = 0; int32 stringSize = 0; int32 blockWidth = 0; int32 fontHeight = textBlock->font->GetFontHeight() + textBlock->font->GetVerticalSpacing(); int32 stringsCnt = (int32)textBlock->multilineStrings.size(); for (int32 line = 0; line < stringsCnt; ++line) { if (line == (int32)textBlock->multilineStrings.size() - 1) { textBlock->cacheUseJustify = false; } int32 xOffset = 0; if (textBlock->align & ALIGN_RIGHT) { //xOffset = (int32)(textBlock->cacheFinalW - textBlock->stringSizes[line]); xOffset = (int32)(textBlock->cacheFinalSize.dx - textBlock->stringSizes[line]); if(xOffset < 0) { xOffset = 0; } } else if(textBlock->align & ALIGN_HCENTER) { //xOffset = (int32)(textBlock->cacheFinalW - textBlock->stringSizes[line]) / 2; xOffset = (int32)(textBlock->cacheFinalSize.dx - textBlock->stringSizes[line]) / 2; if(xOffset < 0) { xOffset = 0; } } if(textBlock->align & ALIGN_HJUSTIFY && textBlock->cacheUseJustify) { stringSize = textBlock->stringSizes[line]; blockWidth =textBlock->cacheW; } else { stringSize = 0; blockWidth = 0; } DrawTextML(textBlock->multilineStrings[line], textBlock->cacheDx, textBlock->cacheDy, blockWidth, xOffset, yOffset, stringSize); yOffset += fontHeight; } } }