don't use CROSS_FLAGS for executables, as -all-staic prevents Android from looking...
[gnash.git] / libcore / StaticText.h
blobf392a73574631f7b9743496e39450d504abf3d0c
1 // StaticText.h: StaticText DisplayObject implementation for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_STATIC_TEXT_H
21 #define GNASH_STATIC_TEXT_H
23 #include "DisplayObject.h" // for inheritance
24 #include "swf/DefineTextTag.h"
26 #include <vector>
27 #include <boost/dynamic_bitset.hpp>
28 #include <boost/intrusive_ptr.hpp>
29 #include <cassert>
31 // Forward declarations
32 namespace gnash {
33 namespace SWF {
34 class TextRecord;
38 namespace gnash {
40 /// Static text fields, SWF-defined with read-only text.
42 /// StaticText objects hold mutable selection and color information.
43 class StaticText : public DisplayObject
45 public:
47 StaticText(movie_root& mr, as_object* object, const SWF::DefineTextTag* def,
48 DisplayObject* parent)
50 DisplayObject(mr, object, parent),
51 _def(def),
52 _selectionColor(0, 255, 255, 255)
54 assert(_def);
57 /// Return a pointer to this if our definition contains any static text.
59 /// This is non-const because a TextSnapshot needs to add selection and
60 /// color information to this StaticText. It also resets selection.
62 /// @param to A vector of pointers to TextRecords containing text.
63 /// @param numChars The total number of DisplayObjects in all TextRecords is
64 /// written to this variable.
65 /// Note: This function always removes any existing selection and resizes
66 /// the bitset to the number of DisplayObjects in all TextRecords.
67 virtual StaticText* getStaticText(std::vector<const SWF::TextRecord*>& to,
68 size_t& numChars);
70 virtual void display(Renderer& renderer, const Transform& xform);
72 void setSelected(size_t pos, bool selected) {
73 _selectedText.set(pos, selected);
76 /// Return a bitset showing which DisplayObjects (by index) are selected.
78 /// Note: mutable information is meaningless until the StaticText is
79 /// queried with getStaticText(). This is because under normal
80 /// circumstances there is no need for it.
81 /// Note also: the size() member of boost::dynamic_bitset returns 0 before
82 /// getStaticText() is called; afterwards it is equivalent to the
83 /// number of DisplayObjects in the StaticText's definition.
84 const boost::dynamic_bitset<>& getSelected() const {
85 return _selectedText;
88 void setSelectionColor(boost::uint32_t color);
90 virtual SWFRect getBounds() const {
91 return _def->bounds();
94 virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
96 const rgba& selectionColor() const {
97 return _selectionColor;
100 private:
102 const boost::intrusive_ptr<const SWF::DefineTextTag> _def;
104 /// A bitmask indicating which static text DisplayObjects are selected
106 /// This is only present for static text fields, and only after
107 /// a TextSnapshot has queried the DisplayObject for text.
108 boost::dynamic_bitset<> _selectedText;
110 /// The color of the background for selected DisplayObjects.
112 /// This is alawys opaque.
113 rgba _selectionColor;
118 } // end namespace gnash
121 #endif
124 // Local Variables:
125 // mode: C++
126 // indent-tabs-mode: t
127 // End: