Gnash  0.8.11dev
DefineEditTextTag.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_SWF_DEFINEEDITTEXTTAG_H
20 #define GNASH_SWF_DEFINEEDITTEXTTAG_H
21 
22 #include "SWFRect.h"
23 #include "DefinitionTag.h"
24 #include "SWF.h" // for TagType definition
25 #include "RGBA.h"
26 #include "TextField.h"
27 
28 #include <boost/intrusive_ptr.hpp>
29 #include <string>
30 #include <cstdint> // for std::uint16_t and friends
31 
32 
33 // Forward declarations
34 namespace gnash {
35  class SWFStream;
36  class movie_definition;
37  class RunResources;
38  class Font;
39 }
40 
41 namespace gnash {
42 namespace SWF {
43 
45 //
57 {
58 
59 public:
60 
62 
64  static void loader(SWFStream& in, TagType tag, movie_definition& m,
65  const RunResources& r);
66 
67  const SWFRect& bounds() const { return _rect; }
68 
70  DisplayObject* parent) const;
71 
74  const std::string& defaultText() const {
75  return _defaultText;
76  }
77 
83  const std::string& variableName() const {
84  return _variableName;
85  }
86 
88  //
91  unsigned int maxChars() const {
92  return _maxChars;
93  }
94 
96  std::uint16_t rightMargin() const {
97  return _rightMargin;
98  }
99 
101  std::uint16_t leftMargin() const {
102  return _leftMargin;
103  }
104 
106  std::uint16_t indent() const {
107  return _indent;
108  }
109 
111  // @@ what if has_font is false ??
112  std::uint16_t textHeight() const {
113  return _textHeight;
114  }
115 
117  const rgba& color() const {
118  return _color;
119  }
120 
123  //
125  std::uint16_t leading() const {
126  return _leading;
127  }
128 
129  bool multiline() const {
130  return _multiline;
131  }
132 
133  bool password() const {
134  return _password;
135  }
136 
139  return _alignment;
140  }
141 
143  bool border() const {
144  return _border;
145  }
146 
147  bool autoSize() const {
148  return _autoSize;
149  }
150 
152  bool wordWrap() const {
153  return _wordWrap;
154  }
155 
157  bool hasText() const {
158  return _hasText;
159  }
160 
161  bool readOnly() const
162  {
163  return _readOnly;
164  }
165 
166  bool noSelect() const
167  {
168  return _noSelect;
169  }
170 
172  bool html() const { return _html; }
173 
175  //
178  bool getUseEmbeddedGlyphs() const
179  {
180  return _useOutlines;
181  }
182 
183  boost::intrusive_ptr<Font> getFont() const
184  {
185  return _font;
186  }
187 
188 private:
189 
191  //
193  DefineEditTextTag(SWFStream& in, movie_definition& m, std::uint16_t id);
194 
196  void read(SWFStream& in, movie_definition& m);
197 
198  SWFRect _rect;
199 
200  std::string _variableName;
201 
202  // For an SWF-defined textfield we'll read
203  // this from the tag. Dynamic textfields should
204  // behave as always having text by default (not tested).
205  bool _hasText;
206  bool _wordWrap;
207  bool _multiline;
208 
210  bool _password;
211  bool _readOnly;
213  bool _autoSize;
214  bool _noSelect;
215 
218  bool _border;
219 
221  //
244  bool _html;
245 
252  // For an SWF-defined textfield we'll read
253  // this from the tag. Dynamic textfields should
254  // use device fonts by default (so not use outline ones)
255  bool _useOutlines;
256 
257  int _fontID;
258  boost::intrusive_ptr<Font> _font;
259 
261  // TODO: initialize to a meaningful value (see MovieClip::add_textfield)
262  // and make sure get_font_height is not called for rendering purposes
263  // (instead call a method of TextField) (?)
264  std::uint16_t _textHeight;
265 
267  rgba _color;
268 
270  //
273  unsigned int _maxChars;
274 
275  TextField::TextAlignment _alignment;
276 
278  std::uint16_t _leftMargin;
279 
281  std::uint16_t _rightMargin;
282 
284  std::uint16_t _indent;
285 
289  std::uint16_t _leading;
290 
292  std::string _defaultText;
293 };
294 
295 
296 } // namespace gnash::SWF
297 } // namespace gnash
298 
299 #endif
gnash::SWF::DEFINEEDITTEXT
@ DEFINEEDITTEXT
Definition: SWF.h:67
TextField_as.h
gnash::SWF::DefineEditTextTag::hasText
bool hasText() const
Has text defined ?
Definition: DefineEditTextTag.h:157
gnash::SWF::DefineEditTextTag::defaultText
const std::string & defaultText() const
Definition: DefineEditTextTag.h:74
TypesParser.h
gnash::log_swferror
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
gnash::SWF::DefineEditTextTag::textHeight
std::uint16_t textHeight() const
Get height of font in twips.
Definition: DefineEditTextTag.h:112
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
gnash::SWF::DefineEditTextTag::autoSize
bool autoSize() const
Definition: DefineEditTextTag.h:147
gnash::SWF::TagType
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:31
gnash::SWF::DefineEditTextTag::wordWrap
bool wordWrap() const
Word wrap requested ?
Definition: DefineEditTextTag.h:152
gnash::SWF::DefinitionTag
Immutable data representing the definition of a movie display element.
Definition: DefinitionTag.h:48
gnash::rgba
A basic RGBA type.
Definition: RGBA.h:36
gnash::SWF::DefineEditTextTag::leading
std::uint16_t leading() const
Get extra space between lines (in twips).
Definition: DefineEditTextTag.h:125
gnash::SWFStream::read_string
void read_string(std::string &to)
Reads a null-terminated string from the given file and assigns it to the given std::string,...
Definition: SWFStream.cpp:395
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::SWF::DefineEditTextTag::getFont
boost::intrusive_ptr< Font > getFont() const
Definition: DefineEditTextTag.h:183
gnash::SWF::DefineEditTextTag::~DefineEditTextTag
~DefineEditTextTag()
Definition: DefineEditTextTag.h:61
gnash::key::m
@ m
Definition: GnashKey.h:159
Global_as.h
SWFRect.h
UNUSED
#define UNUSED(x)
Definition: utility.h:113
gnash::movie_definition
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
gnash::SWF::DefineEditTextTag::alignment
TextField::TextAlignment alignment() const
Get text alignment.
Definition: DefineEditTextTag.h:138
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::SWF::DefineEditTextTag::multiline
bool multiline() const
Definition: DefineEditTextTag.h:129
gnash::SWFStream::read_s16
std::int16_t read_s16()
Read a aligned signed 16-bit value from the stream.
Definition: SWFStream.cpp:355
IF_VERBOSE_MALFORMED_SWF
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
gnash::SWFRect
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:45
DefineEditTextTag.h
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::SWF::DefineEditTextTag::border
bool border() const
Is border requested ?
Definition: DefineEditTextTag.h:143
gnash::TextField::TextAlignment
TextAlignment
Text alignment values.
Definition: TextField.h:65
gnash::SWF::DefineEditTextTag::bounds
const SWFRect & bounds() const
Definition: DefineEditTextTag.h:67
RGBA.h
gnash::SWF::DefineEditTextTag::rightMargin
std::uint16_t rightMargin() const
Get right margin in twips.
Definition: DefineEditTextTag.h:96
gnash::SWF::DefineEditTextTag::getUseEmbeddedGlyphs
bool getUseEmbeddedGlyphs() const
Return true if this DisplayObject definition requested use of device fonts.
Definition: DefineEditTextTag.h:178
gnash::SWF::DefineEditTextTag::html
bool html() const
Return true if HTML was allowed by definition.
Definition: DefineEditTextTag.h:172
gnash::SWF::DefineEditTextTag::password
bool password() const
Definition: DefineEditTextTag.h:133
Font.h
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
gnash::SWF::DefineEditTextTag::color
const rgba & color() const
Get color of the text.
Definition: DefineEditTextTag.h:117
gnash::SWF::DefineEditTextTag::loader
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Load an SWF::DEFINEEDITTEXT (37) tag.
Definition: DefineEditTextTag.cpp:34
IF_VERBOSE_PARSE
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
gnash::log_parse
void log_parse(StringType msg, Args... args)
Definition: log.h:313
DefinitionTag.h
TextField.h
gnash::TextField
An instance of a DefineEditTextTag.
Definition: TextField.h:57
SWF.h
gnash::Global_as
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
gnash::SWFStream::read_u16
std::uint16_t read_u16()
Read a aligned unsigned 16-bit value from the stream.
Definition: SWFStream.cpp:332
RunResources.h
gnash::SWF::DefineEditTextTag
SWF Tag DefineEditText (37).
Definition: DefineEditTextTag.h:57
gnash::SWF::DefineEditTextTag::createDisplayObject
DisplayObject * createDisplayObject(Global_as &gl, DisplayObject *parent) const
Create a DisplayObject with the given parent.
Definition: DefineEditTextTag.cpp:48
gnash::SWFStream::read_u8
std::uint8_t read_u8()
Read a aligned unsigned 8-bit value from the stream.
Definition: SWFStream.cpp:319
gnash::createTextFieldObject
as_object * createTextFieldObject(Global_as &gl)
Native function to create a plain object with TextField properties.
Definition: TextField_as.cpp:89
movie_definition.h
gnash::DisplayObject
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
gnash::SWF::DefineEditTextTag::maxChars
unsigned int maxChars() const
Return the maximum length of text this widget can hold.
Definition: DefineEditTextTag.h:91
gnash::SWFStream
SWF stream wrapper class.
Definition: SWFStream.h:59
gnash::readRect
SWFRect readRect(SWFStream &in)
Read a bit-packed rectangle from an SWF stream.
Definition: TypesParser.cpp:130
gnash::SWFStream::align
void align()
Consume all bits of current byte.
Definition: SWFStream.h:135
gnash::SWF::DefineEditTextTag::variableName
const std::string & variableName() const
Definition: DefineEditTextTag.h:83
gnash::SWFStream::ensureBytes
void ensureBytes(unsigned long needed)
Ensure the requested number of bytes are available for an aligned read in the currently opened tag.
Definition: SWFStream.cpp:50
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::SWF::DefineEditTextTag::leftMargin
std::uint16_t leftMargin() const
Get left margin in twips.
Definition: DefineEditTextTag.h:101
gnash::SWF::DefineEditTextTag::indent
std::uint16_t indent() const
Get indentation in twips.
Definition: DefineEditTextTag.h:106
gnash::SWF::DefineEditTextTag::noSelect
bool noSelect() const
Definition: DefineEditTextTag.h:166
SWFStream.h
gnash::readRGBA
rgba readRGBA(SWFStream &in)
Read an RGBA rgba from input stream.
Definition: TypesParser.cpp:95
gnash::SWF::DefineEditTextTag::readOnly
bool readOnly() const
Definition: DefineEditTextTag.h:161