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

#undef GTK_DISABLE_DEPRECATED
#define GDK_DISABLE_DEPRECATION_WARNINGS 1
 
#include <gtkmmconfig.h>
#ifndef GTKMM_DISABLE_DEPRECATED


#include <glibmm.h>

#include <gtkmm/combobox.h>
#include <gtkmm/private/combobox_p.h>


/* Copyright (C) 2003 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 <gdkmm/device.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview_private.h> //For SignalProxy_RowSeparator.
#include <gtk/gtk.h>

namespace Gtk
{

ComboBox::ComboBox(bool has_entry)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Gtk::Widget(Glib::ConstructParams(combobox_class_.init(), "has-entry",gboolean(has_entry), nullptr))
{}

ComboBox::ComboBox(const Glib::RefPtr<TreeModel>& model, bool has_entry)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Gtk::Widget(Glib::ConstructParams(combobox_class_.init(), "model",Glib::unwrap(model),"has-entry",gboolean(has_entry), nullptr))
{}

void ComboBox::unset_active()
{
  gtk_combo_box_set_active(gobj(), -1 /* see GTK+ docs */);
}

TreeModel::iterator ComboBox::get_active()
{
  Gtk::TreeModel::iterator iter;

  auto model = get_model();
  if(model)
  {
    gtk_combo_box_get_active_iter(gobj(), iter.gobj());

    //It must be given the model, because the C++ wrapper has extra information.
    iter.set_model_gobject(model->gobj());
  }

  return iter;
}

TreeModel::const_iterator ComboBox::get_active() const
{
  Gtk::TreeModel::const_iterator iter;

  const auto model = get_model();
  if(model)
  {
    gtk_combo_box_get_active_iter(const_cast<GtkComboBox*>(gobj()), iter.gobj());

    //It must be given the model, because the C++ wrapper has extra information.
    iter.set_model_gobject(const_cast<GtkTreeModel*>(model->gobj()));
  }

  return iter;
}


void ComboBox::unset_model()
{
  gtk_combo_box_set_model(gobj(), nullptr);
}


void ComboBox::set_row_separator_func(const SlotRowSeparator& slot)
{
  //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
  //It will be deleted when gtkmm_SignalProxy_RowSeparator_gtk_callback_destroy() is called.
  auto slot_copy = new SlotRowSeparator(slot);

  gtk_combo_box_set_row_separator_func(gobj(),
      &TreeView_Private::gtkmm_SignalProxy_RowSeparator_gtk_callback, slot_copy,
      &TreeView_Private::gtkmm_SignalProxy_RowSeparator_gtk_callback_destroy);
}

void ComboBox::unset_row_separator_func()
{
  gtk_combo_box_set_row_separator_func(gobj(), nullptr, nullptr, nullptr /* See C docs. */);
}

void ComboBox::unset_child()
{
  gtk_combo_box_set_child(gobj(), nullptr);
}

Entry* ComboBox::get_entry()
{
  return dynamic_cast<Gtk::Entry*>(get_child());
}

const Entry* ComboBox::get_entry() const
{
  return dynamic_cast<const Gtk::Entry*>(get_child());
}

Glib::ustring ComboBox::get_entry_text() const
{
  const auto entry = get_entry();
  if(!entry)
    return Glib::ustring();
  else
    return entry->get_text();
}

} // namespace Gtk

namespace
{


static const Glib::SignalProxyInfo ComboBox_signal_changed_info =
{
  "changed",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


using ComboBox_signal_changed_functype = void (*)(GtkComboBox* self);
ComboBox_signal_changed_functype ComboBox_signal_changed_funcptr;
extern "C" {
static void ComboBox_signal_changed_default_callback(GtkComboBox* self)
{
  ComboBox_signal_changed_funcptr( self);
}
} // extern "C"


extern "C" {
static gchar* ComboBox_signal_format_entry_text_connect_callback(GtkComboBox* self, const gchar* path,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<Glib::ustring(const TreeModel::Path&)>;

  auto obj = dynamic_cast<ComboBox*>(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 g_strdup(Glib::c_str_or_nullptr((*static_cast<SlotType*>(slot))(TreeModel::Path(path)
)));
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }

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

static gchar* ComboBox_signal_format_entry_text_notify_callback(GtkComboBox* self, const gchar* path, void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(const TreeModel::Path&)>;

  auto obj = dynamic_cast<ComboBox*>(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))(TreeModel::Path(path)
);
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }

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

static const Glib::SignalProxyInfo ComboBox_signal_format_entry_text_info =
{
  "format-entry-text",
  (GCallback) &ComboBox_signal_format_entry_text_connect_callback,
  (GCallback) &ComboBox_signal_format_entry_text_notify_callback
};


using ComboBox_signal_format_entry_text_functype = gchar* (*)(GtkComboBox* self, const gchar* path);
ComboBox_signal_format_entry_text_functype ComboBox_signal_format_entry_text_funcptr;
extern "C" {
static gchar* ComboBox_signal_format_entry_text_default_callback(GtkComboBox* self, const gchar* path)
{
  return ComboBox_signal_format_entry_text_funcptr( self, path);
}
} // extern "C"
} // anonymous namespace


namespace Glib
{

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

} /* namespace Glib */

namespace Gtk
{


/* The *_Class implementation: */

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

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

  }

  return *this;
}


void ComboBox_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->changed = &ComboBox_signal_changed_default_callback;
  ComboBox_signal_changed_funcptr = &changed_callback;
  klass->format_entry_text = &ComboBox_signal_format_entry_text_default_callback;
  ComboBox_signal_format_entry_text_funcptr = &format_entry_text_callback;
}


void ComboBox_Class::changed_callback(GtkComboBox* 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->on_changed();
        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->changed)
    (*base->changed)(self);
}
gchar* ComboBox_Class::format_entry_text_callback(GtkComboBox* self, const gchar* path)
{
  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 g_strdup(Glib::c_str_or_nullptr(obj->on_format_entry_text(TreeModel::Path(path)
)));
      }
      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->format_entry_text)
    return (*base->format_entry_text)(self, path);

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


Glib::ObjectBase* ComboBox_Class::wrap_new(GObject* o)
{
  return manage(new ComboBox((GtkComboBox*)(o)));

}


/* The implementation: */

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

ComboBox::ComboBox(GtkComboBox* castitem)
:
  Gtk::Widget((GtkWidget*)(castitem))
{
  }


ComboBox::ComboBox(ComboBox&& src) noexcept
: Gtk::Widget(std::move(src))
  , CellLayout(std::move(src))
  , CellEditable(std::move(src))
{}

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

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

ComboBox::CppClassType ComboBox::combobox_class_; // initialize static member

GType ComboBox::get_type()
{
  return combobox_class_.init().get_type();
}


GType ComboBox::get_base_type()
{
  return gtk_combo_box_get_type();
}


int ComboBox::get_active_row_number() const
{
  return gtk_combo_box_get_active(const_cast<GtkComboBox*>(gobj()));
}

void ComboBox::set_active(int index)
{
  gtk_combo_box_set_active(gobj(), index);
}

void ComboBox::set_active(const TreeModel::const_iterator& iter)
{
  gtk_combo_box_set_active_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
}

Glib::RefPtr<TreeModel> ComboBox::get_model()
{
  auto retvalue = Glib::wrap(gtk_combo_box_get_model(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const TreeModel> ComboBox::get_model() const
{
  return const_cast<ComboBox*>(this)->get_model();
}

void ComboBox::set_model(const Glib::RefPtr<TreeModel>& model)
{
  gtk_combo_box_set_model(gobj(), Glib::unwrap(model));
}

void ComboBox::set_button_sensitivity(SensitivityType sensitivity)
{
  gtk_combo_box_set_button_sensitivity(gobj(), static_cast<GtkSensitivityType>(sensitivity));
}

SensitivityType ComboBox::get_button_sensitivity() const
{
  return static_cast<SensitivityType>(gtk_combo_box_get_button_sensitivity(const_cast<GtkComboBox*>(gobj())));
}

bool ComboBox::get_has_entry() const
{
  return gtk_combo_box_get_has_entry(const_cast<GtkComboBox*>(gobj()));
}

void ComboBox::set_entry_text_column(const TreeModelColumnBase& text_column) const
{
  gtk_combo_box_set_entry_text_column(const_cast<GtkComboBox*>(gobj()), (text_column).index());
}

void ComboBox::set_entry_text_column(int text_column)
{
  gtk_combo_box_set_entry_text_column(gobj(), text_column);
}

int ComboBox::get_entry_text_column() const
{
  return gtk_combo_box_get_entry_text_column(const_cast<GtkComboBox*>(gobj()));
}

void ComboBox::set_popup_fixed_width(bool fixed)
{
  gtk_combo_box_set_popup_fixed_width(gobj(), static_cast<int>(fixed));
}

bool ComboBox::get_popup_fixed_width() const
{
  return gtk_combo_box_get_popup_fixed_width(const_cast<GtkComboBox*>(gobj()));
}

void ComboBox::popup()
{
  gtk_combo_box_popup(gobj());
}

void ComboBox::popup(const Glib::RefPtr<Gdk::Device>& device)
{
  gtk_combo_box_popup_for_device(gobj(), Glib::unwrap(device));
}

void ComboBox::popdown()
{
  gtk_combo_box_popdown(gobj());
}

int ComboBox::get_id_column() const
{
  return gtk_combo_box_get_id_column(const_cast<GtkComboBox*>(gobj()));
}

void ComboBox::set_id_column(int id_column)
{
  gtk_combo_box_set_id_column(gobj(), id_column);
}

Glib::ustring ComboBox::get_active_id() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_combo_box_get_active_id(const_cast<GtkComboBox*>(gobj())));
}

bool ComboBox::set_active_id(const Glib::ustring& active_id)
{
  return gtk_combo_box_set_active_id(gobj(), active_id.c_str());
}

void ComboBox::set_child(Widget& child)
{
  gtk_combo_box_set_child(gobj(), (child).gobj());
}

Widget* ComboBox::get_child()
{
  return Glib::wrap(gtk_combo_box_get_child(gobj()));
}

const Widget* ComboBox::get_child() const
{
  return const_cast<ComboBox*>(this)->get_child();
}


Glib::SignalProxy<void()> ComboBox::signal_changed()
{
  return Glib::SignalProxy<void() >(this, &ComboBox_signal_changed_info);
}


Glib::SignalProxy<Glib::ustring(const TreeModel::Path&)> ComboBox::signal_format_entry_text()
{
  return Glib::SignalProxy<Glib::ustring(const TreeModel::Path&) >(this, &ComboBox_signal_format_entry_text_info);
}


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

Glib::PropertyProxy< Glib::RefPtr<TreeModel> > ComboBox::property_model() 
{
  return Glib::PropertyProxy< Glib::RefPtr<TreeModel> >(this, "model");
}

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TreeModel> > ComboBox::property_model() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TreeModel> >(this, "model");
}

Glib::PropertyProxy< int > ComboBox::property_active() 
{
  return Glib::PropertyProxy< int >(this, "active");
}

Glib::PropertyProxy_ReadOnly< int > ComboBox::property_active() const
{
  return Glib::PropertyProxy_ReadOnly< int >(this, "active");
}

Glib::PropertyProxy< bool > ComboBox::property_has_frame() 
{
  return Glib::PropertyProxy< bool >(this, "has-frame");
}

Glib::PropertyProxy_ReadOnly< bool > ComboBox::property_has_frame() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "has-frame");
}

Glib::PropertyProxy_ReadOnly< bool > ComboBox::property_popup_shown() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "popup-shown");
}

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

Glib::PropertyProxy< SensitivityType > ComboBox::property_button_sensitivity() 
{
  return Glib::PropertyProxy< SensitivityType >(this, "button-sensitivity");
}

Glib::PropertyProxy_ReadOnly< SensitivityType > ComboBox::property_button_sensitivity() const
{
  return Glib::PropertyProxy_ReadOnly< SensitivityType >(this, "button-sensitivity");
}

Glib::PropertyProxy< bool > ComboBox::property_popup_fixed_width() 
{
  return Glib::PropertyProxy< bool >(this, "popup-fixed-width");
}

Glib::PropertyProxy_ReadOnly< bool > ComboBox::property_popup_fixed_width() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "popup-fixed-width");
}

Glib::PropertyProxy_ReadOnly< bool > ComboBox::property_has_entry() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "has-entry");
}

Glib::PropertyProxy< int > ComboBox::property_entry_text_column() 
{
  return Glib::PropertyProxy< int >(this, "entry-text-column");
}

Glib::PropertyProxy_ReadOnly< int > ComboBox::property_entry_text_column() const
{
  return Glib::PropertyProxy_ReadOnly< int >(this, "entry-text-column");
}

Glib::PropertyProxy< int > ComboBox::property_id_column() 
{
  return Glib::PropertyProxy< int >(this, "id-column");
}

Glib::PropertyProxy_ReadOnly< int > ComboBox::property_id_column() const
{
  return Glib::PropertyProxy_ReadOnly< int >(this, "id-column");
}

Glib::PropertyProxy< Glib::ustring > ComboBox::property_active_id() 
{
  return Glib::PropertyProxy< Glib::ustring >(this, "active-id");
}

Glib::PropertyProxy_ReadOnly< Glib::ustring > ComboBox::property_active_id() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::ustring >(this, "active-id");
}

Glib::PropertyProxy< Widget* > ComboBox::property_child() 
{
  return Glib::PropertyProxy< Widget* >(this, "child");
}

Glib::PropertyProxy_ReadOnly< Widget* > ComboBox::property_child() const
{
  return Glib::PropertyProxy_ReadOnly< Widget* >(this, "child");
}


void Gtk::ComboBox::on_changed()
{
  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->changed)
    (*base->changed)(gobj());
}
Glib::ustring Gtk::ComboBox::on_format_entry_text(const TreeModel::Path& path)
{
  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->format_entry_text)
    return Glib::convert_return_gchar_ptr_to_ustring((*base->format_entry_text)(gobj(),(path).to_string().c_str()));

  using RType = Glib::ustring;
  return RType();
}


} // namespace Gtk

#endif // GTKMM_DISABLE_DEPRECATED


