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


#include <glibmm.h>

#include <gtkmm/glarea.h>
#include <gtkmm/private/glarea_p.h>


/* Copyright (C) 2015 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 <https://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>

namespace Gtk
{

bool GLArea::has_error() const
{
  return gtk_gl_area_get_error(const_cast<GtkGLArea*>(gobj()));
}

void GLArea::throw_if_error() const
{
  GError* error = gtk_gl_area_get_error(const_cast<GtkGLArea*>(gobj()));
  if(error)
  {
    Glib::Error::throw_exception(g_error_copy(error));
  }
}

void GLArea::unset_error()
{
  gtk_gl_area_set_error(gobj(), nullptr);
}

} //namespace Gtk

namespace
{


extern "C" {
static GdkGLContext* GLArea_signal_create_context_connect_callback(GtkGLArea* self, void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<Glib::RefPtr<Gdk::GLContext>()>;

  auto obj = dynamic_cast<GLArea*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        return Glib::unwrap_copy((*static_cast<SlotType*>(slot))());
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }

  using RType = GdkGLContext*;
  return RType();
}

static GdkGLContext* GLArea_signal_create_context_notify_callback(GtkGLArea* self,  void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void()>;

  auto obj = dynamic_cast<GLArea*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))();
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }

  using RType = GdkGLContext*;
  return RType();
}
} // extern "C"

static const Glib::SignalProxyInfo GLArea_signal_create_context_info =
{
  "create_context",
  (GCallback) &GLArea_signal_create_context_connect_callback,
  (GCallback) &GLArea_signal_create_context_notify_callback
};


using GLArea_signal_create_context_functype = GdkGLContext* (*)(GtkGLArea* self);
GLArea_signal_create_context_functype GLArea_signal_create_context_funcptr;
extern "C" {
static GdkGLContext* GLArea_signal_create_context_default_callback(GtkGLArea* self)
{
  return GLArea_signal_create_context_funcptr( self);
}
} // extern "C"


extern "C" {
static gboolean GLArea_signal_render_connect_callback(GtkGLArea* self, GdkGLContext* context,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<bool(const Glib::RefPtr<Gdk::GLContext>&)>;

  auto obj = dynamic_cast<GLArea*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        return static_cast<int>((*static_cast<SlotType*>(slot))(Glib::wrap(context, true)
));
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }

  using RType = gboolean;
  return RType();
}

static gboolean GLArea_signal_render_notify_callback(GtkGLArea* self, GdkGLContext* context, void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(const Glib::RefPtr<Gdk::GLContext>&)>;

  auto obj = dynamic_cast<GLArea*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(context, true)
);
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }

  using RType = gboolean;
  return RType();
}
} // extern "C"

static const Glib::SignalProxyInfo GLArea_signal_render_info =
{
  "render",
  (GCallback) &GLArea_signal_render_connect_callback,
  (GCallback) &GLArea_signal_render_notify_callback
};


using GLArea_signal_render_functype = gboolean (*)(GtkGLArea* self, GdkGLContext* context);
GLArea_signal_render_functype GLArea_signal_render_funcptr;
extern "C" {
static gboolean GLArea_signal_render_default_callback(GtkGLArea* self, GdkGLContext* context)
{
  return GLArea_signal_render_funcptr( self, context);
}
} // extern "C"


extern "C" {
static void GLArea_signal_resize_connect_callback(GtkGLArea* self, gint width,gint height,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(int, int)>;

  auto obj = dynamic_cast<GLArea*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(width
, height
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}
} // extern "C"

static const Glib::SignalProxyInfo GLArea_signal_resize_info =
{
  "resize",
  (GCallback) &GLArea_signal_resize_connect_callback,
  (GCallback) &GLArea_signal_resize_connect_callback
};


using GLArea_signal_resize_functype = void (*)(GtkGLArea* self, gint width, gint height);
GLArea_signal_resize_functype GLArea_signal_resize_funcptr;
extern "C" {
static void GLArea_signal_resize_default_callback(GtkGLArea* self, gint width, gint height)
{
  GLArea_signal_resize_funcptr( self, width, height);
}
} // extern "C"
} // anonymous namespace


namespace Glib
{

Gtk::GLArea* wrap(GtkGLArea* object, bool take_copy)
{
  return dynamic_cast<Gtk::GLArea *> (Glib::wrap_auto ((GObject*)(object), take_copy));
}

} /* namespace Glib */

namespace Gtk
{


/* The *_Class implementation: */

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

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

  }

  return *this;
}


void GLArea_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->create_context = &GLArea_signal_create_context_default_callback;
  GLArea_signal_create_context_funcptr = &create_context_callback;
  klass->render = &GLArea_signal_render_default_callback;
  GLArea_signal_render_funcptr = &render_callback;
  klass->resize = &GLArea_signal_resize_default_callback;
  GLArea_signal_resize_funcptr = &resize_callback;
}


GdkGLContext* GLArea_Class::create_context_callback(GtkGLArea* 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.
        return Glib::unwrap_copy(obj->on_create_context());
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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_context)
    return (*base->create_context)(self);

  using RType = GdkGLContext*;
  return RType();
}
gboolean GLArea_Class::render_callback(GtkGLArea* self, GdkGLContext* context)
{
  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->on_render(Glib::wrap(context, true)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->render)
    return (*base->render)(self, context);

  using RType = gboolean;
  return RType();
}
void GLArea_Class::resize_callback(GtkGLArea* self, gint width, gint height)
{
  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->on_resize(width
, height
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->resize)
    (*base->resize)(self, width, height);
}


Glib::ObjectBase* GLArea_Class::wrap_new(GObject* o)
{
  return manage(new GLArea((GtkGLArea*)(o)));

}


/* The implementation: */

GLArea::GLArea(const Glib::ConstructParams& construct_params)
:
  Gtk::Widget(construct_params)
{
  }

GLArea::GLArea(GtkGLArea* castitem)
:
  Gtk::Widget((GtkWidget*)(castitem))
{
  }


GLArea::GLArea(GLArea&& src) noexcept
: Gtk::Widget(std::move(src))
{}

GLArea& GLArea::operator=(GLArea&& src) noexcept
{
  Gtk::Widget::operator=(std::move(src));
  return *this;
}

GLArea::~GLArea() noexcept
{
  destroy_();
}

GLArea::CppClassType GLArea::glarea_class_; // initialize static member

GType GLArea::get_type()
{
  return glarea_class_.init().get_type();
}


GType GLArea::get_base_type()
{
  return gtk_gl_area_get_type();
}


GLArea::GLArea()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Gtk::Widget(Glib::ConstructParams(glarea_class_.init()))
{
  

}

Glib::RefPtr<Gdk::GLContext> GLArea::get_context()
{
  auto retvalue = Glib::wrap(gtk_gl_area_get_context(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const Gdk::GLContext> GLArea::get_context() const
{
  return const_cast<GLArea*>(this)->get_context();
}

void GLArea::make_current()
{
  gtk_gl_area_make_current(gobj());
}

void GLArea::queue_render()
{
  gtk_gl_area_queue_render(gobj());
}

void GLArea::attach_buffers()
{
  gtk_gl_area_attach_buffers(gobj());
}

void GLArea::set_error(const Glib::Error& error)
{
  gtk_gl_area_set_error(gobj(), (error).gobj());
}

bool GLArea::get_has_depth_buffer() const
{
  return gtk_gl_area_get_has_depth_buffer(const_cast<GtkGLArea*>(gobj()));
}

void GLArea::set_has_depth_buffer(bool has_depth_buffer)
{
  gtk_gl_area_set_has_depth_buffer(gobj(), static_cast<int>(has_depth_buffer));
}

bool GLArea::get_has_stencil_buffer() const
{
  return gtk_gl_area_get_has_stencil_buffer(const_cast<GtkGLArea*>(gobj()));
}

void GLArea::set_has_stencil_buffer(bool has_stencil_buffer)
{
  gtk_gl_area_set_has_stencil_buffer(gobj(), static_cast<int>(has_stencil_buffer));
}

bool GLArea::get_auto_render() const
{
  return gtk_gl_area_get_auto_render(const_cast<GtkGLArea*>(gobj()));
}

void GLArea::set_auto_render(bool auto_render)
{
  gtk_gl_area_set_auto_render(gobj(), static_cast<int>(auto_render));
}

void GLArea::get_required_version(int& major, int& minor) const
{
  gtk_gl_area_get_required_version(const_cast<GtkGLArea*>(gobj()), &(major), &(minor));
}

void GLArea::set_required_version(int major, int minor)
{
  gtk_gl_area_set_required_version(gobj(), major, minor);
}

void GLArea::set_allowed_apis(Gdk::GLApi apis)
{
  gtk_gl_area_set_allowed_apis(gobj(), static_cast<GdkGLAPI>(apis));
}

Gdk::GLApi GLArea::get_allowed_apis() const
{
  return static_cast<Gdk::GLApi>(gtk_gl_area_get_allowed_apis(const_cast<GtkGLArea*>(gobj())));
}

Gdk::GLApi GLArea::get_api() const
{
  return static_cast<Gdk::GLApi>(gtk_gl_area_get_api(const_cast<GtkGLArea*>(gobj())));
}

#ifndef GTKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
bool GLArea::get_use_es() const
{
  return gtk_gl_area_get_use_es(const_cast<GtkGLArea*>(gobj()));
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // GTKMM_DISABLE_DEPRECATED

#ifndef GTKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void GLArea::set_use_es(bool use_es)
{
  gtk_gl_area_set_use_es(gobj(), static_cast<int>(use_es));
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // GTKMM_DISABLE_DEPRECATED


Glib::SignalProxy<Glib::RefPtr<Gdk::GLContext>()> GLArea::signal_create_context()
{
  return Glib::SignalProxy<Glib::RefPtr<Gdk::GLContext>() >(this, &GLArea_signal_create_context_info);
}


Glib::SignalProxy<bool(const Glib::RefPtr<Gdk::GLContext>&)> GLArea::signal_render()
{
  return Glib::SignalProxy<bool(const Glib::RefPtr<Gdk::GLContext>&) >(this, &GLArea_signal_render_info);
}


Glib::SignalProxy<void(int, int)> GLArea::signal_resize()
{
  return Glib::SignalProxy<void(int, int) >(this, &GLArea_signal_resize_info);
}


Glib::PropertyProxy< bool > GLArea::property_auto_render() 
{
  return Glib::PropertyProxy< bool >(this, "auto-render");
}

Glib::PropertyProxy_ReadOnly< bool > GLArea::property_auto_render() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "auto-render");
}

static_assert(Glib::Traits::ValueCompatibleWithWrapProperty<Glib::RefPtr<Gdk::GLContext>>::value,
  "Type Glib::RefPtr<Gdk::GLContext> cannot be used in _WRAP_PROPERTY. "
  "There is no suitable template specialization of Glib::Value<>.");

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gdk::GLContext> > GLArea::property_context() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gdk::GLContext> >(this, "context");
}

Glib::PropertyProxy< bool > GLArea::property_has_depth_buffer() 
{
  return Glib::PropertyProxy< bool >(this, "has-depth-buffer");
}

Glib::PropertyProxy_ReadOnly< bool > GLArea::property_has_depth_buffer() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "has-depth-buffer");
}

Glib::PropertyProxy< bool > GLArea::property_has_stencil_buffer() 
{
  return Glib::PropertyProxy< bool >(this, "has-stencil-buffer");
}

Glib::PropertyProxy_ReadOnly< bool > GLArea::property_has_stencil_buffer() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "has-stencil-buffer");
}

#ifndef GTKMM_DISABLE_DEPRECATED

Glib::PropertyProxy< bool > GLArea::property_use_es() 
{
  return Glib::PropertyProxy< bool >(this, "use-es");
}
#endif // GTKMM_DISABLE_DEPRECATED


#ifndef GTKMM_DISABLE_DEPRECATED

Glib::PropertyProxy_ReadOnly< bool > GLArea::property_use_es() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "use-es");
}
#endif // GTKMM_DISABLE_DEPRECATED


static_assert(Glib::Traits::ValueCompatibleWithWrapProperty<Gdk::GLApi>::value,
  "Type Gdk::GLApi cannot be used in _WRAP_PROPERTY. "
  "There is no suitable template specialization of Glib::Value<>.");

Glib::PropertyProxy< Gdk::GLApi > GLArea::property_allowed_apis() 
{
  return Glib::PropertyProxy< Gdk::GLApi >(this, "allowed-apis");
}

Glib::PropertyProxy_ReadOnly< Gdk::GLApi > GLArea::property_allowed_apis() const
{
  return Glib::PropertyProxy_ReadOnly< Gdk::GLApi >(this, "allowed-apis");
}

static_assert(Glib::Traits::ValueCompatibleWithWrapProperty<Gdk::GLApi>::value,
  "Type Gdk::GLApi cannot be used in _WRAP_PROPERTY. "
  "There is no suitable template specialization of Glib::Value<>.");

Glib::PropertyProxy_ReadOnly< Gdk::GLApi > GLArea::property_api() const
{
  return Glib::PropertyProxy_ReadOnly< Gdk::GLApi >(this, "api");
}


Glib::RefPtr<Gdk::GLContext> Gtk::GLArea::on_create_context()
{
  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_context)
    return Glib::wrap((*base->create_context)(gobj()));

  using RType = Glib::RefPtr<Gdk::GLContext>;
  return RType();
}
bool Gtk::GLArea::on_render(const Glib::RefPtr<Gdk::GLContext>& context)
{
  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->render)
    return (*base->render)(gobj(),Glib::unwrap(context));

  using RType = bool;
  return RType();
}
void Gtk::GLArea::on_resize(int width, int height)
{
  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->resize)
    (*base->resize)(gobj(),width,height);
}


} // namespace Gtk


