/* $Id: entry.hg,v 1.12 2006/06/13 17:16:26 murrayc Exp $ */

/* entry.h
 * 
 * Copyright (C) 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 <gtkmm/widget.h>
#include <gtkmm/editable.h>
#include <gtkmm/menu.h>
#include <gtkmm/celleditable.h>
#include <gtkmm/entrycompletion.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

namespace Gtk
{

//TODO: This is used in Range too, so put it somewhere more appropriate:
typedef GtkBorder Border;

/** A single line text entry field.
 *
 * The Gtk::Entry widget is a single line text entry widget. A fairly large
 * set of key bindings are supported by default. If the entered text is
 * longer than the allocation of the widget, the widget will scroll so that
 * the cursor position is visible. 
 *
 * @ingroup Widgets
 */
class Entry
: public Widget,
  public Editable,
  public CellEditable
{
  _CLASS_GTKOBJECT(Entry,GtkEntry,GTK_ENTRY,Gtk::Widget,GtkWidget)
  _IGNORE(gtk_entry_new_with_max_length	, gtk_entry_append_text, gtk_entry_prepend_text, gtk_entry_set_position,
          gtk_entry_select_region, gtk_entry_set_editable)
  _IMPLEMENTS_INTERFACE(Editable)
  _IMPLEMENTS_INTERFACE(CellEditable)
public:

  _CTOR_DEFAULT
  

  _WRAP_METHOD(void set_visibility(bool visible = true), gtk_entry_set_visibility)
  _WRAP_METHOD(bool get_visibility() const, gtk_entry_get_visibility)
  _WRAP_METHOD(void set_invisible_char(gunichar ch), gtk_entry_set_invisible_char)
  _WRAP_METHOD(gunichar get_invisible_char() const, gtk_entry_get_invisible_char)	
  _WRAP_METHOD(void set_has_frame(bool setting = true), gtk_entry_set_has_frame)
  _WRAP_METHOD(bool get_has_frame() const, gtk_entry_get_has_frame)

  _WRAP_METHOD(void set_inner_border(const Border& border), gtk_entry_set_inner_border)
  _WRAP_METHOD(Border get_inner_border() const, gtk_entry_get_inner_border)

  _WRAP_METHOD(void set_max_length(int max), gtk_entry_set_max_length)
  _WRAP_METHOD(int get_max_length() const, gtk_entry_get_max_length)
  _WRAP_METHOD(void set_activates_default(bool setting = true), gtk_entry_set_activates_default)
  _WRAP_METHOD(gboolean get_activates_default() const, gtk_entry_get_activates_default)
  _WRAP_METHOD(void set_width_chars(int n_chars), gtk_entry_set_width_chars)
  _WRAP_METHOD(int get_width_chars() const, gtk_entry_get_width_chars)
  _WRAP_METHOD(void set_text(const Glib::ustring &text), gtk_entry_set_text)
  _WRAP_METHOD(Glib::ustring get_text() const, gtk_entry_get_text)
  _WRAP_METHOD(Glib::RefPtr<Pango::Layout> get_layout(), gtk_entry_get_layout, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Pango::Layout> get_layout() const, gtk_entry_get_layout, refreturn, constversion)
  _WRAP_METHOD(void get_layout_offsets(int& x, int& y), gtk_entry_get_layout_offsets)

  _WRAP_METHOD(int layout_index_to_text_index(int layout_index) const, gtk_entry_layout_index_to_text_index)
  _WRAP_METHOD(int text_index_to_layout_index(int text_index) const, gtk_entry_text_index_to_layout_index)

  _WRAP_METHOD(void set_alignment(float xalign), gtk_entry_set_alignment)
  _WRAP_METHOD(void set_alignment(AlignmentEnum xalign), gtk_entry_set_alignment) 
  _WRAP_METHOD(float get_alignment() const, gtk_entry_get_alignment)

  _WRAP_METHOD(void set_completion(const Glib::RefPtr<EntryCompletion>& completion), gtk_entry_set_completion)
  _WRAP_METHOD(Glib::RefPtr<EntryCompletion> get_completion(), gtk_entry_get_completion, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const EntryCompletion> get_completion() const, gtk_entry_get_completion, refreturn, constversion)

  _MEMBER_GET(text_length, text_length, guint16, guint16)

  _WRAP_SIGNAL(void populate_popup(Menu* menu), "populate_popup")
  _WRAP_SIGNAL(void insert_at_cursor(const Glib::ustring& str), "insert_at_cursor")

  //Key-binding signals:

  //This is a keybinding signal, but it is allowed:
  // http://mail.gnome.org/archives/gtk-devel-list/2003-January/msg00108.html
  // "activate is probably about the only exception"
  _WRAP_SIGNAL(void activate(), "activate")

  _IGNORE_SIGNAL("move_cursor")
  _IGNORE_SIGNAL("delete_from_cursor")
  _IGNORE_SIGNAL("cut_clipboard")
  _IGNORE_SIGNAL("copy_clipboard")
  _IGNORE_SIGNAL("paste_clipboard")
  _IGNORE_SIGNAL("toggle_overwrite")
  _IGNORE_SIGNAL("backspace")

  _WRAP_PROPERTY("cursor-position", int)
  _WRAP_PROPERTY("selection-bound", int)
  _WRAP_PROPERTY("editable", bool)
  _WRAP_PROPERTY("max-length", int)
  _WRAP_PROPERTY("visibility", bool)
  _WRAP_PROPERTY("has-frame", bool)
  _WRAP_PROPERTY("invisible-char", gunichar)
  _WRAP_PROPERTY("activates-default", bool)
  _WRAP_PROPERTY("width-chars", int)
  _WRAP_PROPERTY("scroll-offset", int)
  _WRAP_PROPERTY("text", Glib::ustring)
  _WRAP_PROPERTY("xalign", float)
  _WRAP_PROPERTY("truncate-multiline", bool)
};

} /* namespace Gtk */

