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

Method drawAtomText

Engine/source/gui/controls/guiMLTextCtrl.cpp:347–426  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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