summaryrefslogtreecommitdiff
path: root/include/SFML/Graphics/String.hpp
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
committerChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
commit9035708f4c5f7a78d8fb810e87e183fd61fd3350 (patch)
tree030e13b45c9882b799f793aa27007c74862fe934 /include/SFML/Graphics/String.hpp
parenta96b4da2ed67a3e8dcc8e2a0d9af9463a23bb021 (diff)
Imported Upstream version 1.4~svn915
Diffstat (limited to 'include/SFML/Graphics/String.hpp')
-rw-r--r--[-rwxr-xr-x]include/SFML/Graphics/String.hpp68
1 files changed, 31 insertions, 37 deletions
diff --git a/include/SFML/Graphics/String.hpp b/include/SFML/Graphics/String.hpp
index d3a1f73..a7f4718 100755..100644
--- a/include/SFML/Graphics/String.hpp
+++ b/include/SFML/Graphics/String.hpp
@@ -28,6 +28,8 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
+#include <SFML/System/Resource.hpp>
+#include <SFML/System/Unicode.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Rect.hpp>
@@ -55,40 +57,28 @@ public :
};
////////////////////////////////////////////////////////////
- /// Construct the string from a multibyte text
- ///
- /// \param Text : Text assigned to the string
- /// \param Font : Font used to draw the string (SFML built-in font by default)
- /// \param Size : Characters size (30 by default)
+ /// Default constructor
///
////////////////////////////////////////////////////////////
- String(const std::string& Text, const Font& CharFont = Font::GetDefaultFont(), float Size = 30.f);
+ String();
////////////////////////////////////////////////////////////
- /// Construct the string from a unicode text
+ /// Construct the string from any kind of text
///
- /// \param Text : Text assigned to the string ("" by default)
+ /// \param Text : Text assigned to the string
/// \param Font : Font used to draw the string (SFML built-in font by default)
/// \param Size : Characters size (30 by default)
///
////////////////////////////////////////////////////////////
- String(const std::wstring& Text = L"", const Font& CharFont = Font::GetDefaultFont(), float Size = 30.f);
-
- ////////////////////////////////////////////////////////////
- /// Set the text (from a multibyte string)
- ///
- /// \param Text : New text
- ///
- ////////////////////////////////////////////////////////////
- void SetText(const std::string& Text);
+ explicit String(const Unicode::Text& Text, const Font& CharFont = Font::GetDefaultFont(), float Size = 30.f);
////////////////////////////////////////////////////////////
- /// Set the text (from a unicode string)
+ /// Set the text (from any kind of string)
///
/// \param Text : New text
///
////////////////////////////////////////////////////////////
- void SetText(const std::wstring& Text);
+ void SetText(const Unicode::Text& Text);
////////////////////////////////////////////////////////////
/// Set the font of the string
@@ -117,20 +107,12 @@ public :
void SetStyle(unsigned long TextStyle);
////////////////////////////////////////////////////////////
- /// Get the text (returns a unicode string)
+ /// Get the text (the returned text can be converted implicitely to any kind of string)
///
- /// \return Text
+ /// \return String's text
///
////////////////////////////////////////////////////////////
- const std::wstring& GetUnicodeText() const;
-
- ////////////////////////////////////////////////////////////
- /// Get the text (returns a multibyte string)
- ///
- /// \return Text
- ///
- ////////////////////////////////////////////////////////////
- std::string GetText() const;
+ const Unicode::Text& GetText() const;
////////////////////////////////////////////////////////////
/// Get the font used by the string
@@ -157,6 +139,18 @@ public :
unsigned long GetStyle() const;
////////////////////////////////////////////////////////////
+ /// Return the visual position of the Index-th character of the string,
+ /// in coordinates relative to the string
+ /// (note : translation, center, rotation and scale are not applied)
+ ///
+ /// \param Index : Index of the character
+ ///
+ /// \return Position of the Index-th character (end of string if Index is out of range)
+ ///
+ ////////////////////////////////////////////////////////////
+ sf::Vector2f GetCharacterPos(std::size_t Index) const;
+
+ ////////////////////////////////////////////////////////////
/// Get the string rectangle on screen
///
/// \return Rectangle contaning the string in screen coordinates
@@ -170,7 +164,7 @@ protected :
/// /see Drawable::Render
///
////////////////////////////////////////////////////////////
- virtual void Render(const RenderWindow& Window) const;
+ virtual void Render(RenderTarget& Target) const;
private :
@@ -183,12 +177,12 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
- std::wstring myText; ///< Text to display
- const Font* myFont; ///< Font used to display the string
- float mySize; ///< Size of the characters
- unsigned long myStyle; ///< Text style (see Style enum)
- FloatRect myBaseRect; ///< Bounding rectangle of the text in object coordinates
- bool myNeedRectUpdate; ///< Does the bounding rect need an update ?
+ Unicode::Text myText; ///< Text to display
+ ResourcePtr<Font> myFont; ///< Font used to display the string
+ float mySize; ///< Size of the characters
+ unsigned long myStyle; ///< Text style (see Style enum)
+ FloatRect myBaseRect; ///< Bounding rectangle of the text in object coordinates
+ bool myNeedRectUpdate; ///< Does the bounding rect need an update ?
};
} // namespace sf