Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        Ewl.h ewl_menu_item.c ewl_menu_item.h ewl_menu.c ewl_menu.h 
        Makefile.am 
Added Files:
        ewl_context_menu.c ewl_context_menu.h 


Log Message:
these are the first steps to fix the menu, but there are still bugs in. Besides 
it introduce a context menu

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- Ewl.h       6 Feb 2007 13:42:16 -0000       1.25
+++ Ewl.h       6 Mar 2007 21:25:08 -0000       1.26
@@ -297,9 +297,9 @@
 #include <ewl_histogram.h>
 #include <ewl_spectrum.h>
 #include <ewl_menu_item.h>
-#include <ewl_menu_base.h>
 #include <ewl_menu.h>
 #include <ewl_menubar.h>
+#include <ewl_context_menu.h>
 #include <ewl_toolbar.h>
 #include <ewl_check.h>
 #include <ewl_checkbutton.h>
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu_item.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_menu_item.c     6 Feb 2007 13:42:17 -0000       1.16
+++ ewl_menu_item.c     6 Mar 2007 21:25:08 -0000       1.17
@@ -55,43 +55,15 @@
        ewl_object_fill_policy_set(EWL_OBJECT(item), EWL_FLAG_FILL_HFILL);
        ewl_object_fill_policy_set(EWL_OBJECT(EWL_BUTTON(item)->label_object),
                        EWL_FLAG_FILL_HFILL);
-
-       ewl_callback_append(EWL_WIDGET(item), EWL_CALLBACK_CLICKED,
-                       ewl_menu_item_cb_clicked, NULL);
-
        /*
         * Intercept mouse events this will cause callbacks to children of
         * this widget.
         */
-       ewl_container_callback_intercept(EWL_CONTAINER(item),
-                       EWL_CALLBACK_FOCUS_IN);
-       ewl_container_callback_intercept(EWL_CONTAINER(item),
-                       EWL_CALLBACK_FOCUS_OUT);
+       //ewl_container_callback_intercept(EWL_CONTAINER(item),
+       //              EWL_CALLBACK_FOCUS_IN);
+       //ewl_container_callback_intercept(EWL_CONTAINER(item),
+       //              EWL_CALLBACK_FOCUS_OUT);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
-/**
- * @internal
- * @param w: The widget to work with
- * @param ev_data: UNUSED
- * @param user_data: UNUSED
- * @return Returns no value
- * @brief The clicked callback
- */
-void
-ewl_menu_item_cb_clicked(Ewl_Widget *w, void *ev_data __UNUSED__,
-               void *user_data __UNUSED__)
-{       
-       Ewl_Menu_Item *item;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
-
-       item = EWL_MENU_ITEM(w); 
-       if (item->inmenu)
-               ewl_widget_hide(item->inmenu);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu_item.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_menu_item.h     4 Mar 2007 00:52:01 -0000       1.18
+++ ewl_menu_item.h     6 Mar 2007 21:25:08 -0000       1.19
@@ -58,7 +58,6 @@
 /*
  * internally used callbacks, override at your risk
  */
-void ewl_menu_item_cb_clicked(Ewl_Widget *w, void *ev_data, void *user_data);
 
 /**
  * @}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- ewl_menu.c  3 Mar 2007 01:58:19 -0000       1.42
+++ ewl_menu.c  6 Mar 2007 21:25:08 -0000       1.43
@@ -1,7 +1,7 @@
 /* vim: set sw=8 ts=8 sts=8 noexpandtab: */
 #include "ewl_base.h"
 #include "ewl_menu.h"
-#include "ewl_popup.h"
+#include "ewl_context_menu.h"
 #include "ewl_private.h"
 #include "ewl_debug.h"
 #include "ewl_macros.h"
@@ -43,44 +43,38 @@
        /*
         * Initialize the defaults of the inherited fields.
         */
-       if (!ewl_menu_base_init(EWL_MENU_BASE(menu)))
+       if (!ewl_menu_item_init(EWL_MENU_ITEM(menu)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);
 
        ewl_widget_appearance_set(EWL_WIDGET(menu), "menu_container");
        ewl_widget_inherit(EWL_WIDGET(menu), EWL_MENU_TYPE);
 
+       /*
+        * add the callbacks
+        */
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_MOUSE_MOVE,
                            ewl_menu_cb_expand_mouse_move, NULL);
-
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_FOCUS_IN,
                            ewl_menu_cb_expand, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CONFIGURE,
                            ewl_menu_cb_configure, NULL);
-
-       menu->menubar_parent = NULL;
+       ewl_callback_prepend(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
+                               ewl_menu_cb_destroy, NULL);
 
        /*
         * Create the popup menu portion of the widget.
         */
-       menu->base.popup = ewl_popup_new();
-       ewl_window_keyboard_grab_set(EWL_WINDOW(menu->base.popup), TRUE);
-       ewl_window_pointer_grab_set(EWL_WINDOW(menu->base.popup), TRUE);
-       ewl_popup_follow_set(EWL_POPUP(menu->base.popup), EWL_WIDGET(menu));
-       
-       ewl_widget_internal_set(menu->base.popup, TRUE);
-       ewl_widget_appearance_set(EWL_WIDGET(menu->base.popup), EWL_MENU_TYPE);
-       ewl_object_alignment_set(EWL_OBJECT(menu->base.popup),
-                                EWL_FLAG_ALIGN_LEFT | EWL_FLAG_ALIGN_TOP);
-       
-       ewl_callback_append(menu->base.popup, EWL_CALLBACK_MOUSE_DOWN,
-                           ewl_menu_cb_hide, menu);
-
-       ewl_callback_append(menu->base.popup, EWL_CALLBACK_MOUSE_MOVE,
-                               ewl_menu_cb_mouse_move, menu);
-                          
-       ewl_callback_prepend(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
-                               ewl_menu_cb_destroy, NULL);
-       ewl_callback_prepend(menu->base.popup, EWL_CALLBACK_DESTROY,
+       menu->popup = ewl_context_menu_new();
+       ewl_popup_follow_set(EWL_POPUP(menu->popup), EWL_WIDGET(menu));
+       ewl_popup_type_set(EWL_POPUP(menu->popup), 
+                                       EWL_POPUP_TYPE_MENU_VERTICAL);  
+       ewl_widget_internal_set(menu->popup, TRUE);
+       ewl_widget_appearance_set(EWL_WIDGET(menu->popup), EWL_MENU_TYPE);
+
+       /* redirect the menu container to the popup menu */
+       ewl_container_redirect_set(EWL_CONTAINER(menu), 
+                                       EWL_CONTAINER(menu->popup));
+       ewl_callback_prepend(menu->popup, EWL_CALLBACK_DESTROY,
                                ewl_menu_cb_popup_destroy, menu);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
@@ -145,10 +139,10 @@
        if ((parent && (ewl_box_orientation_get(parent) 
                                == EWL_ORIENTATION_VERTICAL))
                || EWL_MENU_ITEM(menu)->inmenu)
-               ewl_popup_type_set(EWL_POPUP(menu->base.popup), 
+               ewl_popup_type_set(EWL_POPUP(menu->popup), 
                                        EWL_POPUP_TYPE_MENU_HORIZONTAL);
        else 
-               ewl_popup_type_set(EWL_POPUP(menu->base.popup), 
+               ewl_popup_type_set(EWL_POPUP(menu->popup), 
                                        EWL_POPUP_TYPE_MENU_VERTICAL);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -176,23 +170,21 @@
        if (menu->menubar_parent) {
                Ewl_Menu *sub, *hide_menu = NULL;
                Ewl_Container *bar;
-               int vis = 0;
 
                bar = EWL_CONTAINER(menu->menubar_parent);
                ewl_container_child_iterate_begin(bar);
                while ((sub = EWL_MENU(ewl_container_child_next(bar)))) {
                        if ((sub != EWL_MENU(w)) 
                                        && EWL_MENU_IS(sub)
-                                       && (sub->base.popup) 
-                                       && VISIBLE(sub->base.popup)) {
+                                       && (sub->popup) 
+                                       && VISIBLE(sub->popup)) {
                                hide_menu = sub;
-                               vis++;
                                break;
                        }
                }
 
-               if (vis && hide_menu) {
-                       ewl_widget_hide(hide_menu->base.popup);
+               if (hide_menu) {
+                       ewl_widget_hide(hide_menu->popup);
                        ewl_callback_call(w, EWL_CALLBACK_FOCUS_IN);
                }
        }
@@ -213,82 +205,22 @@
                                        void *user_data __UNUSED__)
 {
        Ewl_Menu *menu;
+       Ewl_Menu_Item *item;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
        DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
 
        menu = EWL_MENU(w);
+       item = EWL_MENU_ITEM(w);
        
-       ewl_widget_show(menu->base.popup);
-       ewl_window_raise(EWL_WINDOW(menu->base.popup));
-       ewl_widget_focus_send(menu->base.popbox);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @internal
- * @param w: The widget to work with
- * @param ev_data: UNUSED
- * @param user_data: UNUSED
- * @return Returns no value
- * @brief The mouse move callback
- */
-void
-ewl_menu_cb_mouse_move(Ewl_Widget *w, void *ev_data, void *user_data) 
-{
-       Ewl_Event_Mouse *ev;
-       Ewl_Menu *menu;
-       Ewl_Embed *embed, *menu_embed;
-       int x, y, wx, wy;
-       int width, height;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
-       DCHECK_TYPE("user_data", user_data, EWL_MENU_TYPE);
-
-       ev = ev_data;
-       menu = user_data;
-       
-       embed = ewl_embed_widget_find(EWL_WIDGET(menu)->parent);
-       menu_embed = ewl_embed_widget_find(EWL_WIDGET(menu->base.popup));
-       ewl_embed_window_position_get(EWL_EMBED(embed), &wx, &wy);
-       ewl_embed_window_position_get(EWL_EMBED(menu->base.popup), &x, &y);
-       ewl_object_current_size_get(EWL_OBJECT(menu->base.popup), &width, 
&height);
-
-       if (((ev->x + x) > x) && ((ev->y + y) > y) 
-                       && ((ev->x + x) < (x + width)) 
-                       && ((ev->y + y) < (y + height))) {
-               if (ewl_embed_active_embed_get() != menu_embed)
-                       ewl_embed_active_set(menu_embed, 1);
-       } 
-       else {
-               if (menu->menubar_parent) 
-                       ewl_embed_mouse_move_feed(embed, (ev->x + x) - wx, 
-                                                       (ev->y + y) - wy, 0);
+       ewl_widget_show(menu->popup);
+       ewl_window_raise(EWL_WINDOW(menu->popup));
+       if (item->inmenu) {
+               Ewl_Context_Menu *cm;
+               cm = EWL_CONTEXT_MENU(item->inmenu);
+               cm->open_menu = menu->popup;
        }
-}
-
-/**
- * @internal
- * @param w: The widget to work with
- * @param ev_data: UNUSED
- * @param user_data: UNUSED
- * @return Returns no value
- * @brief The hide callback
- */
-void
-ewl_menu_cb_hide(Ewl_Widget *w, void *ev_data __UNUSED__,
-                                       void *user_data __UNUSED__)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
-       
-       if (w == ewl_embed_focused_widget_get(EWL_EMBED(w)))
-               ewl_widget_hide(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -310,8 +242,9 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("data", data);
 
+       /* XXX do we still need to this */
        m = data;
-       if (m->base.popup) m->base.popup = NULL;
+       if (m->popup) m->popup = NULL;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -334,8 +267,8 @@
        DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
 
        menu = EWL_MENU(w);
-       if (menu->base.popup)
-               ewl_callback_del(menu->base.popup, EWL_CALLBACK_DESTROY, 
+       if (menu->popup)
+               ewl_callback_del(menu->popup, EWL_CALLBACK_DESTROY, 
                                                ewl_menu_cb_popup_destroy);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- ewl_menu.h  4 Mar 2007 00:52:01 -0000       1.26
+++ ewl_menu.h  6 Mar 2007 21:25:08 -0000       1.27
@@ -2,8 +2,7 @@
 #ifndef EWL_MENU_H
 #define EWL_MENU_H
 
-#include "ewl_menu_base.h"
-
+#include "ewl_menu_item.h"
 /**
  * @addtogroup Ewl_Menu Ewl_Menu: A Simple Windowed Menu
  * Defines a menu used globally. The contents on the menu are drawn outside of
@@ -49,7 +48,8 @@
  */
 struct Ewl_Menu
 {
-       Ewl_Menu_Base  base;            /**< Inherit from Ewl_Menu_Base */
+       Ewl_Menu_Item  item;            /**< Inherit from Ewl_Menu_Base */
+       Ewl_Widget *popup;              /**< The popup holding the menu items */
 
        Ewl_Widget *menubar_parent;     /**< Parent menu bar */
 };
@@ -80,6 +80,7 @@
 void ewl_menu_cb_configure(Ewl_Widget *w, void *ev_data, void *user_data);
 void ewl_menu_cb_expand(Ewl_Widget *w, void *ev_data, void *user_data);
 void ewl_menu_cb_hide(Ewl_Widget *w, void *ev_data, void *user_data);
+void ewl_menu_cb_realize(Ewl_Widget *w, void *ev_data, void *user_data);
 void ewl_menu_cb_destroy(Ewl_Widget *w, void *ev, void *data);
 void ewl_menu_cb_popup_destroy(Ewl_Widget *w, void *ev, void *data);
 void ewl_menu_cb_expand_mouse_move(Ewl_Widget *w, void *ev_data, 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- Makefile.am 14 Feb 2007 10:40:51 -0000      1.49
+++ Makefile.am 6 Mar 2007 21:25:08 -0000       1.50
@@ -27,6 +27,7 @@
        ewl_combo.h \
        ewl_config.h \
        ewl_container.h \
+       ewl_context_menu.h \
        ewl_cursor.h \
        ewl_datepicker.h \
        ewl_debug.h \
@@ -59,7 +60,6 @@
        ewl_media.h \
        ewl_menu.h \
        ewl_menubar.h \
-       ewl_menu_base.h \
        ewl_menu_item.h \
        ewl_misc.h \
        ewl_model.h \
@@ -113,6 +113,7 @@
        ewl_combo.c \
        ewl_config.c \
        ewl_container.c \
+       ewl_context_menu.c \
        ewl_cursor.c \
        ewl_datepicker.c \
        ewl_dialog.c \
@@ -142,7 +143,6 @@
        ewl_media.c \
        ewl_menu.c \
        ewl_menubar.c \
-       ewl_menu_base.c \
        ewl_menu_item.c \
        ewl_misc.c \
        ewl_model.c \



-------------------------------------------------------------------------
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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to