32 void setMin(T& _var,
const T& _newValue)
39 void setMax(T& _var,
const T& _newValue)
61 space_point = _space_point;
77 float getWidth()
const
83 size_t getCount()
const
89 size_t getPosition()
const
117 mFontHeight = _height;
120 static const char convert_colour[64] =
122 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
123 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
130 RollBackPoint roll_back;
147 for (; index != end; ++index)
149 Char character = *index;
164 line_info.
width = (int)ceil(width);
165 line_info.
count = count;
166 mLength += line_info.
count + 1;
173 mLineInfo.push_back(line_info);
182 else if (character == L
'#')
194 if (character != L
'#')
197 uint32 colour = convert_colour[(character - 48) & 0x3F];
200 for (
char i = 0; i < 5; i++)
209 colour += convert_colour[ ((*index) - 48) & 0x3F ];
228 roll_back.set(line_info.
simbols.size(), index, count, width);
232 roll_back.set(line_info.
simbols.size(), index, count, width);
235 float char_width = info->
width;
236 float char_height = info->
height;
237 float char_advance = info->
advance;
238 float char_bearingX = info->
bearingX;
239 float char_bearingY = info->
bearingY;
241 if (_height != font_height)
243 float scale = (float)_height / font_height;
246 char_height *= scale;
247 char_advance *= scale;
248 char_bearingX *= scale;
249 char_bearingY *= scale;
252 float char_fullAdvance = char_bearingX + char_advance;
256 && (width + char_fullAdvance) > _maxWidth
257 && !roll_back.empty())
260 width = roll_back.getWidth();
261 count = roll_back.getCount();
262 index = roll_back.getTextIter();
263 line_info.
simbols.erase(line_info.
simbols.begin() + roll_back.getPosition(), line_info.
simbols.end());
266 line_info.
width = (int)ceil(width);
267 line_info.
count = count;
268 mLength += line_info.
count + 1;
275 mLineInfo.push_back(line_info);
284 line_info.
simbols.push_back(
CharInfo(info->
uvRect, char_width, char_height, char_advance, char_bearingX, char_bearingY));
285 width += char_fullAdvance;
289 line_info.
width = (int)ceil(width);
290 line_info.
count = count;
291 mLength += line_info.
count;
293 mLineInfo.push_back(line_info);
298 for (VectorLineInfo::iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
301 line->offset = result.
width - line->width;
303 line->offset = (result.
width - line->width) / 2;
311 const int height = mFontHeight;
315 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
318 bool lastline = !(line + 1 != mLineInfo.end());
321 if (top + height > _value.
top || lastline)
324 float left = (float)line->offset;
328 for (VectorCharInfo::const_iterator sim = line->simbols.begin(); sim != line->simbols.end(); ++sim)
333 float fullAdvance = sim->getAdvance() + sim->getBearingX();
334 if (left + fullAdvance / 2.0f > _value.
left)
349 result += line->count + 1;
358 setMin(_position, mLength);
363 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
365 left = (float)line->offset;
366 if (position + line->count >= _position)
368 for (VectorCharInfo::const_iterator sim = line->simbols.begin(); sim != line->simbols.end(); ++sim)
373 if (position == _position)
377 left += sim->getBearingX() + sim->getAdvance();
381 position += line->count + 1;
size_t getTextLength() const
const IntSize & getViewSize() const
__inline void convertColour(uint32 &_colour, VertexColourType _format)
std::vector< LineInfo > VectorLineInfo
const VectorLineInfo & getData() const
_const_fwd_iterator const_iterator
const iterator
const forward iterator for UString
iterator begin()
returns an iterator to the first element of the string
size_t getCursorPosition(const IntPoint &_value)
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
IntPoint getCursorPoint(size_t _position)
#define MYGUI_DEBUG_ASSERT(exp, dest)
virtual int getDefaultHeight()=0
iterator end()
returns an iterator just past the end of the string
virtual GlyphInfo * getGlyphInfo(Char _id)=0
void update(const UString &_text, IFont *_font, int _height, Align _align, VertexColourType _format, int _maxWidth=-1)
types::TPoint< int > IntPoint