MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / drawAtomText

Method drawAtomText

Engine/source/gui/controls/guiMLTextCtrl.cpp:351–430  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

349
350//--------------------------------------------------------------------------
351void GuiMLTextCtrl::drawAtomText(bool sel, U32 start, U32 end, Atom *atom, Line *line, Point2I offset)
352{
353 GFont *font = atom->style->font->fontRes;
354 U32 xOff = 0;
355 if(start != atom->textStart)
356 {
357 const UTF16* buff = mTextBuffer.getPtr() + atom->textStart;
358 xOff += font->getStrNWidth(buff, start - atom->textStart);
359 }
360
361 Point2I drawPoint(offset.x + atom->xStart + xOff, offset.y + atom->yStart);
362
363 ColorI color;
364 if(atom->url)
365 {
366 if(atom->url->mouseDown)
367 color = atom->style->linkColorHL;
368 else
369 color = atom->style->linkColor;
370 }
371 else
372 color = atom->style->color;
373
374 const UTF16* tmp = mTextBuffer.getPtr() + start;
375 U32 tmpLen = end-start;
376
377 GFXDrawUtil *drawer = GFX->getDrawUtil();
378
379 if(!sel)
380 {
381 if(atom->style->shadowOffset.x || atom->style->shadowOffset.y)
382 {
383 ColorI shadowColor = atom->style->shadowColor;
384 shadowColor.alpha = (S32)(mAlpha * shadowColor.alpha);
385 drawer->setBitmapModulation(shadowColor);
386 drawer->drawTextN(font, drawPoint + atom->style->shadowOffset,
387 tmp, tmpLen, mAllowColorChars ? mProfile->mFontColors : NULL);
388 }
389
390 color.alpha = (S32)(mAlpha * color.alpha);
391 drawer->setBitmapModulation(color);
392 drawer->drawTextN(font, drawPoint, tmp, end-start, mAllowColorChars ? mProfile->mFontColors : NULL);
393
394 //if the atom was "clipped", see if we need to draw a "..." at the end
395 if (atom->isClipped)
396 {
397 Point2I p2 = drawPoint;
398 p2.x += font->getStrNWidthPrecise(tmp, tmpLen);
399 drawer->drawTextN(font, p2, "...", 3, mAllowColorChars ? mProfile->mFontColors : NULL);
400 }
401 }
402 else
403 {
404 RectI rect;
405 rect.point.x = drawPoint.x;
406 rect.point.y = line->y + offset.y;
407 rect.extent.x = font->getStrNWidth(tmp, tmpLen) + 1;
408 rect.extent.y = line->height + 1;

Callers

nothing calls this directly

Calls 8

getStrNWidthMethod · 0.80
getDrawUtilMethod · 0.80
setBitmapModulationMethod · 0.80
drawTextNMethod · 0.80
getStrNWidthPreciseMethod · 0.80
drawRectFillMethod · 0.80
getPtrMethod · 0.45
drawLineMethod · 0.45

Tested by

no test coverage detected