1
// as_object.cpp: ActionScript "ContextMenuItem" 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
21
#include "gnashconfig.h"
24
#include "ui/ContextMenuItem_as.h"
27
#include "Global_as.h"
28
#include "smart_ptr.h" // for boost intrusive_ptr
29
#include "builtin_function.h" // need builtin_function
34
// Forward declarations
36
as_value contextmenuitem_ctor(const fn_call& fn);
37
as_value contextmenuitem_copy(const fn_call& fn);
38
void attachContextMenuItemInterface(as_object& o);
42
// extern (used by Global.cpp)
44
contextmenuitem_class_init(as_object& where, const ObjectURI& uri)
46
registerBuiltinClass(where, contextmenuitem_ctor,
47
attachContextMenuItemInterface, 0, uri);
53
attachContextMenuItemInterface(as_object& o)
55
const int flags = PropFlags::dontEnum |
56
PropFlags::dontDelete |
57
PropFlags::onlySWF7Up;
59
Global_as* gl = getGlobal(o);
60
o.init_member("copy", gl->createFunction(contextmenuitem_copy), flags);
64
contextmenuitem_copy(const fn_call& fn)
66
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
68
Global_as* gl = getGlobal(fn);
69
string_table& st = getStringTable(fn);
72
gl->getMember(st.find("ContextMenuItem")).to_as_function();
74
if (!ctor) return as_value();
77
args += ptr->getMember(st.find("caption")),
78
ptr->getMember(NSV::PROP_ON_SELECT),
79
ptr->getMember(st.find("separatorBefore")),
80
ptr->getMember(NSV::PROP_ENABLED),
81
ptr->getMember(st.find("visible"));
83
return ctor->constructInstance(fn.env(), args);
88
contextmenuitem_ctor(const fn_call& fn)
90
as_object* obj = fn.this_ptr;
92
string_table& st = getStringTable(fn);
94
obj->set_member(st.find("caption"), fn.nargs ? fn.arg(0) : as_value());
95
obj->set_member(NSV::PROP_ON_SELECT, fn.nargs > 1 ? fn.arg(1) : as_value());
96
obj->set_member(st.find("separatorBefore"), fn.nargs > 2 ?
98
obj->set_member(NSV::PROP_ENABLED, fn.nargs > 3 ? fn.arg(3) : true);
99
obj->set_member(st.find("visible"), fn.nargs > 4 ? fn.arg(4) : true);
104
} // anonymous namespace
109
// indent-tabs-mode: t