Gnash
0.8.10
|
00001 // 00002 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 00003 // Free Software Foundation, Inc. 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 #ifndef GNASH_SWF_DEFINEEDITTEXTTAG_H 00020 #define GNASH_SWF_DEFINEEDITTEXTTAG_H 00021 00022 #include "SWFRect.h" 00023 #include "DefinitionTag.h" 00024 #include "SWF.h" // for TagType definition 00025 #include "RGBA.h" 00026 #include "TextField.h" 00027 00028 #include <boost/intrusive_ptr.hpp> 00029 #include <string> 00030 #include <boost/cstdint.hpp> // for boost::uint16_t and friends 00031 00032 00033 // Forward declarations 00034 namespace gnash { 00035 class SWFStream; 00036 class movie_definition; 00037 class RunResources; 00038 class Font; 00039 } 00040 00041 namespace gnash { 00042 namespace SWF { 00043 00045 // 00056 class DefineEditTextTag : public DefinitionTag 00057 { 00058 00059 public: 00060 00061 ~DefineEditTextTag() {} 00062 00064 static void loader(SWFStream& in, TagType tag, movie_definition& m, 00065 const RunResources& r); 00066 00067 const SWFRect& bounds() const { return _rect; } 00068 00069 DisplayObject* createDisplayObject(Global_as& gl, 00070 DisplayObject* parent) const; 00071 00074 const std::string& defaultText() const { 00075 return _defaultText; 00076 } 00077 00083 const std::string& variableName() const { 00084 return _variableName; 00085 } 00086 00088 // 00091 unsigned int maxChars() const { 00092 return _maxChars; 00093 } 00094 00096 boost::uint16_t rightMargin() const { 00097 return _rightMargin; 00098 } 00099 00101 boost::uint16_t leftMargin() const { 00102 return _leftMargin; 00103 } 00104 00106 boost::uint16_t indent() const { 00107 return _indent; 00108 } 00109 00111 // @@ what if has_font is false ?? 00112 boost::uint16_t textHeight() const { 00113 return _textHeight; 00114 } 00115 00117 const rgba& color() const { 00118 return _color; 00119 } 00120 00123 // 00125 boost::uint16_t leading() const { 00126 return _leading; 00127 } 00128 00129 bool multiline() const { 00130 return _multiline; 00131 } 00132 00133 bool password() const { 00134 return _password; 00135 } 00136 00138 TextField::TextAlignment alignment() const { 00139 return _alignment; 00140 } 00141 00143 bool border() const { 00144 return _border; 00145 } 00146 00147 bool autoSize() const { 00148 return _autoSize; 00149 } 00150 00152 bool wordWrap() const { 00153 return _wordWrap; 00154 } 00155 00157 bool hasText() const { 00158 return _hasText; 00159 } 00160 00161 bool readOnly() const 00162 { 00163 return _readOnly; 00164 } 00165 00166 bool noSelect() const 00167 { 00168 return _noSelect; 00169 } 00170 00172 bool html() const { return _html; } 00173 00175 // 00178 bool getUseEmbeddedGlyphs() const 00179 { 00180 return _useOutlines; 00181 } 00182 00183 boost::intrusive_ptr<Font> getFont() const 00184 { 00185 return _font; 00186 } 00187 00188 private: 00189 00191 // 00193 DefineEditTextTag(SWFStream& in, movie_definition& m, boost::uint16_t id); 00194 00196 void read(SWFStream& in, movie_definition& m); 00197 00198 SWFRect _rect; 00199 00200 std::string _variableName; 00201 00202 // For an SWF-defined textfield we'll read 00203 // this from the tag. Dynamic textfields should 00204 // behave as always having text by default (not tested). 00205 bool _hasText; 00206 bool _wordWrap; 00207 bool _multiline; 00208 00210 bool _password; 00211 bool _readOnly; 00213 bool _autoSize; 00214 bool _noSelect; 00215 00218 bool _border; 00219 00221 // 00244 bool _html; 00245 00252 // For an SWF-defined textfield we'll read 00253 // this from the tag. Dynamic textfields should 00254 // use device fonts by default (so not use outline ones) 00255 bool _useOutlines; 00256 00257 int _fontID; 00258 boost::intrusive_ptr<Font> _font; 00259 00261 // TODO: initialize to a meaningful value (see MovieClip::add_textfield) 00262 // and make sure get_font_height is not called for rendering purposes 00263 // (instead call a method of TextField) (?) 00264 boost::uint16_t _textHeight; 00265 00267 rgba _color; 00268 00270 // 00273 unsigned int _maxChars; 00274 00275 TextField::TextAlignment _alignment; 00276 00278 boost::uint16_t _leftMargin; 00279 00281 boost::uint16_t _rightMargin; 00282 00284 boost::uint16_t _indent; 00285 00289 boost::uint16_t _leading; 00290 00292 std::string _defaultText; 00293 }; 00294 00295 00296 } // namespace gnash::SWF 00297 } // namespace gnash 00298 00299 #endif