Fix get_character_extents.
authorKarol Furmaniak <k.furmaniak@samsung.com>
Thu, 21 Nov 2013 13:59:39 +0000 (14:59 +0100)
committerKarol Furmaniak <k.furmaniak@samsung.com>
Thu, 21 Nov 2013 13:59:39 +0000 (14:59 +0100)
Fix for widgets: elm_label, elm_popup, elm_bubble, elm_fileselector_entry.

eail/eail/eail_bubble.c
eail/eail/eail_fileselector_entry.c
eail/eail/eail_label.c
eail/eail/eail_popup.c

index cb8f205..39d3740 100644 (file)
@@ -27,6 +27,7 @@
 #include "eail_bubble.h"
 
 static void atk_action_interface_init(AtkActionIface *iface);
+static void atk_text_interface_init(AtkTextIface *iface);
 
 /**
  * @brief Definition of EailBubble type
@@ -34,6 +35,8 @@ static void atk_action_interface_init(AtkActionIface *iface);
 G_DEFINE_TYPE_WITH_CODE(EailBubble,
                         eail_bubble,
                         EAIL_TYPE_TEXT,
+                        G_IMPLEMENT_INTERFACE(ATK_TYPE_TEXT,
+                                              atk_text_interface_init)
                         G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION,
                                               atk_action_interface_init));
 
@@ -297,3 +300,83 @@ atk_action_interface_init(AtkActionIface *iface)
    iface->get_name        = eail_bubble_action_name_get;
    iface->do_action       = eail_bubble_do_action;
 }
+
+/**
+ * @brief Get the bounding box containing the glyph
+ *  representing the character at a particular text offset.
+ *
+ * @param text AtkText instance
+ * @param offset The offset of the text character for which
+ * bounding information is required.
+ * @param x Pointer for the x cordinate of the bounding box
+ * @param y Pointer for the y cordinate of the bounding box
+ * @param width Pointer for the width of the bounding box
+ * @param height Pointer for the height of the bounding box
+ * @param coords specify whether coordinates are relative to the
+ * screen or widget window
+ *
+ */
+static void
+eail_bubble_get_character_extents(AtkText *text,
+                                  gint offset,
+                                  gint *x,
+                                  gint *y,
+                                  gint *width,
+                                  gint *height,
+                                  AtkCoordType coords)
+{
+   int result = -1;
+   const Evas_Object *textblock = NULL;
+   Evas_Textblock_Cursor *cur = NULL;
+   Evas_Object *label = NULL;
+   Evas_Object *label_edje_layer = NULL;
+   Evas_Object *bubble_edje_layer = NULL;
+
+   Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
+   if (!widget) return;
+
+   bubble_edje_layer = elm_layout_edje_get(widget);
+   if (!bubble_edje_layer) return;
+
+   label= edje_object_part_swallow_get(bubble_edje_layer, "elm.swallow.content");
+   if (!label) return;
+
+   label_edje_layer = elm_layout_edje_get(label);
+   if (!label_edje_layer) return;
+
+   textblock = edje_object_part_object_get(label_edje_layer, "elm.text");
+   if (!textblock) return;
+
+   cur = evas_object_textblock_cursor_new(textblock);
+   if (!cur) return;
+
+   evas_textblock_cursor_pos_set(cur, offset);
+
+   result = evas_textblock_cursor_char_geometry_get(cur, x, y, width, height);
+
+   evas_textblock_cursor_free(cur);
+
+   if (-1 == result) return;
+
+   if (coords == ATK_XY_SCREEN)
+   {
+      int ee_x, ee_y;
+      Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
+
+      ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
+      *x += ee_x;
+      *y += ee_y;
+    }
+}
+
+
+/**
+ * @brief Initializes AtkTextIface interface
+ *
+ * @param iface AtkTextIface instance
+ */
+static void
+atk_text_interface_init(AtkTextIface *iface)
+{
+   iface->get_character_extents = eail_bubble_get_character_extents;
+}
index 4c99407..fe349ca 100644 (file)
@@ -458,6 +458,71 @@ eail_fileselector_entry_get_text_before_offset(AtkText *text,
                                end_offset);
 }
 
+/*
+ * @brief Get the bounding box containing the glyph
+ *  representing the character at a particular text offset.
+ *
+ * @param text AtkText instance
+ * @param offset The offset of the text character for which
+ * bounding information is required.
+ * @param x Pointer for the x cordinate of the bounding box
+ * @param y Pointer for the y cordinate of the bounding box
+ * @param width Pointer for the width of the bounding box
+ * @param height Pointer for the height of the bounding box
+ * @param coords specify whether coordinates are relative to the
+ * screen or widget window
+ *
+ */
+static void
+eail_fileselector_entry_get_character_extents(AtkText *text,
+                                              gint offset,
+                                              gint *x,
+                                              gint *y,
+                                              gint *width,
+                                              gint *height,
+                                              AtkCoordType coords)
+{
+   int result = -1;
+   const Evas_Object *textblock = NULL;
+   Evas_Textblock_Cursor *cur = NULL;
+   Evas_Object *entry = NULL;
+   Evas_Object *fileselector_entry_edje_layer = NULL;
+
+   Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
+   if (!widget) return;
+
+   fileselector_entry_edje_layer = elm_layout_edje_get(widget);
+   if (!fileselector_entry_edje_layer) return;
+
+   entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
+                                        "elm.swallow.entry");
+   if (!entry) return;
+
+   textblock = elm_entry_textblock_get(entry);
+   if (!textblock) return;
+
+   cur = evas_object_textblock_cursor_new(textblock);
+   if (!cur) return;
+
+   evas_textblock_cursor_pos_set(cur, offset);
+
+   result = evas_textblock_cursor_char_geometry_get(cur, x, y, width, height);
+
+   evas_textblock_cursor_free(cur);
+
+   if (-1 == result) return;
+
+   if (coords == ATK_XY_SCREEN)
+   {
+      int ee_x, ee_y;
+      Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
+
+      ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
+      *x += ee_x;
+      *y += ee_y;
+    }
+}
+
 /**
  * @brief Initializer for AtkTextIface interface
  *
@@ -472,6 +537,7 @@ atk_text_interface_init(AtkTextIface *iface)
     iface->get_text_after_offset = eail_fileselector_entry_get_text_after_offset;
     iface->get_text_at_offset = eail_fileselector_entry_get_text_at_offset;
     iface->get_text_before_offset = eail_fileselector_entry_get_text_before_offset;
+    iface->get_character_extents = eail_fileselector_entry_get_character_extents;
 }
 
 /*
index 0170cf6..1c3b65a 100644 (file)
@@ -467,6 +467,65 @@ eail_label_get_offset_at_point(AtkText *text,
    return result;
 }
 
+/*
+ * @brief Get the bounding box containing the glyph
+ *  representing the character at a particular text offset.
+ *
+ * @param text AtkText instance
+ * @param offset The offset of the text character for which
+ * bounding information is required.
+ * @param x Pointer for the x cordinate of the bounding box
+ * @param y Pointer for the y cordinate of the bounding box
+ * @param width Pointer for the width of the bounding box
+ * @param height Pointer for the height of the bounding box
+ * @param coords specify whether coordinates are relative to the
+ * screen or widget window
+ *
+ */
+static void
+eail_label_get_character_extents(AtkText *text,
+                                 gint offset,
+                                 gint *x,
+                                 gint *y,
+                                 gint *width,
+                                 gint *height,
+                                 AtkCoordType coords)
+{
+   int result = -1;
+   const Evas_Object *textblock = NULL;
+   Evas_Textblock_Cursor *cur = NULL;
+   Evas_Object *label_edje_layer = NULL;
+
+   Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
+
+   if (!widget) return;
+
+   label_edje_layer = elm_layout_edje_get(widget);
+
+   if (!label_edje_layer) return;
+
+   textblock = edje_object_part_object_get(label_edje_layer, "elm.text");
+
+   cur = evas_object_textblock_cursor_new(textblock);
+   evas_textblock_cursor_pos_set(cur, offset);
+
+   result = evas_textblock_cursor_char_geometry_get(cur, x, y, width, height);
+
+   evas_textblock_cursor_free(cur);
+
+   if (-1 == result) return;
+
+   if (coords == ATK_XY_SCREEN)
+   {
+      int ee_x, ee_y;
+      Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
+
+      ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
+      *x += ee_x;
+      *y += ee_y;
+    }
+}
+
 /**
  * @brief Initializes AtkTextIface interface
  *
@@ -484,5 +543,6 @@ atk_text_interface_init(AtkTextIface *iface)
    iface->get_text_at_offset = eail_label_get_text_at_offset;
    iface->get_text_before_offset = eail_label_get_text_before_offset;
    iface->get_offset_at_point = eail_label_get_offset_at_point;
+   iface->get_character_extents = eail_label_get_character_extents;
 }
 
index db46ea9..22bb2e8 100644 (file)
@@ -421,6 +421,82 @@ eail_popup_get_character_count(AtkText *popup)
 }
 
 /**
+ * @brief Get the bounding box containing the glyph
+ *  representing the character at a particular text offset.
+ *
+ * @param text AtkText instance
+ * @param offset The offset of the text character for which
+ * bounding information is required.
+ * @param x Pointer for the x cordinate of the bounding box
+ * @param y Pointer for the y cordinate of the bounding box
+ * @param width Pointer for the width of the bounding box
+ * @param height Pointer for the height of the bounding box
+ * @param coords specify whether coordinates are relative to the
+ * screen or widget window
+ *
+ */
+static void
+eail_popup_get_character_extents(AtkText *text,
+                                 gint offset,
+                                 gint *x,
+                                 gint *y,
+                                 gint *width,
+                                 gint *height,
+                                 AtkCoordType coords)
+{
+   int result = -1;
+   const Evas_Object *textblock = NULL;
+   Evas_Textblock_Cursor *cur = NULL;
+   Evas_Object *label = NULL;
+   Evas_Object *layout = NULL;
+   Evas_Object *layout_edje_layer = NULL;
+   Evas_Object *label_edje_layer = NULL;
+   Evas_Object *popup_edje_layer = NULL;
+
+   Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
+   if (!widget) return;
+
+   popup_edje_layer = elm_layout_edje_get(widget);
+   if (!popup_edje_layer) return;
+
+   layout = edje_object_part_swallow_get(popup_edje_layer, "elm.swallow.content");
+   if (!layout) return;
+
+   layout_edje_layer = elm_layout_edje_get(layout);
+   if (!layout_edje_layer) return;
+
+   label = edje_object_part_swallow_get(layout_edje_layer, "elm.swallow.content");
+   if (!label) return;
+
+   label_edje_layer = elm_layout_edje_get(label);
+   if (!label_edje_layer) return;
+
+   textblock = edje_object_part_object_get(label_edje_layer, "elm.text");
+   if (!textblock) return;
+
+   cur = evas_object_textblock_cursor_new(textblock);
+   if (!cur) return;
+
+   evas_textblock_cursor_pos_set(cur, offset);
+
+   result = evas_textblock_cursor_char_geometry_get(cur, x, y, width, height);
+
+   evas_textblock_cursor_free(cur);
+
+   if (-1 == result) return;
+
+   if (coords == ATK_XY_SCREEN)
+   {
+      int ee_x, ee_y;
+      Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
+
+      ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
+      *x += ee_x;
+      *y += ee_y;
+    }
+}
+
+/**
  * @brief Initializer for AtkTextIface interface class
  *
  * Defines callbacks for AtkTextIface.
@@ -433,4 +509,5 @@ atk_text_interface_init(AtkTextIface *iface)
     iface->get_text = eail_popup_get_text;
     iface->get_character_at_offset = eail_popup_get_character_at_offset;
     iface->get_character_count = eail_popup_get_character_count;
+    iface->get_character_extents = eail_popup_get_character_extents;
 }