28 #ifndef _CEGUIRenderedStringWordWrapper_h_
29 #define _CEGUIRenderedStringWordWrapper_h_
31 #include "CEGUI/FormattedRenderedString.h"
32 #include "CEGUI/JustifiedRenderedString.h"
33 #include "CEGUI/Vector.h"
54 void format(
const Window* ref_wnd,
const Sizef& area_size);
57 const Rectf* clip_rect)
const;
58 size_t getFormattedLineCount()
const;
59 float getHorizontalExtent(
const Window* ref_wnd)
const;
60 float getVerticalExtent(
const Window* ref_wnd)
const;
73 template <> CEGUIEXPORT
75 const Sizef& area_size);
95 const Sizef& area_size)
100 rstring = *d_renderedString;
105 for (
size_t line = 0; line < rstring.
getLineCount(); ++line)
107 while ((rs_width = rstring.
getPixelSize(ref_wnd, line).d_width) > 0)
110 if (rs_width <= area_size.d_width)
114 rstring.
split(ref_wnd, line, area_size.d_width, lstring);
116 frs->format(ref_wnd, area_size);
117 d_lines.push_back(frs);
123 frs = CEGUI_NEW_AO T(*
new RenderedString(rstring));
124 frs->format(ref_wnd, area_size);
125 d_lines.push_back(frs);
129 template <
typename T>
130 void RenderedStringWordWrapper<T>::draw(
const Window* ref_wnd,
131 GeometryBuffer& buffer,
132 const Vector2f& position,
133 const ColourRect* mod_colours,
134 const Rectf* clip_rect)
const
136 Vector2f line_pos(position);
137 typename LineList::const_iterator i = d_lines.begin();
138 for (; i != d_lines.end(); ++i)
140 (*i)->draw(ref_wnd, buffer, line_pos, mod_colours, clip_rect);
141 line_pos.d_y += (*i)->getVerticalExtent(ref_wnd);
146 template <
typename T>
147 size_t RenderedStringWordWrapper<T>::getFormattedLineCount()
const
149 return d_lines.size();
153 template <
typename T>
154 float RenderedStringWordWrapper<T>::getHorizontalExtent(
const Window* ref_wnd)
const
159 typename LineList::const_iterator i = d_lines.begin();
160 for (; i != d_lines.end(); ++i)
162 const float cur_width = (*i)->getHorizontalExtent(ref_wnd);
171 template <
typename T>
172 float RenderedStringWordWrapper<T>::getVerticalExtent(
const Window* ref_wnd)
const
177 typename LineList::const_iterator i = d_lines.begin();
178 for (; i != d_lines.end(); ++i)
179 h += (*i)->getVerticalExtent(ref_wnd);
185 template <
typename T>
188 for (
size_t i = 0; i < d_lines.size(); ++i)
193 CEGUI_DELETE_AO d_lines[i];
205 #endif // end of guard _CEGUIRenderedStringWordWrapper_h_