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


#include <glibmm.h>

#include <gtkmm/layoutmanager.h>
#include <gtkmm/private/layoutmanager_p.h>


/* Copyright (C) 2019 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, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/layoutchild.h>
#include <gtkmm/widget.h>
#include <gtk/gtk.h>

namespace Gtk
{
// This vfunc callback is custom implemented because we want the output
// arguments of the C++ vfunc to be int& (not int*), and the vfunc_callback
// function may be called from gtk with NULL pointers.
void LayoutManager_Class::measure_vfunc_callback(GtkLayoutManager* self,
  GtkWidget* widget, GtkOrientation orientation, int for_size,
  int* minimum, int* natural, int* minimum_baseline, int* natural_baseline)
{
  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.
        int no_minimum = 0;
        int no_natural = 0;
        int no_minimum_baseline = 0;
        int no_natural_baseline = 0;
        obj->measure_vfunc(*Glib::wrap(widget),
          static_cast<Orientation>(orientation), for_size,
          (minimum ? *minimum : no_minimum),
          (natural ? *natural : no_natural),
          (minimum_baseline ? *minimum_baseline : no_minimum_baseline),
          (natural_baseline ? *natural_baseline : no_natural_baseline));
        return;
      }
      catch (...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->measure)
    (*base->measure)(self, widget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
}

} // namespace Gtk

namespace
{
} // anonymous namespace


namespace Glib
{

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

} /* namespace Glib */


namespace Gtk
{


/* The *_Class implementation: */

const Glib::Class& LayoutManager_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_ = &LayoutManager_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(gtk_layout_manager_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


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

  klass->get_request_mode = &get_request_mode_vfunc_callback;
  klass->measure = &measure_vfunc_callback;
  klass->allocate = &allocate_vfunc_callback;
  klass->create_layout_child = &create_layout_child_vfunc_callback;
  klass->root = &root_vfunc_callback;
  klass->unroot = &unroot_vfunc_callback;

}

GtkSizeRequestMode LayoutManager_Class::get_request_mode_vfunc_callback(GtkLayoutManager* self, GtkWidget* widget)
{
  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<GtkSizeRequestMode>(obj->get_request_mode_vfunc(*Glib::wrap(widget)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->get_request_mode)
    return (*base->get_request_mode)(self, widget);

  using RType = GtkSizeRequestMode;
  return RType();
}
void LayoutManager_Class::allocate_vfunc_callback(GtkLayoutManager* self, GtkWidget* widget, int width, int height, int baseline)
{
  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->allocate_vfunc(*Glib::wrap(widget)
, width, height, baseline);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->allocate)
    (*base->allocate)(self, widget, width, height, baseline);
}
GtkLayoutChild* LayoutManager_Class::create_layout_child_vfunc_callback(GtkLayoutManager* self, GtkWidget* widget, GtkWidget* for_child)
{
  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 Glib::unwrap(obj->create_layout_child_vfunc(*Glib::wrap(widget)
, *Glib::wrap(for_child)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->create_layout_child)
    return (*base->create_layout_child)(self, widget, for_child);

  using RType = GtkLayoutChild*;
  return RType();
}
void LayoutManager_Class::root_vfunc_callback(GtkLayoutManager* self)
{
  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->root_vfunc();
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->root)
    (*base->root)(self);
}
void LayoutManager_Class::unroot_vfunc_callback(GtkLayoutManager* self)
{
  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->unroot_vfunc();
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  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->unroot)
    (*base->unroot)(self);
}


Glib::ObjectBase* LayoutManager_Class::wrap_new(GObject* object)
{
  return new LayoutManager((GtkLayoutManager*)object);
}


/* The implementation: */

GtkLayoutManager* LayoutManager::gobj_copy()
{
  reference();
  return gobj();
}

LayoutManager::LayoutManager(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

LayoutManager::LayoutManager(GtkLayoutManager* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


LayoutManager::LayoutManager(LayoutManager&& src) noexcept
: Glib::Object(std::move(src))
{}

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


LayoutManager::~LayoutManager() noexcept
{}


LayoutManager::CppClassType LayoutManager::layoutmanager_class_; // initialize static member

GType LayoutManager::get_type()
{
  return layoutmanager_class_.init().get_type();
}


GType LayoutManager::get_base_type()
{
  return gtk_layout_manager_get_type();
}


LayoutManager::LayoutManager()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Glib::Object(Glib::ConstructParams(layoutmanager_class_.init()))
{
  

}

void LayoutManager::measure(Widget& widget, Orientation orientation, int for_size, int& minimum, int& natural, int& minimum_baseline, int& natural_baseline) const
{
  gtk_layout_manager_measure(const_cast<GtkLayoutManager*>(gobj()), (widget).gobj(), static_cast<GtkOrientation>(orientation), for_size, &(minimum), &(natural), &(minimum_baseline), &(natural_baseline));
}

void LayoutManager::allocate(Widget& widget, int width, int height, int baseline)
{
  gtk_layout_manager_allocate(gobj(), (widget).gobj(), width, height, baseline);
}

SizeRequestMode LayoutManager::get_request_mode() const
{
  return static_cast<SizeRequestMode>(gtk_layout_manager_get_request_mode(const_cast<GtkLayoutManager*>(gobj())));
}

Widget* LayoutManager::get_widget()
{
  return Glib::wrap(gtk_layout_manager_get_widget(gobj()));
}

const Widget* LayoutManager::get_widget() const
{
  return const_cast<LayoutManager*>(this)->get_widget();
}

void LayoutManager::layout_changed()
{
  gtk_layout_manager_layout_changed(gobj());
}

Glib::RefPtr<LayoutChild> LayoutManager::get_layout_child(Widget& child)
{
  auto retvalue = Glib::wrap(gtk_layout_manager_get_layout_child(gobj(), (child).gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const LayoutChild> LayoutManager::get_layout_child(Widget& child) const
{
  return const_cast<LayoutManager*>(this)->get_layout_child(child);
}


SizeRequestMode Gtk::LayoutManager::get_request_mode_vfunc(const Widget& widget) const
{
  const auto 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->get_request_mode)
  {
    SizeRequestMode retval(static_cast<SizeRequestMode>((*base->get_request_mode)(const_cast<GtkLayoutManager*>(gobj()),const_cast<GtkWidget*>((widget).gobj()))));
    return retval;
  }

  using RType = SizeRequestMode;
  return RType();
}
void Gtk::LayoutManager::measure_vfunc(const Widget& widget, Orientation orientation, int for_size, int& minimum, int& natural, int& minimum_baseline, int& natural_baseline) const
{
  const auto 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->measure)
  {
    (*base->measure)(const_cast<GtkLayoutManager*>(gobj()),const_cast<GtkWidget*>((widget).gobj()),static_cast<GtkOrientation>(orientation),for_size,&(minimum),&(natural),&(minimum_baseline),&(natural_baseline));
  }
}
void Gtk::LayoutManager::allocate_vfunc(const Widget& widget, int width, int height, int baseline) 
{
  const auto 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->allocate)
  {
    (*base->allocate)(gobj(),const_cast<GtkWidget*>((widget).gobj()),width,height,baseline);
  }
}
Glib::RefPtr<LayoutChild> Gtk::LayoutManager::create_layout_child_vfunc(const Widget& widget, const Widget& for_child) 
{
  const auto 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->create_layout_child)
  {
    Glib::RefPtr<LayoutChild> retval(Glib::wrap((*base->create_layout_child)(gobj(),const_cast<GtkWidget*>((widget).gobj()),const_cast<GtkWidget*>((for_child).gobj())), true));
    return retval;
  }

  using RType = Glib::RefPtr<LayoutChild>;
  return RType();
}
void Gtk::LayoutManager::root_vfunc() 
{
  const auto 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->root)
  {
    (*base->root)(gobj());
  }
}
void Gtk::LayoutManager::unroot_vfunc() 
{
  const auto 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->unroot)
  {
    (*base->unroot)(gobj());
  }
}


} // namespace Gtk


