sge_TextEditor
sge_TextEditor(void)Methods:
bool insert(Uint16 c)
Adds an (unicode) char before the cursor.
bool remove_left(void)
Removes the char left of cursor.
bool remove_right(void)
Removes the char right of cursor.
inline bool move_left(void)
Move the cursor to the left.
inline bool move_right(void)
Move the cursor to the right.
bool move_start(void)
Move the cursor to the start.
bool move_end(void)
Move the cursor to the end.
std::string get_string(bool wCursor=true)
Returns the text as latin1 with or without the cursor char.
Uint16* get_ucstring(bool wCursor=true)
Returns a unicode c-style string (allocated with new).
virtual bool check(SDL_Event* event)
Process an SDL_Event. The text can be edited with [Backspace], [Delete], [Left arrow] and [Right arrow]. Returns true if the text changed.
void change_cursor(Uint16 c)
Change the cursor char. Default is the '|' character.
void clear_text(void)
Clears the text string.
void change_text(const std::string s)
Changes the text.
void change_uctext(Uint16 *text)
Changes the text (c-style unicode).
void change_textf(const char *text, ...)
Changes the text (printf c-style).
void max_chars(unsigned int c)
Set max chars (default: limited only by memory).
unsigned int get_chars(void)
Returns the number of characters in the current string.
sge_text(void)Methods:
SDL_Surface* get_textSurface(bool copy=false)
Get a pointer to the text surface or (if copy=true) returns a copy (don't forget to free it later). This will not work with SFonts with an alpha channel.
bool update_textSurface(bool force=false)
Updates the textsurface if the text has changed (or if force=true) and returns true if the surface was updated.
void set_ttFont(sge_TTFont *font, Uint8 r, Uint8 g, Uint8 b, Uint8 br=0, Uint8 bg=0, Uint8 bb=0)
Sets the truetype font and color. If you use antialiasing, the background color must be set to the background color of the area where you will render the text. If the background has more than one color it might be better to use sge_TTF_AA_Alpha().
void set_bmFont(sge_bmpFont *bm_font)
Sets the bitmap font.
void show_cursor(bool mode)
Should the cursor be drawn when rendering text?
SDL_Rect render_text(SDL_Surface *surface, Sint16 x, Sint16 y)
Renders the text directly to the given surface (instead of rendering to the text surface with update_textSurface()). Return the size and position of the rendered text.
void use_TTrender(void)
Render text using truetype fonts. The default is to use the last set font.
void use_BMrender(void)
Render text using bitmap fonts. The default is to use the last set font.
void set_alpha(Uint8 alpha)
Sets the alpha value for the text (doesn't work with alpha channel SFonts).
bool get_color(SDL_Color *fg)
Fills fg with the RGB color of the truetype font if set. Returns false if the color is not set.
bool get_bg(SDL_Color *bg)
Fills bg with the background RGB color of the truetype font if set. Returns false if the color is not set.
sge_TextSurface(SDL_Surface *screen, Sint16 x=0, Sint16 y=0)Methods:
sge_TextSurface(SDL_Surface *screen, const std::string text, Sint16 x=0, Sint16 y=0)
You can set a default text if you want.
See sge_text and sge_surface.
sge_TextSsprite(SDL_Surface *screen, Sint16 x=0, Sint16 y=0)Methods:
sge_TextSsprite(SDL_Surface *screen, const std::string text, Sint16 x=0, Sint16 y=0)
You can set a default text if you want.
See sge_text and sge_ssprite.
sge_TextSprite(SDL_Surface *screen, Sint16 x=0, Sint16 y=0)Methods:
sge_TextSprite(SDL_Surface *screen, const std::string text, Sint16 x=0, Sint16 y=0)
You can set a default text if you want.
See sge_text and sge_sprite.
Copyright © 1999-2003 Anders Lindström
Last updated 030808