1 /** Collection of some useful xform helper functions
6 #include FORMS_H_LOCATION
13 #include "xform_helpers.h"
17 // Take a string and add breaks so that it fits into a desired label width, w
18 string formatted( string const & sin, int w, int size, int style )
21 if (sin.empty() ) return sout;
23 // break sin up into a vector of individual words
24 vector<string> sentence;
26 for (string::const_iterator sit = sin.begin();
27 sit != sin.end(); ++sit) {
28 if ((*sit) == ' ' || (*sit) == '\n') {
29 sentence.push_back(word);
35 // Flush remaining contents of word
36 if (!word.empty() ) sentence.push_back(word);
39 for (vector<string>::const_iterator vit = sentence.begin();
40 vit != sentence.end(); ++vit) {
41 if (!l1.empty() ) l1 += ' ';
43 int length = fl_get_string_width(style, size, l1.c_str(),
46 if (!sout.empty() ) sout += '\n';
53 // Flush remaining contents of line
55 if (!sout.empty() ) sout += '\n';