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 <boost/cstdint.hpp> // for boost::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  boost::uint16_t rightMargin() const {
97  return _rightMargin;
98  }
99 
101  boost::uint16_t leftMargin() const {
102  return _leftMargin;
103  }
104 
106  boost::uint16_t indent() const {
107  return _indent;
108  }
109 
111  // @@ what if has_font is false ??
112  boost::uint16_t textHeight() const {
113  return _textHeight;
114  }
115 
117  const rgba& color() const {
118  return _color;
119  }
120 
123  //
125  boost::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, boost::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  boost::uint16_t _textHeight;
265 
267  rgba _color;
268 
270  //
273  unsigned int _maxChars;
274 
275  TextField::TextAlignment _alignment;
276 
278  boost::uint16_t _leftMargin;
279 
281  boost::uint16_t _rightMargin;
282 
284  boost::uint16_t _indent;
285 
289  boost::uint16_t _leading;
290 
292  std::string _defaultText;
293 };
294 
295 
296 } // namespace gnash::SWF
297 } // namespace gnash
298 
299 #endif