Gnash  0.8.11dev
TextFormat_as.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 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 //
20 //
21 
22 #ifndef GNASH_TEXTFORMAT_H
23 #define GNASH_TEXTFORMAT_H
24 
25 #include <vector>
26 #include <cstdint>
27 #include <string>
28 #include <boost/optional.hpp>
29 
30 #include "TextField.h"
31 #include "RGBA.h"
32 
33 namespace gnash {
34  class as_object;
35 }
36 
37 namespace gnash {
38 
40 //
42 //
44 class TextFormat_as : public Relay
45 {
46 public:
47 
48  TextFormat_as();
49 
51 
53  const boost::optional<bool>& underlined() const { return _underline; }
54 
56  const boost::optional<bool>& bold() const { return _bold; }
57 
59  const boost::optional<bool>& italic() const { return _italic; }
60 
62  const boost::optional<rgba>& color() const { return _color; }
63 
65  const boost::optional<bool>& bullet() const { return _bullet; }
66 
68  //
71  return _display;
72  }
73 
74  const boost::optional<std::vector<int> >& tabStops() const {
75  return _tabStops;
76  }
77 
79  const boost::optional<std::uint16_t>& indent() const { return _indent; }
80 
82  const boost::optional<TextField::TextAlignment>& align() const { return _align; }
83 
85  const boost::optional<std::string>& font() const { return _font; }
86 
87  // See doc for _target member
88  const boost::optional<std::string>& target() const { return _target; }
89 
90  // See doc for _url member
91  const boost::optional<std::string>& url() const { return _url; }
92 
94  const boost::optional<std::uint32_t>& blockIndent() const {
95  return _blockIndent;
96  }
97 
100  const boost::optional<std::uint16_t>& leading() const { return _leading; }
101 
103  const boost::optional<std::uint16_t>& leftMargin() const { return _leftMargin; }
104 
106  const boost::optional<std::uint16_t>& rightMargin() const {
107  return _rightMargin;
108  }
109 
111  const boost::optional<std::uint16_t>& size() const { return _pointSize; }
112 
114 
115  void targetSet(const boost::optional<std::string>& s) { _target=s; }
116 
117  void urlSet(const boost::optional<std::string>& s) { _url=s; }
118 
119  void underlinedSet(const boost::optional<bool>& x) { _underline = x; }
120 
121  void italicSet(const boost::optional<bool>& x) { _italic = x; }
122 
123  void boldSet(const boost::optional<bool>& x) { _bold = x; }
124 
125  void bulletSet(const boost::optional<bool>& x) { _bullet = x; }
126 
127  void colorSet(const boost::optional<rgba>& x) { _color = x; }
128 
129  void indentSet(const boost::optional<std::uint16_t>& x) { _indent = x; }
130 
131  void fontSet(const boost::optional<std::string>& font) { _font=font; }
132 
133  void alignSet(const boost::optional<TextField::TextAlignment>& x) { _align = x; }
134 
135  void alignSet(const std::string& align);
136 
137  void blockIndentSet(const boost::optional<std::uint32_t>& x) {
138  _blockIndent = x;
139  }
140 
141  void leadingSet(const boost::optional<std::uint16_t>& x) { _leading = x; }
142 
143  void leftMarginSet(const boost::optional<std::uint16_t>& x) { _leftMargin = x; }
144 
145  void rightMarginSet(const boost::optional<std::uint16_t>& x) {
146  _rightMargin = x;
147  }
148 
149  void sizeSet(const boost::optional<std::uint16_t>& x) { _pointSize = x; }
150 
151  void tabStopsSet(const std::vector<int>& tabStops) { _tabStops = tabStops; }
152 
155  void displaySet(const std::string& display);
156 private:
157 
159  boost::optional<bool> _underline;
160 
162  boost::optional<bool> _bold;
163 
165  boost::optional<bool> _italic;
166 
167  //
168  boost::optional<bool> _bullet;
169 
171 
173  //
178  boost::optional<TextField::TextAlignment> _align;
179 
180  //
181  boost::optional<std::uint32_t> _blockIndent;
182 
184  //
187  boost::optional<rgba> _color;
188 
194  boost::optional<std::string> _font;
195 
198  boost::optional<std::uint16_t> _indent;
199 
202  boost::optional<std::uint16_t> _leading;
203 
205  boost::optional<std::uint16_t> _leftMargin;
206 
208  boost::optional<std::uint16_t> _rightMargin;
209 
211  boost::optional<std::uint16_t> _pointSize;
212 
214  boost::optional<std::vector<int> > _tabStops;
215 
221  boost::optional<std::string> _target;
222 
225  boost::optional<std::string> _url;
226 };
227 
228 void textformat_class_init(as_object& global, const ObjectURI& uri);
229 
230 void registerTextFormatNative(as_object& global);
231 
232 } // end of gnash namespace
233 
234 #endif
235 
gnash::TextFormat_as::bullet
const boost::optional< bool > & bullet() const
Whether the text should have a bullet.
Definition: TextFormat_as.h:65
gnash::TextFormat_as::fontSet
void fontSet(const boost::optional< std::string > &font)
Definition: TextFormat_as.h:131
gnash::toNumber
double toNumber(const as_value &v, const VM &vm)
Convert an as_value to a double.
Definition: VM.cpp:451
gnash::TextFormat_as::indentSet
void indentSet(const boost::optional< std::uint16_t > &x)
Definition: TextFormat_as.h:129
Movie.h
movie_root.h
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::toBool
bool toBool(const as_value &v, const VM &vm)
Convert an as_value to boolean type.
Definition: VM.cpp:445
height
@ height
Definition: klash_part.cpp:329
gnash::toInt
std::int32_t toInt(const as_value &v, const VM &vm)
AS2-compatible conversion to 32bit integer.
Definition: VM.cpp:463
gnash::TextFormat_as::alignSet
void alignSet(const boost::optional< TextField::TextAlignment > &x)
Definition: TextFormat_as.h:133
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
gnash::TextField::TEXTFORMAT_BLOCK
@ TEXTFORMAT_BLOCK
Definition: TextField.h:75
gnash::toObject
as_object * toObject(const as_value &v, VM &vm)
Convert an as_value to an object.
Definition: VM.cpp:457
gnash::key::T
@ T
Definition: GnashKey.h:132
gnash::TextFormat_as::leftMarginSet
void leftMarginSet(const boost::optional< std::uint16_t > &x)
Definition: TextFormat_as.h:143
gnash::movie_root::getRootMovie
Movie & getRootMovie()
Access the originating root movie (not necessarily _level0)
Definition: movie_root.h:303
gnash::TextFormat_as::rightMarginSet
void rightMarginSet(const boost::optional< std::uint16_t > &x)
Definition: TextFormat_as.h:145
gnash::TextFormat_as::blockIndent
const boost::optional< std::uint32_t > & blockIndent() const
The block indent.
Definition: TextFormat_as.h:94
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
LOG_ONCE
#define LOG_ONCE(x)
Definition: log.h:49
gnash::TextField::ALIGN_RIGHT
@ ALIGN_RIGHT
Definition: TextField.h:67
gnash::pixelsToTwips
std::int32_t pixelsToTwips(double a)
Definition: GnashNumeric.h:144
_
#define _(String)
Definition: log.h:44
gnash::TextFormat_as::font
const boost::optional< std::string > & font() const
Font name.
Definition: TextFormat_as.h:85
gnash::as_object::init_member
void init_member(const std::string &name, const as_value &val, int flags=DefaultFlags)
Initialize a member value by string.
Definition: as_object.cpp:669
gnash::textformat_class_init
void textformat_class_init(as_object &global, const ObjectURI &uri)
Definition: TextFormat_as.cpp:374
gnash::VM
The AVM1 virtual machine.
Definition: VM.h:72
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::TextFormat_as::underlined
const boost::optional< bool > & underlined() const
Return a Boolean value that indicates whether the text is underlined.
Definition: TextFormat_as.h:53
gnash::TextFormat_as::underlinedSet
void underlinedSet(const boost::optional< bool > &x)
Definition: TextFormat_as.h:119
gnash::TextField::ALIGN_CENTER
@ ALIGN_CENTER
Definition: TextField.h:68
gnash::TextFormat_as::colorSet
void colorSet(const boost::optional< rgba > &x)
Definition: TextFormat_as.h:127
gnash::TextFormat_as::leadingSet
void leadingSet(const boost::optional< std::uint16_t > &x)
Definition: TextFormat_as.h:141
gnash::key::s
@ s
Definition: GnashKey.h:165
NativeFunction.h
Global_as.h
gnash::TextField::TextFormatDisplay
TextFormatDisplay
Text format display values.
Definition: TextField.h:74
gnash::TextFormat_as
The TextFormat_as Relay type stores text properties.
Definition: TextFormat_as.h:45
gnash::getGlobal
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
gnash::twipsToPixels
double twipsToPixels(int i)
Definition: GnashNumeric.h:97
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
gnash::TextFormat_as::bulletSet
void bulletSet(const boost::optional< bool > &x)
Definition: TextFormat_as.h:125
gnash::TextFormat_as::color
const boost::optional< rgba > & color() const
Return the color of text using this text format.
Definition: TextFormat_as.h:62
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::TextFormat_as::size
const boost::optional< std::uint16_t > & size() const
Return a float that indicates the point size in twips.
Definition: TextFormat_as.h:111
gnash::createObject
as_object * createObject(const Global_as &gl)
Definition: Global_as.cpp:303
gnash::as_object::DefaultFlags
static const int DefaultFlags
The most common flags for built-in properties.
Definition: as_object.h:192
gnash::key::t
@ t
Definition: GnashKey.h:166
gnash::TextFormat_as::rightMargin
const boost::optional< std::uint16_t > & rightMargin() const
Indicates the right margin of the paragraph in twips.
Definition: TextFormat_as.h:106
gnash::TextFormat_as::displaySet
void displaySet(TextField::TextFormatDisplay x)
These are not optional!
Definition: TextFormat_as.h:154
gnash::TextField::ALIGN_LEFT
@ ALIGN_LEFT
Definition: TextField.h:66
gnash::fontlib::get_font
Font * get_font(const std::string &name, bool bold, bool italic)
Definition: fontlib.cpp:50
gnash::key::a
@ a
Definition: GnashKey.h:147
gnash::Relay
This is the base class for type-specific object data.
Definition: Relay.h:50
gnash::Global_as::createClass
as_object * createClass(Global_as::ASFunction ctor, as_object *prototype)
Create an ActionScript class.
Definition: Global_as.cpp:180
gnash::TextField::TextAlignment
TextAlignment
Text alignment values.
Definition: TextField.h:65
StringPredicates.h
gnash::Movie::definition
virtual const movie_definition * definition() const =0
gnash::key::F
@ F
Definition: GnashKey.h:118
gnash::TextFormat_as::italicSet
void italicSet(const boost::optional< bool > &x)
Definition: TextFormat_as.h:121
gnash::TextFormat_as::target
const boost::optional< std::string > & target() const
Definition: TextFormat_as.h:88
gnash::TextFormat_as::bold
const boost::optional< bool > & bold() const
Return a Boolean value that indicates whether the text is boldface.
Definition: TextFormat_as.h:56
IF_VERBOSE_ASCODING_ERRORS
#define IF_VERBOSE_ASCODING_ERRORS(x)
Definition: log.h:397
gnash::TextFormat_as::tabStops
const boost::optional< std::vector< int > > & tabStops() const
Definition: TextFormat_as.h:74
gnash::get
T * get(as_object *o)
Extract the DisplayObject attached to an object.
Definition: as_object.h:842
gnash::StringNoCaseEqual
A case-insensitive string equality operator.
Definition: StringPredicates.h:42
gnash::VM::registerNative
void registerNative(as_c_function_ptr fun, unsigned int x, unsigned int y)
Definition: VM.cpp:268
gnash::TextFormat_as::indent
const boost::optional< std::uint16_t > & indent() const
Indentation from left margin to the first character in the paragraph.
Definition: TextFormat_as.h:79
RGBA.h
gnash::TextFormat_as::boldSet
void boldSet(const boost::optional< bool > &x)
Definition: TextFormat_as.h:123
GnashNumeric.h
Font.h
gnash::TextFormat_as::leftMargin
const boost::optional< std::uint16_t > & leftMargin() const
Indicates the left margin of the paragraph, in points.
Definition: TextFormat_as.h:103
gnash::TextField::TEXTFORMAT_INLINE
@ TEXTFORMAT_INLINE
Definition: TextField.h:76
gnash::TextFormat_as::urlSet
void urlSet(const boost::optional< std::string > &s)
Definition: TextFormat_as.h:117
VM.h
gnash::TextFormat_as::targetSet
void targetSet(const boost::optional< std::string > &s)
Setters.
Definition: TextFormat_as.h:115
gnash::log_aserror
void log_aserror(StringType msg, Args... args)
Definition: log.h:331
log.h
gnash::getRoot
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
gnash::TextFormat_as::leading
const boost::optional< std::uint16_t > & leading() const
Definition: TextFormat_as.h:100
fn_call.h
gnash::key::f
@ f
Definition: GnashKey.h:152
TextField.h
gnash::TextField
An instance of a DefineEditTextTag.
Definition: TextField.h:57
namedStrings.h
gnash::Global_as
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
gnash::registerTextFormatNative
void registerTextFormatNative(as_object &o)
Definition: TextFormat_as.cpp:241
gnash::getSWFVersion
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
gnash::movie_definition::exportID
virtual std::uint16_t exportID(const std::string &) const
Get the id that corresponds to a symbol.
Definition: movie_definition.h:396
test.uri
uri
Definition: test.py:12
gnash::fontlib::get_default_font
boost::intrusive_ptr< Font > get_default_font()
Return a default device font.
Definition: fontlib.cpp:42
gnash::TextField::ALIGN_JUSTIFY
@ ALIGN_JUSTIFY
Definition: TextField.h:69
gnash::TextFormat_as::blockIndentSet
void blockIndentSet(const boost::optional< std::uint32_t > &x)
Definition: TextFormat_as.h:137
gnash::TextFormat_as::TextFormat_as
TextFormat_as()
Definition: TextFormat_as.cpp:216
gnash::TextFormat_as::tabStopsSet
void tabStopsSet(const std::vector< int > &tabStops)
Definition: TextFormat_as.h:151
gnash::TextFormat_as::sizeSet
void sizeSet(const boost::optional< std::uint16_t > &x)
Definition: TextFormat_as.h:149
gnash::TextFormat_as::align
const boost::optional< TextField::TextAlignment > & align() const
Paragraph alignment.
Definition: TextFormat_as.h:82
movie_definition.h
TextFormat_as.h
Array_as.h
gnash::TextFormat_as::~TextFormat_as
~TextFormat_as()
Definition: TextFormat_as.h:50
gnash::key::o
@ o
Definition: GnashKey.h:161
gnash::key::P
@ P
Definition: GnashKey.h:128
width
@ width
Definition: klash_part.cpp:329
gnash::foreachArray
void foreachArray(as_object &array, T &pred)
Definition: Array_as.h:78
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::ObjectURI
A URI for describing as_objects.
Definition: ObjectURI.h:45
x
std::int32_t x
Definition: BitmapData_as.cpp:434
test.v
v
Definition: test.py:11
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::TextFormat_as::display
TextField::TextFormatDisplay display() const
The display type (block or inline).
Definition: TextFormat_as.h:70
gnash::TextFormat_as::italic
const boost::optional< bool > & italic() const
Return a Boolean value that indicates whether the text is italicized.
Definition: TextFormat_as.h:59
gnash::TextFormat_as::url
const boost::optional< std::string > & url() const
Definition: TextFormat_as.h:91
fontlib.h