MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / DrawText

Function DrawText

src/Utils/MiscUI/MessageBox.cpp:699–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697};
698
699CSize DrawText(CDC* pDC, CRect rect, const CString& str, LOGFONT font, BOOL bCalculate = FALSE)
700{
701 CSize sz(0, 0);
702
703 if (str.IsEmpty())
704 return sz;
705
706 CPoint pt = rect.TopLeft();
707 CPoint ptCur = pt;
708
709 LOGFONT lf;
710 memcpy(&lf, &font, sizeof(LOGFONT));
711
712 CFont tempFont;
713 tempFont.CreateFontIndirect(&lf);
714
715 CFont* pOldFont = pDC->SelectObject(&tempFont);
716
717 TEXTMETRIC textMetric;
718 pDC->GetTextMetrics(&textMetric);
719 int nHeight = textMetric.tmHeight;
720 int nWidth = textMetric.tmAveCharWidth;
721
722 CString strText;
723
724 //iterate through all characters of the string
725 for (int i = 0; i <= str.GetLength(); ++i)
726 {
727 Command nCmd = Command::None;
728 if (i < str.GetLength())
729 {
730 switch (str.GetAt(i))
731 {
732 case L'\n':
733 nCmd = Command::NewLine;
734 break;
735 case L'\t':
736 nCmd = Command::Tabulation;
737 break;
738 case L'\r':
739 break;
740 default:
741 strText += str.GetAt(i);
742 break;
743 }
744 }
745 else // Immitates new line at the end of the string
746 nCmd = Command::NewLine;
747
748 if (nCmd != Command::None)
749 {
750 if (!strText.IsEmpty())
751 {
752 if (!bCalculate)
753 pDC->TextOut(ptCur.x, ptCur.y, strText);
754 CSize s = pDC->GetTextExtent(strText);
755 ptCur.x += s.cx;
756 strText.Empty();

Callers 15

ComboBoxSubclassProcMethod · 0.85
ButtonSubclassProcMethod · 0.85
GetTextSizeMethod · 0.85
OnPaintMethod · 0.85
DrawBlameMethod · 0.85
DrawViewTitleMethod · 0.85
PaintMethod · 0.85
GetTextSizeFunction · 0.85
OnNMCustomdrawMethod · 0.85
DrawTagBranchMessageMethod · 0.85
DrawTagBranchMethod · 0.85

Calls 9

SelectObjectMethod · 0.80
GetTextMetricsMethod · 0.80
TextOutMethod · 0.80
GetTextExtentMethod · 0.80
IsEmptyMethod · 0.45
CreateFontIndirectMethod · 0.45
GetLengthMethod · 0.45
EmptyMethod · 0.45
DeleteObjectMethod · 0.45

Tested by

no test coverage detected