- wxClientDC dc(this);
- dc.SetFont(GetFont());
-
- // calculate the length: we want each line be no longer than maxLength
- // pixels and we only break lines at words boundary
- wxString current;
- wxCoord height, width,
- widthMax = 0;
- m_heightLine = 0;
-
- bool breakLine = FALSE;
- for ( const wxChar *p = text.c_str(); ; p++ )
- {
- if ( *p == _T('\n') || *p == _T('\0') )
- {
- dc.GetTextExtent(current, &width, &height);
- if ( width > widthMax )
- widthMax = width;
-
- if ( height > m_heightLine )
- m_heightLine = height;
-
- m_textLines.Add(current);
-
- if ( !*p )
- {
- // end of text
- break;
- }
-
- current.clear();
- breakLine = FALSE;
- }
- else if ( breakLine && (*p == _T(' ') || *p == _T('\t')) )
- {
- // word boundary - break the line here
- m_textLines.Add(current);
- current.clear();
- breakLine = FALSE;
- }
- else // line goes on
- {
- current += *p;
- dc.GetTextExtent(current, &width, &height);
- if ( width > maxLength )
- breakLine = TRUE;