Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_attach.h ewl_combo.c ewl_combo.h ewl_config.c ewl_dnd.c 
        ewl_embed.c ewl_embed.h ewl_enums.h ewl_filelist.c ewl_list.c 
        ewl_mvc.c ewl_mvc.h ewl_tree2.c ewl_tree2.h 


Log Message:
- add mvc range selection rm
- add multiselect capabilities to ewl_list
- add single and multiselect capabilities to ewl_tree2, both row and cell based
- doxy fixes

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_attach.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_attach.h        13 Oct 2006 01:53:05 -0000      1.14
+++ ewl_attach.h        18 Oct 2006 16:28:08 -0000      1.15
@@ -89,7 +89,7 @@
        ewl_attach_get(EWL_WIDGET(w), EWL_ATTACH_TYPE_NAME)
 
 /**
- * @def ewl_attach_association_set(w, data)
+ * @def ewl_attach_widget_association_set(w, data)
  * Convenience method to attach data to a notebook item
  */
 #define ewl_attach_widget_association_set(w, data) \
@@ -97,7 +97,7 @@
                        EWL_ATTACH_TYPE_WIDGET_ASSOCIATION, data)
 
 /**
- * @def ewl_attach_association_get(w)
+ * @def ewl_attach_widget_association_get(w)
  * Convenience method to get the data attached to a notebook item
  */
 #define ewl_attach_widget_association_get(w) \
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_combo.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -3 -r1.34 -r1.35
--- ewl_combo.c 15 Oct 2006 22:34:14 -0000      1.34
+++ ewl_combo.c 18 Oct 2006 16:28:08 -0000      1.35
@@ -3,6 +3,8 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
+static void ewl_combo_cb_selected_change(Ewl_MVC *mvc);
+
 /**
  * @return Returns a pointer to a new combo on success, NULL on failure.
  * @brief Create a new combo box
@@ -275,13 +277,13 @@
        combo = data;
 
        i = ewl_container_child_index_get(EWL_CONTAINER(combo->popup), w);
-       ewl_mvc_selected_set(EWL_MVC(combo), i, 0);
+       ewl_mvc_selected_set(EWL_MVC(combo), i, -1);
        ewl_combo_cb_increment_clicked(NULL, NULL, data);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void
+static void
 ewl_combo_cb_selected_change(Ewl_MVC *mvc)
 {
        Ewl_View *view;
@@ -314,7 +316,7 @@
                view->assign(combo->header, 
                                model->fetch(mvc_data, idx->row, 0));
        }
-       else
+       else if (view->header_fetch)
                combo->header = view->header_fetch(mvc_data, -1);
 
        if (combo->header)
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_combo.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_combo.h 3 Oct 2006 05:17:13 -0000       1.16
+++ ewl_combo.h 18 Oct 2006 16:28:08 -0000      1.17
@@ -60,8 +60,6 @@
 void ewl_combo_cb_increment_clicked(Ewl_Widget *w, void *ev, void *data);
 void ewl_combo_cb_item_clicked(Ewl_Widget *w, void *ev, void *data);
 
-void ewl_combo_cb_selected_change(Ewl_MVC *mvc);
-
 /**
  * @}
  */
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_config.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_config.c        10 Oct 2006 21:26:24 -0000      1.19
+++ ewl_config.c        18 Oct 2006 16:28:08 -0000      1.20
@@ -148,6 +148,7 @@
  * @param cfg: The Ewl_Config to work with
  * @param k: the key to set in the configuration database
  * @param v: the string value that will be associated with the key
+ * @param state: The state of the key being set, persistent or transient
  * @return Returns no value.
  * @brief set the value of key to the specified string
  *
@@ -186,6 +187,7 @@
  * @param cfg: The Ewl_Config to work with
  * @param k: the key to set in the configuration database
  * @param v: the integer value that will be associated with the key
+ * @param state: The state of the key being set, persistent or transient
  * @return Returns TRUE on success, FALSE on failure.
  * @brief Set the value of key to the specified integer
  *
@@ -233,6 +235,7 @@
  * @param cfg: The Ewl_Config to work with
  * @param k: the key to set in the configuration database
  * @param v: the float value that will be associated with the key
+ * @param state: The state of the key being set, persistent or transient
  * @return Returns no value
  * @brief Set the value of key to the specified float
  *
@@ -283,6 +286,7 @@
  * @param g: the green value that will be associated with the key
  * @param b: the blue value that will be associated with the key
  * @param a: the alpha value that will be associated with the key
+ * @param state: The state of the key being set, persistent or transient
  * @return Returns no value
  * @brief Set the value of key to the specified color
  *
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_dnd.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- ewl_dnd.c   13 Oct 2006 02:08:00 -0000      1.28
+++ ewl_dnd.c   18 Oct 2006 16:28:08 -0000      1.29
@@ -154,7 +154,8 @@
 
 /**
  * @param w: The widget to test for an provided type
- * @param w: The mimetype to test for provideance on a specific widget
+ * @param type: The mimetype to test for provideance on a specific widget
+ * @return Returns TRUE if the types contains the given type, FALSE otherwise
  * @brief: Verifies the specified widget provides the given mimetype
  */
 int
@@ -240,7 +241,8 @@
 
 /**
  * @param w: The widget to test for an accepted type
- * @param w: The mimetype to test for acceptance on a specific widget
+ * @param type: The mimetype to test for acceptance on a specific widget
+ * @return Returns TRUE if the widget accepts the given type, FALSE otherwise
  * @brief: Verifies the specified widget accepts the given mimetype
  */
 int
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_embed.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -3 -r1.89 -r1.90
--- ewl_embed.c 13 Oct 2006 22:02:53 -0000      1.89
+++ ewl_embed.c 18 Oct 2006 16:28:08 -0000      1.90
@@ -999,8 +999,10 @@
 
 /**
  * @param embed: the embed where the selection data event is to occur
+ * @param type: The type to feed
  * @param data: a pointer to the data received that generated the event
  * @param len: length of the data that generated the event
+ * @param format: The bit format of the data 
  * @return Returns no value.
  * @brief Sends the event for selection data received into an embed.
  */
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_embed.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ewl_embed.h 13 Oct 2006 22:02:53 -0000      1.30
+++ ewl_embed.h 18 Oct 2006 16:28:08 -0000      1.31
@@ -110,7 +110,6 @@
 const char     *ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int 
y,int*,int*,int*,int*);
 const char     *ewl_embed_dnd_drop_feed(Ewl_Embed* embed, int x, int y, int 
internal);
 void           ewl_embed_dnd_data_feed(Ewl_Embed* embed, char *type, void 
*data, unsigned int len, unsigned int format);
-void            ewl_embed_selection_data_feed(Ewl_Embed *embed, char *type, 
void *data, unsigned int len, unsigned int format);
 
 void            ewl_embed_mouse_out_feed(Ewl_Embed *embed, int x, int y,
                                         unsigned int modifiers);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_enums.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -3 -r1.61 -r1.62
--- ewl_enums.h 15 Oct 2006 22:34:14 -0000      1.61
+++ ewl_enums.h 18 Oct 2006 16:28:08 -0000      1.62
@@ -724,30 +724,55 @@
  */
 typedef enum Ewl_Rotate Ewl_Rotate;
 
+/**
+ * @enum Ewl_Selection_Type
+ * The selection type enum
+ */
 enum Ewl_Selection_Type
 {
-       EWL_SELECTION_TYPE_INDEX,
-       EWL_SELECTION_TYPE_RANGE
+       EWL_SELECTION_TYPE_INDEX,       /**< Single index */
+       EWL_SELECTION_TYPE_RANGE        /**< Range of indices */
 };
+
+/**
+ * Ewl_Selection_Type
+ */
 typedef enum Ewl_Selection_Type Ewl_Selection_Type;
 
+/**
+ * @enum Ewl_Selection_Mode
+ * The slecetion mode enum
+ */
 enum Ewl_Selection_Mode
 {
-       EWL_SELECTION_MODE_NONE,
-       EWL_SELECTION_MODE_SINGLE,
-       EWL_SELECTION_MODE_MULTI
+       EWL_SELECTION_MODE_NONE,        /**< No selection allowed */
+       EWL_SELECTION_MODE_SINGLE,      /**< Single select only */
+       EWL_SELECTION_MODE_MULTI        /**< Multi select mode */
 };
+
+/**
+ * Ewl_Selection_Mode
+ */
 typedef enum Ewl_Selection_Mode Ewl_Selection_Mode;
 
+/**
+ * @enum Ewl_Tree_Selection_Type
+ * The tree selection type 
+ */
 enum Ewl_Tree_Selection_Type
 {
-       EWL_TREE_SELECT_ROW,
-       EWL_TREE_SELECT_CELL
+       EWL_TREE_SELECTION_TYPE_ROW,    /**< Row selection */
+       EWL_TREE_SELECTION_TYPE_CELL    /**< Cell selection */
 };
+
+/**
+ * Ewl_Tree_Selection_Type
+ */
 typedef enum Ewl_Tree_Selection_Type Ewl_Tree_Selection_Type;
 
 /**
  * @}
  */ 
-#endif                         /* __EWL_ENUMS_H__ */
+
+#endif
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_filelist.c      14 Sep 2006 05:35:38 -0000      1.19
+++ ewl_filelist.c      18 Oct 2006 16:28:08 -0000      1.20
@@ -605,6 +605,12 @@
        DRETURN_INT(fl->scroll_flags.h, DLEVEL_STABLE);
 }
 
+/**
+ * @param fl: The filelist to work with
+ * @param path: The path to get the icon for
+ * @return Returns the stock icon for the given file
+ * @brief Retrieves the stock icon for the given file
+ */
 const char *
 ewl_filelist_stock_icon_get(Ewl_Filelist *fl, const char *path)
 {
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_list.c  15 Oct 2006 22:34:14 -0000      1.9
+++ ewl_list.c  18 Oct 2006 16:28:08 -0000      1.10
@@ -123,6 +123,10 @@
        DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE);
        DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
 
+       if (ewl_mvc_selection_mode_get(EWL_MVC(c)) ==
+                                       EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE);
+
        ewl_callback_append(w, EWL_CALLBACK_CLICKED, 
                                ewl_list_cb_item_clicked, c);
 
@@ -140,7 +144,7 @@
 void
 ewl_list_cb_item_clicked(Ewl_Widget *w, void *ev __UNUSED__, void *data)
 {
-       Ewl_List *list;
+       int row;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
@@ -148,10 +152,8 @@
        DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
        DCHECK_TYPE("data", data, EWL_LIST_TYPE);
 
-       list = data;
-
-       ewl_mvc_selected_set(EWL_MVC(list), 
-               ewl_container_child_index_get(EWL_CONTAINER(list), w), 0);
+       row = ewl_container_child_index_get(EWL_CONTAINER(data), w);
+       ewl_mvc_handle_click(EWL_MVC(data), row, -1);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -173,5 +175,4 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
-
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_mvc.c   17 Oct 2006 15:35:37 -0000      1.6
+++ ewl_mvc.c   18 Oct 2006 16:28:08 -0000      1.7
@@ -3,7 +3,23 @@
 #include "ewl_macros.h"
 #include "ewl_debug.h"
 
+/* XXX There is a bit of behaviour that maybe considered a bug in here. If
+ * the user has a list of say 4 items. The user clicks on item 2 then
+ * control clicks on item one, then shift clicks on item 4. Item 2 will now
+ * be in the selected list twice. A rm _should_ remove both instances, but
+ * this could be confusing for the user. 
+ *
+ * The only solution is to do a selected_is for each index that is added to
+ * the selected list, and for each range, check if that range intersects
+ * anything else in the selected list. This could be slow and painful.
+ *
+ * Leaving it with the same item possibly in the list multiple times for
+ * now.
+ */
+
 static void ewl_mvc_selected_change_notify(Ewl_MVC *mvc);
+static void ewl_mvc_selected_rm_item(Ewl_MVC *mvc, Ewl_Selection *sel, 
+                                               int row, int column);
 
 /**
  * @param mvc: The MVC to initialize
@@ -144,9 +160,8 @@
        mvc->data = data;
        ewl_mvc_dirty_set(mvc, TRUE);
 
-       /* let the inheriting widget know that the data has changed */
-       if (mvc->cb.selected_change)
-               mvc->cb.selected_change(mvc);
+       /* new data, clear out the old selection list */
+       ewl_mvc_selected_clear(mvc);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -255,7 +270,10 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
-       
+
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE); 
+
        ecore_list_clear(mvc->selected);
        ewl_mvc_selected_change_notify(mvc);
 
@@ -278,7 +296,6 @@
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
-       /* make sure we're selecting and received items to select */
        if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
                DRETURN(DLEVEL_STABLE);
 
@@ -314,6 +331,9 @@
        DCHECK_PARAM_PTR_RET("mvc", mvc, NULL);
        DCHECK_TYPE_RET("mvc", mvc, EWL_MVC_TYPE, NULL);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN_PTR(NULL, DLEVEL_STABLE);       
+
        DRETURN_PTR(mvc->selected, DLEVEL_STABLE);
 }
 
@@ -337,6 +357,9 @@
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE); 
+
        /* make sure the start comes before the end */
        if (erow < srow)
        {
@@ -353,29 +376,10 @@
        }
 
        if (mvc->selection_mode == EWL_SELECTION_MODE_SINGLE)
-       {
-               Ewl_Selection_Idx *si;
-
-               si = NEW(Ewl_Selection_Idx, 1);
-               si->sel.type = EWL_SELECTION_TYPE_INDEX;
-               si->row = srow;
-               si->column = scolumn;
+               sel = ewl_mvc_selection_index_new(srow, scolumn);
 
-               sel = EWL_SELECTION(si);
-       }
        else
-       {
-               Ewl_Selection_Range *si;
-
-               si = NEW(Ewl_Selection_Range, 1);
-               si->sel.type = EWL_SELECTION_TYPE_RANGE;
-               si->start.row = srow;
-               si->start.column = scolumn;
-               si->end.row = erow;
-               si->end.column = ecolumn;
-
-               sel = EWL_SELECTION(si);
-       }
+               sel = ewl_mvc_selection_range_new(srow, scolumn, erow, ecolumn);
 
        ecore_list_append(mvc->selected, sel);
        ewl_mvc_selected_change_notify(mvc);
@@ -397,6 +401,9 @@
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE); 
+
        ecore_list_clear(mvc->selected);
        ewl_mvc_selected_add(mvc, row, column);
 
@@ -413,17 +420,16 @@
 void
 ewl_mvc_selected_add(Ewl_MVC *mvc, int row, int column)
 {
-       Ewl_Selection_Idx *si;
+       Ewl_Selection *si;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
-       si = NEW(Ewl_Selection_Idx, 1);
-       si->sel.type = EWL_SELECTION_TYPE_INDEX;
-       si->row = row;
-       si->column = column;
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE);
 
+       si = ewl_mvc_selection_index_new(row, column);
        ecore_list_append(mvc->selected, si);
        ewl_mvc_selected_change_notify(mvc);
 
@@ -445,13 +451,15 @@
        DCHECK_PARAM_PTR_RET("mvc", mvc, NULL);
        DCHECK_TYPE_RET("mvc", mvc, EWL_MVC_TYPE, NULL);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+
        ecore_list_goto_last(mvc->selected);
        sel = ecore_list_current(mvc->selected);
        if (!sel) DRETURN_PTR(NULL, DLEVEL_STABLE);
 
        ret = NEW(Ewl_Selection_Idx, 1);
        ret->sel.type = EWL_SELECTION_TYPE_INDEX;
-
        if (sel->type == EWL_SELECTION_TYPE_INDEX)
        {
                Ewl_Selection_Idx *si;
@@ -488,9 +496,13 @@
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
-       /* XXX should this check for the same selected area bein in the list
-        * twice? What if the user does a box select on the tree, then
-        * another, larger, box select? */
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE); 
+
+       /* We walk the entire list. The reason for this is that you can have
+        * the same cell in the list multiple times. This can happen if
+        * they've single selected something, then did a multiselection over
+        * top of it again. */
        ecore_list_goto_first(mvc->selected);
        while ((sel = ecore_list_current(mvc->selected)))
        {
@@ -501,52 +513,28 @@
                        si = EWL_SELECTION_IDX(sel);
                        if ((si->row == row) && (si->column == column))
                        {
-                               ecore_list_remove(mvc->selected);
-                               break;
+                               ewl_mvc_selected_rm_item(mvc, sel, row, column);
+                               continue;
                        }
                }
                else
                {
                        Ewl_Selection_Range *si;
-                       int tmp;
 
                        si = EWL_SELECTION_RANGE(sel);
-                               
-                       /* verify the range has the top/left most
-                        * cell first */
-                       if (si->end.row < si->start.row)
-                       {
-                               tmp = si->end.row;
-                               si->end.row = si->start.row;
-                               si->start.row = tmp;
-                       }
-       
-                       if (si->end.column < si->start.column)
-                       {
-                               tmp = si->end.column;
-                               si->end.column = si->start.column;
-                               si->start.column = tmp;
-                       }
-
                        if ((si->start.row <= row) 
                                        && (si->end.row >= row)
                                        && (si->start.column <= column) 
                                        && (si->end.column >= column))
                        {
-                               ecore_list_remove(mvc->selected);
-
-                               DWARNING("Can't rm from range's yet\n");
-                               /* find top cells */
-                               /* find left cells */
-                               /* find right cells */
-                               /* find bottom cells */
-
-                               break;
+                               ewl_mvc_selected_rm_item(mvc, sel, row, column);
+                               continue;
                        }
                }
 
                ecore_list_next(mvc->selected);
        }
+       ewl_mvc_selected_change_notify(mvc);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -566,6 +554,9 @@
        DCHECK_PARAM_PTR_RET("mvc", mvc, 0);
        DCHECK_TYPE_RET("mvc", mvc, EWL_MVC_TYPE, 0);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN_INT(0, DLEVEL_STABLE);  
+
        /* make sure we only return 1 or 0 for the single select case */
        if (mvc->selection_mode == EWL_SELECTION_MODE_SINGLE)
        {
@@ -612,6 +603,9 @@
        DCHECK_PARAM_PTR_RET("mvc", mvc, FALSE);
        DCHECK_TYPE_RET("mvc", mvc, EWL_MVC_TYPE, FALSE);
 
+       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+               DRETURN_INT(FALSE, DLEVEL_STABLE);      
+
        ecore_list_goto_first(mvc->selected);
        while ((sel = ecore_list_next(mvc->selected)))
        {
@@ -628,27 +622,9 @@
                }
                else
                {
-                       int tmp;
                        Ewl_Selection_Range *si;
 
                        si = EWL_SELECTION_RANGE(sel);
-                               
-                       /* verify the range has the top/left most
-                        * cell first */
-                       if (si->end.row < si->start.row)
-                       {
-                               tmp = si->end.row;
-                               si->end.row = si->start.row;
-                               si->start.row = tmp;
-                       }
-       
-                       if (si->end.column < si->start.column)
-                       {
-                               tmp = si->end.column;
-                               si->end.column = si->start.column;
-                               si->start.column = tmp;
-                       }
-
                        if ((si->start.row <= row) 
                                        && (si->end.row >= row)
                                        && (si->start.column <= column) 
@@ -663,6 +639,112 @@
        DRETURN_INT(ret, DLEVEL_STABLE);
 }
 
+Ewl_Selection *
+ewl_mvc_selection_index_new(int row, int column)
+{
+       Ewl_Selection_Idx *sel;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       sel = NEW(Ewl_Selection_Idx, 1);
+       sel->sel.type = EWL_SELECTION_TYPE_INDEX;
+       sel->row = row;
+       sel->column = column;
+
+       DRETURN_PTR(sel, DLEVEL_STABLE);
+}
+
+Ewl_Selection *
+ewl_mvc_selection_range_new(int srow, int scolumn, int erow, int ecolumn)
+{
+       Ewl_Selection_Range *sel;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       sel = NEW(Ewl_Selection_Range, 1);
+       sel->sel.type = EWL_SELECTION_TYPE_RANGE;
+       sel->start.row = srow;
+       sel->start.column = scolumn;
+       sel->end.row = erow;
+       sel->end.column = ecolumn;
+
+       DRETURN_PTR(sel, DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param mvc: The mvc to work with
+ * @param row: The row to add
+ * @param column: The column to add
+ * @return Returns no value
+ * @brief Handles the click of the given cell
+ */
+void
+ewl_mvc_handle_click(Ewl_MVC *mvc, int row, int column)
+{
+       unsigned int modifiers;
+       int multi_select = FALSE;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("mvc", mvc);
+       DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
+
+       if (ewl_mvc_selection_mode_get(mvc) == EWL_SELECTION_MODE_MULTI)
+               multi_select = TRUE;
+
+       modifiers = ewl_ev_modifiers_get();
+        if (multi_select && (modifiers & EWL_KEY_MODIFIER_SHIFT))
+       {
+               /* is this the first click? */
+               if (ewl_mvc_selected_count_get(mvc) > 0)
+               {
+                       Ewl_Selection *sel;
+                       int srow, scolumn;
+
+                       /* A shift will add the current position into a 
+                        * range with the last selected item. If the 
+                        * last selected is a range, it will take the 
+                        * start position */
+                       sel = ecore_list_goto_last(mvc->selected);
+                       if (sel->type == EWL_SELECTION_TYPE_INDEX)
+                       {
+                               Ewl_Selection_Idx *idx;
+
+                               idx = EWL_SELECTION_IDX(sel);
+                               srow = idx->row;
+                               scolumn = idx->column;
+                       }
+                       else
+                       {
+                               Ewl_Selection_Range *idx;
+
+                               idx = EWL_SELECTION_RANGE(sel);
+                               srow = idx->start.row;
+                               scolumn = idx->start.column;
+                       }
+
+                       /* remove the original and add the extended one to
+                        * the list */
+                       ecore_list_remove(mvc->selected);
+                       ewl_mvc_selected_range_add(mvc, srow, scolumn,
+                                                       row, column);
+               }
+               else
+                       ewl_mvc_selected_set(mvc, row, column);
+       }
+        else if (multi_select && (modifiers & EWL_KEY_MODIFIER_CTRL))
+        {
+                if (ewl_mvc_selected_is(mvc, row, column))
+                        ewl_mvc_selected_rm(mvc, row, column);
+                else
+                        ewl_mvc_selected_add(mvc, row, column);
+        }
+        else
+                ewl_mvc_selected_set(mvc, row, column);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
 /**
  * @internal
  * @param mvc: The MVC to set the callback into
@@ -720,6 +802,123 @@
 
        /* notify the app */
        ewl_callback_call(EWL_WIDGET(mvc), EWL_CALLBACK_VALUE_CHANGED);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/* This will remove @a sel from the mvc widget @a mvc. Then, if @a sel is a
+ * range selection it will remove @a row/@a column from the given selection
+ * and add up to 4 new ranges into the @a mvc widget.
+ * 
+ * The range remove works like this:
+ *   - first allocate as much space off the top to the first range.
+ *     - this will go from the top left corner, to the selected (row - 1)
+ *       and far right edge.
+ *   - second, from the deletion row, far left to bottom row and (deletion 
column - 1) 
+ *     make this the second range
+ *   - third, from the deletoin row, (deletion column + 1) to the bottom
+ *     right corner this is the third range
+ *   - fourth, from deletion row + 1, deletion column to bottom row,
+ *     deletion column, this is the fourth range
+ * 
+ * If a range would be only one item, we make it an Ewl_Selection_Index as
+ * needed. Steps can be skipped if they would result in a zero item range.
+ */
+static void
+ewl_mvc_selected_rm_item(Ewl_MVC *mvc, Ewl_Selection *sel, int row, int column)
+{
+       Ewl_Selection_Range *si;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("mvc", mvc);
+       DCHECK_PARAM_PTR("sel", sel);
+       DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
+
+       ecore_list_goto(mvc->selected, sel);
+       ecore_list_remove(mvc->selected);
+
+       /* done if this is an index */
+       if (sel->type != EWL_SELECTION_TYPE_RANGE)
+               DRETURN(DLEVEL_STABLE);
+
+       si = EWL_SELECTION_RANGE(sel);
+
+       /* find top cells */
+       if (row > si->start.row)
+       {
+               Ewl_Selection *n;
+               int erow;
+
+               erow = (row - 1);
+
+               /* one item left in the grouping */
+               if ((((si->start.row - erow) + 1) * 
+                               ((si->start.column - si->end.column) + 1)) == 1)
+                       n = ewl_mvc_selection_index_new(si->start.row,
+                                                       si->start.column);
+
+               else
+                       n = ewl_mvc_selection_range_new(si->start.row,
+                                                       si->start.column,
+                                                       erow, si->end.column);
+               
+               ecore_list_append(mvc->selected, n);
+       }
+
+       /* find left cells */
+       if (column > si->start.column)
+       {
+               Ewl_Selection *n;
+               int ecolumn;
+
+               ecolumn = (column - 1);
+               if ((((si->end.row - row) + 1) * 
+                               ((si->start.column - ecolumn) + 1)) == 1)
+                       n = ewl_mvc_selection_index_new(row, si->start.column);
+
+               else
+                       n = ewl_mvc_selection_range_new(row, si->start.column,
+                                                       si->end.row, ecolumn);
+
+               ecore_list_append(mvc->selected, n);
+       }
+
+       /* find right cells */
+       if (column < si->end.column)
+       {
+               Ewl_Selection *n;
+               int scolumn;
+
+               scolumn = column + 1;
+               if ((((si->end.row - row) + 1) * 
+                               ((scolumn - si->end.column) + 1)) == 1)
+                       n = ewl_mvc_selection_index_new(row, si->end.column);
+
+               else
+                       n = ewl_mvc_selection_range_new(row, scolumn,
+                                                       si->end.row,
+                                                       si->end.column);
+
+               ecore_list_append(mvc->selected, n);
+       }
+
+       /* find bottom cells */
+       if (row < si->end.row)
+       {
+               Ewl_Selection *n;
+               int srow;
+
+               srow = row + 1;
+               if ((((srow - si->end.row) + 1) * 
+                               ((column - column) + 1)) == 1)
+                       n = ewl_mvc_selection_index_new(si->end.row, column);
+
+               else
+                       n = ewl_mvc_selection_range_new(srow, column,
+                                                       si->end.row, column);
+
+               ecore_list_append(mvc->selected, n);
+       }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_mvc.h   17 Oct 2006 15:35:37 -0000      1.6
+++ ewl_mvc.h   18 Oct 2006 16:28:08 -0000      1.7
@@ -27,8 +27,8 @@
 {
        Ewl_Selection sel;
 
-       unsigned int row;
-       unsigned int column;
+       int row;
+       int column;
 };
 
 #define EWL_SELECTION_RANGE(x) ((Ewl_Selection_Range *)x)
@@ -39,8 +39,8 @@
 
        struct
        {
-               unsigned int row;
-               unsigned int column;
+               int row;
+               int column;
        } start,
          end;
 };
@@ -113,6 +113,10 @@
 int             ewl_mvc_selected_count_get(Ewl_MVC *mvc);
 unsigned int    ewl_mvc_selected_is(Ewl_MVC *mvc, int row, int column);
 
+Ewl_Selection  *ewl_mvc_selection_index_new(int row, int column);
+Ewl_Selection  *ewl_mvc_selection_range_new(int srow, int scolumn,
+                                               int erow, int ecolumn);
+
 /* 
  * internal
  */
@@ -120,6 +124,12 @@
 void            ewl_mvc_selected_change_cb_set(Ewl_MVC *mvc, void 
(*cb)(Ewl_MVC *mvc));
 
 void            ewl_mvc_cb_destroy(Ewl_Widget *w, void *ev, void *data);
+
+void            ewl_mvc_handle_click(Ewl_MVC *mvc, int row, int column);
+
+/**
+ * @}
+ */
 
 #endif
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- ewl_tree2.c 15 Oct 2006 22:34:14 -0000      1.35
+++ ewl_tree2.c 18 Oct 2006 16:28:08 -0000      1.36
@@ -9,6 +9,9 @@
 static void ewl_tree2_cb_header_changed(Ewl_Widget *w, void *ev, 
                                                        void *data);
 
+static void ewl_tree2_cb_row_clicked(Ewl_Widget *w, void *ev, void *data);
+static void ewl_tree2_cb_cell_clicked(Ewl_Widget *w, void *ev, void *data);
+
 /**
  * @return Returns NULL on failure, a new tree widget on success.
  * @brief Allocate and initialize a new tree widget
@@ -61,7 +64,7 @@
        tree->columns = ecore_list_new();
        ecore_list_set_free_cb(tree->columns, ewl_tree2_cb_column_free);
 
-       tree->mode = EWL_SELECTION_MODE_NONE;
+       tree->type = EWL_TREE_SELECTION_TYPE_CELL;
 
        tree->header = ewl_hpaned_new();
        ewl_container_child_append(EWL_CONTAINER(tree), tree->header);
@@ -265,17 +268,18 @@
 
 /**
  * @param tree: The tree to get the mode from
- * @return Returns the current Ewl_Tree_Mode of the tree
- * @brief Get the mode from the tree
+ * @return Returns the current Ewl_Tree_Selection_Type of the tree
+ * @brief Get the selection type from the tree
  */
-Ewl_Selection_Mode 
-ewl_tree2_selection_mode_get(Ewl_Tree2 *tree)
+Ewl_Tree_Selection_Type
+ewl_tree2_selection_type_get(Ewl_Tree2 *tree)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("tree", tree, EWL_SELECTION_MODE_NONE);
-       DCHECK_TYPE_RET("tree", tree, EWL_TREE2_TYPE, EWL_SELECTION_MODE_NONE);
+       DCHECK_PARAM_PTR_RET("tree", tree, EWL_TREE_SELECTION_TYPE_CELL);
+       DCHECK_TYPE_RET("tree", tree, EWL_TREE2_TYPE,
+                                       EWL_TREE_SELECTION_TYPE_CELL);
 
-       DRETURN_INT(tree->mode, DLEVEL_STABLE);
+       DRETURN_INT(tree->type, DLEVEL_STABLE);
 }
 
 /**
@@ -285,22 +289,20 @@
  * @brief Set the mode of the tree
  */
 void 
-ewl_tree2_selection_mode_set(Ewl_Tree2 *tree, Ewl_Selection_Mode mode)
+ewl_tree2_selection_type_set(Ewl_Tree2 *tree, Ewl_Tree_Selection_Type type)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("tree", tree);
        DCHECK_TYPE("tree", tree, EWL_TREE2_TYPE);
 
-       if (tree->mode == mode)
+       if (tree->type == type)
                DRETURN(DLEVEL_STABLE);
 
-       tree->mode = mode;
- 
-       /* if the mode is none then we don't care about the selected list */
-       if (tree->mode == EWL_SELECTION_MODE_NONE)
-       {
-               ewl_mvc_selected_list_set(EWL_MVC(tree), NULL);
-       }
+       tree->type = type;
+
+       /* if we switched types then the current set of selections isn't
+        * valid anymore so we clear them out */
+       ewl_mvc_selected_clear(EWL_MVC(tree));
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -556,6 +558,9 @@
                row = ewl_row_new();
                ewl_row_header_set(EWL_ROW(row), EWL_ROW(tree->header));
                ewl_container_child_append(EWL_CONTAINER(tree->rows), row);
+               ewl_attach_widget_association_set(row, tree);
+               ewl_callback_append(row, EWL_CALLBACK_CLICKED,  
+                                       ewl_tree2_cb_row_clicked, NULL);
                ewl_widget_show(row);
 
                if (i % 2)
@@ -573,9 +578,11 @@
 
                        cell = ewl_cell_new();
                        ewl_object_fill_policy_set(EWL_OBJECT(cell),
-                                                  EWL_FLAG_FILL_HSHRINK |
-                                                  EWL_FLAG_FILL_HFILL);
+                                                  EWL_FLAG_FILL_ALL);
                        ewl_container_child_append(EWL_CONTAINER(row), cell);
+                       ewl_attach_widget_association_set(cell, row);
+                       ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
+                                               ewl_tree2_cb_cell_clicked, 
NULL);
                        ewl_widget_show(cell);
 
                        val = col->model->fetch(mvc_data, i, column);
@@ -810,5 +817,49 @@
        DRETURN_INT(c->sort, DLEVEL_STABLE);
 }
 
+static void
+ewl_tree2_cb_row_clicked(Ewl_Widget *w, void *ev __UNUSED__, 
+                                       void *data __UNUSED__)
+{
+       Ewl_Tree2 *tree;
+       int row;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+
+       tree = ewl_attach_widget_association_get(w);
+       if (tree->type != EWL_TREE_SELECTION_TYPE_ROW)
+               DRETURN(DLEVEL_STABLE);
+
+       row = ewl_container_child_index_get(EWL_CONTAINER(tree->rows), w);
+       ewl_mvc_handle_click(EWL_MVC(tree), row, -1);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+ewl_tree2_cb_cell_clicked(Ewl_Widget *w, void *ev __UNUSED__, 
+                                       void *data __UNUSED__)
+{
+       Ewl_Row *row;
+       Ewl_Tree2 *tree;
+       int r, column;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+
+       row = ewl_attach_widget_association_get(w);
+       tree = ewl_attach_widget_association_get(row);
+       if (tree->type != EWL_TREE_SELECTION_TYPE_CELL)
+               DRETURN(DLEVEL_STABLE);
+
+       r = ewl_container_child_index_get(EWL_CONTAINER(tree->rows), 
+                                               EWL_WIDGET(row));
+       column = ewl_container_child_index_get(EWL_CONTAINER(row), w);
+       ewl_mvc_handle_click(EWL_MVC(tree), r, column);
 
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- ewl_tree2.h 15 Oct 2006 22:34:14 -0000      1.32
+++ ewl_tree2.h 18 Oct 2006 16:28:08 -0000      1.33
@@ -90,7 +90,7 @@
        Ecore_List *columns;     /**< The tree columns. */
        int *rowcache;           /**< Cache of row sizes */
 
-       Ewl_Selection_Mode mode;         /**< The mode of the tree */
+       Ewl_Tree_Selection_Type type;    /**< The selection type of the tree */
 
        unsigned char fixed:1;    /**< Rows are fixed height */
        unsigned char headers_visible:1; /**< Are the headers visible? */
@@ -138,9 +138,9 @@
                                               unsigned char visible);
 unsigned int    ewl_tree2_headers_visible_get(Ewl_Tree2 *tree);
 
-Ewl_Selection_Mode ewl_tree2_selection_mode_get(Ewl_Tree2 *tree);
-void            ewl_tree2_selection_mode_set(Ewl_Tree2 *tree, 
-                                               Ewl_Selection_Mode mode);
+Ewl_Tree_Selection_Type ewl_tree2_selection_type_get(Ewl_Tree2 *tree);
+void            ewl_tree2_selection_type_set(Ewl_Tree2 *tree, 
+                                               Ewl_Tree_Selection_Type type);
 
 void            ewl_tree2_fixed_rows_set(Ewl_Tree2 *tree, unsigned int fixed);
 unsigned int    ewl_tree2_fixed_rows_get(Ewl_Tree2 *tree);



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to