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

Method drawText

Engine/source/gui/controls/guiTextEditCtrl.cpp:1308–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1306}
1307
1308void GuiTextEditCtrl::drawText( const RectI &drawRect, bool isFocused )
1309{
1310 StringBuffer textBuffer;
1311 Point2I drawPoint = drawRect.point;
1312 Point2I paddingLeftTop, paddingRightBottom;
1313
1314 // Or else just copy it over.
1315 char *renderText = Con::getReturnBuffer( GuiTextEditCtrl::MAX_STRING_LENGTH );
1316 getRenderText( renderText );
1317
1318 // Apply password masking (make the masking char optional perhaps?)
1319 if(mPasswordText)
1320 {
1321 const U32 renderLen = dStrlen( renderText );
1322 for( U32 i = 0; i < renderLen; i++ )
1323 textBuffer.append(mPasswordMask);
1324 }
1325 else
1326 {
1327 textBuffer.set( renderText );
1328 }
1329
1330 // Just a little sanity.
1331 if(mCursorPos > textBuffer.length())
1332 mCursorPos = textBuffer.length();
1333
1334 paddingLeftTop.set(( mProfile->mTextOffset.x != 0 ? mProfile->mTextOffset.x : 3 ), mProfile->mTextOffset.y);
1335 paddingRightBottom = paddingLeftTop;
1336
1337 // Center vertically:
1338 drawPoint.y += ( ( drawRect.extent.y - paddingLeftTop.y - paddingRightBottom.y - S32( mProfile->mFont->getHeight() ) ) / 2 ) + paddingLeftTop.y;
1339
1340 // Align horizontally:
1341
1342 S32 textWidth = mProfile->mFont->getStrNWidth(textBuffer.getPtr(), textBuffer.length());
1343
1344 switch( mProfile->mAlignment )
1345 {
1346 case GuiControlProfile::RightJustify:
1347 drawPoint.x += ( drawRect.extent.x - textWidth - paddingRightBottom.x );
1348 break;
1349 case GuiControlProfile::CenterJustify:
1350 drawPoint.x += ( ( drawRect.extent.x - textWidth ) / 2 );
1351 break;
1352 default:
1353 case GuiControlProfile::LeftJustify :
1354 drawPoint.x += paddingLeftTop.x;
1355 break;
1356 }
1357
1358 ColorI fontColor = mActive ? mProfile->mFontColor : mProfile->mFontColorNA;
1359
1360 // now draw the text
1361 Point2I cursorStart, cursorEnd;
1362 mTextOffset.y = drawPoint.y;
1363 mTextOffset.x = drawPoint.x;
1364
1365 if ( drawRect.extent.x - paddingLeftTop.x > textWidth )

Callers 15

renderButtonMethod · 0.45
renderJustifiedTextMethod · 0.45
onRenderMethod · 0.45
onRenderMethod · 0.45
onRenderMethod · 0.45
onRenderMethod · 0.45
renderNodeNameMethod · 0.45
onRenderMethod · 0.45
renderGraphTooltipMethod · 0.45
onRenderCellMethod · 0.45
onRenderCellMethod · 0.45
onRenderCellMethod · 0.45

Calls 15

getReturnBufferFunction · 0.85
mFloorFunction · 0.85
getStrNWidthMethod · 0.80
getCharMethod · 0.80
getCharWidthMethod · 0.80
setBitmapModulationMethod · 0.80
getDrawUtilMethod · 0.80
drawRectFillMethod · 0.80
drawTextNMethod · 0.80
dStrlenFunction · 0.50
Point2IClass · 0.50
appendMethod · 0.45

Tested by

no test coverage detected