// Generated by gtkmmproc -- DO NOT MODIFY!


#include <cluttermm/behaviour-path.h>
#include <cluttermm/private/behaviour-path_p.h>

/* Copyright (C) 2007 The cluttermm 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 <clutter/clutter.h>

namespace Clutter
{

// static
Glib::RefPtr<BehaviourPath> BehaviourPath::create_with_knots(const Glib::RefPtr<Alpha>& alpha,
                                                             const std::vector<Knot>& knots)
{
  const Glib::RefPtr<Path> path = Path::create();
  const Knot* data  = knots.data();
  const int n_knots = knots.size();

  if (n_knots > 0)
  {
    clutter_path_add_move_to(path->gobj(), data[0].gobj()->x, data[0].gobj()->y);

    for (int i = 1; i < n_knots; ++i)
      clutter_path_add_line_to(path->gobj(), data[i].gobj()->x, data[i].gobj()->y);
  }

  return Glib::RefPtr<BehaviourPath>(new BehaviourPath(alpha, path));
}

// static
Glib::RefPtr<BehaviourPath> create_with_description(const Glib::RefPtr<Alpha>& alpha,
                                                    const Glib::ustring& description)
{
  return BehaviourPath::create(alpha, Path::create(description));
}

} // namespace Clutter

namespace
{


static void BehaviourPath_signal_knot_reached_callback(ClutterBehaviourPath* self, guint p0,void* data)
{
  using namespace Clutter;
  typedef sigc::slot< void,guint > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(p0);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo BehaviourPath_signal_knot_reached_info =
{
  "knot_reached",
  (GCallback) &BehaviourPath_signal_knot_reached_callback,
  (GCallback) &BehaviourPath_signal_knot_reached_callback
};


} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Clutter::BehaviourPath> wrap(ClutterBehaviourPath* object, bool take_copy)
{
  return Glib::RefPtr<Clutter::BehaviourPath>( dynamic_cast<Clutter::BehaviourPath*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Clutter
{


/* The *_Class implementation: */

const Glib::Class& BehaviourPath_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &BehaviourPath_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(clutter_behaviour_path_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:
  Scriptable::add_interface(get_type());

  }

  return *this;
}


void BehaviourPath_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


  klass->knot_reached = &knot_reached_callback;
}


void BehaviourPath_Class::knot_reached_callback(ClutterBehaviourPath* self, guint p0)
{
  Glib::ObjectBase *const 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_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_knot_reached(p0);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

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


Glib::ObjectBase* BehaviourPath_Class::wrap_new(GObject* object)
{
  return new BehaviourPath((ClutterBehaviourPath*)object);
}


/* The implementation: */

ClutterBehaviourPath* BehaviourPath::gobj_copy()
{
  reference();
  return gobj();
}

BehaviourPath::BehaviourPath(const Glib::ConstructParams& construct_params)
:
  Behaviour(construct_params)
{

}

BehaviourPath::BehaviourPath(ClutterBehaviourPath* castitem)
:
  Behaviour((ClutterBehaviour*)(castitem))
{}


BehaviourPath::~BehaviourPath()
{}


BehaviourPath::CppClassType BehaviourPath::behaviourpath_class_; // initialize static member

GType BehaviourPath::get_type()
{
  return behaviourpath_class_.init().get_type();
}


GType BehaviourPath::get_base_type()
{
  return clutter_behaviour_path_get_type();
}


BehaviourPath::BehaviourPath(const Glib::RefPtr<Alpha>& alpha, const Glib::RefPtr<Path>& path)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Behaviour(Glib::ConstructParams(behaviourpath_class_.init(), "alpha", Glib::unwrap(alpha), "path", Glib::unwrap(path), static_cast<char*>(0)))
{
  

}

Glib::RefPtr<BehaviourPath> BehaviourPath::create(const Glib::RefPtr<Alpha>& alpha, const Glib::RefPtr<Path>& path)
{
  return Glib::RefPtr<BehaviourPath>( new BehaviourPath(alpha, path) );
}
void BehaviourPath::set_path(const Glib::RefPtr<Path>& path)
{
clutter_behaviour_path_set_path(gobj(), Glib::unwrap(path)); 
}

Glib::RefPtr<Path> BehaviourPath::get_path()
{

  Glib::RefPtr<Path> retvalue = Glib::wrap(clutter_behaviour_path_get_path(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

Glib::RefPtr<const Path> BehaviourPath::get_path() const
{
  return const_cast<BehaviourPath*>(this)->get_path();
}


Glib::SignalProxy1< void,guint > BehaviourPath::signal_knot_reached()
{
  return Glib::SignalProxy1< void,guint >(this, &BehaviourPath_signal_knot_reached_info);
}


void Clutter::BehaviourPath::on_knot_reached(guint knot_num)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->knot_reached)
    (*base->knot_reached)(gobj(),knot_num);
}


} // namespace Clutter


