~ubuntu-branches/ubuntu/maverick/gnash/maverick

« back to all changes in this revision

Viewing changes to libcore/asobj/Mouse_as.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Micah Gersten, Micah Gersten, Chris Coulson
  • Date: 2010-09-28 23:38:37 UTC
  • mfrom: (1.1.14 upstream) (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100928233837-wcay0dodera1c7sz
Tags: 0.8.8-5ubuntu1
[ Micah Gersten <micahg@ubuntu.com> ]
* FFe - LP: #636667
* Merge from debian unstable.  Remaining changes:
  + Add Ubuntu flash alternatives in postinst and prerm
    - update debian/browser-plugin-gnash.postinst
    - update debian/browser-plugin-gnash.prerm

[ Chris Coulson <chris.coulson@canonical.com> ]
* Ensure the directories we are installing alternatives too exist
  already
  - add debian/browser-plugin-gnash.dirs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Mouse.cpp:  ActionScript "Mouse" input device class, for Gnash.
 
2
// 
 
3
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
 
4
//   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
 
19
//
 
20
 
 
21
#include "namedStrings.h"
 
22
#include "Mouse_as.h"
 
23
#include "as_object.h" // for inheritance
 
24
#include "log.h"
 
25
#include "fn_call.h"
 
26
#include "Global_as.h"
 
27
#include "smart_ptr.h" // for boost intrusive_ptr
 
28
#include "builtin_function.h" // need builtin_function
 
29
#include "NativeFunction.h" 
 
30
#include "VM.h" // for registerNative
 
31
#include "AsBroadcaster.h" // for initializing self as a broadcaster
 
32
#include "movie_root.h" // for GUI callback
 
33
 
 
34
namespace gnash {
 
35
 
 
36
// Forward declarations
 
37
namespace {    
 
38
    as_value mouse_hide(const fn_call& fn);
 
39
    as_value mouse_show(const fn_call& fn);
 
40
 
 
41
    void attachMouseInterface(as_object& o);
 
42
}
 
43
 
 
44
/// Mouse isn't a proper class in AS
 
45
//
 
46
/// Gnash's Mouse_as just has static methods.
 
47
void
 
48
Mouse_as::registerNative(as_object& o)
 
49
{
 
50
    VM& vm = getVM(o);
 
51
 
 
52
    vm.registerNative(mouse_show, 5, 0);
 
53
    vm.registerNative(mouse_hide, 5, 1);
 
54
}
 
55
 
 
56
 
 
57
// extern (used by Global.cpp)
 
58
void
 
59
mouse_class_init(as_object& where, const ObjectURI& uri)
 
60
{
 
61
    registerBuiltinObject(where, attachMouseInterface, uri);
 
62
}
 
63
 
 
64
 
 
65
namespace {
 
66
 
 
67
void
 
68
attachMouseInterface(as_object& o)
 
69
{
 
70
    VM& vm = getVM(o);
 
71
 
 
72
    const int flags = PropFlags::dontEnum |
 
73
                      PropFlags::dontDelete |
 
74
                      PropFlags::readOnly;
 
75
 
 
76
    o.init_member("show", vm.getNative(5, 0), flags);
 
77
    o.init_member("hide", vm.getNative(5, 1), flags);
 
78
 
 
79
    // Mouse is always initialized as an AsBroadcaster, even for
 
80
    // SWF5.   
 
81
    AsBroadcaster::initialize(o);
 
82
 
 
83
    Global_as& gl = getGlobal(o);
 
84
    as_object* null = 0;
 
85
    callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, &o, null, 7);
 
86
}
 
87
 
 
88
/// Returns whether the mouse was visible before the call.
 
89
//
 
90
/// The return is not a boolean, but rather 1 or 0.
 
91
as_value
 
92
mouse_hide(const fn_call& fn)
 
93
{
 
94
    movie_root& m = getRoot(fn);
 
95
    const int success = (m.callInterface("Mouse.hide") == "true") ? 1 : 0;
 
96
 
 
97
    // returns 1 if mouse was visible before call.
 
98
    return as_value(success);
 
99
}
 
100
 
 
101
/// Returns whether the mouse was visible before the call.
 
102
//
 
103
/// The return is not a boolean, but rather 1 or 0.
 
104
as_value
 
105
mouse_show(const fn_call& fn)
 
106
{
 
107
    movie_root& m = getRoot(fn);
 
108
    const int success = (m.callInterface("Mouse.show") == "true") ? 1 : 0;
 
109
 
 
110
    // returns 1 if Mouse was visible before call.
 
111
    return as_value(success);
 
112
}
 
113
 
 
114
} // anonymous namespace
 
115
} // end of gnash namespace