Enlightenment CVS committal
Author : codewarrior
Project : e17
Module : libs/etk
Dir : e17/libs/etk/src/lib
Modified Files:
etk_canvas.c etk_canvas.h etk_evas_object.c
Log Message:
[Etk_Canvas] Add convenience methods for adding Evas objects directly into
the canvas (wrappers around Etk_Evas_Object)
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_canvas.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- etk_canvas.c 19 Apr 2008 18:23:34 -0000 1.26
+++ etk_canvas.c 19 Apr 2008 21:24:26 -0000 1.27
@@ -7,6 +7,7 @@
#include <stdlib.h>
+#include "etk_evas_object.h"
#include "etk_signal.h"
#include "etk_signal_callback.h"
#include "etk_utils.h"
@@ -150,6 +151,65 @@
if (x) *x = c->pos.x;
if (y) *y = c->pos.y;
}
+}
+
+/**
+ * @brief Adds an Evas_Object to the canvas. This is a convenience function
+ * that uses Etk_Evas_Object.
+ * @param canvas the canvas container
+ * @parem evas_object the evas object to add
+ * @return returns the Etk_Evas_Object holding the @a evas_object
+ * @note You will need to show the widget after it has been added.
+ */
+Etk_Widget *etk_canvas_object_add(Etk_Canvas *canvas, Evas_Object *evas_object)
+{
+ Etk_Widget *etk_evas_object;
+
+ if (!canvas || !evas_object)
+ return NULL;
+
+ etk_evas_object = etk_evas_object_new_from_object(evas_object);
+ etk_canvas_put(canvas, etk_evas_object, 0, 0);
+ return etk_evas_object;
+}
+
+/**
+ * @brief Removed an Evas_Object from the canvas.
+ * @param canvas the canvas container
+ * @param evas_object the Evas_Object to remove
+ */
+void etk_canvas_object_remove(Etk_Canvas *canvas, Evas_Object *evas_object)
+{
+ Etk_Widget *etk_evas_object = NULL;
+
+ if (!canvas || !evas_object)
+ return;
+
+ if ((etk_evas_object = evas_object_data_get(evas_object,
"_Etk_Evas_Object::Widget")) == NULL)
+ return;
+
+ evas_object_data_set(evas_object, "_Etk_Evas_Object::Widget", NULL);
+ _etk_canvas_child_remove(ETK_CONTAINER(canvas), etk_evas_object);
+}
+
+/**
+ * @brief Moves an Evas_Object around in the canvas
+ * @param canvas the canvas container
+ * @param evas_object the Evas_Object to move
+ * @param x the x coordinate to move to inside the canvas
+ * @param y the y coordinate to move to inside the canvas
+ */
+void etk_canvas_object_move(Etk_Canvas *canvas, Evas_Object *evas_object, int
x, int y)
+{
+ Etk_Widget *etk_evas_object = NULL;
+
+ if (!canvas || !evas_object)
+ return;
+
+ if ((etk_evas_object = evas_object_data_get(evas_object,
"_Etk_Evas_Object::Widget")) == NULL)
+ return;
+
+ etk_canvas_move(canvas, etk_evas_object, x, y);
}
/**************************
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_canvas.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- etk_canvas.h 19 Apr 2008 18:23:34 -0000 1.12
+++ etk_canvas.h 19 Apr 2008 21:24:26 -0000 1.13
@@ -45,6 +45,8 @@
void etk_canvas_move(Etk_Canvas *canvas, Etk_Widget *widget, int x, int
y);
void etk_canvas_child_position_get(Etk_Canvas *canvas, Etk_Widget
*widget, int *x, int *y);
+Etk_Widget *etk_canvas_object_add(Etk_Canvas *canvas, Evas_Object
*evas_object);
+
/** @} */
#ifdef __cplusplus
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_evas_object.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_evas_object.c 17 Apr 2008 03:27:34 -0000 1.1
+++ etk_evas_object.c 19 Apr 2008 21:24:26 -0000 1.2
@@ -104,6 +104,7 @@
{
etk_evas_object->object = evas_object;
etk_object_notify(ETK_OBJECT(etk_evas_object), "evas-object");
+ evas_object_data_set(evas_object, "_Etk_Evas_Object::Widget",
etk_evas_object);
}
_etk_evas_object_load(etk_evas_object);
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs