1
// TextSnapshot_as.h: ActionScript 3 "TextSnapshot" class, for Gnash.
3
// Copyright (C) 2009 Free Software Foundation, Inc.
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.
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.
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
20
#ifndef GNASH_ASOBJ3_TEXTSNAPSHOT_H
21
#define GNASH_ASOBJ3_TEXTSNAPSHOT_H
24
#include "gnashconfig.h"
27
#include "as_object.h"
38
// Forward declarations
39
class TextSnapshot_as: public as_object
44
typedef std::vector<const SWF::TextRecord*> Records;
46
/// Should remain in the order of insertion
47
/// We should only ever iterate from begin to end, so there's no
48
/// performance issue.
49
typedef std::vector<std::pair<StaticText*, Records> > TextFields;
51
/// Construct a TextSnapshot_as from a MovieClip.
53
/// @param mc The MovieClip to search for static text. If 0, the
54
/// TextSnapshot is invalid, which should be reflected in
56
TextSnapshot_as(const MovieClip* mc);
58
static void init(as_object& where, const ObjectURI& uri);
60
std::string getText(boost::int32_t start, boost::int32_t end,
63
boost::int32_t findText(boost::int32_t start, const std::string& text,
64
bool ignoreCase) const;
66
bool valid() const { return _valid; }
68
size_t getCount() const { return _count; }
70
void setSelected(size_t start, size_t end, bool selected);
72
bool getSelected(size_t start, size_t end) const;
74
std::string getSelectedText(bool newlines) const;
76
void getTextRunInfo(size_t start, size_t end, Array_as& ri) const;
80
void markReachableResources() const;
84
/// Generate a string from the TextRecords in this TextSnapshot.
86
/// @param to The string to write to
87
/// @param newline If true, newlines are written after every
88
/// StaticText in this TextSnapshot
89
/// @param selectedOnly Only write DisplayObject that are selected to.
90
/// @param start The start index
91
/// @param len The number of StaticText DisplayObjects to traverse.
92
/// This includes non-selected DisplayObjects.
93
void makeString(std::string& to, bool newline = false,
94
bool selectedOnly = false,
95
std::string::size_type start = 0,
96
std::string::size_type len = std::string::npos) const;
98
TextFields _textFields;
100
/// Whether the object is valid, i.e. it was constructed with a MovieClip.
102
/// This should be deducible from another member, but since there seems
103
/// to be no point in storing the MovieClip this bool will do instead.
106
/// The number of DisplayObjects
108
/// There is no need to store this, but it is quicker than counting
109
/// afresh every time.
114
void registerTextSnapshotNative(as_object& global);
118
// GNASH_ASOBJ3_TEXTSNAPSHOT_H
123
// indent-tabs-mode: t