/*
 * Copyright (c) 2009  The cluttermm 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 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 <http://www.gnu.org/licenses/>.
 */

#include <cluttermm/actor.h>
#include <cluttermm/color.h>
#include <pangomm.h>
 
_DEFS(cluttermm,clutter)
_PINCLUDE(cluttermm/private/actor_p.h)

namespace Clutter
{

class Text : public Actor
{
  _CLASS_GOBJECT(Text, ClutterText, CLUTTER_TEXT, Actor, ClutterActor)

protected:
  _CTOR_DEFAULT()
  _WRAP_CTOR(Text(const Glib::ustring& font_name, const Glib::ustring& text), clutter_text_new_with_text)
  _WRAP_CTOR(Text(const Glib::ustring& font_name, const Glib::ustring& text, const Color& color), clutter_text_new_full)

public:
  _WRAP_CREATE()
  _WRAP_CREATE(const Glib::ustring& font_name, const Glib::ustring& text)
  _WRAP_CREATE(const Glib::ustring& font_name, const Glib::ustring& text, const Color& color)

#m4 dnl _CONVERSION(`ClutterActor*',`Glib::RefPtr<Text>',`Glib::wrap((ClutterText*)$3)')

  _WRAP_METHOD(void set_text(const Glib::ustring& text), clutter_text_set_text)
  _WRAP_METHOD(void set_markup(const Glib::ustring& markup), clutter_text_set_markup)
  _WRAP_METHOD(Glib::ustring get_text() const, clutter_text_get_text)

  _WRAP_METHOD(void set_activatable(bool activatable=true), clutter_text_set_activatable)
  _WRAP_METHOD(bool get_activatable() const, clutter_text_get_activatable)

  _WRAP_METHOD(void set_attributes(Pango::AttrList& attrs), clutter_text_set_attributes)
  _WRAP_METHOD(Pango::AttrList get_attributes(), clutter_text_get_attributes)

  _WRAP_METHOD(void set_color(const Color& color), clutter_text_set_color)
  _WRAP_METHOD_DOCS_ONLY(clutter_text_get_color)
  Color get_color() const;
  _IGNORE(clutter_text_get_color)

  _WRAP_METHOD(void set_ellipsize(Pango::EllipsizeMode mode), clutter_text_set_ellipsize)
  _WRAP_METHOD(Pango::EllipsizeMode get_ellipsize(), clutter_text_get_ellipsize)

  _WRAP_METHOD(void set_font_name(const Glib::ustring& font_name), clutter_text_set_font_name)
  _WRAP_METHOD(Glib::ustring get_font_name() const, clutter_text_get_font_name)

  _WRAP_METHOD(void set_font_description(const Pango::FontDescription& font_desc), clutter_text_set_font_description)
#m4 _CONVERSION(`PangoFontDescription*',`Pango::FontDescription',`Pango::FontDescription(($3))')
  _WRAP_METHOD(Pango::FontDescription get_font_description() const, clutter_text_get_font_description)
  
  _WRAP_METHOD(void set_password_char(gunichar wc), clutter_text_set_password_char)
  _WRAP_METHOD(gunichar get_password_char() const, clutter_text_get_password_char)

  _WRAP_METHOD(void set_justify(bool justify=true), clutter_text_set_justify)
  _WRAP_METHOD(bool get_justify() const, clutter_text_get_justify)

  _WRAP_METHOD(Glib::RefPtr<Pango::Layout> get_layout(), clutter_text_get_layout)
  _WRAP_METHOD(Glib::RefPtr<const Pango::Layout> get_layout() const, clutter_text_get_layout, constversion)

  _WRAP_METHOD(void set_line_alignment(Pango::Alignment alignment), clutter_text_set_line_alignment)
  _WRAP_METHOD(Pango::Alignment get_line_alignment() const, clutter_text_get_line_alignment)

  _WRAP_METHOD(void set_line_wrap(bool line_wrap=true), clutter_text_set_line_wrap)
  _WRAP_METHOD(bool get_line_wrap() const, clutter_text_get_line_wrap)

  _WRAP_METHOD(Pango::WrapMode get_line_wrap_mode() const, clutter_text_get_line_wrap_mode)
  _WRAP_METHOD(void set_line_wrap_mode(Pango::WrapMode wrap_mode), clutter_text_set_line_wrap_mode)

  _WRAP_METHOD(int get_max_length() const, clutter_text_get_max_length)
  _WRAP_METHOD(void set_max_length(int max_length), clutter_text_set_max_length)

  _WRAP_METHOD(void set_selectable(bool selectable=true), clutter_text_set_selectable)
  _WRAP_METHOD(bool get_selectable() const, clutter_text_get_selectable)

  _WRAP_METHOD(void set_selection(gssize start_pos, gssize end_pos), clutter_text_set_selection)
  _WRAP_METHOD(Glib::ustring get_selection() const, clutter_text_get_selection)

  _WRAP_METHOD(void set_selection_bound(int selection_bound), clutter_text_set_selection_bound)
  _WRAP_METHOD(int get_selection_bound() const, clutter_text_get_selection_bound)

  _WRAP_METHOD(void set_selection_color(const Color& color), clutter_text_set_selection_color)
  _WRAP_METHOD_DOCS_ONLY(clutter_text_get_selection_color)
  Color get_selection_color() const;
  _IGNORE(clutter_text_get_color)

  _WRAP_METHOD(void set_single_line_mode(bool single_line=true), clutter_text_set_single_line_mode)
  _WRAP_METHOD(bool get_single_line_mode() const, clutter_text_get_single_line_mode)

  _WRAP_METHOD(void set_use_markup(bool setting=true), clutter_text_set_use_markup)
  _WRAP_METHOD(bool get_use_markup() const, clutter_text_get_use_markup)

  _WRAP_METHOD(void set_editable(bool editable=true), clutter_text_set_editable)
  _WRAP_METHOD(bool get_editable() const, clutter_text_get_editable)

  _WRAP_METHOD(void insert(gunichar wc), clutter_text_insert_unichar)
  _WRAP_METHOD(void insert(const Glib::ustring& text, gssize position), clutter_text_insert_text)

  _WRAP_METHOD(void delete_chars(guint len), clutter_text_delete_chars)
  _WRAP_METHOD(void delete_text(gssize start_pos, gssize end_pos), clutter_text_delete_text)
  _WRAP_METHOD(bool delete_selection(), clutter_text_delete_selection)

  _WRAP_METHOD(Glib::ustring get_chars(gssize start_pos, gssize end_pos) const, clutter_text_get_chars)

  _WRAP_METHOD(void set_cursor_color(const Color& color), clutter_text_set_cursor_color)
  _WRAP_METHOD(void get_cursor_color(Color& color) const, clutter_text_get_cursor_color)

  _WRAP_METHOD(void set_cursor_position(int position), clutter_text_set_cursor_position)
  _WRAP_METHOD(int get_cursor_position() const, clutter_text_get_cursor_position)

  _WRAP_METHOD(void set_cursor_visible(bool visible), clutter_text_set_cursor_visible)
  _WRAP_METHOD(bool get_cursor_visible() const, clutter_text_get_cursor_visible)

  _WRAP_METHOD(void set_cursor_size(int size), clutter_text_set_cursor_size)
  _WRAP_METHOD(unsigned int get_cursor_size() const, clutter_text_get_cursor_size)

  _WRAP_METHOD(bool activate(), clutter_text_activate)

  _WRAP_METHOD(bool position_to_coords(int position, float &x, float &y, float &line_height), clutter_text_position_to_coords)

#m4 _CONVERSION(`const Pango::AttrList&',`PangoAttrList*',`const_cast<PangoAttrList*>(($3).gobj())')
  _WRAP_METHOD(void set_preedit_string(const Glib::ustring& preedit_str, const Pango::AttrList& preedit_attrs, guint ursor_pos), clutter_text_set_preedit_string)

  _WRAP_SIGNAL(void activate(), "activate")
  _WRAP_SIGNAL(void text_changed(), "text_changed")
  _WRAP_SIGNAL(void cursor_event(const Geometry& geometry), "cursor_event")
  //These are action signals, so probably shouldn't be wrapped:
  //_WRAP_SIGNAL(void insert_text(const char* new_text, int new_text_length, int position), "insert-text", no_default_handler)
  //_WRAP_SIGNAL(void delete_text(int start_pos, int end_pos), "insert-text", no_default_handler)
  
  _WRAP_PROPERTY("activatable", bool)
  _WRAP_PROPERTY("attributes", Pango::AttrList)
  _WRAP_PROPERTY("color", Color)
  _WRAP_PROPERTY("cursor-color", Color)
  _WRAP_PROPERTY("cursor-color-set", bool)
  _WRAP_PROPERTY("cursor-size", int)
  _WRAP_PROPERTY("cursor-visible", bool)
  _WRAP_PROPERTY("editable", bool)
  _WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
  _WRAP_PROPERTY("font-name", Glib::ustring)
  _WRAP_PROPERTY("font-description", Pango::FontDescription)
  _WRAP_PROPERTY("justify", bool)
  _WRAP_PROPERTY("line-alignment", Pango::Alignment)
  _WRAP_PROPERTY("line-wrap-mode", Pango::WrapMode)
  _WRAP_PROPERTY("line-wrap", bool)
  _WRAP_PROPERTY("max-length", int)
  _WRAP_PROPERTY("password-char", gunichar)
  _WRAP_PROPERTY("position", int)
  _WRAP_PROPERTY("selectable", bool)
  _WRAP_PROPERTY("selection-bound", int)
  _WRAP_PROPERTY("selection-color", Color)
  _WRAP_PROPERTY("selection-color-set", bool)
  _WRAP_PROPERTY("single-line-mode", bool)
  _WRAP_PROPERTY("text", Glib::ustring)
  _WRAP_PROPERTY("use-markup", bool)
};

} // namespace Clutter
