27 #ifndef _CEGUIRenderedStringWordWrapper_h_
28 #define _CEGUIRenderedStringWordWrapper_h_
30 #include "CEGUI/FormattedRenderedString.h"
31 #include "CEGUI/JustifiedRenderedString.h"
32 #include "CEGUI/Vector.h"
53 void format(
const Window* ref_wnd,
const Sizef& area_size);
56 const Rectf* clip_rect)
const;
57 size_t getFormattedLineCount()
const;
58 float getHorizontalExtent(
const Window* ref_wnd)
const;
59 float getVerticalExtent(
const Window* ref_wnd)
const;
72 template <> CEGUIEXPORT
74 const Sizef& area_size);
94 const Sizef& area_size)
99 rstring = *d_renderedString;
104 for (
size_t line = 0; line < rstring.
getLineCount(); ++line)
106 while ((rs_width = rstring.
getPixelSize(ref_wnd, line).d_width) > 0)
109 if (rs_width <= area_size.d_width)
113 rstring.
split(ref_wnd, line, area_size.d_width, lstring);
115 frs->format(ref_wnd, area_size);
116 d_lines.push_back(frs);
122 frs = CEGUI_NEW_AO T(*
new RenderedString(rstring));
123 frs->format(ref_wnd, area_size);
124 d_lines.push_back(frs);
128 template <
typename T>
129 void RenderedStringWordWrapper<T>::draw(
const Window* ref_wnd,
130 GeometryBuffer& buffer,
131 const Vector2f& position,
132 const ColourRect* mod_colours,
133 const Rectf* clip_rect)
const
135 Vector2f line_pos(position);
136 typename LineList::const_iterator i = d_lines.begin();
137 for (; i != d_lines.end(); ++i)
139 (*i)->draw(ref_wnd, buffer, line_pos, mod_colours, clip_rect);
140 line_pos.d_y += (*i)->getVerticalExtent(ref_wnd);
145 template <
typename T>
146 size_t RenderedStringWordWrapper<T>::getFormattedLineCount()
const
148 return d_lines.size();
152 template <
typename T>
153 float RenderedStringWordWrapper<T>::getHorizontalExtent(
const Window* ref_wnd)
const
158 typename LineList::const_iterator i = d_lines.begin();
159 for (; i != d_lines.end(); ++i)
161 const float cur_width = (*i)->getHorizontalExtent(ref_wnd);
170 template <
typename T>
171 float RenderedStringWordWrapper<T>::getVerticalExtent(
const Window* ref_wnd)
const
176 typename LineList::const_iterator i = d_lines.begin();
177 for (; i != d_lines.end(); ++i)
178 h += (*i)->getVerticalExtent(ref_wnd);
184 template <
typename T>
187 for (
size_t i = 0; i < d_lines.size(); ++i)
192 CEGUI_DELETE_AO d_lines[i];
204 #endif // end of guard _CEGUIRenderedStringWordWrapper_h_