Gnash  0.8.10
Public Types | Public Member Functions | Static Public Member Functions
gnash::TextField Class Reference

An instance of a DefineEditTextTag. More...

#include <TextField.h>

Inheritance diagram for gnash::TextField:
gnash::InteractiveObject gnash::DisplayObject gnash::GcResource

List of all members.

Public Types

enum  TextAlignment { ALIGN_LEFT = 0, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_JUSTIFY }
 Text alignment values. More...
enum  TextFormatDisplay { TEXTFORMAT_BLOCK = 0, TEXTFORMAT_INLINE = 1 }
 Text format display values. More...
enum  AutoSize { AUTOSIZE_NONE, AUTOSIZE_LEFT, AUTOSIZE_CENTER, AUTOSIZE_RIGHT }
 Possible autoSize values. More...
enum  TypeValue { typeInvalid, typeDynamic, typeInput }
 Possible type values. More...
typedef std::vector< size_t > LineStarts

Public Member Functions

 TextField (as_object *object, DisplayObject *parent, const SWF::DefineEditTextTag &def)
 Constructs a TextField as specified in a DefineEditText tag.
 TextField (as_object *object, DisplayObject *parent, const SWFRect &bounds)
 Constructs a TextField with default values and the specified bounds.
 ~TextField ()
bool mouseEnabled () const
 Returns true for now, TextField is always "Mouse-Enabled".
InteractiveObjecttopmostMouseEntity (boost::int32_t x, boost::int32_t y)
 Returns a pointer to the topmost InteractiveObject at (x,y)
virtual int getDefinitionVersion () const
 Return the version of the SWF this was parsed from.
void mouseEvent (const event_id &id)
 This function is called as a user-input handler.
void keyInput (key::code k)
 Handle user input from a key press.
const std::string & getVariableName () const
void set_variable_name (const std::string &newname)
void updateText (const std::string &s)
 Set our text to the given string by effect of an update of a.
std::string get_text_value () const
 Return value of our text.
std::string get_htmltext_value () const
 Return value of our htmlText.
bool getTextDefined () const
 Return true if text is defined.
size_t getCaretIndex () const
const std::pair< size_t, size_t > & getSelection () const
 Get a std::pair of size_t with start/end of selection.
void replaceSelection (const std::string &replace)
 Replace the current selection with the new text.
void setSelection (int start, int end)
 Set the current selection.
virtual void setWidth (double width)
 Override of DisplayObject::setWidth.
virtual void setHeight (double height)
 Override of DisplayObject::setHeight.
virtual void display (Renderer &renderer, const Transform &xform)
 Draw the dynamic string.
void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
 Add the DisplayObject's invalidated bounds *to* the given ranges list.
virtual SWFRect getBounds () const
 Get bounding SWFRect of this TextField.
bool pointInShape (boost::int32_t x, boost::int32_t y) const
 Return true if the given point falls in this DisplayObject's shape.
bool getDrawBackground () const
 Return true if the 'background' should be drawn.
void setDrawBackground (bool draw)
 Specify whether to draw the background.
rgba getBackgroundColor () const
 Return color of the background.
void setBackgroundColor (const rgba &col)
 Set color of the background.
bool getDrawBorder () const
 Return true if this TextField should have its border visible.
void setDrawBorder (bool draw)
 Specify whether to draw the border.
rgba getBorderColor () const
 Return color of the border.
void setBorderColor (const rgba &col)
 Set color of the border.
const rgbagetTextColor () const
 Return color of the text.
void setTextColor (const rgba &col)
 Set color of the text.
bool getEmbedFonts () const
 Return true if this TextField should use embedded font glyphs, false if it should use device font glyphs.
boost::int32_t maxChars () const
 Get the current maxChars setting of the TextField.
void maxChars (boost::int32_t max)
 Set the current maxChars setting of the TextField.
bool multiline () const
 Get the current multiline setting of the TextField.
void multiline (bool b)
 Set the current multiline setting of the TextField.
bool password () const
 Get the current password setting of the TextField.
void password (bool b)
 Set the current password setting of the TextField.
void setEmbedFonts (bool use)
 Set whether this TextField should use embedded font glyphs, or use device font glyphs.
AutoSize getAutoSize () const
 Get autoSize value.
TextAlignment getTextAlignment ()
 Return text TextAlignment.
void setAutoSize (AutoSize val)
 Set autoSize value.
void setType (TypeValue val)
 Set type (input or dynamic)
TypeValue getType () const
 Get type (input, dynamic or invalid)
bool isReadOnly () const
 Return true if this TextField is read-only.
bool doWordWrap () const
 Return true if text should continue to next available line when hitting end of bounding box.
void setWordWrap (bool on)
 Set wordWrap parameter.
bool doHtml () const
 Return true if HTML markup in text should be rendered.
void setHtml (bool on)
 Set html parameter.
bool isSelectable () const
 Return true if the TextField text is selectable.
void setSelectable (bool v)
 Set 'selectable' parameter.
virtual bool isSelectableTextField () const
 Return true if the TextField text is selectable.
void removeTextField ()
 Remove this textfield from the stage.
boost::intrusive_ptr< const FontsetFont (boost::intrusive_ptr< const Font > newfont)
 Set our font, return previously set one.
const FontgetFont ()
boost::uint16_t getFontHeight () const
void setFontHeight (boost::uint16_t h)
boost::uint16_t getLeftMargin () const
void setLeftMargin (boost::uint16_t h)
boost::uint16_t getRightMargin () const
void setRightMargin (boost::uint16_t h)
boost::uint16_t getIndent () const
void setIndent (boost::uint16_t h)
boost::uint16_t getBlockIndent () const
void setBlockIndent (boost::uint16_t h)
TextAlignment getAlignment () const
void setAlignment (TextAlignment h)
boost::int16_t getLeading () const
void setLeading (boost::int16_t h)
bool getUnderlined () const
TextFormatDisplay getDisplay () const
bool getBullet () const
const std::vector< int > & getTabStops () const
bool isRestrict () const
const std::string & getRestrict () const
size_t getScroll () const
size_t getMaxScroll () const
size_t getHScroll () const
size_t getMaxHScroll () const
size_t getBottomScroll () const
void setUnderlined (bool v)
void setTabStops (const std::vector< int > &tabStops)
void setBullet (bool b)
void setURL (std::string url)
void setTarget (std::string target)
void setRestrict (const std::string &restrict)
void setDisplay (TextFormatDisplay display)
void setScroll (size_t scroll)
void setMaxScroll (size_t maxScroll)
void setHScroll (size_t hScroll)
void setMaxHScroll (size_t maxHScroll)
void setbottomScroll (size_t bottomScroll)
size_t cursorRecord ()
 Returns the number of the record that the cursor is in.
void setTextFormat (TextFormat_as &tf)
const SWFRectgetTextBoundingBox () const
void setTextValue (const std::wstring &wstr)
 Set our text to the given string.

Static Public Member Functions

static TypeValue parseTypeValue (const std::string &val)
 Parse type string value.
static const char * typeValueName (TypeValue val)
 Return type value as a string.

Detailed Description

An instance of a DefineEditTextTag.


Member Typedef Documentation

typedef std::vector<size_t> gnash::TextField::LineStarts

Member Enumeration Documentation

Possible autoSize values.

Enumerator:
AUTOSIZE_NONE 

Do not automatically resize TextField as text grow/shrink.

AUTOSIZE_LEFT 

Expand TextField, anchor the top-left side.

AUTOSIZE_CENTER 

Expand TextField, anchor the horizontal center.

AUTOSIZE_RIGHT 

Expand TextField, anchor the top-right side.

Text alignment values.

Enumerator:
ALIGN_LEFT 
ALIGN_RIGHT 
ALIGN_CENTER 
ALIGN_JUSTIFY 

Text format display values.

Enumerator:
TEXTFORMAT_BLOCK 
TEXTFORMAT_INLINE 

Possible type values.

Enumerator:
typeInvalid 

Invalid value.

typeDynamic 

Do not accept input, text is only changed by variable name or assigning to the .text member

typeInput 

Accept user input.


Constructor & Destructor Documentation

gnash::TextField::TextField ( as_object object,
DisplayObject parent,
const SWF::DefineEditTextTag def 
)
gnash::TextField::TextField ( as_object object,
DisplayObject parent,
const SWFRect bounds 
)

Constructs a TextField with default values and the specified bounds.

Notably, the default textHeight is 12pt (240 twips).

Parameters:
parentA pointer to the DisplayObject parent of this TextField
boundsA SWFRect specifying the bounds of this TextField

References assert, gnash::key::f, gnash::fontlib::get_default_font(), and setFont().

gnash::TextField::~TextField ( )

Member Function Documentation

void gnash::TextField::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
) [virtual]

Add the DisplayObject's invalidated bounds *to* the given ranges list.

NOTE that this method should include the bounds that it covered the last time clear_invalidated() was called, as those need to be rerendered as well (to clear the region previously occupied by this DisplayObject).

That's why it returns the *union* of old_invalidated_ranges and the current bounds. The function is also used internally by set_invalidated() to update m_old_invalidated_ranges itself (you may notice some kind of circular reference), but that's no problem since old_invalidated_ranges is NULL during that call.

It is used to determine what area needs to be re-rendered. The coordinates are world coordinates (in TWIPS). Only instances with _invalidated flag set are checked unless force is set.

Implements gnash::InteractiveObject.

References gnash::DisplayObject::invalidated(), gnash::geometry::SnappingRanges2d::add(), gnash::DisplayObject::m_old_invalidated_ranges, gnash::getWorldMatrix(), getBounds(), gnash::SWFRect::expand_to_rect(), gnash::SWFMatrix::transform(), and gnash::SWFRect::getRange().

size_t gnash::TextField::cursorRecord ( )

Returns the number of the record that the cursor is in.

References gnash::key::i.

void gnash::TextField::display ( Renderer renderer,
const Transform xform 
) [virtual]
bool gnash::TextField::doHtml ( ) const [inline]

Return true if HTML markup in text should be rendered.

bool gnash::TextField::doWordWrap ( ) const [inline]

Return true if text should continue to next available line when hitting end of bounding box.

std::string gnash::TextField::get_htmltext_value ( ) const

Return value of our htmlText.

References gnash::getSWFVersion(), gnash::getObject(), and gnash::utf8::encodeCanonicalString().

std::string gnash::TextField::get_text_value ( ) const
TextAlignment gnash::TextField::getAlignment ( ) const [inline]

Referenced by getTextAlignment().

AutoSize gnash::TextField::getAutoSize ( ) const [inline]

Get autoSize value.

rgba gnash::TextField::getBackgroundColor ( ) const

Return color of the background.

Referenced by display().

boost::uint16_t gnash::TextField::getBlockIndent ( ) const [inline]
rgba gnash::TextField::getBorderColor ( ) const

Return color of the border.

Referenced by display().

size_t gnash::TextField::getBottomScroll ( ) const [inline]
virtual SWFRect gnash::TextField::getBounds ( ) const [inline, virtual]

Get bounding SWFRect of this TextField.

Implements gnash::InteractiveObject.

Referenced by add_invalidated_bounds(), setWidth(), and setHeight().

bool gnash::TextField::getBullet ( ) const [inline]
size_t gnash::TextField::getCaretIndex ( ) const [inline]
int gnash::TextField::getDefinitionVersion ( ) const [virtual]

Return the version of the SWF this was parsed from.

TODO: work out what this means for dynamic TextFields.

Reimplemented from gnash::DisplayObject.

References gnash::DisplayObject::get_root(), and gnash::MovieClip::getDefinitionVersion().

TextFormatDisplay gnash::TextField::getDisplay ( ) const [inline]
bool gnash::TextField::getDrawBackground ( ) const

Return true if the 'background' should be drawn.

Referenced by display().

bool gnash::TextField::getDrawBorder ( ) const

Return true if this TextField should have its border visible.

Referenced by display().

bool gnash::TextField::getEmbedFonts ( ) const [inline]

Return true if this TextField should use embedded font glyphs, false if it should use device font glyphs.

Referenced by display().

const Font* gnash::TextField::getFont ( ) [inline]
boost::uint16_t gnash::TextField::getFontHeight ( ) const [inline]

Referenced by display().

size_t gnash::TextField::getHScroll ( ) const [inline]
boost::uint16_t gnash::TextField::getIndent ( ) const [inline]
boost::int16_t gnash::TextField::getLeading ( ) const [inline]
boost::uint16_t gnash::TextField::getLeftMargin ( ) const [inline]
size_t gnash::TextField::getMaxHScroll ( ) const [inline]
size_t gnash::TextField::getMaxScroll ( ) const [inline]
const std::string& gnash::TextField::getRestrict ( ) const [inline]
boost::uint16_t gnash::TextField::getRightMargin ( ) const [inline]
size_t gnash::TextField::getScroll ( ) const [inline]
const std::pair<size_t, size_t>& gnash::TextField::getSelection ( ) const [inline]

Get a std::pair of size_t with start/end of selection.

Both start and end should invariably be within the range of the text.

const std::vector<int>& gnash::TextField::getTabStops ( ) const [inline]
TextField::TextAlignment gnash::TextField::getTextAlignment ( )
const SWFRect& gnash::TextField::getTextBoundingBox ( ) const [inline]
const rgba& gnash::TextField::getTextColor ( ) const [inline]

Return color of the text.

bool gnash::TextField::getTextDefined ( ) const [inline]

Return true if text is defined.

Referenced by gnash::MovieClip::getTextFieldVariables().

TypeValue gnash::TextField::getType ( ) const [inline]

Get type (input, dynamic or invalid)

bool gnash::TextField::getUnderlined ( ) const [inline]
const std::string& gnash::TextField::getVariableName ( ) const [inline]
bool gnash::TextField::isReadOnly ( ) const [inline]

Return true if this TextField is read-only.

References typeInput.

Referenced by display(), and keyInput().

bool gnash::TextField::isRestrict ( ) const [inline]
bool gnash::TextField::isSelectable ( ) const [inline]

Return true if the TextField text is selectable.

Referenced by isSelectableTextField().

virtual bool gnash::TextField::isSelectableTextField ( ) const [inline, virtual]

Return true if the TextField text is selectable.

Reimplemented from gnash::DisplayObject.

References isSelectable().

void gnash::TextField::keyInput ( key::code  k)
boost::int32_t gnash::TextField::maxChars ( ) const [inline]

Get the current maxChars setting of the TextField.

Referenced by keyInput().

void gnash::TextField::maxChars ( boost::int32_t  max) [inline]

Set the current maxChars setting of the TextField.

Parameters:
maxThe maximum number of characters that can be input by the user (Does not restrict Scripts)
bool gnash::TextField::mouseEnabled ( ) const [inline, virtual]

Returns true for now, TextField is always "Mouse-Enabled".

Implements gnash::InteractiveObject.

void gnash::TextField::mouseEvent ( const event_id id) [virtual]
bool gnash::TextField::multiline ( ) const [inline]

Get the current multiline setting of the TextField.

Referenced by keyInput().

void gnash::TextField::multiline ( bool  b) [inline]

Set the current multiline setting of the TextField.

Parameters:
bIf true "Enter" key will be recognized (Does not restrict Scripts)

References gnash::key::b.

TextField::TypeValue gnash::TextField::parseTypeValue ( const std::string &  val) [static]

Parse type string value.

Parameters:
valType value as a string (one of input or dynamic)
Returns:
an TypeValue identifier. typeInvalid if invalid.

References typeInput, typeDynamic, and typeInvalid.

bool gnash::TextField::password ( ) const [inline]

Get the current password setting of the TextField.

void gnash::TextField::password ( bool  b) [inline]

Set the current password setting of the TextField.

Parameters:
bIf true characters in the TextField will be displayed as (*)

References gnash::key::b.

bool gnash::TextField::pointInShape ( boost::int32_t  x,
boost::int32_t  y 
) const [virtual]

Return true if the given point falls in this DisplayObject's shape.

Point coordinates are in world TWIPS

The default implementation warns about a missing override and invokes pointInBounds().

Reimplemented from gnash::InteractiveObject.

References gnash::getWorldMatrix(), gnash::SWFMatrix::invert(), gnash::SWFMatrix::transform(), gnash::SWFRect::point_test(), gnash::geometry::Point2d::x, and gnash::geometry::Point2d::y.

void gnash::TextField::removeTextField ( )

Remove this textfield from the stage.

This is to implement TextField.removeTextField, will basically forward the request to its parent. Eventually this and MovieClip::removeMovieClip will be merged in a single function to be later used also for AS3 removeChild().

References gnash::DisplayObject::get_depth(), gnash::DisplayObject::getTarget(), gnash::key::p, gnash::DisplayObject::parent(), assert, gnash::DisplayObject::to_movie(), _, gnash::typeName(), and gnash::MovieClip::remove_display_object().

void gnash::TextField::replaceSelection ( const std::string &  replace)

Replace the current selection with the new text.

Parameters:
replaceString to replace the current selection

References gnash::getSWFVersion(), gnash::getObject(), gnash::utf8::decodeCanonicalString(), assert, start, and gnash::image::end().

void gnash::TextField::set_variable_name ( const std::string &  newname)

Set the name of a variable associated to this TextField's displayed text. Calling this function will override any previous setting for the variable name.

References updateText().

void gnash::TextField::setAlignment ( TextAlignment  h)
void gnash::TextField::setAutoSize ( AutoSize  val)

Set autoSize value.

Parameters:
valThe AutoSize to use

References gnash::DisplayObject::set_invalidated().

void gnash::TextField::setBackgroundColor ( const rgba col)

Set color of the background.

Use setDrawBackground to actually use this value.

Parameters:
colRGBA Object with color information. TextField background will be drawn in this color

References gnash::DisplayObject::set_invalidated().

void gnash::TextField::setBlockIndent ( boost::uint16_t  h)
void gnash::TextField::setBorderColor ( const rgba col)

Set color of the border.

Use setDrawBorder to actually use this value.

Parameters:
colRGBA Object with color information. TextField border will be drawn in this color.

References gnash::DisplayObject::set_invalidated().

void gnash::TextField::setbottomScroll ( size_t  bottomScroll) [inline]
void gnash::TextField::setBullet ( bool  b)

References gnash::key::b.

Referenced by setTextFormat().

void gnash::TextField::setDisplay ( TextFormatDisplay  display)
void gnash::TextField::setDrawBackground ( bool  draw)

Specify whether to draw the background.

Parameters:
drawIf true the background of this TextField will be drawn

References gnash::DisplayObject::set_invalidated().

void gnash::TextField::setDrawBorder ( bool  draw)

Specify whether to draw the border.

Parameters:
drawIf true the border of this TextField will be drawn

References gnash::DisplayObject::set_invalidated().

void gnash::TextField::setEmbedFonts ( bool  use)

Set whether this TextField should use embedded font glyphs, or use device font glyphs.

Parameters:
use

References gnash::DisplayObject::set_invalidated().

boost::intrusive_ptr< const Font > gnash::TextField::setFont ( boost::intrusive_ptr< const Font newfont)

Set our font, return previously set one.

Parameters:
newfontWill be stored in an intrusive_ptr

References gnash::DisplayObject::set_invalidated().

Referenced by TextField().

void gnash::TextField::setFontHeight ( boost::uint16_t  h)
void gnash::TextField::setHeight ( double  height) [virtual]
void gnash::TextField::setHScroll ( size_t  hScroll) [inline]
void gnash::TextField::setHtml ( bool  on) [inline]

Set html parameter.

Parameters:
onIf true HTML tags in the text will be parsed and rendered

Referenced by keyInput().

void gnash::TextField::setIndent ( boost::uint16_t  h)
void gnash::TextField::setLeading ( boost::int16_t  h)
void gnash::TextField::setLeftMargin ( boost::uint16_t  h)
void gnash::TextField::setMaxHScroll ( size_t  maxHScroll) [inline]
void gnash::TextField::setMaxScroll ( size_t  maxScroll) [inline]
void gnash::TextField::setRestrict ( const std::string &  restrict)
void gnash::TextField::setRightMargin ( boost::uint16_t  h)
void gnash::TextField::setScroll ( size_t  scroll) [inline]
void gnash::TextField::setSelectable ( bool  v) [inline]

Set 'selectable' parameter.

Parameters:
vIf true text in this TextField will be selectable

References test::v.

void gnash::TextField::setSelection ( int  start,
int  end 
)

Set the current selection.

Parameters:
startThe index of the beginning of the selection.
endThe index of the end of the selection. If start is greater than end, the values are swapped, ensuring end is never less than start.

References start, and gnash::image::end().

void gnash::TextField::setTabStops ( const std::vector< int > &  tabStops)
void gnash::TextField::setTarget ( std::string  target)
void gnash::TextField::setTextColor ( const rgba col)

Set color of the text.

Parameters:
colRGBA Object with color information. Text in this TextField will be displayed in this color.

References gnash::DisplayObject::set_invalidated(), gnash::renderer::opengl::for_each(), gnash::SWF::TextRecord::setColor(), and gnash::key::_1.

Referenced by setTextFormat().

void gnash::TextField::setTextFormat ( TextFormat_as tf)
void gnash::TextField::setTextValue ( const std::wstring &  wstr)

Set our text to the given string.

This function will also update any registered variable

References updateText(), gnash::getSWFVersion(), gnash::getObject(), gnash::as_object::set_member(), and gnash::utf8::encodeCanonicalString().

Referenced by TextField(), and keyInput().

void gnash::TextField::setType ( TypeValue  val) [inline]

Set type (input or dynamic)

Parameters:
valThe TypeValue to use, no-op if typeInvalid.

References typeInvalid.

void gnash::TextField::setUnderlined ( bool  v)
void gnash::TextField::setURL ( std::string  url)
void gnash::TextField::setWidth ( double  width) [virtual]
void gnash::TextField::setWordWrap ( bool  on)

Set wordWrap parameter.

Parameters:
onIf true text hitting bounding box limits will continue to next line. If false, either text will be truncated or bounding box expanded, depending on autoSize (see getAutoSize)

References gnash::DisplayObject::set_invalidated().

InteractiveObject * gnash::TextField::topmostMouseEntity ( boost::int32_t  x,
boost::int32_t  y 
) [virtual]
const char * gnash::TextField::typeValueName ( TypeValue  val) [static]

Return type value as a string.

Parameters:
valType value (enum)
Returns:
a C-string representation of the type value. The returns is *never* NULL.

References typeInput, and typeDynamic.

void gnash::TextField::updateText ( const std::string &  s)

Set our text to the given string by effect of an update of a.

registered variable name This call only updates the text and is only meant to be called by ourselves or by MovieClip when a registered TextVariable is updated.

References gnash::getSWFVersion(), gnash::getObject(), and gnash::utf8::decodeCanonicalString().

Referenced by setTextValue(), and set_variable_name().


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