Made to Order Software Corporation Logo

libsswf: sswf::TagEditText Class Reference

Defines a dynamic edit text box. More...

#include <libsswf.h>

Inheritance diagram for sswf::TagEditText:

:TagBaseID :TagCSMTextSettings :TagBase :MemoryManager

List of all members.

Public Types

 Defines the different possible alignment. More...

Public Member Functions

void AddUsedString (const char *string)
 Add a string that will be used with that edit text box.
virtual ErrorManager::error_code_t Save (Data &data)
 Save an edit text box in a Data buffer.
void SetAlign (edit_text_alignment_t align)
 Set the alignment for the text.
void SetAutoSize (bool status=true)
 Automatically resizing the edit text box.
void SetBorder (bool status=true)
 Mark whether a border should be rendered.
void SetBounds (const SRectangle &bounds)
 Set the bounds of the edit text.
void SetColor (Color &color)
 The color used to render the font.
void SetFont (const TagFont *font, long height)
 Set the font to use to render the glyphs.
void SetHTML (bool status=true)
 Defines the box as using HTML or plain text.
void SetIndent (long indent)
 Set the identation of the first line of text.
void SetLeading (long leading)
 Set the identation of the first line of text.
void SetMargins (long left, long right)
 Defines the side margin.
void SetMaxLength (long length)
 Set the maximum length of the text in number of characters.
void SetMultiline (bool status=true)
 Set the multiline flag to the specified status.
void SetNoSelect (bool status=true)
 Set whether the user can select the text.
void SetOutline (bool status=true)
 Set whether an outline should be rendered.
void SetPassword (bool status=true)
 Set the password flag.
void SetReadOnly (bool status=true)
 Mark the edit text box as read-only.
void SetText (const char *text)
 Set the text to be rendered on screen.
void SetUsedGlyphs (const char *lists)
 Mark a set of glyphs as in use.
void SetVariableName (const char *name)
 Set the name of the variable.
void SetWordWrap (bool status=true)
 Set whether words should wrap.
 TagEditText (TagBase *parent)
 Initializes the object.
virtual swf_type_t TypeFlags (void) const
 Returns the type of an edit text box.

Private Member Functions

virtual ErrorManager::error_code_t ParseTag (swf_tag_t tag, const Data &data)
 Parse data from a file into a EditText tag.
virtual ErrorManager::error_code_t PreSave (void)
 Check that the edit text box can be saved and in which version.

Private Attributes

edit_text_alignment_t f_align
bool f_autosize
bool f_border
SRectangle f_bounds
Color f_color
const TagFontf_font
unsigned short f_font_height
bool f_has_color
bool f_html
long f_indent
long f_leading
long f_left_margin
long f_max_length
bool f_multiline
bool f_no_select
bool f_outline
bool f_password
bool f_readonly
long f_right_margin
char * f_text
char * f_var_name
bool f_word_wrap

Detailed Description

This tag is used to create a text box. People can write text in that box unless it is marked as read-only. Using an action scripts it is also possible to modify the text defined in an edit text box.

One important feature is the use of embedded fonts. In that case, you probably want to mark the edit text with a set of glyphs which need to be included (or "*" for all the glyphs of the font.)

See also:


SWF Alexis' Reference—DefineEditText

SWF Alexis' Reference—swf_tag

Member Enumeration Documentation

This enumaration defines the list of possible alignment in an edit text box.

EDIT_TEXT_ALIGNMENT_LEFT  Defines the left alignment.

This value is used to have the text rendered on the left edge.

This is the default value.

EDIT_TEXT_ALIGNMENT_RIGHT  Defines the right alignment.

This value is used to have the text rendered on the right edge.

EDIT_TEXT_ALIGNMENT_CENTER  Defines the centered alignment.

This value is used to have the text horizontally rendered in the center of the edit text box.

EDIT_TEXT_ALIGNMENT_JUSTIFY  Defines the justified alignment.

This value is supposed to have to text aligned on the left and right edges adding some space where spaces are rendered so it looks like it fits exactly.

This may work in the current version, but it has not been working in older versions (v4, v5).

Constructor & Destructor Documentation

TagEditText::TagEditText ( TagBase parent  ) 

The constructor ensures that all the variables are set to their default.

[in] parent The parent must be a TagHeader

References EDIT_TEXT_ALIGNMENT_LEFT, f_align, f_border, f_font, f_font_height, f_has_color, f_indent, f_leading, f_left_margin, f_max_length, f_multiline, f_no_select, f_outline, f_password, f_readonly, f_right_margin, f_text, f_used_glyphs, f_used_strings, f_var_name, and f_word_wrap.

Member Function Documentation

void TagEditText::AddUsedString ( const char *  string  ) 

This function is used to tell the edit text box that it will need to be able to display the specified string.

This can be used to obtimize the number of glyphs included in your movie. If your edit text box cannot be edited by an end user, then it is sufficient to only save the glyphs that will at some point be used and forget about the others (especially to save some space in your file.)

For instance, if you have a set of action scripts testing different values and setting the edit text to pre-defined strings such as "Running", "Stopped", "Waiting" and "Paused" then you do not need to save the 'z' letter for instance.

Calling this function multiple times cumulates the strings.

[in] string A string to add to the list of strings in use

References f_used_strings, sswf::mbtowc(), sswf::MemoryManager::MemAlloc(), sswf::MemoryManager::MemFree(), and sswf::wcslen().

void TagEditText::SetAlign ( edit_text_alignment_t  align  ) 

This function sets the alignment for the text drawn in the edit text box.

The alignment can be set to one of these:

[in] align The alignment to use

References f_align.

void TagEditText::SetAutoSize ( bool  status = true  ) 

This function defines whether the box should be automatically resized or the size is defined statically.

[in] status If true, the box will resize itself around the defined text

References f_autosize.

void TagEditText::SetBorder ( bool  status = true  ) 

This function requests that a border be drawn around the edit text box.

Note that the border color is usually black, and the background is always white.

If your text is white, it will not show up.
[in] status If true, draw a background and edge

References f_border.

void TagEditText::SetBounds ( const SRectangle bounds  ) 

This function takes a rectangle representing the bounds of the edit text in the output.

[in] bounds The bounds of the edit text box.

References f_bounds.

void TagEditText::SetColor ( Color color  ) 

This function is used to set the color to use to render the font.

Note that you can later use the font as a mask over pretty much any other drawings giving an effect that looks like colorful fonts.

[in] color The color to use to draw the font

References f_color, and f_has_color.

void TagEditText::SetFont ( const TagFont font,
long  height 

This function defines the font to use with the edit text box and the height we want the font to be rendered at.

Note that if the font is a system font then the height has to be in system font metrics (such as 14 for a 14 points font.) When the font is an embedded font, then the height is taken in Twips.
[in] font The font tag used to render this edit text box.
[in] height The height to use to draw the characters.

References f_font, and f_font_height.

void TagEditText::SetHTML ( bool  status = true  ) 

The text in the edit text box can be set to Plain Text (the default) or HTML.

When set to HTML, a few tags are understood:

  • <a>...</a>
  • <b>...</b>
  • <br>
  • <font>...</font>
  • <i>...</i>
  • <li>...</li>
  • <p>...</p>
  • <tab>
  • <textformat>...</textformat>
  • <u>...</u>
For more information about the supported HTML, please, see SWF Alexis' Reference.

[in] status If set to true, the text in the box is expected to be HTML.
See also:
SWF Alexis' Reference—DefineEditText

References f_html.

void TagEditText::SetIndent ( long  indent  ) 

This alue represents the identation of the first line of text in a paragraph.

[in] indent The identation of the text

References f_indent.

void TagEditText::SetLeading ( long  leading  ) 

This alue represents the number of pixels (in TWIPS) to skip vertically between lines of text.

[in] leading The space between lines.

References f_leading.

void TagEditText::SetMargins ( long  left,
long  right 

This function defines the left and right margin for the text to be rendered in the box.

The margins are useful if you request a border and/or edge to be rendered.

[in] left The width of the margin on the left side
[in] right The width of the margin on the right side

References f_left_margin, and f_right_margin.

void TagEditText::SetMaxLength ( long  length  ) 

If the text is editable, to avoid letting people type as much as they want, use this function and set the limit you want. It is wise to always do so.

This is supposed to be counted in characters. Encodings like UTF-8 or some asian languages may not be able to handling this properly/
[in] length The maximum length a user can type

References f_max_length.

void TagEditText::SetMultiline ( bool  status = true  ) 

This function changes the behavior of the edit text box whenever strings longer than what can be rendered are used in an edit text.

References f_multiline.

void TagEditText::SetNoSelect ( bool  status = true  ) 

This function is used to mark the text in the edit text box as selectable or not. In general, an edit text box used for a label should be marked unselectable and read-only.

[in] status The new status for the no-select flag.

References f_no_select.

void TagEditText::SetOutline ( bool  status = true  ) 

This flag defines whether an embedded font should be used.

[in] status Set to true to use a system default font

References f_outline.

void TagEditText::SetPassword ( bool  status = true  ) 

By default, an edit text box is expected to be used for other purposes than passwords. But it can be useful, once in a while, to let people login. For that purpose, you can use this function.

The result of setting this flag to true is that the edit text box only renders asterisks,

[in] status If true, the edit text box only displays asterisks.

References f_password.

void TagEditText::SetReadOnly ( bool  status = true  ) 

This function marks the edit text box as read-only. This means it can be used to display a string and the user has to right to change its content.

[in] status The new status for the read-only flag.

References f_readonly.

void TagEditText::SetText ( const char *  text  ) 

This function sets the text that will be rendered on the screen.

The glyphs of the default text are automatically marked as required for this animation.

See also:
sswf::TagEditText::AddUsedString(const char *string)

References f_text, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagEditText::SetUsedGlyphs ( const char *  used_glyphs  ) 

This function can be used to mark a set of glyphs as in use.

The special string "*" or a NULL pointer will request the function to mark all the glyphs as being in use.

The special character - (dash/minus) is used to define a range unless it is found at the very beginning or the very end of the string. For instance, to include all the upper case latin 1 letters, one can use "A-Z".

The use of this function is not cumulative. Calling it again overwrites the previous glyphs in use.

This glyphs marked in used must be marked as such after the PreSave() function of the corresponding TagFont is called. For this reason, we must saved this information here.
See also:
sswf::TagEditText::AddUsedString(const char *string)

References f_used_glyphs, sswf::mbtowc(), sswf::MemoryManager::MemAlloc(), and sswf::MemoryManager::MemFree().

void TagEditText::SetVariableName ( const char *  name  ) 

This function is used to mark this edit text box with a name. This name can later be used in action scripts to read and set the text of the edit text box.

[in] name The name of the variable

References f_var_name, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagEditText::SetWordWrap ( bool  status = true  ) 

This function is used to change the word wrap status.

By default an edit text box is set to have its text wrap.

[in] status Set to true to get words to wrap, false otherwise

References f_word_wrap.

TagBase::swf_type_t TagEditText::TypeFlags ( void   )  const [virtual]

This function returns the type of an edit text box.

An edit text box is a definition and a reference.


Implements sswf::TagBase.


Member Data Documentation

unsigned short sswf::TagEditText::f_font_height [private]

Referenced by ParseTag(), Save(), SetFont(), and TagEditText().

bool sswf::TagEditText::f_html [private]

Referenced by ParseTag(), Save(), and SetHTML().

The documentation for this class was generated from the following files:

Generated on Wed Mar 18 15:13:59 2009 for libsswf by  doxygen 1.5.5