Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/bin/tests/mvc


Modified Files:
        ewl_mvc.c 


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/bin/tests/mvc/ewl_mvc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_mvc.c   17 Oct 2006 15:35:37 -0000      1.2
+++ ewl_mvc.c   18 Oct 2006 16:28:08 -0000      1.3
@@ -6,8 +6,6 @@
 
 static int selected_set(char *buf, int len);
 static int selected_get(char *buf, int len);
-static int selected_list_set(char *buf, int len);
-static int selected_list_get(char *buf, int len);
 static int selected_range_single_add(char *buf, int len);
 static int selected_range_multi_add(char *buf, int len);
 static int selected_count_get(char *buf, int len);
@@ -18,6 +16,11 @@
 static int selected_clear(char *buf, int len);
 
 static int selected_rm_idx(char *buf, int len);
+static int selected_rm_unselected_idx(char *buf, int len);
+static int selected_rm_2x1_bottom(char *buf, int len);
+static int selected_rm_2x1_top(char *buf, int len);
+static int selected_rm_1x2_left(char *buf, int len);
+static int selected_rm_1x2_right(char *buf, int len);
 static int selected_rm_from_range_top_left_point(char *buf, int len);
 static int selected_rm_from_range_bottom_right_point(char *buf, int len);
 static int selected_rm_from_range_middle_point(char *buf, int len);
@@ -26,11 +29,15 @@
 static int selected_rm_from_range_top_edge_point(char *buf, int len);
 static int selected_rm_from_range_bottom_edge_point(char *buf, int len);
 
+static int ewl_mvc_is_index(char *buf, int len, Ewl_Selection *sel, 
+                                               int row, int column);
+static int ewl_mvc_is_range(char *buf, int len, Ewl_Selection *sel, 
+                                       int srow, int scolumn,
+                                       int erow, int ecolumn);
+
 static Ewl_Unit_Test mvc_unit_tests[] = {
                {"Set selected", selected_set},
                {"Get selected", selected_get},
-               {"List set selected", selected_list_set},
-               {"List get selected", selected_list_get},
                {"Range (single select) add", selected_range_single_add},
                {"Range (multi select) add", selected_range_multi_add},
                {"Count get", selected_count_get},
@@ -40,6 +47,11 @@
                {"Is not selected (range)", selected_is_not_range},
                {"Selected clear", selected_clear},
                {"Remove index", selected_rm_idx},
+               {"Remove non-selected index", selected_rm_unselected_idx},
+               {"Remove bottom from 2x1", selected_rm_2x1_bottom},
+               {"Remove top from 2x1", selected_rm_2x1_top},
+               {"Remove left from 1x2", selected_rm_1x2_left},
+               {"Remove right from 1x2", selected_rm_1x2_right},
                {"Remove from range, top left point",
                                selected_rm_from_range_top_left_point},
                {"Remove from range, bottom right point",
@@ -127,18 +139,6 @@
 }
 
 static int
-selected_list_set(char *buf, int len)
-{
-       return FALSE;
-}
-
-static int
-selected_list_get(char *buf, int len)
-{
-       return FALSE;
-}
-
-static int
 selected_range_single_add(char *buf, int len)
 {
        Ewl_Widget *t;
@@ -340,50 +340,561 @@
 static int
 selected_rm_idx(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_set(m, 6, 8);
+       ewl_mvc_selected_add(m, 3, 0);
+       ewl_mvc_selected_add(m, 9, 1);
+       ewl_mvc_selected_add(m, 1, 2);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 9, 1);
+       if (ewl_mvc_selected_is(m, 9, 1))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+static int
+selected_rm_unselected_idx(char *buf, int len)
+{
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_set(m, 6, 8);
+       ewl_mvc_selected_add(m, 3, 0);
+       ewl_mvc_selected_add(m, 9, 1);
+       ewl_mvc_selected_add(m, 1, 2);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 10, 2);
+       if (ewl_mvc_selected_is(m, 10, 2))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+static int
+selected_rm_2x1_bottom(char *buf, int len)
+{
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 1, 1, 2, 1);
+
+       ewl_mvc_selected_rm(m, 2, 1);
+       if (ewl_mvc_selected_is(m, 2, 1))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 1)
+       {
+               snprintf(buf, len, "Incorrect number of selected items");
+               return FALSE;
+       }
+
+       sel = ecore_list_goto_first(m->selected);
+
+       /* should have 1 index [(1,1)] */
+       if (!ewl_mvc_is_index(buf, len, sel, 1, 1))
+               return FALSE;
+
+       return TRUE;
+}
+
+static int
+selected_rm_2x1_top(char *buf, int len)
+{
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 1, 1, 2, 1);
+
+       ewl_mvc_selected_rm(m, 1, 1);
+       if (ewl_mvc_selected_is(m, 1, 1))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 1)
+       {
+               snprintf(buf, len, "Incorrect number of selected items");
+               return FALSE;
+       }
+
+       sel = ecore_list_goto_first(m->selected);
+
+       /* should have 1 index [(2,1)] */
+       if (!ewl_mvc_is_index(buf, len, sel, 2, 1))
+               return FALSE;
+
+       return TRUE;
+}
+
+static int
+selected_rm_1x2_left(char *buf, int len)
+{
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 1, 1, 1, 2);
+
+       ewl_mvc_selected_rm(m, 1, 1);
+       if (ewl_mvc_selected_is(m, 1, 1))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 1)
+       {
+               snprintf(buf, len, "Incorrect number of selected items");
+               return FALSE;
+       }
+
+       sel = ecore_list_goto_first(m->selected);
+
+       /* should have 1 index [(1,2)] */
+       if (!ewl_mvc_is_index(buf, len, sel, 1, 2))
+               return FALSE;
+
+       return TRUE;
+}
+
+static int
+selected_rm_1x2_right(char *buf, int len)
+{
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 1, 1, 1, 2);
+
+       ewl_mvc_selected_rm(m, 1, 2);
+       if (ewl_mvc_selected_is(m, 1, 2))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 1)
+       {
+               snprintf(buf, len, "Incorrect number of selected items");
+               return FALSE;
+       }
+
+       sel = ecore_list_goto_first(m->selected);
+
+       /* should have 1 index [(1,1)] */
+       if (!ewl_mvc_is_index(buf, len, sel, 1, 1))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_top_left_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 1, 2);
+       if (ewl_mvc_selected_is(m, 1, 2))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 2 ranges [(1,3)(6,8)] [(2,2)(6,2)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 3, 6, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 2, 2, 6, 2))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_bottom_right_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 6, 8);
+       if (ewl_mvc_selected_is(m, 6, 8))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 2 ranges [(1,2)(5,8)] [(6,2)(6,7)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 5, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 6, 2, 6, 7))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_middle_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 4, 5);
+       if (ewl_mvc_selected_is(m, 4, 5))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 4 ranges: [(1,2)(3,8)] 
+                                [(4,2)(6,4)] 
+                                [(4,6)(6,8)]
+                                [(5,5)(6,5)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 3, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 4, 2, 6, 4))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 2);
+       if (!ewl_mvc_is_range(buf, len, sel, 4, 6, 6, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 3);
+       if (!ewl_mvc_is_range(buf, len, sel, 5, 5, 6, 5))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_left_edge_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 4, 2);
+       if (ewl_mvc_selected_is(m, 4, 2))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 3 ranges: [(1,2)(3,8)] 
+                                [(4,3)(6,8)]
+                                [(5,2)(6,2)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 3, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 4, 3, 6, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 2);
+       if (!ewl_mvc_is_range(buf, len, sel, 5, 2, 6, 2))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_right_edge_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 3, 8);
+       if (ewl_mvc_selected_is(m, 3, 8))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 3 ranges: [(1,2)(2,8)] 
+                                [(3,2)(6,7)] 
+                                [(4,8)(6,8)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 2, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 3, 2, 6, 7))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 2);
+       if (!ewl_mvc_is_range(buf, len, sel, 4, 8, 6, 8))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_top_edge_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 1, 5);
+       if (ewl_mvc_selected_is(m, 1, 5))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 3 ranges: [(1,2)(6,4)] 
+                                [(1,6)(6,8)]
+                                [(2,5)(6,5)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 6, 4))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 6, 6, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 2);
+       if (!ewl_mvc_is_range(buf, len, sel, 2, 5, 6, 5))
+               return FALSE;
+
+       return TRUE;
 }
 
 static int
 selected_rm_from_range_bottom_edge_point(char *buf, int len)
 {
-       return FALSE;
+       Ewl_Widget *t;
+       Ewl_MVC *m;
+       Ewl_Selection *sel;
+
+       t = ewl_tree2_new();
+       m = EWL_MVC(t);
+
+       ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI);
+       ewl_mvc_selected_range_add(m, 6, 8, 1, 2);
+
+       ewl_mvc_selected_rm(m, 6, 3);
+       if (ewl_mvc_selected_is(m, 6, 3))
+       {
+               snprintf(buf, len, "Index still selected");
+               return FALSE;
+       }
+
+       if (ewl_mvc_selected_count_get(m) != 41)
+       {
+               snprintf(buf, len, "Incorrect number of selected items: %d",
+                                       ewl_mvc_selected_count_get(m));
+               return FALSE;
+       }
+
+       /* should have 3 ranges: [(1,2)(5,8)] 
+                                [(2,6)]
+                                [(6,4)(6,8)] */
+       sel = ecore_list_goto_index(m->selected, 0);
+       if (!ewl_mvc_is_range(buf, len, sel, 1, 2, 5, 8))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 1);
+       if (!ewl_mvc_is_index(buf, len, sel, 6, 2))
+               return FALSE;
+
+       sel = ecore_list_goto_index(m->selected, 2);
+       if (!ewl_mvc_is_range(buf, len, sel, 6, 4, 6, 8))
+               return FALSE;
+
+       return TRUE;
+}
+
+static int
+ewl_mvc_is_index(char *buf, int len, Ewl_Selection *sel, 
+                                       int row, int column)
+{
+       Ewl_Selection_Idx *idx;
+
+       if (sel->type != EWL_SELECTION_TYPE_INDEX)
+       {
+               snprintf(buf, len, "Incorrect selection type");
+               return FALSE;
+       }
+
+       idx = EWL_SELECTION_IDX(sel);
+       if ((idx->row != row) || (idx->column != column))
+       {
+               snprintf(buf, len, "Incorrect indices in index "
+                                       "([%d %d] vs [%d %d])",
+                                       idx->row, idx->column,
+                                       row, column);
+               return FALSE;
+       }
+
+       return TRUE;
 }
 
+static int
+ewl_mvc_is_range(char *buf, int len, Ewl_Selection *sel, 
+                                       int srow, int scolumn,
+                                       int erow, int ecolumn)
+{
+       Ewl_Selection_Range *rng;
+
+       if (sel->type != EWL_SELECTION_TYPE_RANGE)
+       {
+               snprintf(buf, len, "Incorrect selection type");
+               return FALSE;
+       }
+
+       rng = EWL_SELECTION_RANGE(sel);
+       if ((rng->start.row != srow) || (rng->start.column != scolumn))
+       {
+               snprintf(buf, len, "Start row/column incorrect "
+                                       "([%d %d] vs [%d %d])",
+                                       rng->start.row, rng->start.column,
+                                       srow, scolumn);
+               return FALSE;
+       }
+
+       if ((rng->end.row != erow) || (rng->end.column != ecolumn))
+       {
+               snprintf(buf, len, "End row/column incorrect "
+                                       "([%d %d] vs [%d %d])",
+                                       rng->end.row, rng->end.column,
+                                       erow, ecolumn);
+               return FALSE;
+       }
+
+       return TRUE;
+}
 
 



-------------------------------------------------------------------------
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