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

Method getTextPosition

Engine/source/gui/controls/guiMLTextCtrl.cpp:1074–1104  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1072
1073//--------------------------------------------------------------------------
1074S32 GuiMLTextCtrl::getTextPosition(const Point2I& localCoords)
1075{
1076 AssertFatal(mAwake, "Can't get the text position of a sleeping control.");
1077 if(mDirty)
1078 reflow();
1079
1080 for(Line *walk = mLineList; walk; walk = walk->next)
1081 {
1082 if((S32)localCoords.y < (S32)walk->y)
1083 return walk->textStart;
1084
1085 if(localCoords.y >= walk->y && localCoords.y < walk->y + walk->height)
1086 {
1087 for(Atom *awalk = walk->atomList; awalk; awalk = awalk->next)
1088 {
1089 if(localCoords.x < awalk->xStart)
1090 return awalk->textStart;
1091 if(localCoords.x >= awalk->xStart + awalk->width)
1092 continue;
1093 // it's in the text block...
1094 GFont *font = awalk->style->font->fontRes;
1095
1096 const UTF16 *tmp16 = mTextBuffer.getPtr() + awalk->textStart;
1097 U32 bp = font->getBreakPos(tmp16, awalk->len, localCoords.x - awalk->xStart, false);
1098 return awalk->textStart + bp;
1099 }
1100 return walk->textStart + walk->len;
1101 }
1102 }
1103 return mTextBuffer.length() - 1;
1104}
1105
1106//--------------------------------------------------------------------------
1107GuiMLTextCtrl::Font *GuiMLTextCtrl::allocFont(const char *faceName, U32 faceNameLen, U32 size)

Callers

nothing calls this directly

Calls 3

getBreakPosMethod · 0.80
getPtrMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected