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 <boost/cstdint.hpp>
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<boost::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<boost::uint32_t>& blockIndent() const {
95  return _blockIndent;
96  }
97 
100  const boost::optional<boost::uint16_t>& leading() const { return _leading; }
101 
103  const boost::optional<boost::uint16_t>& leftMargin() const { return _leftMargin; }
104 
106  const boost::optional<boost::uint16_t>& rightMargin() const {
107  return _rightMargin;
108  }
109 
111  const boost::optional<boost::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<boost::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<boost::uint32_t>& x) {
138  _blockIndent = x;
139  }
140 
141  void leadingSet(const boost::optional<boost::uint16_t>& x) { _leading = x; }
142 
143  void leftMarginSet(const boost::optional<boost::uint16_t>& x) { _leftMargin = x; }
144 
145  void rightMarginSet(const boost::optional<boost::uint16_t>& x) {
146  _rightMargin = x;
147  }
148 
149  void sizeSet(const boost::optional<boost::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<boost::uint32_t> _blockIndent;
182 
184  //
187  boost::optional<rgba> _color;
188 
189  // The name of a font for text as a string.
190  boost::optional<std::string> _font;
191 
194  boost::optional<boost::uint16_t> _indent;
195 
198  boost::optional<boost::uint16_t> _leading;
199 
201  boost::optional<boost::uint16_t> _leftMargin;
202 
204  boost::optional<boost::uint16_t> _rightMargin;
205 
207  boost::optional<boost::uint16_t> _pointSize;
208 
210  boost::optional<std::vector<int> > _tabStops;
211 
217  boost::optional<std::string> _target;
218 
221  boost::optional<std::string> _url;
222 };
223 
224 void textformat_class_init(as_object& global, const ObjectURI& uri);
225 
226 void registerTextFormatNative(as_object& global);
227 
228 } // end of gnash namespace
229 
230 #endif
231