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
TextField::TextAlignment alignment() const
Get text alignment.
Definition: DefineEditTextTag.h:138
std::uint16_t rightMargin() const
Get right margin in twips.
Definition: DefineEditTextTag.h:96
bool password() const
Definition: DefineEditTextTag.h:133
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
bool getUseEmbeddedGlyphs() const
Return true if this DisplayObject definition requested use of device fonts.
Definition: DefineEditTextTag.h:178
boost::intrusive_ptr< Font > getFont() const
Definition: DefineEditTextTag.h:183
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Load an SWF::DEFINEEDITTEXT (37) tag.
Definition: DefineEditTextTag.cpp:34
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
std::uint16_t leftMargin() const
Get left margin in twips.
Definition: DefineEditTextTag.h:101
Immutable data representing the definition of a movie display element.
Definition: DefinitionTag.h:47
std::uint16_t textHeight() const
Get height of font in twips.
Definition: DefineEditTextTag.h:112
bool noSelect() const
Definition: DefineEditTextTag.h:166
const SWFRect & bounds() const
Definition: DefineEditTextTag.h:67
bool readOnly() const
Definition: DefineEditTextTag.h:161
const rgba & color() const
Get color of the text.
Definition: DefineEditTextTag.h:117
unsigned int maxChars() const
Return the maximum length of text this widget can hold.
Definition: DefineEditTextTag.h:91
std::uint16_t leading() const
Get extra space between lines (in twips).
Definition: DefineEditTextTag.h:125
Definition: GnashKey.h:164
const std::string & defaultText() const
Definition: DefineEditTextTag.h:74
bool hasText() const
Has text defined ?
Definition: DefineEditTextTag.h:157
~DefineEditTextTag()
Definition: DefineEditTextTag.h:61
TextAlignment
Text alignment values.
Definition: TextField.h:64
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:53
bool autoSize() const
Definition: DefineEditTextTag.h:147
bool multiline() const
Definition: DefineEditTextTag.h:129
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:49
SWF Tag DefineEditText (37).
Definition: DefineEditTextTag.h:56
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
bool html() const
Return true if HTML was allowed by definition.
Definition: DefineEditTextTag.h:172
bool border() const
Is border requested ?
Definition: DefineEditTextTag.h:143
Definition: GnashKey.h:159
DisplayObject * createDisplayObject(Global_as &gl, DisplayObject *parent) const
Create a DisplayObject with the given parent.
Definition: DefineEditTextTag.cpp:48
bool wordWrap() const
Word wrap requested ?
Definition: DefineEditTextTag.h:152
Definition: GnashKey.h:331
SWF stream wrapper class.
Definition: SWFStream.h:58
const std::string & variableName() const
Definition: DefineEditTextTag.h:83
std::uint16_t indent() const
Get indentation in twips.
Definition: DefineEditTextTag.h:106
A basic RGBA type.
Definition: RGBA.h:35