Enhancement: adds a typedef for the collection type

master
Marco Antognini 2012-08-02 13:48:21 +02:00
parent e6d596c34e
commit fbc97e0007
2 changed files with 13 additions and 8 deletions

View File

@ -73,7 +73,7 @@ RichText & RichText::operator << (const sf::String &string)
void RichText::setCharacterSize(unsigned int size)
{
// Set character size
for(std::list<sf::Text>::iterator it = myTexts.begin();
for(collection_type::iterator it = myTexts.begin();
it != myTexts.end(); ++it)
{
it->setCharacterSize(size);
@ -90,7 +90,7 @@ void RichText::setCharacterSize(unsigned int size)
void RichText::setFont(const sf::Font &font)
{
// Set character size
for(std::list<sf::Text>::iterator it = myTexts.begin();
for(collection_type::iterator it = myTexts.begin();
it != myTexts.end(); ++it)
{
it->setFont(font);
@ -120,7 +120,7 @@ void RichText::clear()
////////////////////////////////////////////////////////////////////////////////
// Get text list
////////////////////////////////////////////////////////////////////////////////
const std::list<sf::Text> & RichText::getTextList() const
const RichText::collection_type & RichText::getTextList() const
{
return myTexts;
}
@ -172,7 +172,7 @@ void RichText::draw(sf::RenderTarget& target, sf::RenderStates states) const
states.transform *= getTransform();
// Draw
for(std::list<sf::Text>::const_iterator it = myTexts.begin();
for(collection_type::const_iterator it = myTexts.begin();
it != myTexts.end(); ++it)
{
// Add transformation
@ -200,7 +200,7 @@ void RichText::updateSize() const
// Sum all sizes (height not implemented)
mySize.x = 0.f;
mySize.y = myTexts.begin()->getGlobalBounds().height;
for(std::list<sf::Text>::const_iterator it = myTexts.begin();
for(collection_type::const_iterator it = myTexts.begin();
it != myTexts.end(); ++it)
{
// Update width
@ -226,7 +226,7 @@ void RichText::updatePosition() const
sf::Vector2f offset;
// Draw
for(std::list<sf::Text>::iterator it = myTexts.begin();
for(collection_type::iterator it = myTexts.begin();
it != myTexts.end(); ++it)
{
// Set all the origins to the first one

View File

@ -16,6 +16,11 @@ namespace sfe
class RichText : public sf::Drawable, public sf::Transformable
{
public:
//////////////////////////////////////////////////////////////////////////
// Typedef for collection type
//////////////////////////////////////////////////////////////////////////
typedef std::list<sf::Text> collection_type;
//////////////////////////////////////////////////////////////////////////
// Constructor
//////////////////////////////////////////////////////////////////////////
@ -46,7 +51,7 @@ public:
//////////////////////////////////////////////////////////////////////////
// Get text list
//////////////////////////////////////////////////////////////////////////
const std::list<sf::Text> &getTextList() const;
const collection_type &getTextList() const;
//////////////////////////////////////////////////////////////////////////
// Get character size
@ -87,7 +92,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Member data
//////////////////////////////////////////////////////////////////////////
mutable std::list<sf::Text> myTexts; ///< List of texts
mutable collection_type myTexts; ///< List of texts
sf::Color myCurrentColor; ///< Last used color
sf::Text::Style myCurrentStyle; ///< Last style used
mutable sf::Vector2f mySize; ///< Size of the text