1
// Mouse.cpp: ActionScript "Mouse" input device class, for Gnash.
3
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
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.
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.
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
21
#include "namedStrings.h"
23
#include "as_object.h" // for inheritance
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
36
// Forward declarations
38
as_value mouse_hide(const fn_call& fn);
39
as_value mouse_show(const fn_call& fn);
41
void attachMouseInterface(as_object& o);
44
/// Mouse isn't a proper class in AS
46
/// Gnash's Mouse_as just has static methods.
48
Mouse_as::registerNative(as_object& o)
52
vm.registerNative(mouse_show, 5, 0);
53
vm.registerNative(mouse_hide, 5, 1);
57
// extern (used by Global.cpp)
59
mouse_class_init(as_object& where, const ObjectURI& uri)
61
registerBuiltinObject(where, attachMouseInterface, uri);
68
attachMouseInterface(as_object& o)
72
const int flags = PropFlags::dontEnum |
73
PropFlags::dontDelete |
76
o.init_member("show", vm.getNative(5, 0), flags);
77
o.init_member("hide", vm.getNative(5, 1), flags);
79
// Mouse is always initialized as an AsBroadcaster, even for
81
AsBroadcaster::initialize(o);
83
Global_as& gl = getGlobal(o);
85
callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, &o, null, 7);
88
/// Returns whether the mouse was visible before the call.
90
/// The return is not a boolean, but rather 1 or 0.
92
mouse_hide(const fn_call& fn)
94
movie_root& m = getRoot(fn);
95
const int success = (m.callInterface("Mouse.hide") == "true") ? 1 : 0;
97
// returns 1 if mouse was visible before call.
98
return as_value(success);
101
/// Returns whether the mouse was visible before the call.
103
/// The return is not a boolean, but rather 1 or 0.
105
mouse_show(const fn_call& fn)
107
movie_root& m = getRoot(fn);
108
const int success = (m.callInterface("Mouse.show") == "true") ? 1 : 0;
110
// returns 1 if Mouse was visible before call.
111
return as_value(success);
114
} // anonymous namespace
115
} // end of gnash namespace