Enlightenment CVS committal
Author : moom
Project : e17
Module : libs/etk
Dir : e17/libs/etk/src/lib
Modified Files:
etk_embed.c etk_embed.h
Log Message:
* [Embed] Change API of etk_embed_new()
Add functions: etk_embed_pointer_method_set()
etk_embed_position_method_set()
Fix position of popup-windows in an embed widget
Doc++
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_embed.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- etk_embed.c 6 Oct 2006 17:04:14 -0000 1.5
+++ etk_embed.c 10 Mar 2007 18:19:21 -0000 1.6
@@ -16,6 +16,7 @@
static void _etk_embed_evas_position_get(Etk_Toplevel *toplevel, int *x, int
*y);
static void _etk_embed_screen_position_get(Etk_Toplevel *toplevel, int *x, int
*y);
static void _etk_embed_size_get(Etk_Toplevel *toplevel, int *w, int *h);
+static void _etk_embed_pointer_set(Etk_Toplevel *toplevel, Etk_Pointer_Type
pointer_type);
/**************************
*
@@ -28,7 +29,7 @@
* @brief Gets the type of an Etk_Embed
* @return Returns the type of an Etk_Embed
*/
-Etk_Type *etk_embed_type_get()
+Etk_Type *etk_embed_type_get(void)
{
static Etk_Type *embed_type = NULL;
@@ -43,14 +44,10 @@
/**
* @brief Creates a new embed widget
- * @param evas the evas where the embed object should belong
- * @param window_position_get the function to call to know the top-left corner
of the window containing the evas. @n
- * It's used to place correctly the menus and the combobox windows. If the
embed widget does not contain a menu bar
- * or a combobox, this can be set to NULL.
- * @param window_data the data to pass as the first param when @a
window_position_get is called. It can be set to NULL.
- * @return Returns the new embed widget, or NULL on failure (if the evas is
invalid)
+ * @param evas the Evas where the embed object should belong
+ * @return Returns the new embed widget, or NULL on failure (most probably
because the Evas is invalid)
*/
-Etk_Widget *etk_embed_new(Evas *evas, void (*window_position_get)(void
*window_data, int *x, int *y), void *window_data)
+Etk_Widget *etk_embed_new(Evas *evas)
{
Etk_Widget *embed;
@@ -58,34 +55,31 @@
return NULL;
embed = etk_widget_new(ETK_EMBED_TYPE, NULL);
- ETK_EMBED(embed)->window_position_get = window_position_get;
- ETK_EMBED(embed)->window_data = window_data;
ETK_TOPLEVEL(embed)->evas = evas;
ETK_TOPLEVEL(embed)->evas_position_get = _etk_embed_evas_position_get;
ETK_TOPLEVEL(embed)->screen_position_get = _etk_embed_screen_position_get;
ETK_TOPLEVEL(embed)->size_get = _etk_embed_size_get;
+ ETK_TOPLEVEL(embed)->pointer_set = _etk_embed_pointer_set;
- /* TODO: remove font path */
- evas_font_path_append(evas, PACKAGE_DATA_DIR "/fonts/");
/* TODO: FIXME: We need that to force the widget to realize... */
etk_object_properties_set(ETK_OBJECT(embed), "theme_group", "", NULL);
/* If the widget has failed to realize, we destroy it, and we return NULL */
if (!(ETK_WIDGET(embed)->smart_object))
{
- ETK_WARNING("The embed widget could not be created, the evas seems
invalid");
+ ETK_WARNING("The embed widget could not be created, the Evas seems
invalid");
etk_object_destroy(ETK_OBJECT(embed));
return NULL;
}
- /* TODO: FIXME: This is dirty too... used to first the children of the
embed to be realized */
+ /* Force the children of the embed to be realized */
etk_object_notify(ETK_OBJECT(embed), "evas");
return embed;
}
/**
- * @brief Gets the smart-object of the embed widget. This object can be
manipulated like the other evas objects,
+ * @brief Gets the smart-object of the embed widget. This object can be
manipulated like the other Evas objects,
* with evas_object_move(), evas_object_resize(), evas_object_clip_set(), ...
* @param embed an embed widget
* @return Returns the smart-object of the embed widget
@@ -97,6 +91,42 @@
return ETK_WIDGET(embed)->smart_object;
}
+/**
+ * @brief Sets the function to call to get the position of the Evas where the
embed widget belongs, relative to the
+ * screen. This is used to place correctly the menus and the combobox windows
in the embed widget, so if the embed
+ * widget does not contain a menu bar or a combobox, you don't need to call
this function
+ * @param embed an embed widget
+ * @param position_get the function to call to get the position of top-left
corner of the Evas. The
+ * returned position should be relative to the top-left corner of the screen
+ * @param position_data the data to pass as the first param when @a
position_get is called. It can be set to NULL
+ */
+void etk_embed_position_method_set(Etk_Embed *embed, void (*position_get)(void
*position_data, int *x, int *y), void *position_data)
+{
+ if (!embed)
+ return;
+
+ embed->position_get = position_get;
+ embed->position_data = position_data;
+}
+
+/**
+ * @brief Sets the function to call to set the current mouse pointer used by
the Embed.
+ * This is used to change the pointer when the mouse is over an entry for
example, so if the embed
+ * widget does not contain a widget that makes the pointer change (such as an
entry or a tree), you don't
+ * need to call this function
+ * @param embed an embed widget
+ * @param pointer_set the function to call to set the current mouse pointer
+ * @param pointer_data the data to pass as the first param when @a pointer_set
is called. It can be set to NULL
+ */
+void etk_embed_pointer_method_set(Etk_Embed *embed, void (*pointer_set)(void
*pointer_data, Etk_Pointer_Type pointer_type), void *pointer_data)
+{
+ if (!embed)
+ return;
+
+ embed->pointer_set = pointer_set;
+ embed->pointer_data = pointer_data;
+}
+
/**************************
*
* Etk specific functions
@@ -109,8 +139,10 @@
if (!embed)
return;
- embed->window_position_get = NULL;
- embed->window_data = NULL;
+ embed->position_get = NULL;
+ embed->position_data = NULL;
+ embed->pointer_set = NULL;
+ embed->pointer_data = NULL;
}
/**************************
@@ -119,13 +151,13 @@
*
**************************/
-/* Gets the evas position of the embed widget */
+/* Gets the position of the embed widget, relative to the Evas where it
belongs */
static void _etk_embed_evas_position_get(Etk_Toplevel *toplevel, int *x, int
*y)
{
etk_widget_geometry_get(ETK_WIDGET(toplevel), x, y, NULL, NULL);
}
-/* Gets the screen position of the embed widget */
+/* Gets the position of the embed widget, relative to the screen */
static void _etk_embed_screen_position_get(Etk_Toplevel *toplevel, int *x, int
*y)
{
Etk_Embed *embed;
@@ -135,11 +167,13 @@
return;
etk_widget_geometry_get(ETK_WIDGET(embed), x, y, NULL, NULL);
- if (embed->window_position_get)
+ if (embed->position_get)
{
- embed->window_position_get(embed->window_data, &win_x, &win_y);
- x += win_x;
- y += win_y;
+ embed->position_get(embed->position_data, &win_x, &win_y);
+ if (x)
+ *x += win_x;
+ if (y)
+ *y += win_y;
}
}
@@ -149,6 +183,18 @@
etk_widget_geometry_get(ETK_WIDGET(toplevel), NULL, NULL, w, h);
}
+/* Sets the current mouse-pointer */
+static void _etk_embed_pointer_set(Etk_Toplevel *toplevel, Etk_Pointer_Type
pointer_type)
+{
+ Etk_Embed *embed;
+
+ if (!(embed = ETK_EMBED(toplevel)))
+ return;
+
+ if (embed->pointer_set)
+ embed->pointer_set(embed->pointer_data, pointer_type);
+}
+
/** @} */
/**************************
@@ -163,15 +209,23 @@
* @image html widgets/embed.png
*
* The embed widget allows you to add Etk widgets in your Evas programs,
without having to create an Etk_Window. @n
- * The embed widget is created with etk_embed_new() which requires a valid
Evas and, optionally, a function to call
- * to get the position of the window containing the Evas. This function is
used to know where the popup-windows should
- * be popped up. Thus, this is not required if the embed widget doesn't make
any window pop up (i.e. if it contains no
- * menu-bar, no combobox, ...). @n
+ * The embed widget is created with etk_embed_new() which only requires the
Evas where to create the embed object. You
+ * can then get the corresponding Evas object with etk_embed_object_get().
This object can be manipulated as any other
+ * Evas objects, with evas_object_move(), evas_object_resize(),
evas_object_show(), ... @n
+ *
+ * If the embed widget contains widgets that makes popup-windows pop up (such
as a combobox or a menubar), you should
+ * also call etk_embed_position_method_set() to set the function to call to
get the position of the Evas where the embed
+ * object belongs. Without this function, the menus and the combobox-windows
will pop up at an incorrect position. @n
+ * Also, if the embed widget contains widgets that may change the mouse
pointer (such as an entry or a tree), you have
+ * to call etk_embed_pointer_method_set() to set the function to call to
change the current mouse pointer. Otherwise,
+ * the mouse pointer will not be changed. @n
+ *
* Here is an example that adds a colorpicker in an existing Ecore_Evas:
* @code
* //This function gets the position of the window containing the embed object.
- * //This is needed only if the embed widget uses popup-windows. This is so
unused in this example
- * static void _window_position_get(void *window_data, int *x, int *y)
+ * //This is needed only if the embed widget uses popup-windows so this is
unused in this example since
+ * //the embed widget only contains a colorpicker
+ * static void window_position_get(void *window_data, int *x, int *y)
* {
* ecore_evas_geometry_get(window_data, x, y, NULL, NULL);
* }
@@ -183,23 +237,31 @@
* Etk_Widget *embed, *colorpicker;
* Evas_Object *embed_object;
*
+ * //Create the embed widget
* evas = ecore_evas_get(ee);
- * embed = etk_embed_new(evas, _window_position_get, ee);
+ * embed = etk_embed_new(evas);
+ * etk_embed_position_method_set(ETK_EMBED(embed, window_position_get, ee);
+ *
+ * //Pack a colorpicker into the embed widget
* colorpicker = etk_colorpicker_new();
* etk_container_add(ETK_CONTAINER(embed), colorpicker);
* etk_widget_show_all(embed);
*
+ * //Get the Evas object corresponding to the embed widget.
+ * //Then, we place it at (10,10) and resize it to 250x150
* embed_object = etk_embed_object_get(ETK_EMBED(embed));
* evas_object_move(embed_object, 10, 10);
* evas_object_resize(embed_object, 250, 150);
* //Note: evas_object_show(embed) is not required here since
- * //"etk_widget_show_all(embed);" shows automatically the embed object
+ * //etk_widget_show_all(embed) shows automatically the embed object
* }
* @endcode @n
*
* \par Object Hierarchy:
* - Etk_Object
* - Etk_Widget
- * - Etk_Toplevel
- * - Etk_Embed
+ * - Etk_Container
+ * - Etk_Bin
+ * - Etk_Toplevel
+ * - Etk_Embed
*/
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_embed.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_embed.h 6 Oct 2006 17:04:14 -0000 1.3
+++ etk_embed.h 10 Mar 2007 18:19:21 -0000 1.4
@@ -7,20 +7,22 @@
/**
* @defgroup Etk_Embed Etk_Embed
- * @brief The Etk_Embed widget is a toplevel widget that can be embed in an
existing Evas and can be
- * manipulated as a normal evas object.
+ * @brief The Etk_Embed widget is a toplevel widget that can be embedded in an
existing Evas and can be
+ * manipulated as a normal Evas object.
* @{
*/
-/** @brief Gets the type of an embed widget */
+/** Gets the type of an embed widget */
#define ETK_EMBED_TYPE (etk_embed_type_get())
-/** @brief Casts the object to an Etk_Embed */
+/** Casts the object to an Etk_Embed */
#define ETK_EMBED(obj) (ETK_OBJECT_CAST((obj), ETK_EMBED_TYPE,
Etk_Embed))
-/** @brief Check if the object is an Etk_Embed */
+/** Check if the object is an Etk_Embed */
#define ETK_IS_EMBED(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_EMBED_TYPE))
+
/**
- * @brief @widget A toplevel widget that can be manipulated as a normal evas
object.
+ * @brief @widget A toplevel widget that can be embedded in an existing Evas
and
+ * be manipulated as a normal Evas object.
* @structinfo
*/
struct Etk_Embed
@@ -29,15 +31,22 @@
/* Inherit from Etk_Toplevel */
Etk_Toplevel toplevel;
- void (*window_position_get)(void *window_data, int *x, int *y);
- void *window_data;
+ void (*position_get)(void *window_data, int *x, int *y);
+ void *position_data;
+
+ void (*pointer_set)(void *window_data, Etk_Pointer_Type pointer_type);
+ void *pointer_data;
};
-Etk_Type *etk_embed_type_get();
-Etk_Widget *etk_embed_new(Evas *evas, void (*window_position_get)(void
*window_data, int *x, int *y), void *window_data);
+
+Etk_Type *etk_embed_type_get(void);
+Etk_Widget *etk_embed_new(Evas *evas);
Evas_Object *etk_embed_object_get(Etk_Embed *embed_widget);
-
+
+void etk_embed_position_method_set(Etk_Embed *embed, void (*position_get)(void
*position_data, int *x, int *y), void *position_data);
+void etk_embed_pointer_method_set(Etk_Embed *embed, void (*pointer_set)(void
*pointer_data, Etk_Pointer_Type pointer_type), void *pointer_data);
+
/** @} */
#endif
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs