Definition at line 197 of file TextArea.h. References cLineHeight, mBreakOnLines, mFormatted, mNrLines, OglGui::OglWindow::mOglWnd, mScrollBar, mStrings, mText, OglGui::ScrollBar::SetRange(), and StringWidth(). Referenced by DisplayFunc(). 00198 { 00199 if (mFormatted) 00200 return; 00201 OGLWND* top = oglSys.GetTopOGLWND(mOglWnd); 00202 if (! top->hFont) 00203 return; 00204 00205 int maxWidth = mOglWnd->width - 2 - (mScrollBar ? cLineHeight : 0); 00206 std::string::size_type start = 0; 00207 // crude way of displaying newlines, WARNING: line lenghts are not checked: 00208 if (mBreakOnLines) 00209 while (start < mText.size()) 00210 { 00211 std::string::size_type end = mText.find('\n', start); 00212 if ((end == std::string::npos) || (end <= start)) 00213 { 00214 mStrings.push_back(mText.substr(start)); 00215 start = mText.size(); 00216 } 00217 else 00218 { 00219 mStrings.push_back(mText.substr(start, end - start + 1)); 00220 start = end + 1; 00221 while (mText[start] == ' ') 00222 start++; 00223 } 00224 } 00225 else 00226 while (start < mText.size()) 00227 { 00228 std::string::size_type end = mText.size(); 00229 while ((end != std::string::npos) && (end > start) && 00230 (StringWidth(top, start, end) >= maxWidth)) 00231 { // XXX RvB should also break at newlines 00232 std::string::size_type res = mText.rfind(' ', end); 00233 end = (res != std::string::npos) ? res - 1 : res; 00234 } 00235 if ((end == std::string::npos) || (end <= start)) 00236 { 00237 mStrings.push_back(mText.substr(start)); 00238 start = mText.size(); 00239 } 00240 else 00241 { 00242 mStrings.push_back(mText.substr(start, end - start + 1)); 00243 start = end + 1; 00244 while (start < mText.size() && mText[start] == ' ') 00245 start++; 00246 } 00247 } 00248 mFormatted = true; 00249 if (mScrollBar) 00250 mScrollBar->SetRange(mStrings.size(), mNrLines); 00251 }
Here is the call graph for this function:
|