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

@ -112,25 +112,25 @@ CSFML_API void sfRenderImage_Display(sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Draw something on a renderimage
///
/// \param renderImage : Renderimage to draw in
/// \param sprite / string / shape : Object to draw
/// \param renderImage : Renderimage to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_DrawSprite(sfRenderImage* renderImage, sfSprite* sprite);
CSFML_API void sfRenderImage_DrawShape (sfRenderImage* renderImage, sfShape* shape);
CSFML_API void sfRenderImage_DrawString(sfRenderImage* renderImage, sfString* string);
CSFML_API void sfRenderImage_DrawText (sfRenderImage* renderImage, sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a renderimage with a shader
///
/// \param renderImage : Renderimage to draw in
/// \param sprite / string / shape : Object to draw
/// \param shader : Shader to use
/// \param renderImage : Renderimage to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_DrawSpriteWithShader(sfRenderImage* renderImage, sfSprite* sprite, sfShader* shader);
CSFML_API void sfRenderImage_DrawShapeWithShader (sfRenderImage* renderImage, sfShape* shape, sfShader* shader);
CSFML_API void sfRenderImage_DrawStringWithShader(sfRenderImage* renderImage, sfString* string, sfShader* shader);
CSFML_API void sfRenderImage_DrawTextWithShader (sfRenderImage* renderImage, sfText* text, sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the renderimage with the given color

View file

@ -292,25 +292,25 @@ CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow,
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / string / shape : Object to draw
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, sfSprite* sprite);
CSFML_API void sfRenderWindow_DrawShape (sfRenderWindow* renderWindow, sfShape* shape);
CSFML_API void sfRenderWindow_DrawString(sfRenderWindow* renderWindow, sfString* string);
CSFML_API void sfRenderWindow_DrawText (sfRenderWindow* renderWindow, sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow with a shader
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / string / shape : Object to draw
/// \param shader : Shader to use
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, sfSprite* sprite, sfShader* shader);
CSFML_API void sfRenderWindow_DrawShapeWithShader (sfRenderWindow* renderWindow, sfShape* shape, sfShader* shader);
CSFML_API void sfRenderWindow_DrawStringWithShader(sfRenderWindow* renderWindow, sfString* string, sfShader* shader);
CSFML_API void sfRenderWindow_DrawTextWithShader (sfRenderWindow* renderWindow, sfText* text, sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the screen with the given color

View file

@ -22,8 +22,8 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_STRING_H
#define SFML_STRING_H
#ifndef SFML_TEXT_H
#define SFML_TEXT_H
////////////////////////////////////////////////////////////
// Headers
@ -36,389 +36,389 @@
////////////////////////////////////////////////////////////
/// sfString styles
/// sfText styles
////////////////////////////////////////////////////////////
typedef enum
{
sfStringRegular = 0, ///< Regular characters, no style
sfStringBold = 1 << 0, ///< Characters are bold
sfStringItalic = 1 << 1, ///< Characters are in italic
sfStringUnderlined = 1 << 2 ///< Characters are underlined
} sfStringStyle;
sfTextRegular = 0, ///< Regular characters, no style
sfTextBold = 1 << 0, ///< Characters are bold
sfTextItalic = 1 << 1, ///< Characters are in italic
sfTextUnderlined = 1 << 2 ///< Characters are underlined
} sfTextStyle;
////////////////////////////////////////////////////////////
/// Create a new string
/// Create a new text
///
/// \return A new sfString object, or NULL if it failed
/// \return A new sfText object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfString* sfString_Create();
CSFML_API sfText* sfText_Create();
////////////////////////////////////////////////////////////
/// Destroy an existing string
/// Destroy an existing text
///
/// \param string : String to delete
/// \param text : Text to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_Destroy(sfString* string);
CSFML_API void sfText_Destroy(sfText* text);
////////////////////////////////////////////////////////////
/// Set the X position of a string
/// Set the X position of a text
///
/// \param string : String to modify
/// \param x : New X coordinate
/// \param text : String to modify
/// \param x : New X coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetX(sfString* string, float x);
CSFML_API void sfText_SetX(sfText* text, float x);
////////////////////////////////////////////////////////////
/// Set the Y position of a string
/// Set the Y position of a text
///
/// \param string : String to modify
/// \param y : New Y coordinate
/// \param text : String to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetY(sfString* string, float y);
CSFML_API void sfText_SetY(sfText* text, float y);
////////////////////////////////////////////////////////////
/// Set the position of a string
/// Set the position of a text
///
/// \param string : String to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
/// \param text : String to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetPosition(sfString* string, float x, float y);
CSFML_API void sfText_SetPosition(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a string
/// Set the horizontal scale of a text
///
/// \param string : String to modify
/// \param scale : New scale (must be strictly positive)
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetScaleX(sfString* string, float scale);
CSFML_API void sfText_SetScaleX(sfText* text, float scale);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a string
/// Set the vertical scale of a text
///
/// \param string : String to modify
/// \param scale : New scale (must be strictly positive)
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetScaleY(sfString* string, float scale);
CSFML_API void sfText_SetScaleY(sfText* text, float scale);
////////////////////////////////////////////////////////////
/// Set the scale of a string
/// Set the scale of a text
///
/// \param string : String to modify
/// \param text : String to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetScale(sfString* string, float scaleX, float scaleY);
CSFML_API void sfText_SetScale(sfText* text, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a string
/// Set the orientation of a text
///
/// \param string : String to modify
/// \param text : String to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetRotation(sfString* string, float rotation);
CSFML_API void sfText_SetRotation(sfText* text, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a string, in coordinates
/// Set the local origin of a text, in coordinates
/// relative to its left-top corner
///
/// \param string : String to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
/// \param text : String to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetOrigin(sfString* string, float x, float y);
CSFML_API void sfText_SetOrigin(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a string
/// Set the color of a text
///
/// \param string : String to modify
/// \param color : New color
/// \param text : String to modify
/// \param color : New color
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetColor(sfString* string, sfColor color);
CSFML_API void sfText_SetColor(sfText* text, sfColor color);
////////////////////////////////////////////////////////////
/// Set the blending mode for a string
/// Set the blending mode for a text
///
/// \param string : String to modify
/// \param mode : New blending mode
/// \param text : String to modify
/// \param mode : New blending mode
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetBlendMode(sfString* string, sfBlendMode mode);
CSFML_API void sfText_SetBlendMode(sfText* text, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a string
/// Get the X position of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetX(sfString* string);
CSFML_API float sfText_GetX(sfText* text);
////////////////////////////////////////////////////////////
/// Get the top Y of a string
/// Get the top Y of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetY(sfString* string);
CSFML_API float sfText_GetY(sfText* text);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a string
/// Get the horizontal scale of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetScaleX(sfString* string);
CSFML_API float sfText_GetScaleX(sfText* text);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a string
/// Get the vertical scale of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetScaleY(sfString* string);
CSFML_API float sfText_GetScaleY(sfText* text);
////////////////////////////////////////////////////////////
/// Get the orientation of a string
/// Get the orientation of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetRotation(sfString* string);
CSFML_API float sfText_GetRotation(sfText* text);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a string
/// Get the X position of the origin a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current X origin position
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetOriginX(sfString* string);
CSFML_API float sfText_GetOriginX(sfText* text);
////////////////////////////////////////////////////////////
/// Get the top Y of the origin of a string
/// Get the top Y of the origin of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current Y origin position
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetOriginY(sfString* string);
CSFML_API float sfText_GetOriginY(sfText* text);
////////////////////////////////////////////////////////////
/// Get the color of a string
/// Get the color of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfString_GetColor(sfString* string);
CSFML_API sfColor sfText_GetColor(sfText* text);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a string
/// Get the current blending mode of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfString_GetBlendMode(sfString* string);
CSFML_API sfBlendMode sfText_GetBlendMode(sfText* text);
////////////////////////////////////////////////////////////
/// Move a string
/// Move a text
///
/// \param string : String to modify
/// \param text : String to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_Move(sfString* string, float offsetX, float offsetY);
CSFML_API void sfText_Move(sfText* text, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a string
/// Scale a text
///
/// \param string : String to modify
/// \param text : String to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_Scale(sfString* string, float factorX, float factorY);
CSFML_API void sfText_Scale(sfText* text, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a string
/// Rotate a text
///
/// \param string : String to modify
/// \param angle : Angle of rotation, in degrees
/// \param text : String to modify
/// \param angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_Rotate(sfString* string, float angle);
CSFML_API void sfText_Rotate(sfText* text, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the string's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
///
/// \param string : String object
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_TransformToLocal(sfString* string, float pointX, float pointY, float* x, float* y);
CSFML_API void sfText_TransformToLocal(sfText* text, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Transform a point from the string's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
///
/// \param string : String object
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_TransformToGlobal(sfString* string, float pointX, float pointY, float* X, float* y);
CSFML_API void sfText_TransformToGlobal(sfText* text, float pointX, float pointY, float* X, float* y);
////////////////////////////////////////////////////////////
/// Set the text of a string (from a multibyte string)
/// Set the string of a text (from a multibyte string)
///
/// \param string : String to modify
/// \param text : New text
/// \param text : Text to modify
/// \param string : New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetText(sfString* string, const char* text);
CSFML_API void sfText_SetString(sfText* text, const char* string);
////////////////////////////////////////////////////////////
/// Set the text of a string (from a unicode string)
/// Set the string of a text (from a unicode string)
///
/// \param string : String to modify
/// \param text : New text
/// \param text : Text to modify
/// \param string : New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetUnicodeText(sfString* string, const sfUint32* text);
CSFML_API void sfText_SetUnicodeString(sfText* text, const sfUint32* string);
////////////////////////////////////////////////////////////
/// Set the font of a string
/// Set the font of a text
///
/// \param string : String to modify
/// \param font : Font to use
/// \param text : String to modify
/// \param font : Font to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetFont(sfString* string, sfFont* font);
CSFML_API void sfText_SetFont(sfText* text, sfFont* font);
////////////////////////////////////////////////////////////
/// Set the size of a string
/// Set the size of a text
///
/// \param string : String to modify
/// \param size : New size, in pixels
/// \param text : String to modify
/// \param size : New size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetSize(sfString* string, float size);
CSFML_API void sfText_SetSize(sfText* text, float size);
////////////////////////////////////////////////////////////
/// Set the style of a string
/// Set the style of a text
///
/// \param string : String to modify
/// \param style : New style (see sfStringStyle enum)
/// \param text : String to modify
/// \param style : New style (see sfTextStyle enum)
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_SetStyle(sfString* string, unsigned long style);
CSFML_API void sfText_SetStyle(sfText* text, unsigned long style);
////////////////////////////////////////////////////////////
/// Get the text of a string (returns a unicode string)
/// Get the string of a text (returns a unicode string)
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Text as UTF-32
/// \return String as UTF-32
///
////////////////////////////////////////////////////////////
CSFML_API const sfUint32* sfString_GetUnicodeText(sfString* string);
CSFML_API const sfUint32* sfText_GetUnicodeString(sfText* text);
////////////////////////////////////////////////////////////
/// Get the text of a string (returns an ANSI string)
/// Get the text of a text (returns an ANSI string)
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Text an a locale-dependant ANSI string
/// \return String an a locale-dependant ANSI string
///
////////////////////////////////////////////////////////////
CSFML_API const char* sfString_GetText(sfString* string);
CSFML_API const char* sfText_GetString(sfText* text);
////////////////////////////////////////////////////////////
/// Get the font used by a string
/// Get the font used by a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Pointer to the font
///
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfString_GetFont(sfString* string);
CSFML_API sfFont* sfText_GetFont(sfText* text);
////////////////////////////////////////////////////////////
/// Get the size of the characters of a string
/// Get the size of the characters of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Size of the characters
///
////////////////////////////////////////////////////////////
CSFML_API float sfString_GetSize(sfString* string);
CSFML_API float sfText_GetSize(sfText* text);
////////////////////////////////////////////////////////////
/// Get the style of a string
/// Get the style of a text
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Current string style (see sfStringStyle enum)
/// \return Current string style (see sfTextStyle enum)
///
////////////////////////////////////////////////////////////
CSFML_API unsigned long sfString_GetStyle(sfString* string);
CSFML_API unsigned long sfText_GetStyle(sfText* text);
////////////////////////////////////////////////////////////
/// Return the visual position of the Index-th character of the string,
/// Return the visual position of the Index-th character of the text,
/// in coordinates relative to the string
/// (note : translation, origin, rotation and scale are not applied)
///
/// \param string : String to read
/// \param index : Index of the character
/// \param x : Value to fill with the X coordinate of the position
/// \param y : Value to fill with the y coordinate of the position
/// \param text : String to read
/// \param index : Index of the character
/// \param x : Value to fill with the X coordinate of the position
/// \param y : Value to fill with the y coordinate of the position
///
////////////////////////////////////////////////////////////
CSFML_API void sfString_GetCharacterPos(sfString* string, size_t index, float* x, float* y);
CSFML_API void sfText_GetCharacterPos(sfText* text, size_t index, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a string on screen
/// Get the bounding rectangle of a text on screen
///
/// \param string : String to read
/// \param text : String to read
///
/// \return Rectangle contaning the string in screen coordinates
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfString_GetRect(sfString* string);
CSFML_API sfFloatRect sfText_GetRect(sfText* text);
#endif // SFML_STRING_H
#endif // SFML_TEXT_H

View file

@ -33,7 +33,7 @@ typedef struct sfRenderImage sfRenderImage;
typedef struct sfRenderWindow sfRenderWindow;
typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite;
typedef struct sfString sfString;
typedef struct sfText sfText;
typedef struct sfView sfView;