From: Enlightenment C. <no...@cv...> - 2006-10-18 16:28:41
|
Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin/tests/tree2 Modified Files: ewl_tree2.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/tree2/ewl_tree2.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_tree2.c 17 Oct 2006 05:00:00 -0000 1.1 +++ ewl_tree2.c 18 Oct 2006 16:28:08 -0000 1.2 @@ -35,6 +35,8 @@ static void ewl_tree2_cb_scroll_headers(Ewl_Widget *w, void *ev, void *data); static void ewl_tree2_cb_plain_view(Ewl_Widget *w, void *ev, void *data); static void ewl_tree2_cb_set_rows_clicked(Ewl_Widget *w, void *ev, void *data); +static void tree2_cb_value_changed(Ewl_Widget *w, void *ev, void *data); +static void tree2_cb_select_mode_change(Ewl_Widget *w, void *ev, void *data); void test_info(Ewl_Test *test) @@ -74,7 +76,10 @@ tree = ewl_tree2_new(); ewl_container_child_append(EWL_CONTAINER(box), tree); ewl_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_ALL); + ewl_callback_append(tree, EWL_CALLBACK_VALUE_CHANGED, + tree2_cb_value_changed, NULL); ewl_mvc_data_set(EWL_MVC(tree), data); + ewl_mvc_selection_mode_set(EWL_MVC(tree), EWL_SELECTION_MODE_MULTI); ewl_widget_name_set(tree, "tree"); ewl_widget_show(tree); @@ -134,6 +139,13 @@ ewl_tree2_cb_set_rows_clicked, NULL); ewl_widget_show(o); + o = ewl_button_new(); + ewl_button_label_set(EWL_BUTTON(o), "Row select"); + ewl_container_child_append(EWL_CONTAINER(o2), o); + ewl_callback_append(o, EWL_CALLBACK_CLICKED, + tree2_cb_select_mode_change, NULL); + ewl_widget_show(o); + return 1; } @@ -349,5 +361,59 @@ ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); } +static void +tree2_cb_value_changed(Ewl_Widget *w, void *ev __UNUSED__, + void *data __UNUSED__) +{ + Ecore_List *selected; + Ewl_Selection *sel; + + printf("Selected:\n"); + selected = ewl_mvc_selected_list_get(EWL_MVC(w)); + ecore_list_goto_first(selected); + while ((sel = ecore_list_next(selected))) + { + if (sel->type == EWL_SELECTION_TYPE_INDEX) + { + Ewl_Selection_Idx *idx; + + idx = EWL_SELECTION_IDX(sel); + printf(" %d %d\n", idx->row, idx->column); + } + else + { + Ewl_Selection_Range *idx; + int i, k; + + idx = EWL_SELECTION_RANGE(sel); + for (i = idx->start.row; i <= idx->end.row; i++) + { + for (k = idx->start.column; k <= + idx->end.column; k++) + printf(" %d %d\n", i, k); + } + } + } +} + +static void +tree2_cb_select_mode_change(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, + void *data __UNUSED__) +{ + Ewl_Widget *tree; + tree = ewl_widget_name_find("tree"); + if (!strcmp(ewl_button_label_get(EWL_BUTTON(w)), "Row select")) + { + ewl_button_label_set(EWL_BUTTON(w), "Cell select"); + ewl_tree2_selection_type_set(EWL_TREE2(tree), + EWL_TREE_SELECTION_TYPE_ROW); + } + else + { + ewl_button_label_set(EWL_BUTTON(w), "Row select"); + ewl_tree2_selection_type_set(EWL_TREE2(tree), + EWL_TREE_SELECTION_TYPE_CELL); + } +} |