[cluttermm] Add TextBuffer and add Text methods.



commit 58b6b4efba27e2c49cdd7cb9aaafef3beccebc5c
Author: Ian Martin <martin_id vodafone co nz>
Date:   Thu Apr 10 16:33:50 2014 +0200

    Add TextBuffer and add Text methods.
    
    This is based on changes in this patch:
    https://bugzilla.gnome.org/show_bug.cgi?id=725125#c8

 clutter/cluttermm.h           |    1 +
 clutter/src/filelist.am       |    5 ++-
 clutter/src/text-buffer.ccg   |   36 ++++++++++++++++++++
 clutter/src/text-buffer.hg    |   72 +++++++++++++++++++++++++++++++++++++++++
 clutter/src/text.ccg          |   17 ++++++++++
 clutter/src/text.hg           |   52 +++++++++++++++++++++++------
 codegen/m4/convert_clutter.m4 |    3 ++
 7 files changed, 173 insertions(+), 13 deletions(-)
---
diff --git a/clutter/cluttermm.h b/clutter/cluttermm.h
index 37c2d8d..8fb8f54 100644
--- a/clutter/cluttermm.h
+++ b/clutter/cluttermm.h
@@ -118,6 +118,7 @@
 #include <cluttermm/snap-constraint.h>
 #include <cluttermm/stage.h>
 #include <cluttermm/text.h>
+#include <cluttermm/text-buffer.h>
 #include <cluttermm/texture.h>
 #include <cluttermm/threads.h>
 #include <cluttermm/timeline.h>
diff --git a/clutter/src/filelist.am b/clutter/src/filelist.am
index 2c13a02..81a9839 100644
--- a/clutter/src/filelist.am
+++ b/clutter/src/filelist.am
@@ -63,7 +63,7 @@ files_hg =                    \
        offscreen-effect.hg \
        page-turn-effect.hg \
        path.hg                 \
-  path-constraint.hg \
+       path-constraint.hg \
        property-transition.hg  \
        rectangle.hg            \
        score.hg                \
@@ -72,9 +72,10 @@ files_hg =                   \
        shader.hg               \
        shader-effect.hg \
        size.hg                 \
-  snap-constraint.hg \
+       snap-constraint.hg \
        stage.hg                \
        text.hg                 \
+       text-buffer.hg                  \
        texture.hg              \
        timeline.hg             \
        transition.hg \
diff --git a/clutter/src/text-buffer.ccg b/clutter/src/text-buffer.ccg
new file mode 100644
index 0000000..a54253a
--- /dev/null
+++ b/clutter/src/text-buffer.ccg
@@ -0,0 +1,36 @@
+/* Copyright (C) 2007 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.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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <clutter/clutter.h>
+
+namespace Clutter
+{
+
+TextBuffer::TextBuffer(const Glib::ustring& text)
+:
+  _CONSTRUCT("text", text.c_str(), "text_len", text.size())
+{
+}
+
+void TextBuffer::set_text(const Glib::ustring& text)
+{
+  clutter_text_buffer_set_text(gobj(), text.c_str(), -1);
+}
+
+
+
+} //namespace Clutter
diff --git a/clutter/src/text-buffer.hg b/clutter/src/text-buffer.hg
new file mode 100644
index 0000000..e55f8d8
--- /dev/null
+++ b/clutter/src/text-buffer.hg
@@ -0,0 +1,72 @@
+/* Copyright (C) 2013 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.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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/object.h>
+#include <glibmm/ustring.h>
+
+
+_DEFS(cluttermm,clutter)
+_PINCLUDE(glibmm/private/object_p.h)
+
+
+namespace Clutter
+{
+
+class TextBuffer: public Glib::Object
+{
+  _CLASS_GOBJECT(TextBuffer, ClutterTextBuffer, CLUTTER_TEXT_BUFFER, Glib::Object, GObject)
+  _DERIVES_INITIALLY_UNOWNED()
+
+protected:
+  _WRAP_CTOR(TextBuffer(), clutter_text_buffer_new)
+
+  _WRAP_METHOD_DOCS_ONLY(clutter_text_buffer_new_with_text)
+  explicit TextBuffer(const Glib::ustring& text);
+
+public:
+
+  _WRAP_CREATE()
+
+
+  /**
+   * sets the text in the buffer.
+   * */
+  void set_text(const Glib::ustring& text);
+  _IGNORE(clutter_text_buffer_set_text)
+
+
+  _WRAP_METHOD(Glib::ustring get_text() const, clutter_text_buffer_get_text)
+  _WRAP_METHOD(gsize get_bytes() const,clutter_text_buffer_get_bytes )
+  _WRAP_METHOD(guint get_length() const, clutter_text_buffer_get_length)
+  _WRAP_METHOD(void set_max_length(int max_length),clutter_text_buffer_set_max_length)
+  _WRAP_METHOD(int get_max_length() const, clutter_text_buffer_get_max_length)
+
+
+  _WRAP_METHOD(guint insert_text(guint position, const Glib::ustring& chars, int n_chars), 
clutter_text_buffer_insert_text)
+  _WRAP_METHOD(guint delete_text(guint position, int n_chars), clutter_text_buffer_delete_text)
+  _WRAP_METHOD(void emit_inserted_text(guint position, const Glib::ustring& chars, guint n_chars), 
clutter_text_buffer_emit_inserted_text)
+  _WRAP_METHOD(void emit_deleted_text(guint position, guint n_chars), clutter_text_buffer_emit_deleted_text)
+
+  _WRAP_SIGNAL(void deleted_text(guint position, guint n_chars), deleted_text)
+  _WRAP_SIGNAL(void inserted_text(guint position, const Glib::ustring& chars, guint n_chars), inserted_text)
+
+  _WRAP_PROPERTY("length", guint)
+  _WRAP_PROPERTY("max-length", int)
+  _WRAP_PROPERTY("text", Glib::ustring)
+};
+
+} // namespace Clutter
diff --git a/clutter/src/text.ccg b/clutter/src/text.ccg
index aa05911..eeb6925 100644
--- a/clutter/src/text.ccg
+++ b/clutter/src/text.ccg
@@ -16,6 +16,8 @@
  */
 
 #include <clutter/clutter.h>
+#include <cluttermm/color.h>
+#include <cluttermm/text-buffer.h>
 
 namespace Clutter
 {
@@ -41,4 +43,19 @@ Color Text::get_cursor_color() const
   return color;
 }
 
+Color Text::get_selected_text_color() const
+{
+  Color color;
+  clutter_text_get_selected_text_color(const_cast<ClutterText*>(gobj()), color.gobj());
+  return color;
+}
+
+Rect Text::get_cursor_rect() const
+{
+  Rect rect;
+  clutter_text_get_cursor_rect(const_cast<ClutterText*>(gobj()), rect.gobj());
+  return rect;
+}
+
+
 } // namespace Clutter
diff --git a/clutter/src/text.hg b/clutter/src/text.hg
index a2532ab..657f5b1 100644
--- a/clutter/src/text.hg
+++ b/clutter/src/text.hg
@@ -16,7 +16,10 @@
  */
 
 #include <cluttermm/actor.h>
-#include <cluttermm/color.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <cluttermm/types.h>
+
 #include <pangomm.h>
 
 _DEFS(cluttermm,clutter)
@@ -25,6 +28,9 @@ _PINCLUDE(cluttermm/private/actor_p.h)
 namespace Clutter
 {
 
+class TextBuffer;
+class Color;
+
 class Text : public Actor
 {
   _CLASS_GOBJECT(Text, ClutterText, CLUTTER_TEXT, Actor, ClutterActor)
@@ -33,23 +39,31 @@ 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)
+  _WRAP_CTOR(Text(const Glib::RefPtr<TextBuffer>& buffer), clutter_text_new_with_buffer)
 
 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)
+  _WRAP_CREATE(const Glib::RefPtr<TextBuffer>& buffer)
 
 #m4 dnl _CONVERSION(`ClutterActor*',`Glib::RefPtr<Text>',`Glib::wrap((ClutterText*)$3)')
 
+  _WRAP_METHOD(void set_buffer(const Glib::RefPtr<TextBuffer>& buffer), clutter_text_set_buffer)
+
+  _WRAP_METHOD(Glib::RefPtr<TextBuffer> get_buffer(), clutter_text_get_buffer, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const TextBuffer> get_buffer() const, clutter_text_get_buffer, refreturn, 
constversion)
+
   _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(void set_activatable(bool activatable = true), clutter_text_set_activatable)
   _WRAP_METHOD(bool get_activatable() const, clutter_text_get_activatable)
 
+  //TODO: Should attrs be const?
   _WRAP_METHOD(void set_attributes(Pango::AttrList& attrs), clutter_text_set_attributes)
-  _WRAP_METHOD(Pango::AttrList get_attributes(), clutter_text_get_attributes)
+  _WRAP_METHOD(Pango::AttrList get_attributes() const, clutter_text_get_attributes)
 
   _WRAP_METHOD(void set_color(const Color& color), clutter_text_set_color)
 
@@ -58,7 +72,7 @@ public:
   _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(Pango::EllipsizeMode get_ellipsize() const, 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)
@@ -70,7 +84,7 @@ public:
   _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(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)
@@ -79,7 +93,7 @@ public:
   _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(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)
@@ -88,7 +102,7 @@ public:
   _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(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)
@@ -101,11 +115,15 @@ public:
 
   _WRAP_METHOD_DOCS_ONLY(clutter_text_get_selection_color)
   Color get_selection_color() const;
-  _IGNORE(clutter_text_get_selectino_color)
+  _IGNORE(clutter_text_get_selection_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_DOCS_ONLY(clutter_text_get_selected_text_color)
+  Color get_selected_text_color() const;
+  _IGNORE(clutter_text_get_selected_text_color)
+
   _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)
 
@@ -137,39 +155,51 @@ public:
   _WRAP_METHOD(void set_cursor_size(int size), clutter_text_set_cursor_size)
   _WRAP_METHOD(guint get_cursor_size() const, clutter_text_get_cursor_size)
 
+  Rect get_cursor_rect() const;
+  _IGNORE(clutter_text_get_cursor_rect)
+
   _WRAP_METHOD(bool activate(), clutter_text_activate)
+  _WRAP_METHOD(int coords_to_position(float x, float y), clutter_text_coords_to_position )
 
   _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_METHOD(void get_layout_offsets(int& x, int& y), clutter_text_get_layout_offsets)
+
   _WRAP_SIGNAL(void activate(), "activate")
   _WRAP_SIGNAL(void text_changed(), "text_changed")
-  _WRAP_SIGNAL(void cursor_event(const Geometry& geometry), "cursor_event")
+
+
+  _WRAP_SIGNAL(void cursor_changed(), "cursor_changed")
   //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("buffer", Glib::RefPtr<TextBuffer>)
   _WRAP_PROPERTY("color", Color)
   _WRAP_PROPERTY("cursor-color", Color)
   _WRAP_PROPERTY("cursor-color-set", bool)
+  _WRAP_PROPERTY("cursor-position", guint)
   _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("font-name", Glib::ustring)
   _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("position", int) //TODO: Marked for removal in clutter.
   _WRAP_PROPERTY("selectable", bool)
+  _WRAP_PROPERTY("selected-text-color", Color)
+  _WRAP_PROPERTY("selected-text-color-set", bool)
   _WRAP_PROPERTY("selection-bound", int)
   _WRAP_PROPERTY("selection-color", Color)
   _WRAP_PROPERTY("selection-color-set", bool)
diff --git a/codegen/m4/convert_clutter.m4 b/codegen/m4/convert_clutter.m4
index 469d6c8..77d20ce 100644
--- a/codegen/m4/convert_clutter.m4
+++ b/codegen/m4/convert_clutter.m4
@@ -124,6 +124,9 @@ _CONVERSION(`ClutterShader*',`Glib::RefPtr<const Shader>', `Glib::wrap($3)')
 
 _CONVERSION(`ClutterStage*',`Glib::RefPtr<Stage>',`Glib::wrap($3)')
 
+_CONVERSION(`const Glib::RefPtr<TextBuffer>&',`ClutterTextBuffer*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`ClutterTextBuffer*',`Glib::RefPtr<TextBuffer>',`Glib::wrap($3)')
+
 _CONVERSION(`const Glib::RefPtr<Texture>&',`ClutterTexture*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`ClutterTexture*',`Glib::RefPtr<Texture>',`Glib::wrap($3)')
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]