1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <grts/structs.ui.h>
#include <grtpp_util.h>
#include "mforms_ObjectReference_impl.h"
#include <typeinfo>
#include "mforms/base.h"
#include "mforms/menubar.h"
#include "mforms/dockingpoint.h"
//================================================================================
// mforms_ObjectReference
grt::IntegerRef mforms_ObjectReference::valid() const
{
if (_data)
return grt::IntegerRef(1);
else
return grt::IntegerRef(0);
}
grt::IntegerRef mforms_ObjectReference::isEqualTo(const grt::Ref<mforms_ObjectReference> &other)
{
if (_data == NULL && other->get_data() == NULL)
return grt::IntegerRef(1);
if (_data && other->get_data())
return grt::IntegerRef(_data == other->get_data() ? 1 : 0);
return grt::IntegerRef(1);
}
mforms::Object *mforms_from_grt(mforms_ObjectReferenceRef object)
{
if (!object.is_valid() || !*object->valid())
return 0;
return object->get_data();
}
static void release_object(mforms::Object *object)
{
if (object)
object->release();
}
mforms_ObjectReferenceRef mforms_to_grt(grt::GRT *grt, mforms::Object *object, const std::string &type_name)
{
if (object)
{
// view is not necessarily managed, in some cases the view must be deleted by the caller
//assert(object->is_managed());
mforms_ObjectReferenceRef ref(grt);
object->retain();
ref->set_data(object, object->is_managed() ? release_object : NULL);
ref->type(grt::StringRef(type_name.empty() ? grt::get_type_name(typeid(*object)) : type_name));
return ref;
}
return mforms_ObjectReferenceRef();
}
mforms_ObjectReferenceRef mforms_to_grt(grt::GRT *grt, mforms::ContextMenu *menu)
{
return mforms_to_grt(grt, menu, "ContextMenu");
}
mforms_ObjectReferenceRef mforms_to_grt(grt::GRT *grt, mforms::DockingPoint *dpoint)
{
return mforms_to_grt(grt, dpoint, "DockingPoint");
}
|