MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / exceedsMaxWidth

Method exceedsMaxWidth

src/Interface/TextEdit.cpp:348–360  ·  view source on GitHub ↗

* Checks if adding a certain character to * the text edit will exceed the maximum width. * Used to make sure user input stays within bounds. * @param c Character to add. * @return True if it exceeds, False if it doesn't. */

Source from the content-addressed store, hash-verified

346 * @return True if it exceeds, False if it doesn't.
347 */
348bool TextEdit::exceedsMaxWidth(wchar_t c)
349{
350 int w = 0;
351 std::wstring s = _value;
352
353 s += c;
354 for (std::wstring::iterator i = s.begin(); i < s.end(); ++i)
355 {
356 w += _text->getFont()->getCharSize(*i).w;
357 }
358
359 return (w > getWidth());
360}
361
362/**
363 * Focuses the text edit when it's pressed on.

Callers

nothing calls this directly

Calls 2

getCharSizeMethod · 0.80
getFontMethod · 0.45

Tested by

no test coverage detected