Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
Ewl.h.in Makefile.am ewl_menu_base.c ewl_menu_base.h
Added Files:
ewl_menu_item.c ewl_menu_item.h ewl_menu_separator.c
ewl_menu_separator.h
Log Message:
- move the menu_item and menu_separator to their own files
- format/type check the menu_base code
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Ewl.h.in,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- Ewl.h.in 10 Oct 2005 15:27:10 -0000 1.21
+++ Ewl.h.in 24 Oct 2005 03:35:29 -0000 1.22
@@ -307,6 +307,8 @@
#include <ewl_spinner.h>
#include <ewl_image.h>
#include <ewl_spectrum.h>
+#include <ewl_menu_item.h>
+#include <ewl_menu_separator.h>
#include <ewl_menu_base.h>
#include <ewl_imenu.h>
#include <ewl_menu.h>
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- Makefile.am 10 Oct 2005 15:27:10 -0000 1.12
+++ Makefile.am 24 Oct 2005 03:35:29 -0000 1.13
@@ -44,6 +44,8 @@
ewl_menu.h \
ewl_menubar.h \
ewl_menu_base.h \
+ ewl_menu_item.h \
+ ewl_menu_separator.h \
ewl_misc.h \
ewl_notebook.h \
ewl_object.h \
@@ -106,6 +108,8 @@
ewl_menu.c \
ewl_menubar.c \
ewl_menu_base.c \
+ ewl_menu_item.c \
+ ewl_menu_separator.c \
ewl_misc.c \
ewl_notebook.c \
ewl_object.c \
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menu_base.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ewl_menu_base.c 23 Oct 2005 17:20:18 -0000 1.11
+++ ewl_menu_base.c 24 Oct 2005 03:35:29 -0000 1.12
@@ -11,30 +11,29 @@
* Sets up the internal variables for the menu item and places the icon from
* @a image and label from @a title in the menu item.
*/
-int ewl_menu_base_init(Ewl_Menu_Base * menu)
+int
+ewl_menu_base_init(Ewl_Menu_Base *menu)
{
DENTER_FUNCTION(DLEVEL_STABLE);
-
DCHECK_PARAM_PTR_RET("menu", menu, FALSE);
/*
* Initialize the defaults of the inherited fields.
*/
- ewl_menu_item_init(EWL_MENU_ITEM(menu));
+ if (!ewl_menu_item_init(EWL_MENU_ITEM(menu)))
+ DRETURN_INT(FALSE, DLEVEL_STABLE);
+
ewl_widget_appearance_set(EWL_WIDGET(menu), "menu_base");
ewl_widget_inherit(EWL_WIDGET(menu), "menu_base");
ewl_callback_del(EWL_WIDGET(menu), EWL_CALLBACK_CLICKED,
- ewl_menu_item_clicked_cb);
-
+ ewl_menu_item_clicked_cb);
ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_SELECT,
- ewl_menu_base_expand_cb, NULL);
-
+ ewl_menu_base_expand_cb, NULL);
ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_DESELECT,
- ewl_menu_base_collapse_cb, NULL);
-
- ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
- ewl_menu_base_destroy_cb, NULL);
+ ewl_menu_base_collapse_cb, NULL);
+ ewl_callback_prepend(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
+ ewl_menu_base_destroy_cb, NULL);
/*
* The popbox actually holds the children, and is simply added to the
@@ -58,294 +57,6 @@
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
-/**
- * @return Returns a pointer to a new menu item on success, NULL on failure.
- * @brief Create a new menu item to place in a menu
- */
-Ewl_Widget *ewl_menu_item_new(void)
-{
- Ewl_Menu_Item *item;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- item = NEW(Ewl_Menu_Item, 1);
- if (!item)
- DRETURN_PTR(NULL, DLEVEL_STABLE);
-
- ewl_menu_item_init(item);
-
- DRETURN_PTR(EWL_WIDGET(item), DLEVEL_STABLE);
-}
-
-/**
- * @param item: the item to be initialized
- * @return Returns no value.
- * @brief Initialize the fields of a menu item to their defaults
- */
-int ewl_menu_item_init(Ewl_Menu_Item * item)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- DCHECK_PARAM_PTR_RET("item", item, FALSE);
-
- /*
- * Initialize the inherited container fields.
- */
- if (!ewl_box_init(EWL_BOX(item)))
- DRETURN_INT(FALSE, DLEVEL_STABLE);
-
- ewl_box_orientation_set(EWL_BOX(item), EWL_ORIENTATION_HORIZONTAL);
- ewl_widget_appearance_set(EWL_WIDGET(item), "menuitem");
- ewl_widget_inherit(EWL_WIDGET(item), "menuitem");
-
- ewl_object_fill_policy_set(EWL_OBJECT(item), EWL_FLAG_FILL_HFILL);
-
- ewl_callback_append(EWL_WIDGET(item), EWL_CALLBACK_CONFIGURE,
- ewl_menu_item_configure_cb, NULL);
- ewl_callback_append(EWL_WIDGET(item), EWL_CALLBACK_CLICKED,
- ewl_menu_item_clicked_cb, NULL);
-
- /*
- * Intercept mouse events this will cause callbacks to children of
- * this widget.
- */
- ewl_container_callback_intercept(EWL_CONTAINER(item),
- EWL_CALLBACK_SELECT);
- ewl_container_callback_intercept(EWL_CONTAINER(item),
- EWL_CALLBACK_DESELECT);
-
- DRETURN_INT(TRUE, DLEVEL_STABLE);
-}
-
-/**
- * @return Returns the text currently used by a menu item
- * @param item: the menu item
- * @brief Get the text of a menu item
- */
-char *
-ewl_menu_item_text_get( Ewl_Menu_Item *item )
-{
- if (item->text)
- DRETURN_PTR(ewl_text_text_get(EWL_TEXT(item->text)),
DLEVEL_STABLE);
- DRETURN_PTR(NULL, DLEVEL_STABLE);
-}
-
-/**
- * @param item: the menu item of which to set the text
- * @param text: the text in string form
- * @brief Sets the text of a menu item
- */
-void
-ewl_menu_item_text_set( Ewl_Menu_Item *item, char *text )
-{
- Ewl_Container *redirect;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("item", item);
-
- /*
- * Save and restore after we've made our changes.
- */
- redirect = ewl_container_redirect_get(EWL_CONTAINER(item));
- ewl_container_redirect_set(EWL_CONTAINER(item), NULL);
-
- if (text) {
-
- /*
- * Setup the text object and add it to the menu.
- */
- if (!item->text) {
- item->text = ewl_text_new();
- ewl_container_child_append(EWL_CONTAINER(item),
- item->text);
- ewl_widget_show(item->text);
- }
-
- /*
- * Set the request text.
- */
- if (item->text) {
- ewl_text_text_set(EWL_TEXT(item->text), text);
- if (!item->icon)
- ewl_menu_item_image_set(item, NULL);
- }
- }
- else if (item->text) {
- ewl_widget_destroy(item->text);
- item->text = NULL;
- }
-
- ewl_container_redirect_set(EWL_CONTAINER(item), redirect);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @return Returns the image currently used by a menu item
- * @param item: the menu item
- * @brief Get the image of a menu item
- */
-char *
-ewl_menu_item_image_get(Ewl_Menu_Item *item)
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR_RET("item", item, NULL);
-
- if (item->icon && ewl_widget_type_is(item->icon, "image"))
- DRETURN_PTR(ewl_image_file_get(EWL_IMAGE(item->icon)),
DLEVEL_STABLE);
- DRETURN_PTR(NULL, DLEVEL_STABLE);
-}
-
-/**
- * @param item: the menu item
- * @param image: the image filename
- * @brief Set the image of a menu item
- */
-void
-ewl_menu_item_image_set( Ewl_Menu_Item *item, char *image )
-{
- DENTER_FUNCTION(DLEVEL_STABLE);
- DCHECK_PARAM_PTR("item", item);
-
- /*
- * Destroy the icon if it's the wrong type.
- */
- if (item->icon && (
- (image && !ewl_widget_type_is(item->icon, "image")) ||
- (!image && !ewl_widget_type_is(item->icon, "spacer")))) {
- ewl_widget_destroy(item->icon);
- item->icon = NULL;
- }
-
- /*
- * Create the appropriate widget if necessary.
- */
- if (!item->icon) {
- Ewl_Container *redirect;
-
- /*
- * Save the current redirect and override to avoid issues with
- * submenus
- */
- redirect = ewl_container_redirect_get(EWL_CONTAINER(item));
- ewl_container_redirect_set(EWL_CONTAINER(item), NULL);
-
- /*
- * Create the icon if one is requested, or a spacer if not, but
- * there is text to be displayed.
- */
- if (image)
- item->icon = ewl_image_new();
- else if (item->text)
- item->icon = ewl_spacer_new();
-
- /*
- * Setup display prperties on icon if created.
- */
- if (item->icon) {
- ewl_object_alignment_set(EWL_OBJECT(item->icon),
- EWL_FLAG_ALIGN_CENTER);
- ewl_object_maximum_size_set(EWL_OBJECT(item->icon),
- 20, 20);
- ewl_container_child_prepend(EWL_CONTAINER(item),
- item->icon);
- ewl_widget_show(item->icon);
- }
-
- ewl_container_redirect_set(EWL_CONTAINER(item), redirect);
- }
-
- if (image && item->icon)
- ewl_image_file_set(EWL_IMAGE(item->icon), image, NULL);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @return Returns a new menu item separator on success, NULL on failure.
- * @brief Create a separator menu item
- */
-Ewl_Widget *ewl_menu_separator_new()
-{
- Ewl_Menu_Separator *sep;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- sep = NEW(Ewl_Menu_Separator, 1);
- if (!sep)
- DRETURN_PTR(NULL, DLEVEL_STABLE);
-
- ewl_menu_separator_init(sep);
-
- DRETURN_PTR(EWL_WIDGET(sep), DLEVEL_STABLE);
-}
-
-/**
- * @param sep: the menu separator item to initialize
- * @return Returns no value.
- * @brief Initialize a menu separator item
- *
- * Sets up the internal fields of the menu separator item to
- * some sane defaults.
- */
-void ewl_menu_separator_init(Ewl_Menu_Separator *sep)
-{
- Ewl_Widget *separator;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- DCHECK_PARAM_PTR("sep", sep);
-
- ewl_menu_item_init(EWL_MENU_ITEM(sep));
-
- separator = ewl_separator_new(EWL_ORIENTATION_HORIZONTAL);
- if (!separator)
- DRETURN(DLEVEL_STABLE);
-
- ewl_container_child_append(EWL_CONTAINER(sep), separator);
- ewl_widget_show(separator);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-ewl_menu_item_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__)
-{
- int x;
- Ewl_Container *c;
- Ewl_Widget *child;
-
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- c = EWL_CONTAINER(w);
- x = CURRENT_X(w);
- ecore_list_goto_first(c->children);
- while ((child = ecore_list_next(c->children))) {
- int width;
-
- width = ewl_object_preferred_w_get(EWL_OBJECT(child));
- ewl_object_place(EWL_OBJECT(child), x, CURRENT_Y(w), width,
- CURRENT_H(w));
- x += width;
- }
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-ewl_menu_item_clicked_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__)
-{
- Ewl_Menu_Item *item = EWL_MENU_ITEM(w);
- DENTER_FUNCTION(DLEVEL_STABLE);
-
- if (item->inmenu)
- ewl_widget_hide(item->inmenu);
-
- DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
void
ewl_menu_base_expand_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
@@ -356,6 +67,8 @@
Ewl_Menu_Item *item = EWL_MENU_ITEM(w);
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
if (!menu->popup)
DRETURN(DLEVEL_STABLE);
@@ -379,11 +92,10 @@
pb = EWL_CONTAINER(menu->popbox);
- ecore_list_goto_first(pb->children);
-
/*
* Give all the items in the submenu a reference to this popup.
*/
+ ecore_list_goto_first(pb->children);
while ((child = ecore_list_next(pb->children))) {
if (ewl_widget_type_is(child, "menuitem")) {
item = EWL_MENU_ITEM(child);
@@ -398,13 +110,15 @@
}
void
-ewl_menu_base_collapse_cb(Ewl_Widget * w, void *ev_data __UNUSED__,
+ewl_menu_base_collapse_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
{
Ewl_Menu_Base *menu;
Ewl_Widget *focused;
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
menu = EWL_MENU_BASE(w);
@@ -416,24 +130,30 @@
}
void
-ewl_menu_base_popup_hide_cb(Ewl_Widget * w __UNUSED__,
+ewl_menu_base_popup_hide_cb(Ewl_Widget *w __UNUSED__,
void *ev_data __UNUSED__, void *user_data)
{
- Ewl_Widget *ppop = user_data;
+ Ewl_Widget *ppop;
+
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("user_data", user_data);
+ ppop = user_data;
ewl_widget_hide(ppop);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
void
-ewl_menu_base_popup_show_cb(Ewl_Widget * w __UNUSED__,
+ewl_menu_base_popup_show_cb(Ewl_Widget *w __UNUSED__,
void *ev_data __UNUSED__, void *user_data)
{
- Ewl_Widget *ppop = user_data;
+ Ewl_Widget *ppop;
+
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("user_data", user_data);
+ ppop = user_data;
ewl_widget_show(ppop);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -443,9 +163,11 @@
ewl_menu_base_popbox_key_down_cb(Ewl_Widget *w __UNUSED__, void *ev_data,
void *user_data __UNUSED__)
{
- Ewl_Event_Key_Down *ev = ev_data;
- DENTER_FUNCTION(DLEVEL_STABLE);
+ Ewl_Event_Key_Down *ev;
+ DENTER_FUNCTION(DLEVEL_STABLE);
+
+ ev = ev_data;
printf("Menu item: %s\n", ev->keyname);
if (!strcmp(ev->keyname, "Down")) {
printf("Menu item down\n");
@@ -464,17 +186,19 @@
}
void
-ewl_menu_base_destroy_cb(Ewl_Widget * w, void *ev_data __UNUSED__,
+ewl_menu_base_destroy_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
{
- Ewl_Menu_Base *menu;
+ Ewl_Menu_Base *menu;
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
menu = EWL_MENU_BASE(w);
-
if (menu->popup)
ewl_widget_destroy(menu->popup);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menu_base.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_menu_base.h 23 Oct 2005 17:20:18 -0000 1.6
+++ ewl_menu_base.h 24 Oct 2005 03:35:29 -0000 1.7
@@ -5,68 +5,17 @@
* @file ewl_menu_base.h
* @defgroup Ewl_Menu_Base Menu_Base: The Basic Menu Functionality
* @brief Defines the basic menu classes that are extended to an actual menu
- * implementation by inheriting classes such as Ewl_Menu and Ewl_IMenu.
+ * implementation by inheriting classes such as Ewl_Menu and Ewl_Imenu.
*
* @{
*/
/**
- * @themekey /menuitem/file
- * @themekey /menuitem/group
- *
* @themekey /menu_base/file
* @themekey /menu_base/group
*/
/**
- * This serves as a basis for all menu related entries. It provides the most
- * basic layout facilities for items in a menu.
- */
-typedef struct Ewl_Menu_Item Ewl_Menu_Item;
-
-/**
- * @def EWL_MENU_ITEM(mi)
- * Typecasts a pointer to an Ewl_Menu_Item pointer.
- */
-#define EWL_MENU_ITEM(mi) ((Ewl_Menu_Item *)mi)
-
-/**
- * @struct Ewl_Menu_Item
- * Inherits from Ewl_Box to gain it's layout abilities, places policy on top
- * of the box framework to provide a simple menu layout of icon and label.
- */
-struct Ewl_Menu_Item
-{
- Ewl_Box box; /**< Inherit from Ewl_Box */
- Ewl_Widget *icon; /**< The image in this menu item */
- Ewl_Widget *text; /**< The text label for this menu item */
- Ewl_Widget *inmenu; /**< Set if inside a menu */
-};
-
-/**
- * A simple separator widget for putting lines between items in the menu.
- * Special widget so enclosing menus can assume it can be treated as an
- * Ewl_Menu_Item.
- */
-typedef struct Ewl_Menu_Separator Ewl_Menu_Separator;
-
-/**
- * @def EWL_MENU_SEPARATOR(s)
- * Typecasts a pointer to an Ewl_Menu_Separator pointer.
- */
-#define EWL_MENU_SEPARATOR(s) ((Ewl_Menu_Separator *)s)
-
-/**
- * @struct Ewl_Menu_Separator
- * Inherits from Ewl_Menu_Item and limits it's functionality to simply provide
- * a separator between items in a menu.
- */
-struct Ewl_Menu_Separator
-{
- Ewl_Menu_Item item; /**< Inherit from Ewl_Menu_Item */
-};
-
-/**
* Provides the basic functionality common to the various menu classes.
*/
typedef struct Ewl_Menu_Base Ewl_Menu_Base;
@@ -85,38 +34,21 @@
int hold; /**< Indicates not to hide this on a deselect */
};
-Ewl_Widget *ewl_menu_item_new(void);
-int ewl_menu_item_init(Ewl_Menu_Item * menu);
-char *ewl_menu_item_text_get(Ewl_Menu_Item * item);
-void ewl_menu_item_text_set(Ewl_Menu_Item * item, char *text);
-char *ewl_menu_item_image_get(Ewl_Menu_Item * item);
-void ewl_menu_item_image_set(Ewl_Menu_Item * item, char *image);
-
-
-Ewl_Widget *ewl_menu_separator_new(void);
-void ewl_menu_separator_init(Ewl_Menu_Separator *sep);
-
-int ewl_menu_base_init(Ewl_Menu_Base *menu);
+int ewl_menu_base_init(Ewl_Menu_Base *menu);
/*
* Internally used callbacks, override at your own risk.
*/
void ewl_menu_base_expand_cb(Ewl_Widget *w, void *ev_data, void *user_data);
-void ewl_menu_base_collapse_cb(Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_menu_base_destroy_cb(Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_menu_base_collapse_cb(Ewl_Widget *w, void *ev_data, void *user_data);
+void ewl_menu_base_destroy_cb(Ewl_Widget *w, void *ev_data, void *user_data);
-void ewl_menu_item_configure_cb(Ewl_Widget *w, void *ev_data, void *user_data);
-void ewl_menu_item_clicked_cb(Ewl_Widget *w, void *ev_data, void *user_data);
-void ewl_menu_item_child_show_cb(Ewl_Container *parent, Ewl_Widget *child);
-void ewl_menu_item_child_resize_cb(Ewl_Container *parent, Ewl_Widget *child,
- int size, Ewl_Orientation o);
-
-void ewl_menu_base_popup_show_cb(Ewl_Widget * w, void *ev_data,
- void *user_data);
-void ewl_menu_base_popup_hide_cb(Ewl_Widget * w, void *ev_data,
- void *user_data);
-void ewl_menu_base_popbox_key_down_cb(Ewl_Widget * w, void *ev_data,
- void *user_data);
+void ewl_menu_base_popup_show_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_menu_base_popup_hide_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_menu_base_popbox_key_down_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
/**
* @}
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs