Crazy Eddie's GUI System  0.8.7
RenderedString.h
1 /***********************************************************************
2  created: 25/05/2009
3  author: Paul Turner
4  *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIRenderedString_h_
28 #define _CEGUIRenderedString_h_
29 
30 #include "CEGUI/Size.h"
31 #include "CEGUI/Rect.h"
32 #include <vector>
33 #include <utility>
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
50 class CEGUIEXPORT RenderedString :
51  public AllocatedObject<RenderedString>
52 {
53 public:
56 
58  virtual ~RenderedString();
59 
96  void draw(const Window* ref_wnd,
97  const size_t line, GeometryBuffer& buffer,
98  const Vector2f& position, const ColourRect* mod_colours,
99  const Rectf* clip_rect, const float space_extra) const;
100 
115  Sizef getPixelSize(const Window* ref_wnd, const size_t line) const;
116 
118  float getHorizontalExtent(const Window* ref_wnd) const;
119 
121  float getVerticalExtent(const Window* ref_wnd) const;
122 
124  void appendComponent(const RenderedStringComponent& component);
125 
128 
130  size_t getComponentCount() const;
131 
155  void split(const Window* ref_wnd,
156  const size_t line, float split_point, RenderedString& left);
157 
159  size_t getSpaceCount(const size_t line) const;
160 
163 
165  size_t getLineCount() const;
166 
168  void setSelection(const Window* ref_wnd, float start, float end);
169 
174 
175 protected:
177  typedef std::vector<RenderedStringComponent*
178  CEGUI_VECTOR_ALLOC(RenderedStringComponent*)> ComponentList;
182  typedef std::pair<size_t, size_t> LineInfo;
184  typedef std::vector<LineInfo
185  CEGUI_VECTOR_ALLOC(LineInfo)> LineList;
191  static void clearComponentList(ComponentList& list);
192 };
193 
194 } // End of CEGUI namespace section
195 
196 #if defined(_MSC_VER)
197 # pragma warning(pop)
198 #endif
199 
200 #endif // end of guard _CEGUIRenderedString_h_
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::RenderedString::d_components
ComponentList d_components
RenderedStringComponent objects that comprise this RenderedString.
Definition: RenderedString.h:180
CEGUI::RenderedString::operator=
RenderedString & operator=(const RenderedString &rhs)
Assignment.
CEGUI::RenderedString::~RenderedString
virtual ~RenderedString()
Destructor.
CEGUI::RenderedString::ComponentList
std::vector< RenderedStringComponent *CEGUI_VECTOR_ALLOC(RenderedStringComponent *)> ComponentList
Collection type used to hold the string components.
Definition: RenderedString.h:178
CEGUI::RenderedString::appendComponent
void appendComponent(const RenderedStringComponent &component)
append component to the list of components drawn for this string.
CEGUI::RenderedString::RenderedString
RenderedString(const RenderedString &other)
Copy constructor.
CEGUI::RenderedString::LineInfo
std::pair< size_t, size_t > LineInfo
track info for a line. first is componetn idx, second is component count.
Definition: RenderedString.h:182
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::RenderedString
Class representing a rendered string of entities.
Definition: RenderedString.h:52
CEGUI::RenderedString::cloneComponentList
void cloneComponentList(const ComponentList &list)
Make this object's component list a clone of list.
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::RenderedString::appendLineBreak
void appendLineBreak()
linebreak the rendered string at the present position.
CEGUI::Vector2< float >
CEGUI::ColourRect
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:45
CEGUI::RenderedString::d_lines
LineList d_lines
lines that make up this string.
Definition: RenderedString.h:187
CEGUI::RenderedString::getComponentCount
size_t getComponentCount() const
return the number of components that make up this string.
CEGUI::RenderedString::clearComponents
void clearComponents()
clear the list of components drawn for this string.
CEGUI::RenderedString::getPixelSize
Sizef getPixelSize(const Window *ref_wnd, const size_t line) const
Return the pixel size of a specified line for the RenderedString.
CEGUI::RenderedString::getVerticalExtent
float getVerticalExtent(const Window *ref_wnd) const
Return the sum vertical extent of all lines, in pixels.
CEGUI::RenderedString::getLineCount
size_t getLineCount() const
return number of lines in this string.
CEGUI::RenderedString::clearComponentList
static void clearComponentList(ComponentList &list)
Free components in the given ComponentList and clear the list.
CEGUI::RenderedString::RenderedString
RenderedString()
Constructor.
CEGUI::RenderedStringComponent
Base class representing a part of a rendered string. The 'part' represented may be a text string,...
Definition: RenderedStringComponent.h:49
CEGUI::RenderedString::split
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.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::RenderedString::getSpaceCount
size_t getSpaceCount(const size_t line) const
return the total number of spacing characters in the specified line.
CEGUI::Size< float >
CEGUI::RenderedString::getHorizontalExtent
float getHorizontalExtent(const Window *ref_wnd) const
Return the maximum horizontal extent of all lines, in pixels.
CEGUI::RenderedString::setSelection
void setSelection(const Window *ref_wnd, float start, float end)
set selection highlight
CEGUI::Rect< float >
CEGUI::RenderedString::LineList
std::vector< LineInfo CEGUI_VECTOR_ALLOC(LineInfo)> LineList
Collection type used to hold details about the lines.
Definition: RenderedString.h:185
CEGUI::RenderedString::draw
void draw(const Window *ref_wnd, const size_t line, GeometryBuffer &buffer, const Vector2f &position, const ColourRect *mod_colours, const Rectf *clip_rect, const float space_extra) const
Draw the string to a GeometryBuffer.