| 88 | }; |
| 89 | |
| 90 | void TextView::update( |
| 91 | const UString::utf32string& _text, |
| 92 | IFont* _font, |
| 93 | int _height, |
| 94 | Align _align, |
| 95 | VertexColourType _format, |
| 96 | int _maxWidth) |
| 97 | { |
| 98 | mFontHeight = _height; |
| 99 | |
| 100 | // массив для быстрой конвертации цветов |
| 101 | static const char convert_colour[64] = { |
| 102 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 103 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 104 | |
| 105 | mViewSize.clear(); |
| 106 | |
| 107 | RollBackPoint roll_back; |
| 108 | IntSize result; |
| 109 | float width = 0.0f; |
| 110 | size_t count = 0; |
| 111 | mLength = 0; |
| 112 | mLineInfo.clear(); |
| 113 | LineInfo line_info; |
| 114 | int font_height = _font->getDefaultHeight(); |
| 115 | |
| 116 | UString::utf32string::const_iterator end = _text.end(); |
| 117 | UString::utf32string::const_iterator index = _text.begin(); |
| 118 | |
| 119 | /*if (index == end) |
| 120 | return;*/ |
| 121 | |
| 122 | result.height += _height; |
| 123 | |
| 124 | for (; index != end; ++index) |
| 125 | { |
| 126 | Char character = *index; |
| 127 | |
| 128 | // new line |
| 129 | if (character == FontCodeType::CR || character == FontCodeType::NEL || character == FontCodeType::LF) |
| 130 | { |
| 131 | if (character == FontCodeType::CR) |
| 132 | { |
| 133 | UString::utf32string::const_iterator peeki = index; |
| 134 | ++peeki; |
| 135 | if ((peeki != end) && (*peeki == FontCodeType::LF)) |
| 136 | index = peeki; // skip both as one newline |
| 137 | } |
| 138 | |
| 139 | line_info.width = (int)std::ceil(width); |
| 140 | line_info.count = count; |
| 141 | mLength += line_info.count + 1; |
| 142 | |
| 143 | result.height += _height; |
| 144 | setMax(result.width, line_info.width); |
| 145 | width = 0; |
| 146 | count = 0; |
| 147 |
no test coverage detected