// Generated by gmmproc 2.46.1 -- DO NOT MODIFY!


#include <glibmm.h>

#include <atkmm/value.h>
#include <atkmm/private/value_p.h>


// -*- c++ -*-
/* $Id: value.ccg,v 1.1 2003/01/21 13:37:08 murrayc Exp $ */

/* Copyright 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <atk/atkvalue.h>

namespace Atk
{

void Value::get_value_and_text(double& value, Glib::ustring& text)
{
  gchar* c_text = 0;
  atk_value_get_value_and_text(gobj(), &(value), &c_text);
  if (c_text) {
    text = c_text;
    g_free (c_text);
  }
}

} //namespace


namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Atk::Value> wrap(AtkValue* object, bool take_copy)
{
  return Glib::RefPtr<Atk::Value>( dynamic_cast<Atk::Value*> (Glib::wrap_auto_interface<Atk::Value> ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} // namespace Glib


namespace Atk
{


/* The *_Class implementation: */

const Glib::Interface_Class& Value_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Interface_Class has to know the interface init function
    // in order to add interfaces to implementing types.
    class_init_func_ = &Value_Class::iface_init_function;

    // We can not derive from another interface, and it is not necessary anyway.
    gtype_ = atk_value_get_type();
  }

  return *this;
}

void Value_Class::iface_init_function(void* g_iface, void*)
{
  const auto klass = static_cast<BaseClassType*>(g_iface);

  //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  g_assert(klass != nullptr); 

  klass->get_current_value = &get_current_value_vfunc_callback;
  klass->get_maximum_value = &get_maximum_value_vfunc_callback;
  klass->get_minimum_value = &get_minimum_value_vfunc_callback;
  klass->set_current_value = &set_current_value_vfunc_callback;

}

void Value_Class::get_current_value_vfunc_callback(AtkValue* self, GValue* value)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        obj->get_current_value_vfunc(*reinterpret_cast<Glib::ValueBase*>(value)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_current_value)
  {
    (*base->get_current_value)(self, value);
  }

}
void Value_Class::get_maximum_value_vfunc_callback(AtkValue* self, GValue* value)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        obj->get_maximum_value_vfunc(*reinterpret_cast<Glib::ValueBase*>(value)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_maximum_value)
  {
    (*base->get_maximum_value)(self, value);
  }

}
void Value_Class::get_minimum_value_vfunc_callback(AtkValue* self, GValue* value)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        obj->get_minimum_value_vfunc(*reinterpret_cast<Glib::ValueBase*>(value)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->get_minimum_value)
  {
    (*base->get_minimum_value)(self, value);
  }

}
gboolean Value_Class::set_current_value_vfunc_callback(AtkValue* self, const GValue* value)
{
  const auto obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        return static_cast<int>(obj->set_current_value_vfunc(*reinterpret_cast<const Glib::ValueBase*>(value)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)  );

  // Call the original underlying C function:
  if(base && base->set_current_value)
  {
    gboolean retval = (*base->set_current_value)(self, value);
    return retval;
  }

  typedef gboolean RType;
  return RType();
}


Glib::ObjectBase* Value_Class::wrap_new(GObject* object)
{
  return new Value((AtkValue*)(object));
}


/* The implementation: */

Value::Value()
:
  Glib::Interface(value_class_.init())
{}

Value::Value(AtkValue* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

Value::Value(const Glib::Interface_Class& interface_class)
: Glib::Interface(interface_class)
{
}

Value::Value(Value&& src) noexcept
: Glib::Interface(std::move(src))
{}

Value& Value::operator=(Value&& src) noexcept
{
  Glib::Interface::operator=(std::move(src));
  return *this;
}

Value::~Value() noexcept
{}

// static
void Value::add_interface(GType gtype_implementer)
{
  value_class_.init().add_interface(gtype_implementer);
}

Value::CppClassType Value::value_class_; // initialize static member

GType Value::get_type()
{
  return value_class_.init().get_type();
}


GType Value::get_base_type()
{
  return atk_value_get_type();
}


#ifndef ATKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Value::get_current_value(Glib::ValueBase& value) const
{
  atk_value_get_current_value(const_cast<AtkValue*>(gobj()), (value).gobj());
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // ATKMM_DISABLE_DEPRECATED

#ifndef ATKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Value::get_maximum_value(Glib::ValueBase& value) const
{
  atk_value_get_maximum_value(const_cast<AtkValue*>(gobj()), (value).gobj());
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // ATKMM_DISABLE_DEPRECATED

#ifndef ATKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Value::get_minimum_value(Glib::ValueBase& value) const
{
  atk_value_get_minimum_value(const_cast<AtkValue*>(gobj()), (value).gobj());
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // ATKMM_DISABLE_DEPRECATED

#ifndef ATKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
bool Value::set_current_value(const Glib::ValueBase& value)
{
  return atk_value_set_current_value(gobj(), (value).gobj());
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // ATKMM_DISABLE_DEPRECATED

Range Value::get_range() const
{
  return Glib::wrap(atk_value_get_range(const_cast<AtkValue*>(gobj())));
}

double Value::get_increment()
{
  return atk_value_get_increment(gobj());
}

void Value::set_value(const gdouble new_value)
{
  atk_value_set_value(gobj(), new_value);
}


void Atk::Value::get_current_value_vfunc(Glib::ValueBase& value) const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_current_value)
  {
    (*base->get_current_value)(const_cast<AtkValue*>(gobj()),(value).gobj());
  }
}
void Atk::Value::get_maximum_value_vfunc(Glib::ValueBase& value) const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_maximum_value)
  {
    (*base->get_maximum_value)(const_cast<AtkValue*>(gobj()),(value).gobj());
  }
}
void Atk::Value::get_minimum_value_vfunc(Glib::ValueBase& value) const
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->get_minimum_value)
  {
    (*base->get_minimum_value)(const_cast<AtkValue*>(gobj()),(value).gobj());
  }
}
bool Atk::Value::set_current_value_vfunc(const Glib::ValueBase& value) 
{
  const auto base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->set_current_value)
  {
    bool retval((*base->set_current_value)(gobj(),(value).gobj()));
    return retval;
  }

  typedef bool RType;
  return RType();
}


} // namespace Atk


