28 #ifndef _CEGUIRenderedStringWordWrapper_h_
29 #define _CEGUIRenderedStringWordWrapper_h_
31 #include "CEGUIFormattedRenderedString.h"
32 #include "CEGUIJustifiedRenderedString.h"
33 #include "CEGUIVector.h"
54 void format(
const Size& area_size);
57 size_t getFormattedLineCount()
const;
58 float getHorizontalExtent()
const;
59 float getVerticalExtent()
const;
65 typedef std::vector<FormattedRenderedString*>
LineList;
71 template <> CEGUIEXPORT
96 rstring = *d_renderedString;
101 for (
size_t line = 0; line < rstring.
getLineCount(); ++line)
103 while ((rs_width = rstring.
getPixelSize(line).d_width) > 0)
106 if (rs_width <= area_size.d_width)
110 rstring.
split(line, area_size.d_width, lstring);
112 frs->format(area_size);
113 d_lines.push_back(frs);
119 frs =
new T(*
new RenderedString(rstring));
120 frs->format(area_size);
121 d_lines.push_back(frs);
125 template <
typename T>
126 void RenderedStringWordWrapper<T>::draw(GeometryBuffer& buffer,
127 const Vector2& position,
128 const ColourRect* mod_colours,
129 const Rect* clip_rect)
const
131 Vector2 line_pos(position);
132 typename LineList::const_iterator i = d_lines.begin();
133 for (; i != d_lines.end(); ++i)
135 (*i)->draw(buffer, line_pos, mod_colours, clip_rect);
136 line_pos.d_y += (*i)->getVerticalExtent();
141 template <
typename T>
142 size_t RenderedStringWordWrapper<T>::getFormattedLineCount()
const
144 return d_lines.size();
148 template <
typename T>
149 float RenderedStringWordWrapper<T>::getHorizontalExtent()
const
154 typename LineList::const_iterator i = d_lines.begin();
155 for (; i != d_lines.end(); ++i)
157 const float cur_width = (*i)->getHorizontalExtent();
166 template <
typename T>
167 float RenderedStringWordWrapper<T>::getVerticalExtent()
const
172 typename LineList::const_iterator i = d_lines.begin();
173 for (; i != d_lines.end(); ++i)
174 h += (*i)->getVerticalExtent();
180 template <
typename T>
183 for (
size_t i = 0; i < d_lines.size(); ++i)
200 #endif // end of guard _CEGUIRenderedStringWordWrapper_h_
std::vector< FormattedRenderedString * > LineList
type of collection used to track the formatted lines.
Definition: CEGUIRenderedStringWordWrapper.h:65
Class used as a two dimensional vector (aka a Point)
Definition: CEGUIVector.h:45
Class that handles wrapping of a rendered string into sub-strings. Each sub-string is rendered using ...
Definition: CEGUIRenderedStringWordWrapper.h:45
Size getPixelSize(const size_t line) const
return the pixel size of the specified line.
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: CEGUIGeometryBuffer.h:42
Class that holds the size (width & height) of something.
Definition: CEGUISize.h:43
Class that holds details of colours for the four corners of a rectangle.
Definition: CEGUIColourRect.h:44
RenderedStringWordWrapper(const RenderedString &string)
Constructor.
Definition: CEGUIRenderedStringWordWrapper.h:76
Class representing a rendered string of entities.
Definition: CEGUIRenderedString.h:50
size_t getLineCount() const
return number of lines in this string.
void split(const size_t line, float split_point, RenderedString &left)
split the string in line line as close to split_point as possible.
void deleteFormatters()
Delete the current formatters and associated RenderedStrings.
Definition: CEGUIRenderedStringWordWrapper.h:181
LineList d_lines
collection of lines.
Definition: CEGUIRenderedStringWordWrapper.h:67
~RenderedStringWordWrapper()
Destructor.
Definition: CEGUIRenderedStringWordWrapper.h:84
Class encapsulating operations on a Rectangle.
Definition: CEGUIRect.h:44