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_
std::vector< FormattedRenderedString *CEGUI_VECTOR_ALLOC(FormattedRenderedString *)> LineList
type of collection used to track the formatted lines.
Definition: RenderedStringWordWrapper.h:66
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Class that handles wrapping of a rendered string into sub-strings. Each sub-string is rendered using ...
Definition: RenderedStringWordWrapper.h:44
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:42
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:43
RenderedStringWordWrapper(const RenderedString &string)
Constructor.
Definition: RenderedStringWordWrapper.h:78
Class representing a rendered string of entities.
Definition: RenderedString.h:50
size_t getLineCount() const
return number of lines in this string.
void deleteFormatters()
Delete the current formatters and associated RenderedStrings.
Definition: RenderedStringWordWrapper.h:185
LineList d_lines
collection of lines.
Definition: RenderedStringWordWrapper.h:68
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
~RenderedStringWordWrapper()
Destructor.
Definition: RenderedStringWordWrapper.h:86
void split(const Window *ref_wnd, const size_t line, float split_point, RenderedString &left)
split the string in line line as close to split_point as possible.
Sizef getPixelSize(const Window *ref_wnd, const size_t line) const
Return the pixel size of a specified line for the RenderedString.