103 const string *finalText = &
text;
104 string conversionResult;
107 for (string::const_iterator
i = text.begin();
i != text.end();
i++) {
109 conversionResult.append(
"#n#" );
111 conversionResult += (*i);
113 finalText = &conversionResult;
116 if (
m_text != *finalText) {
170 float currentHeight = vertInterval;
171 for (vector< TextLine >::size_type
i = lineNumber;
i <
m_lines.size(); ++
i) {
172 const float lineHeight =
m_lines[
i].height;
176 currentHeight -= lineHeight;
203 glColor4f( color.
r, color.
g, color.
b, color.
a );
212 for (
int charPos = start; charPos <= end; charPos++)
213 inRasterPos += font.
drawChar( str[charPos] );
228 glEnable( GL_LINE_SMOOTH );
237 for (
size_t i = start;
i < end;
i++) {
249 glRasterPos2f( 0, 0 );
254 for (vector< TextFragment >::const_iterator frag = line.
fragments.begin(); frag != line.
fragments.end(); frag++) {
259 rasterpos =
drawChars(
m_text, frag->start, frag->end, frag->font, frag->color, rasterpos );
264 glRasterPos2f( 0, 0 );
268 glDisable( GL_LINE_SMOOTH );
278 const string::size_type startPos,
279 const string::size_type endPos,
282 string::size_type *resultPos,
283 const char optionalTerminator =
'\0'
286 *formatSuccess =
false;
288 string::size_type curPos;
289 for (curPos = startPos; curPos < endPos; curPos++) {
290 const char c = str[curPos];
293 *formatSuccess =
true;
298 if (isdigit( c ) || c ==
'.' || c ==
',')
304 *resultPos = curPos+1;
305 if (formatSuccess && num.size() > 0) {
308 *resultValue = atof( num.c_str() );
317 const string::size_type startPos,
318 const string::size_type endPos,
321 string::size_type *resultPos
324 *formatSuccess =
false;
325 string::size_type curPos = startPos;
331 if (!formatSuccess)
return;
344 string::size_type *resultPos,
348 const string::size_type endPos =
m_text.size();
351 bool formatSuccess =
false;
352 string::size_type curPos = startPos;
353 if (curPos < endPos) {
385 f.setStrokeWeight( strokeWeight );
402 if (curPos == endPos) {
414 if (curPos == endPos)
433 const string::size_type endPos,
434 string::size_type &startPos,
438 string::size_type curPos = startPos;
441 while (curPos < endPos) {
443 if (width-charWidth < 0.0)
450 if (curPos > startPos) {
452 frag.
start = startPos;
469 string::size_type startPos,
470 string::size_type endPos,
473 string::size_type *resultPos
476 string::size_type curPos = startPos;
477 double curWidth = maxWidth;
478 bool forceEndLine =
false;
479 while (curPos < endPos) {
482 if (formatPos == std::string::npos || formatPos >= endPos) {
489 if (curPos < formatPos)
495 if (curPos >= endPos) {
502 const string::size_type oldPos = curPos;
504 if (curPos == oldPos) {
515 if (!forceEndLine && curPos < endPos) {
527 if (ellipsisWidth < maxWidth) {
532 for (i = frag.
end; i >= frag.
start; i--) {
534 if (curWidth+ellipsisWidth <= maxWidth) {
540 if (i < frag.
start) {
548 curWidth += ellipsisWidth;
562 for (i = frag.
end; i >= frag.
start; i--) {
576 line.
width = maxWidth-curWidth;
583 string::size_type startPos,
585 string::size_type *resultPos
588 string::size_type curPos = startPos;
589 double curWidth = maxWidth;
590 const string::size_type endPos =
m_text.size();
591 bool forceEndLine =
false;
593 string::size_type wordBreakPos = endPos;
596 while (curPos < endPos) {
599 string::size_type endFragPos = formatPos;
600 if (formatPos == std::string::npos || formatPos >= endPos)
605 while (curPos < endFragPos) {
608 wordBreakPos = curPos;
609 if (curWidth-charWidth < 0.0)
615 if (curPos == endPos) {
617 wordBreakPos = endPos;
619 }
else if (curPos < endFragPos) {
623 assert( curPos == formatPos );
627 if (curPos >= endPos) {
635 if (curWidth < 0.0) {
643 wordBreakPos = endPos;
653 string::size_type endLinePos = wordBreakPos+1;
706 string::size_type ignorePos = 0;
724 string::size_type endNextLinePos = 0;
735 if ( endNextLinePos >=
m_text.size() )
739 nextLinePos = endNextLinePos;
752 sprintf( buf,
"#c%.3g:%.3g:%.3g#", r, g, b );
755 sprintf( buf,
"#c%.3g:%.3g:%.3g:%.3g#", r, g, b, a );
766 , m_widthExceeded( ELLIPSIS )
767 , m_needLayout( true )
768 , m_layoutVersion( 0 )
769 , m_verticalScaling( 0.7 )
770 , m_horizontalScaling( 0.7 )
781 , m_justification( j )
782 , m_widthExceeded( w )
783 , m_needLayout( true )
784 , m_layoutVersion( 0 )
785 , m_verticalScaling( 0.7 )
786 , m_horizontalScaling( 0.7 )