/* 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 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

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

#include <gtkmm/misc.h>
#include <pangomm/attrlist.h>


namespace Gtk
{

class Menu;

/** A widget that displays a small to medium amount of text.
 *
 * A simple setable widget for holding a Glib::ustring.
 *
 * The Label widget looks like this:
 * @image html label1.png
 *
 * @ingroup Widgets
 */
class Label : public Misc
{
  _CLASS_GTKOBJECT(Label, GtkLabel, GTK_LABEL, Gtk::Misc,GtkMisc)
  _IGNORE(gtk_label_get, gtk_label_parse_uline)
public:
  Label();
  explicit Label(const Glib::ustring& label, bool mnemonic = false);

_DEPRECATE_IFDEF_START
  /** This constructor is a shortcut for often used code
   * when you want to create a label with alignment different
   * than default one.
   * @code
   * Gtk::Label label(text, x, y, mnemonic);
   * @endcode
   * is equivalent to:
   * @code
   * Gtk::Label label(text, mnemonic);
   * label.set_alignment(x, y);
   * @endcode
   *
   * @deprecated Use another constructor.
   */
  Label(const Glib::ustring& label, float xalign, float yalign, bool mnemonic = false);
_DEPRECATE_IFDEF_END

  /** This constructor is a shortcut for often used code
   * when you want to create a label with alignment different
   * than default one.
   * @code
   * Gtk::Label label(text, x, y, mnemonic);
   * @endcode
   * is equivalent to:
   * @code
   * Gtk::Label label(text, mnemonic);
   * label.set_halign(x);
   * label.set_valign(y);
   * @endcode
   */
  Label(const Glib::ustring& label, Align xalign, Align yalign = ALIGN_CENTER, bool mnemonic = false);


  /// Doesn't use markup.
  _WRAP_METHOD(void set_text(const Glib::ustring &str), gtk_label_set_text)
  _WRAP_METHOD(Glib::ustring get_text() const, gtk_label_get_text)

  _WRAP_METHOD(void set_attributes(Pango::AttrList& attrs), gtk_label_set_attributes)
  _WRAP_METHOD(Pango::AttrList get_attributes() const, gtk_label_get_attributes)

  //TODO: Remove set_label() or set_text()?
  _WRAP_METHOD(void set_label(const Glib::ustring& str), gtk_label_set_label)
  _WRAP_METHOD(Glib::ustring get_label() const, gtk_label_get_label)
  _WRAP_METHOD(void set_markup(const Glib::ustring& str), gtk_label_set_markup)
  _WRAP_METHOD(void set_use_markup(bool setting = true), gtk_label_set_use_markup)
  _WRAP_METHOD(bool get_use_markup() const, gtk_label_get_use_markup)
  _WRAP_METHOD(void set_use_underline(bool setting = true), gtk_label_set_use_underline)
  _WRAP_METHOD(bool get_use_underline() const, gtk_label_get_use_underline)

  _WRAP_METHOD(void set_markup_with_mnemonic(const Glib::ustring& str), gtk_label_set_markup_with_mnemonic)
  _WRAP_METHOD(guint get_mnemonic_keyval() const, gtk_label_get_mnemonic_keyval)
  _WRAP_METHOD(void set_mnemonic_widget(Widget& widget), gtk_label_set_mnemonic_widget)
  _WRAP_METHOD(Widget* get_mnemonic_widget(), gtk_label_get_mnemonic_widget)
  _WRAP_METHOD(const Widget* get_mnemonic_widget() const, gtk_label_get_mnemonic_widget)
  _WRAP_METHOD(void set_text_with_mnemonic(const Glib::ustring& str), gtk_label_set_text_with_mnemonic)
  _WRAP_METHOD(void set_justify(Justification jtype),gtk_label_set_justify)
  _WRAP_METHOD(Justification get_justify() const, gtk_label_get_justify)

  _WRAP_METHOD(void set_ellipsize(Pango::EllipsizeMode mode), gtk_label_set_ellipsize)
  _WRAP_METHOD(Pango::EllipsizeMode get_ellipsize() const, gtk_label_get_ellipsize)

  _WRAP_METHOD(void set_width_chars(int n_chars), gtk_label_set_width_chars)
  _WRAP_METHOD(int get_width_chars() const, gtk_label_get_width_chars)

  _WRAP_METHOD(void set_max_width_chars(int n_chars), gtk_label_set_max_width_chars)
  _WRAP_METHOD(int get_max_width_chars() const, gtk_label_get_max_width_chars)

  _WRAP_METHOD(void set_lines(int lines), gtk_label_set_lines)
  _WRAP_METHOD(int get_lines() const, gtk_label_get_lines)

  _WRAP_METHOD(void set_pattern(const Glib::ustring& pattern), gtk_label_set_pattern)
  _WRAP_METHOD(void set_line_wrap(bool wrap = true), gtk_label_set_line_wrap)
  _WRAP_METHOD(bool get_line_wrap() const, gtk_label_get_line_wrap)
  _WRAP_METHOD(void set_line_wrap_mode(Pango::WrapMode wrap_mode), gtk_label_set_line_wrap_mode)
  _WRAP_METHOD(Pango::WrapMode get_line_wrap_mode() const, gtk_label_get_line_wrap_mode)
  _WRAP_METHOD(void set_selectable(bool setting = true), gtk_label_set_selectable)
  _WRAP_METHOD(bool get_selectable() const, gtk_label_get_selectable)
  _WRAP_METHOD(void set_angle(double angle), gtk_label_set_angle)
  _WRAP_METHOD(double get_angle() const, gtk_label_get_angle)
  _WRAP_METHOD(void select_region(int start_offset, int end_offset), gtk_label_select_region)

  /** Selects a range of characters in the label, from @a start_offset to the end,
   * if the label is selectable.
   * See gtk_label_set_selectable(). If the label is not selectable,
   * this function has no effect.
   *
   * @param start_offset Start offset (in characters not bytes)
   */
  void select_region(int start_offset);

  _WRAP_METHOD(bool get_selection_bounds(int& start, int& end) const, gtk_label_get_selection_bounds)

  _WRAP_METHOD(Glib::RefPtr<Pango::Layout> get_layout(), gtk_label_get_layout, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Pango::Layout> get_layout() const, gtk_label_get_layout, refreturn, constversion)
  _WRAP_METHOD(void get_layout_offsets(int& x, int& y) const, gtk_label_get_layout_offsets)

  _WRAP_METHOD(void set_single_line_mode(bool single_line_mode = true), gtk_label_set_single_line_mode)
  _WRAP_METHOD(bool get_single_line_mode() const, gtk_label_get_single_line_mode)

  _WRAP_METHOD(Glib::ustring get_current_uri() const, gtk_label_get_current_uri)

  _WRAP_METHOD(void set_track_visited_links(bool track_links = true), gtk_label_set_track_visited_links)
  _WRAP_METHOD(bool get_track_visited_links() const, gtk_label_get_track_visited_links)

  _WRAP_SIGNAL(void populate_popup(Menu* menu), "populate_popup")

  #m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
  _WRAP_SIGNAL(bool activate_link(const Glib::ustring& uri), "activate-link", no_default_handler)

  //Keybinding signals:
  _IGNORE_SIGNAL("move_cursor")
  _IGNORE_SIGNAL("copy_clipboard")
  _IGNORE_SIGNAL("activate-current-link")

  _WRAP_PROPERTY("label", Glib::ustring)
  _WRAP_PROPERTY("attributes", Pango::AttrList)
  _WRAP_PROPERTY("use-markup", bool)
  _WRAP_PROPERTY("use-underline", bool)
  _WRAP_PROPERTY("justify", Justification)
  _WRAP_PROPERTY("pattern", Glib::ustring)
  _WRAP_PROPERTY("wrap", bool)
  _WRAP_PROPERTY("wrap-mode", Pango::WrapMode)
  _WRAP_PROPERTY("selectable", bool)
  _WRAP_PROPERTY("mnemonic-keyval", guint)
  _WRAP_PROPERTY("mnemonic-widget", Widget*)
  _WRAP_PROPERTY("cursor-position", int)
  _WRAP_PROPERTY("selection-bound", int)
  _WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
  _WRAP_PROPERTY("width-chars", int)
  _WRAP_PROPERTY("single-line-mode", bool)
  _WRAP_PROPERTY("angle", double)
  _WRAP_PROPERTY("max_width_chars", int)
  _WRAP_PROPERTY("track-visited-links", bool)
  _WRAP_PROPERTY("lines", int)
};

}  // namespace Gtk
