FS#90 - Improve Unicode string classes

Added the sf::String class to replace (and enhance) sf::Unicode::Text
FS#138 - Rename sf::String to sf::Text


git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1286 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-11-26 08:07:38 +00:00
parent 9f063921c9
commit 78247bd386
46 changed files with 3003 additions and 1725 deletions

View file

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/System/Resource.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/Unicode.hpp>
#include <SFML/System/String.hpp>
#include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/Rect.hpp>
@ -40,16 +40,15 @@
namespace sf
{
class String;
namespace priv
{
class FontLoader;
}
////////////////////////////////////////////////////////////
/// Font is the low-level class for loading and
/// manipulating character fonts. This class is meant to
/// be used by sf::String
/// be used by sf::Text
////////////////////////////////////////////////////////////
class SFML_API Font : public Resource<Font>
{
@ -71,7 +70,7 @@ public :
/// \return True if loading was successful
///
////////////////////////////////////////////////////////////
bool LoadFromFile(const std::string& filename, unsigned int charSize = 30, const Unicode::Text& charset = ourDefaultCharset);
bool LoadFromFile(const std::string& filename, unsigned int charSize = 30, String charset = ourDefaultCharset);
////////////////////////////////////////////////////////////
/// Load the font from a file in memory
@ -84,7 +83,7 @@ public :
/// \return True if loading was successful
///
////////////////////////////////////////////////////////////
bool LoadFromMemory(const char* data, std::size_t sizeInBytes, unsigned int charSize = 30, const Unicode::Text& charset = ourDefaultCharset);
bool LoadFromMemory(const char* data, std::size_t sizeInBytes, unsigned int charSize = 30, String charset = ourDefaultCharset);
////////////////////////////////////////////////////////////
/// Get the base size of characters in the font;

View file

@ -22,14 +22,14 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_STRING_HPP
#define SFML_STRING_HPP
#ifndef SFML_TEXT_HPP
#define SFML_TEXT_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Resource.hpp>
#include <SFML/System/Unicode.hpp>
#include <SFML/System/String.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Rect.hpp>
@ -39,9 +39,9 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// String defines a graphical 2D text, that can be drawn on screen
/// Text defines a graphical 2D text, that can be drawn on screen
////////////////////////////////////////////////////////////
class SFML_API String : public Drawable
class SFML_API Text : public Drawable
{
public :
@ -60,25 +60,25 @@ public :
/// Default constructor
///
////////////////////////////////////////////////////////////
String();
Text();
////////////////////////////////////////////////////////////
/// Construct the string from any kind of text
///
/// \param text : Text assigned to the string
/// \param font : Font used to draw the string
/// \param size : Characters size
/// \param string : Text assigned to the string
/// \param font : Font used to draw the string
/// \param size : Characters size
///
////////////////////////////////////////////////////////////
explicit String(const Unicode::Text& text, const Font& font = Font::GetDefaultFont(), float size = 30.f);
explicit Text(const String& string, const Font& font = Font::GetDefaultFont(), float size = 30.f);
////////////////////////////////////////////////////////////
/// Set the text (from any kind of string)
///
/// \param text : New text
/// \param string : New text
///
////////////////////////////////////////////////////////////
void SetText(const Unicode::Text& text);
void SetString(const String& string);
////////////////////////////////////////////////////////////
/// Set the font of the string
@ -112,7 +112,7 @@ public :
/// \return String's text
///
////////////////////////////////////////////////////////////
const Unicode::Text& GetText() const;
const String& GetString() const;
////////////////////////////////////////////////////////////
/// Get the font used by the string
@ -177,7 +177,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Unicode::Text myText; ///< Text to display
String myString; ///< String 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)
@ -188,4 +188,4 @@ private :
} // namespace sf
#endif // SFML_STRING_HPP
#endif // SFML_TEXT_HPP