// Generated by gtkmmproc -- DO NOT MODIFY!

#include <gtkmm/entry.h>
#include <gtkmm/private/entry_p.h>

// -*- c++ -*-
/* $Id: entry.ccg,v 1.1.1.1 2003/01/21 13:38:48 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 Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtk/gtkentry.h>


namespace
{

void Entry_signal_populate_popup_callback(GtkEntry* self, GtkMenu* p0,void* data)
{
  using namespace Gtk;
  typedef sigc::slot< void,Menu* > SlotType;

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

const Glib::SignalProxyInfo Entry_signal_populate_popup_info =
{
  "populate_popup",
  (GCallback) &Entry_signal_populate_popup_callback,
  (GCallback) &Entry_signal_populate_popup_callback
};


void Entry_signal_insert_at_cursor_callback(GtkEntry* self, const gchar* p0,void* data)
{
  using namespace Gtk;
  typedef sigc::slot< void,const Glib::ustring& > SlotType;

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

const Glib::SignalProxyInfo Entry_signal_insert_at_cursor_info =
{
  "insert_at_cursor",
  (GCallback) &Entry_signal_insert_at_cursor_callback,
  (GCallback) &Entry_signal_insert_at_cursor_callback
};


const Glib::SignalProxyInfo Entry_signal_activate_info =
{
  "activate",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};

} // anonymous namespace


namespace Glib
{

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

} /* namespace Glib */

namespace Gtk
{


/* The *_Class implementation: */

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

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

  return *this;
}

void Entry_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->populate_popup = &populate_popup_callback;
  klass->insert_at_cursor = &insert_at_cursor_callback;
  klass->activate = &activate_callback;
}


void Entry_Class::populate_popup_callback(GtkEntry* self, GtkMenu* p0)
{
  CppObjectType *const obj = dynamic_cast<CppObjectType*>(
      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 && obj->is_derived_())
  {
    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_populate_popup(Glib::wrap(p0)
);
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }
  else
  {
    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->populate_popup)
      (*base->populate_popup)(self, p0);
  }
}

void Entry_Class::insert_at_cursor_callback(GtkEntry* self, const gchar* p0)
{
  CppObjectType *const obj = dynamic_cast<CppObjectType*>(
      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 && obj->is_derived_())
  {
    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_insert_at_cursor(Glib::convert_const_gchar_ptr_to_ustring(p0)
);
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }
  else
  {
    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->insert_at_cursor)
      (*base->insert_at_cursor)(self, p0);
  }
}

void Entry_Class::activate_callback(GtkEntry* self)
{
  CppObjectType *const obj = dynamic_cast<CppObjectType*>(
      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 && obj->is_derived_())
  {
    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_activate();
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
  }
  else
  {
    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->activate)
      (*base->activate)(self);
  }
}


Glib::ObjectBase* Entry_Class::wrap_new(GObject* o)
{
  return manage(new Entry((GtkEntry*)(o)));

}


/* The implementation: */

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

Entry::Entry(GtkEntry* castitem)
:
  Gtk::Widget((GtkWidget*)(castitem))
{
  }

Entry::~Entry()
{
  destroy_();
}

Entry::CppClassType Entry::entry_class_; // initialize static member

GType Entry::get_type()
{
  return entry_class_.init().get_type();
}

GType Entry::get_base_type()
{
  return gtk_entry_get_type();
}


Entry::Entry()
:
  Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
  Gtk::Widget(Glib::ConstructParams(entry_class_.init()))
{
  }

void Entry::set_visibility(bool visible)
{
  gtk_entry_set_visibility(gobj(), static_cast<int>(visible));
}

bool Entry::get_visibility() const
{
  return gtk_entry_get_visibility(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_invisible_char(gunichar ch)
{
  gtk_entry_set_invisible_char(gobj(), ch);
}

gunichar Entry::get_invisible_char() const
{
  return gtk_entry_get_invisible_char(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_has_frame(bool setting)
{
  gtk_entry_set_has_frame(gobj(), static_cast<int>(setting));
}

bool Entry::get_has_frame() const
{
  return gtk_entry_get_has_frame(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_max_length(int max)
{
  gtk_entry_set_max_length(gobj(), max);
}

int Entry::get_max_length() const
{
  return gtk_entry_get_max_length(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_activates_default(bool setting)
{
  gtk_entry_set_activates_default(gobj(), static_cast<int>(setting));
}

gboolean Entry::get_activates_default() const
{
  return gtk_entry_get_activates_default(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_width_chars(int n_chars)
{
  gtk_entry_set_width_chars(gobj(), n_chars);
}

int Entry::get_width_chars() const
{
  return gtk_entry_get_width_chars(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_text(const Glib::ustring & text)
{
  gtk_entry_set_text(gobj(), text.c_str());
}

Glib::ustring Entry::get_text() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_entry_get_text(const_cast<GtkEntry*>(gobj())));
}

Glib::RefPtr<Pango::Layout> Entry::get_layout()
{

  Glib::RefPtr<Pango::Layout> retvalue = Glib::wrap(gtk_entry_get_layout(gobj()));

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const Pango::Layout> Entry::get_layout() const
{

  Glib::RefPtr<const Pango::Layout> retvalue = Glib::wrap(gtk_entry_get_layout(const_cast<GtkEntry*>(gobj())));

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

void Entry::get_layout_offsets(int& x, int& y)
{
  gtk_entry_get_layout_offsets(gobj(), &x, &y);
}

int Entry::layout_index_to_text_index(int layout_index) const
{
  return gtk_entry_layout_index_to_text_index(const_cast<GtkEntry*>(gobj()), layout_index);
}

int Entry::text_index_to_layout_index(int text_index) const
{
  return gtk_entry_text_index_to_layout_index(const_cast<GtkEntry*>(gobj()), text_index);
}

void Entry::set_alignment(float xalign)
{
  gtk_entry_set_alignment(gobj(), xalign);
}

void Entry::set_alignment(AlignmentEnum xalign)
{
  gtk_entry_set_alignment(gobj(), _gtkmm_align_float_from_enum(xalign));
}

float Entry::get_alignment() const
{
  return gtk_entry_get_alignment(const_cast<GtkEntry*>(gobj()));
}

void Entry::set_completion(const Glib::RefPtr<EntryCompletion>& completion)
{
  gtk_entry_set_completion(gobj(), Glib::unwrap(completion));
}

Glib::RefPtr<EntryCompletion> Entry::get_completion()
{

  Glib::RefPtr<EntryCompletion> retvalue = Glib::wrap(gtk_entry_get_completion(gobj()));

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const EntryCompletion> Entry::get_completion() const
{

  Glib::RefPtr<const EntryCompletion> retvalue = Glib::wrap(gtk_entry_get_completion(const_cast<GtkEntry*>(gobj())));

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

guint16 Entry::get_text_length() const
{
  return gobj()->text_length;
}


Glib::SignalProxy1< void,Menu* > Entry::signal_populate_popup()
{
  return Glib::SignalProxy1< void,Menu* >(this, &Entry_signal_populate_popup_info);
}

Glib::SignalProxy1< void,const Glib::ustring& > Entry::signal_insert_at_cursor()
{
  return Glib::SignalProxy1< void,const Glib::ustring& >(this, &Entry_signal_insert_at_cursor_info);
}

Glib::SignalProxy0< void > Entry::signal_activate()
{
  return Glib::SignalProxy0< void >(this, &Entry_signal_activate_info);
}


Glib::PropertyProxy_ReadOnly<int> Entry::property_cursor_position() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "cursor-position");
}

Glib::PropertyProxy_ReadOnly<int> Entry::property_selection_bound() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "selection-bound");
}

Glib::PropertyProxy<bool> Entry::property_editable() 
{
  return Glib::PropertyProxy<bool>(this, "editable");
}

Glib::PropertyProxy_ReadOnly<bool> Entry::property_editable() const
{
  return Glib::PropertyProxy_ReadOnly<bool>(this, "editable");
}

Glib::PropertyProxy<int> Entry::property_max_length() 
{
  return Glib::PropertyProxy<int>(this, "max-length");
}

Glib::PropertyProxy_ReadOnly<int> Entry::property_max_length() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "max-length");
}

Glib::PropertyProxy<bool> Entry::property_visibility() 
{
  return Glib::PropertyProxy<bool>(this, "visibility");
}

Glib::PropertyProxy_ReadOnly<bool> Entry::property_visibility() const
{
  return Glib::PropertyProxy_ReadOnly<bool>(this, "visibility");
}

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

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

Glib::PropertyProxy<gunichar> Entry::property_invisible_char() 
{
  return Glib::PropertyProxy<gunichar>(this, "invisible-char");
}

Glib::PropertyProxy_ReadOnly<gunichar> Entry::property_invisible_char() const
{
  return Glib::PropertyProxy_ReadOnly<gunichar>(this, "invisible-char");
}

Glib::PropertyProxy<bool> Entry::property_activates_default() 
{
  return Glib::PropertyProxy<bool>(this, "activates-default");
}

Glib::PropertyProxy_ReadOnly<bool> Entry::property_activates_default() const
{
  return Glib::PropertyProxy_ReadOnly<bool>(this, "activates-default");
}

Glib::PropertyProxy<int> Entry::property_width_chars() 
{
  return Glib::PropertyProxy<int>(this, "width-chars");
}

Glib::PropertyProxy_ReadOnly<int> Entry::property_width_chars() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "width-chars");
}

Glib::PropertyProxy_ReadOnly<int> Entry::property_scroll_offset() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "scroll-offset");
}

Glib::PropertyProxy<Glib::ustring> Entry::property_text() 
{
  return Glib::PropertyProxy<Glib::ustring>(this, "text");
}

Glib::PropertyProxy_ReadOnly<Glib::ustring> Entry::property_text() const
{
  return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "text");
}


void Gtk::Entry::on_populate_popup(Menu* menu)
{
  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->populate_popup)
    (*base->populate_popup)(gobj(),(GtkMenu*)Glib::unwrap(menu));
}

void Gtk::Entry::on_insert_at_cursor(const Glib::ustring& str)
{
  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->insert_at_cursor)
    (*base->insert_at_cursor)(gobj(),str.c_str());
}

void Gtk::Entry::on_activate()
{
  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->activate)
    (*base->activate)(gobj());
}


} // namespace Gtk


