~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libcore/asobj/flash/text/TextSnapshot_as.h

  • Committer: Bazaar Package Importer
  • Author(s): Sindhudweep Narayan Sarkar
  • Date: 2009-10-07 00:06:10 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091007000610-mj9rwqe774gizn1j
Tags: 0.8.6-0ubuntu1
new upstream release 0.8.6 (LP: #435897)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// TextSnapshot_as.h:  ActionScript 3 "TextSnapshot" class, for Gnash.
 
2
//
 
3
//   Copyright (C) 2009 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
#ifndef GNASH_ASOBJ3_TEXTSNAPSHOT_H
 
21
#define GNASH_ASOBJ3_TEXTSNAPSHOT_H
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
#include "gnashconfig.h"
 
25
#endif
 
26
 
 
27
#include "as_object.h"
 
28
 
 
29
 
 
30
namespace gnash {
 
31
 
 
32
        class StaticText;
 
33
    class Array_as;
 
34
    namespace SWF {
 
35
        class TextRecord;
 
36
    }
 
37
 
 
38
// Forward declarations
 
39
class TextSnapshot_as: public as_object
 
40
{
 
41
 
 
42
public:
 
43
 
 
44
    typedef std::vector<const SWF::TextRecord*> Records;
 
45
 
 
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;
 
50
 
 
51
    /// Construct a TextSnapshot_as from a MovieClip.
 
52
    //
 
53
    /// @param mc       The MovieClip to search for static text. If 0, the
 
54
    ///                 TextSnapshot is invalid, which should be reflected in
 
55
    ///                 AS return values.
 
56
    TextSnapshot_as(const MovieClip* mc);
 
57
 
 
58
    static void init(as_object& where, const ObjectURI& uri);
 
59
 
 
60
    std::string getText(boost::int32_t start, boost::int32_t end,
 
61
            bool nl) const;
 
62
 
 
63
    boost::int32_t findText(boost::int32_t start, const std::string& text,
 
64
            bool ignoreCase) const;
 
65
 
 
66
    bool valid() const { return _valid; }
 
67
 
 
68
    size_t getCount() const { return _count; }
 
69
 
 
70
    void setSelected(size_t start, size_t end, bool selected);
 
71
    
 
72
    bool getSelected(size_t start, size_t end) const;
 
73
 
 
74
    std::string getSelectedText(bool newlines) const;
 
75
 
 
76
    void getTextRunInfo(size_t start, size_t end, Array_as& ri) const;
 
77
 
 
78
protected:
 
79
 
 
80
    void markReachableResources() const;
 
81
 
 
82
private:
 
83
 
 
84
    /// Generate a string from the TextRecords in this TextSnapshot.
 
85
    //
 
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;
 
97
 
 
98
    TextFields _textFields;
 
99
 
 
100
    /// Whether the object is valid, i.e. it was constructed with a MovieClip.
 
101
    //
 
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.
 
104
    const bool _valid;
 
105
 
 
106
    /// The number of DisplayObjects
 
107
    //
 
108
    /// There is no need to store this, but it is quicker than counting
 
109
    /// afresh every time.
 
110
    const size_t _count;
 
111
 
 
112
};
 
113
 
 
114
void registerTextSnapshotNative(as_object& global);
 
115
 
 
116
} // gnash namespace
 
117
 
 
118
// GNASH_ASOBJ3_TEXTSNAPSHOT_H
 
119
#endif
 
120
 
 
121
// local Variables:
 
122
// mode: C++
 
123
// indent-tabs-mode: t
 
124
// End:
 
125