Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: Ewl.h Makefile.am ewl_combo.c ewl_combo.h ewl_filepicker.c ewl_list.c ewl_list.h ewl_tree2.c ewl_tree2.h Added Files: ewl_mvc.c ewl_mvc.h Log Message: - create an ewl_mvc widget. this inherits from ewl_box and provides all of the common mvc calls. - make ewl_combo, ewl_list and ewl_tree2 inherit from ewl_mvc and remove all the duplicated calls. - This breaks the API. All of the ewl_*_model_set, ewl_*_view_set, ewl_*_data_set and ewl_*_dirty_set are now ewl_mvc_*_set. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- Ewl.h 14 Sep 2006 05:35:38 -0000 1.12 +++ Ewl.h 24 Sep 2006 20:26:50 -0000 1.13 @@ -270,6 +270,7 @@ #include <ewl_misc.h> #include <ewl_box.h> +#include <ewl_mvc.h> #include <ewl_freebox.h> #include <ewl_border.h> =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- Makefile.am 14 Sep 2006 05:35:38 -0000 1.35 +++ Makefile.am 24 Sep 2006 20:26:50 -0000 1.36 @@ -60,6 +60,7 @@ ewl_menu_item.h \ ewl_misc.h \ ewl_model.h \ + ewl_mvc.h \ ewl_notebook.h \ ewl_object.h \ ewl_overlay.h \ @@ -137,6 +138,7 @@ ewl_menu_item.c \ ewl_misc.c \ ewl_model.c \ + ewl_mvc.c \ ewl_notebook.c \ ewl_object.c \ ewl_overlay.c \ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_combo.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ewl_combo.c 11 Sep 2006 05:04:10 -0000 1.30 +++ ewl_combo.c 24 Sep 2006 20:26:50 -0000 1.31 @@ -39,7 +39,7 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("combo", combo, FALSE); - if (!ewl_box_init(EWL_BOX(combo))) + if (!ewl_mvc_init(EWL_MVC(combo))) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_inherit(EWL_WIDGET(combo), EWL_COMBO_TYPE); @@ -92,10 +92,18 @@ void ewl_combo_selected_set(Ewl_Combo *combo, int idx) { + Ewl_View *view; + Ewl_Model *model; + void *mvc_data; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("combo", combo); DCHECK_TYPE("combo", combo, EWL_COMBO_TYPE); + view = ewl_mvc_view_get(EWL_MVC(combo)); + model = ewl_mvc_model_get(EWL_MVC(combo)); + mvc_data = ewl_mvc_data_get(EWL_MVC(combo)); + /* we don't bail out early as the user could have prepended widgets * to their data, so the selected_idx will be the same but the * widget is actually different */ @@ -109,12 +117,12 @@ * the header */ if ((idx > -1) && (!combo->editable)) { - combo->selected = combo->view->construct(); - combo->view->assign(combo->selected, - combo->model->fetch(combo->data, idx, 0)); + combo->selected = view->construct(); + view->assign(combo->selected, + model->fetch(mvc_data, idx, 0)); } - else if (combo->view && combo->view->header_fetch) - combo->selected = combo->view->header_fetch(combo->data, + else if (view && view->header_fetch) + combo->selected = view->header_fetch(mvc_data, combo->selected_idx); if (combo->selected) @@ -145,145 +153,6 @@ } /** - * @param combo: The Ewl_Combo to work with - * @param model: The Ewl_Model to set into the combo - * @return Returns no value. - * @brief Associates the given model with the combo - */ -void -ewl_combo_model_set(Ewl_Combo *combo, Ewl_Model *model) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("combo", combo); - DCHECK_PARAM_PTR("model", model); - DCHECK_TYPE("combo", combo, EWL_COMBO_TYPE); - - combo->model = model; - ewl_combo_dirty_set(combo, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to get the model from - * @return Returns the model currently set into this combo - * @brief Retrieves the model set into the combo box - */ -Ewl_Model * -ewl_combo_model_get(Ewl_Combo *combo) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("combo", combo, NULL); - DCHECK_TYPE_RET("combo", combo, EWL_COMBO_TYPE, NULL); - - DRETURN_PTR(combo->model, DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to set the view into - * @param view: The Ewl_View to set into the combo - * @return Returns no value. - * @brief Set the view for the combo to @a view - */ -void -ewl_combo_view_set(Ewl_Combo *combo, Ewl_View *view) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("combo", combo); - DCHECK_PARAM_PTR("view", view); - DCHECK_TYPE("combo", combo, EWL_COMBO_TYPE); - - combo->view = view; - ewl_combo_dirty_set(combo, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to use. - * @return Returns the view currently set in the combo - * @brief Retrieves the view currently set into the combo - */ -Ewl_View * -ewl_combo_view_get(Ewl_Combo *combo) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("combo", combo, NULL); - DCHECK_TYPE_RET("combo", combo, EWL_COMBO_TYPE, NULL); - - DRETURN_PTR(combo->view, DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to work with - * @param data: The data to set into the combo - * @return Returns no value. - * @brief This sets the data for the combo into the combo itself. - */ -void -ewl_combo_data_set(Ewl_Combo *combo, void *data) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("combo", combo); - DCHECK_PARAM_PTR("data", data); - DCHECK_TYPE("combo", combo, EWL_COMBO_TYPE); - - combo->data = data; - ewl_combo_dirty_set(combo, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to get the data from - * @return Returns the data set into the combo - * @brief This returns the data used in the combo - */ -void * -ewl_combo_data_get(Ewl_Combo *combo) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("combo", combo, NULL); - DCHECK_TYPE_RET("combo", combo, EWL_COMBO_TYPE, NULL); - - DRETURN_PTR(combo->data, DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to work with - * @param dirty: Set to TRUE if the data in the combo has changed - * @return Returns no value - * @brief Setting this to TRUE tells the combo that it's data has changed - * and it will need to re-create it's drop down. - */ -void -ewl_combo_dirty_set(Ewl_Combo *combo, unsigned int dirty) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("combo", combo); - DCHECK_TYPE("combo", combo, EWL_COMBO_TYPE); - - combo->dirty = !!dirty; - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param combo: The Ewl_Combo to use - * @return Returns the dirty status of the combo - * @brief Returns if the combo is currently dirty or not - */ -unsigned int -ewl_combo_dirty_get(Ewl_Combo *combo) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("combo", combo, FALSE); - DCHECK_TYPE_RET("combo", combo, EWL_COMBO_TYPE, FALSE); - - DRETURN_INT(combo->dirty, DLEVEL_STABLE); -} - -/** * @param combo: The Ewl_Combo to use * @param editable: Set if the combo is editable or not * @return Returns no value @@ -371,15 +240,21 @@ ewl_combo_cb_decrement_clicked(Ewl_Widget *w __UNUSED__, void *ev, void *data) { Ewl_Combo *combo; + Ewl_Model *model; + Ewl_View *view; + void *mvc_data; int i; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("data", data); combo = data; + model = ewl_mvc_model_get(EWL_MVC(combo)); + view = ewl_mvc_view_get(EWL_MVC(combo)); + mvc_data = ewl_mvc_data_get(EWL_MVC(combo)); /* nothing to do if we have no model/view or data */ - if ((!combo->model) || (!combo->view)) + if (!model || !view) DRETURN(DLEVEL_STABLE); /* XXX put checks to make sure all the needed module and view @@ -401,24 +276,23 @@ combo->popup->popup); } - if (!combo->dirty) + if (!ewl_mvc_dirty_get(EWL_MVC(combo))) DRETURN(DLEVEL_STABLE); ewl_container_reset(EWL_CONTAINER(combo->popup)); - for (i = 0; i < combo->model->count(combo->data); i++) + for (i = 0; i < model->count(mvc_data); i++) { Ewl_Widget *item; - item = combo->view->construct(); - combo->view->assign(item, - combo->model->fetch(combo->data, i, 0)); + item = view->construct(); + view->assign(item, model->fetch(mvc_data, i, 0)); ewl_container_child_append(EWL_CONTAINER(combo->popup), item); ewl_callback_append(item, EWL_CALLBACK_CLICKED, ewl_combo_cb_item_clicked, combo); ewl_widget_show(item); } - combo->dirty = 0; + ewl_mvc_dirty_set(EWL_MVC(combo), FALSE); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_combo.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ewl_combo.h 15 Mar 2006 04:03:48 -0000 1.14 +++ ewl_combo.h 24 Sep 2006 20:26:50 -0000 1.15 @@ -33,23 +33,18 @@ #define EWL_COMBO(combo) ((Ewl_Combo *) combo) /** - * Inherits from the Ewl_Menu_Base and does not extend the structure, but - * provides policy for drawing on the current evas. + * Inherits from the Ewl_MVC widget */ struct Ewl_Combo { - Ewl_Box box; /**< Inherit from box */ + Ewl_MVC mvc; /**< Inherit from Ewl_MVC */ + Ewl_Menu_Base *popup; /**< Use a menu to display with. */ Ewl_Widget *button; /**< expand/contract button */ Ewl_Widget *selected; /**< Selected widget */ int selected_idx; /**< The selected row */ - Ewl_Model *model; /**< The model for the combo */ - Ewl_View *view; /**< The view for the combo */ - - void *data; /**< The data for the combo */ - unsigned char dirty:1; /**< The combo's data is dirty */ unsigned char editable:1; /**< Is the combo editable */ }; @@ -58,18 +53,6 @@ int ewl_combo_selected_get(Ewl_Combo *combo); void ewl_combo_selected_set(Ewl_Combo *combo, int); - -void ewl_combo_model_set(Ewl_Combo *combo, Ewl_Model *model); -Ewl_Model *ewl_combo_model_get(Ewl_Combo *combo); - -void ewl_combo_view_set(Ewl_Combo *combo, Ewl_View *view); -Ewl_View *ewl_combo_view_get(Ewl_Combo *combo); - -void ewl_combo_data_set(Ewl_Combo *combo, void *data); -void *ewl_combo_data_get(Ewl_Combo *combo); - -void ewl_combo_dirty_set(Ewl_Combo *combo, unsigned int dirty); -unsigned int ewl_combo_dirty_get(Ewl_Combo *combo); void ewl_combo_editable_set(Ewl_Combo *combo, unsigned int editable); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filepicker.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_filepicker.c 27 Apr 2006 02:59:43 -0000 1.10 +++ ewl_filepicker.c 24 Sep 2006 20:26:50 -0000 1.11 @@ -91,9 +91,9 @@ fp->path_combo = ewl_combo_new(); ewl_container_child_append(EWL_CONTAINER(fp), fp->path_combo); - ewl_combo_model_set(EWL_COMBO(fp->path_combo), model); - ewl_combo_view_set(EWL_COMBO(fp->path_combo), view); - ewl_combo_data_set(EWL_COMBO(fp->path_combo), fp->path); + ewl_mvc_model_set(EWL_MVC(fp->path_combo), model); + ewl_mvc_view_set(EWL_MVC(fp->path_combo), view); + ewl_mvc_data_set(EWL_MVC(fp->path_combo), fp->path); ewl_callback_append(fp->path_combo, EWL_CALLBACK_VALUE_CHANGED, ewl_filepicker_cb_path_change, fp); ewl_widget_show(fp->path_combo); @@ -141,9 +141,9 @@ ewl_view_header_fetch_set(view, ewl_filepicker_cb_type_header); fp->type_combo = ewl_combo_new(); - ewl_combo_model_set(EWL_COMBO(fp->type_combo), model); - ewl_combo_view_set(EWL_COMBO(fp->type_combo), view); - ewl_combo_data_set(EWL_COMBO(fp->type_combo), fp); + ewl_mvc_model_set(EWL_MVC(fp->type_combo), model); + ewl_mvc_view_set(EWL_MVC(fp->type_combo), view); + ewl_mvc_data_set(EWL_MVC(fp->type_combo), fp); ewl_combo_selected_set(EWL_COMBO(fp->type_combo), 0); ewl_combo_editable_set(EWL_COMBO(fp->type_combo), TRUE); ewl_callback_append(fp->type_combo, EWL_CALLBACK_VALUE_CHANGED, @@ -711,7 +711,7 @@ if (p && (*(p + 1) != '\0')) ecore_list_prepend(fp->path, strdup(path)); - ewl_combo_dirty_set(EWL_COMBO(fp->path_combo), TRUE); + ewl_mvc_dirty_set(EWL_MVC(fp->path_combo), TRUE); ewl_combo_selected_set(EWL_COMBO(fp->path_combo), 0); DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_list.c 2 Aug 2006 00:44:32 -0000 1.5 +++ ewl_list.c 24 Sep 2006 20:26:50 -0000 1.6 @@ -38,14 +38,12 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("list", list, FALSE); - if (!ewl_box_init(EWL_BOX(list))) + if (!ewl_mvc_init(EWL_MVC(list))) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(EWL_WIDGET(list), EWL_LIST_TYPE); ewl_widget_inherit(EWL_WIDGET(list), EWL_LIST_TYPE); - ewl_box_orientation_set(EWL_BOX(list), EWL_ORIENTATION_VERTICAL); - ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_CONFIGURE, ewl_list_cb_configure, NULL); @@ -57,143 +55,6 @@ } /** - * @param list: The Ewl_List to set the model into - * @param model: The model to set into the list - * @return Returns no value - * @brief Sets the model to be used for the list - */ -void -ewl_list_model_set(Ewl_List *list, Ewl_Model *model) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("list", list); - DCHECK_PARAM_PTR("model", model); - DCHECK_TYPE("list", list, EWL_LIST_TYPE); - - list->model = model; - ewl_list_dirty_set(list, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param list: The list to retrieve the model from - * @return Returns the Ewl_Model associated with the list or NULL if none set - * @brief Retrieves the Ewl_Model associated with the list or NULL if none set - */ -Ewl_Model * -ewl_list_model_get(Ewl_List *list) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("list", list, NULL); - DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, NULL); - - DRETURN_PTR(list->model, DLEVEL_STABLE); -} - -/** - * @param list: The list to set the view on - * @param view: The view to set into the list - * @return Returns no value - * @brief Sets the view @a view into the list @a list - */ -void -ewl_list_view_set(Ewl_List *list, Ewl_View *view) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("list", list); - DCHECK_TYPE("list", list, EWL_LIST_TYPE); - - list->view = view; - ewl_list_dirty_set(list, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param list: The list to get the view from - * @return Returns the Ewl_View set on the list or NULL if none set - * @brief Retrieves the Ewl_View set on the list or NULL if none set - */ -Ewl_View * -ewl_list_view_get(Ewl_List *list) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("list", list, NULL); - DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, NULL); - - DRETURN_PTR(list->view, DLEVEL_STABLE); -} - -/** - * @param list: The list to set the data into - * @param data: The data to set into the list - * @return Returns no value - * @brief Sets the given data into the list - */ -void -ewl_list_data_set(Ewl_List *list, void *data) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("list", list); - DCHECK_TYPE("list", list, EWL_LIST_TYPE); - - list->data = data; - ewl_list_dirty_set(list, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param list: The list to get the data from - * @return Returns the data set into the list or NULL if none set - * @brief Retrieves the data set into the list or NULL if none set - */ -void * -ewl_list_data_get(Ewl_List *list) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("list", list, NULL); - DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, NULL); - - DRETURN_PTR(list->data, DLEVEL_STABLE); -} - -/** - * @param list: The list to set the dirty flag of - * @param dirty: The dirty flag to set - * @return Returns no value - * @brief Sets the dirty status of the list @a list to @a dirty - */ -void -ewl_list_dirty_set(Ewl_List *list, unsigned int dirty) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("list", list); - DCHECK_TYPE("list", list, EWL_LIST_TYPE); - - list->dirty = dirty; - ewl_widget_configure(EWL_WIDGET(list)); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param list: The list to retrieve the dirty flag from - * @return Returns the dirty flag of the list - * @brief Retrieves the dirty flag from the list - */ -unsigned int -ewl_list_dirty_get(Ewl_List *list) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("list", list, 0); - DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, 0); - - DRETURN_INT(list->dirty, DLEVEL_STABLE); -} - -/** * @param list: The list to work with * @param w: The widget to set selected * @return Returns no value @@ -293,6 +154,9 @@ void *data __UNUSED__) { Ewl_List *list; + Ewl_Model *model; + Ewl_View *view; + void *mvc_data; int i; DENTER_FUNCTION(DLEVEL_STABLE); @@ -301,25 +165,30 @@ list = EWL_LIST(w); + model = ewl_mvc_model_get(EWL_MVC(list)); + view = ewl_mvc_view_get(EWL_MVC(list)); + mvc_data = ewl_mvc_data_get(EWL_MVC(list)); + /* if either the list isn't dirty or some of the MVC controls have * not been set on the list just leave this up to the box to handle */ - if ((!ewl_list_dirty_get(list)) || !list->model || !list->view || !list->data) + if ((!ewl_mvc_dirty_get(EWL_MVC(list))) + || !model || !view || !mvc_data) DRETURN(DLEVEL_STABLE); /* create all the widgets and pack into the container */ ewl_container_reset(EWL_CONTAINER(list)); - for (i = 0; i < list->model->count(list->data); i++) + for (i = 0; i < model->count(mvc_data); i++) { Ewl_Widget *o; - o = list->view->construct(); - list->view->assign(o, list->model->fetch(list->data, i, 0)); + o = view->construct(); + view->assign(o, model->fetch(mvc_data, i, 0)); ewl_widget_show(o); ewl_container_child_append(EWL_CONTAINER(list), o); } - ewl_list_dirty_set(list, FALSE); + ewl_mvc_dirty_set(EWL_MVC(list), FALSE); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_list.h 2 Aug 2006 00:44:32 -0000 1.5 +++ ewl_list.h 24 Sep 2006 20:26:50 -0000 1.6 @@ -26,34 +26,17 @@ typedef struct Ewl_List Ewl_List; /** - * Inherits from Ewl_Box and extends to provide a list widget + * Inherits from Ewl_MVC and extends to provide a list widget */ struct Ewl_List { - Ewl_Box box; /**< The box parent */ - - Ewl_Model *model; /**< The model for the list */ - Ewl_View *view; /**< The view for the list */ - void *data; /**< The data for the list */ + Ewl_MVC mvc; /**< The mvc parent */ Ewl_Widget *selected; /**< The selected widget */ - unsigned char dirty:1; /**< Has the model changed? */ }; Ewl_Widget *ewl_list_new(void); int ewl_list_init(Ewl_List *list); - -void ewl_list_model_set(Ewl_List *list, Ewl_Model *model); -Ewl_Model *ewl_list_model_get(Ewl_List *list); - -void ewl_list_view_set(Ewl_List *list, Ewl_View *view); -Ewl_View *ewl_list_view_get(Ewl_List *list); - -void ewl_list_data_set(Ewl_List *list, void *data); -void *ewl_list_data_get(Ewl_List *list); - -void ewl_list_dirty_set(Ewl_List *list, unsigned int dirty); -unsigned int ewl_list_dirty_get(Ewl_List *list); void ewl_list_selected_widget_set(Ewl_List *list, Ewl_Widget *w); Ewl_Widget *ewl_list_selected_widget_get(Ewl_List *list); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- ewl_tree2.c 22 Aug 2006 21:41:45 -0000 1.31 +++ ewl_tree2.c 24 Sep 2006 20:26:50 -0000 1.32 @@ -3,6 +3,7 @@ #include "ewl_debug.h" #include "ewl_macros.h" +static void ewl_tree2_cb_view_change(Ewl_MVC *mvc); static void ewl_tree2_build_tree(Ewl_Tree2 *tree); static void ewl_tree2_cb_column_free(void *data); static void ewl_tree2_cb_header_changed(Ewl_Widget *w, void *ev, @@ -45,13 +46,12 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("tree", tree, FALSE); - if (!ewl_box_init(EWL_BOX(tree))) + if (!ewl_mvc_init(EWL_MVC(tree))) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(EWL_WIDGET(tree), EWL_TREE2_TYPE); ewl_widget_inherit(EWL_WIDGET(tree), EWL_TREE2_TYPE); - ewl_box_orientation_set(EWL_BOX(tree), EWL_ORIENTATION_VERTICAL); ewl_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_SHRINK | EWL_FLAG_FILL_FILL); @@ -69,7 +69,8 @@ ewl_widget_show(tree->header); /* set the default row view */ - ewl_tree2_view_set(tree, ewl_tree2_view_scrolled_get()); + ewl_mvc_view_change_cb_set(EWL_MVC(tree), ewl_tree2_cb_view_change); + ewl_mvc_view_set(EWL_MVC(tree), ewl_tree2_view_scrolled_get()); ewl_tree2_headers_visible_set(tree, TRUE); ewl_tree2_fixed_rows_set(tree, FALSE); @@ -80,94 +81,11 @@ ewl_tree2_cb_destroy, NULL); ewl_widget_focusable_set(EWL_WIDGET(tree), FALSE); - ewl_tree2_dirty_set(tree, TRUE); DRETURN_INT(TRUE, DLEVEL_STABLE); } /** - * @param t: The tree to work with - * @param view: The view to set on the tree - * @return Returns no value - * @brief Sets the current view of the tree rows - */ -void -ewl_tree2_view_set(Ewl_Tree2 *t, Ewl_View *view) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("t", t); - DCHECK_PARAM_PTR("view", view); - DCHECK_TYPE("t", t, EWL_TREE2_TYPE); - - if (t->view == view) - DRETURN(DLEVEL_STABLE); - - t->view = view; - - /* destroy the old view, create a new one and redisplay the tree */ - if (t->rows) ewl_widget_destroy(t->rows); - - t->rows = view->construct(); - ewl_tree2_view_tree2_set(EWL_TREE2_VIEW(t->rows), t); - ewl_container_child_append(EWL_CONTAINER(t), t->rows); - ewl_widget_show(t->rows); - - ewl_tree2_dirty_set(t, TRUE); - ewl_widget_configure(EWL_WIDGET(t)); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param t: The tree to work with - * @return Returns the current view set on the tree - * @brief Retrieves the current view used for the tree - */ -Ewl_View * -ewl_tree2_view_get(Ewl_Tree2 *t) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("t", t, NULL); - DCHECK_TYPE_RET("t", t, EWL_TREE2_TYPE, NULL); - - DRETURN_PTR(t->view, DLEVEL_STABLE); -} - -/** - * @param tree: The Ewl_Tree to set the data into - * @param data: The data to set into the tree - * @return Returns no value. - * @brief Set the data into the tree - */ -void -ewl_tree2_data_set(Ewl_Tree2 *tree, void *data) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("tree", tree); - DCHECK_TYPE("tree", tree, EWL_TREE2_TYPE); - - tree->data = data; - ewl_tree2_dirty_set(tree, TRUE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param tree: The Ewl_Tree to get the data from - * @return Returns the data currently set into the tree or NULL on failure - * @brief Get the data out of the tree - */ -void * -ewl_tree2_data_get(Ewl_Tree2 *tree) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("tree", tree, NULL); - DCHECK_TYPE_RET("tree", tree, EWL_TREE2_TYPE, NULL); - - DRETURN_PTR(tree->data, DLEVEL_STABLE); -} - -/** * @param tree: The Ewl_Tree to append the column too * @param model: The model to use for this column * @param view: The view to use for this column @@ -194,10 +112,10 @@ ewl_tree2_column_model_set(c, model); ewl_tree2_column_view_set(c, view); - ewl_tree2_column_tree_set(c, tree); + ewl_tree2_column_mvc_set(c, EWL_MVC(tree)); ecore_list_append(tree->columns, c); - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -229,10 +147,10 @@ ewl_tree2_column_model_set(c, model); ewl_tree2_column_view_set(c, view); - ewl_tree2_column_tree_set(c, tree); + ewl_tree2_column_mvc_set(c, EWL_MVC(tree)); ecore_list_prepend(tree->columns, c); - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -266,11 +184,11 @@ ewl_tree2_column_model_set(c, model); ewl_tree2_column_view_set(c, view); - ewl_tree2_column_tree_set(c, tree); + ewl_tree2_column_mvc_set(c, EWL_MVC(tree)); ecore_list_goto_index(tree->columns, idx); ecore_list_insert(tree->columns, c); - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -294,7 +212,7 @@ c = ecore_list_remove(tree->columns); ewl_tree2_column_destroy(c); - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -322,7 +240,7 @@ else ewl_widget_show(tree->header); - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -439,7 +357,7 @@ DCHECK_TYPE("tree", tree, EWL_TREE2_TYPE); tree->fixed = fixed; - ewl_tree2_dirty_set(tree, TRUE); + ewl_mvc_dirty_set(EWL_MVC(tree), TRUE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -460,44 +378,10 @@ } /** - * @param tree2: The Ewl_Tree2 to work with - * @param dirty: Set to TRUE if the data in the tree has changed - * @return Returns no value - * @brief Setting this to TRUE tells the tree that it's data has changed - * and it will need to re-create its contents + * @param tree: The tree to work with + * @return Returns the widget that contains the tree rows + * @brief Retrieves the widget containing the tree rows */ -void -ewl_tree2_dirty_set(Ewl_Tree2 *tree2, unsigned int dirty) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("tree2", tree2); - DCHECK_TYPE("tree2", tree2, EWL_TREE2_TYPE); - - if (tree2->dirty == dirty) - DRETURN(DLEVEL_STABLE); - - tree2->dirty = !!dirty; - - ewl_widget_configure(EWL_WIDGET(tree2)); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param tree2: The Ewl_Tree2 to use - * @return Returns the dirty status of the tree - * @brief Returns if the tree is currently dirty or not - */ -unsigned int -ewl_tree2_dirty_get(Ewl_Tree2 *tree2) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("tree2", tree2, FALSE); - DCHECK_TYPE_RET("tree2", tree2, EWL_TREE2_TYPE, FALSE); - - DRETURN_INT(tree2->dirty, DLEVEL_STABLE); -} - Ewl_Widget * ewl_tree2_view_widget_get(Ewl_Tree2 *tree) { @@ -554,11 +438,11 @@ tree = EWL_TREE2(w); /* if the tree isn't dirty we're done */ - if (!ewl_tree2_dirty_get(tree)) + if (!ewl_mvc_dirty_get(EWL_MVC(tree))) DRETURN(DLEVEL_STABLE); ewl_tree2_build_tree(tree); - ewl_tree2_dirty_set(tree, FALSE); + ewl_mvc_dirty_set(EWL_MVC(tree), FALSE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -591,14 +475,14 @@ } /* loop over the columns and reset the sort settings */ - ecore_list_goto_first(c->parent->columns); - while ((col = ecore_list_next(c->parent->columns))) + ecore_list_goto_first(EWL_TREE2(c->parent)->columns); + while ((col = ecore_list_next(EWL_TREE2(c->parent)->columns))) { /* skip the current column */ if (col == c) { /* we're the index before the one we're now on */ - index = ecore_list_index(c->parent->columns) - 1; + index = ecore_list_index(EWL_TREE2(c->parent)->columns) - 1; continue; } @@ -610,11 +494,32 @@ c->sort = ((c->sort + 1) % EWL_SORT_DIRECTION_MAX); if (!c->sort) c->sort ++; - c->model->sort(c->parent->data, index, c->sort); + c->model->sort(ewl_mvc_data_get(c->parent), index, c->sort); + ewl_mvc_dirty_set(c->parent, TRUE); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +static void +ewl_tree2_cb_view_change(Ewl_MVC *mvc) +{ + Ewl_View *view; + Ewl_Tree2 *t; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("mvc", mvc); + DCHECK_TYPE("mvc", mvc, EWL_TREE2_TYPE); - /* force the tree to redraw */ - ewl_tree2_dirty_set(c->parent, TRUE); - ewl_widget_configure(EWL_WIDGET(c->parent)); + t = EWL_TREE2(mvc); + view = ewl_mvc_view_get(mvc); + + /* destroy the old view, create a new one and redisplay the tree */ + if (t->rows) ewl_widget_destroy(t->rows); + + t->rows = view->construct(); + ewl_tree2_view_tree2_set(EWL_TREE2_VIEW(t->rows), t); + ewl_container_child_append(EWL_CONTAINER(t), t->rows); + ewl_widget_show(t->rows); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -624,11 +529,14 @@ { Ewl_Tree2_Column *col; int column = 0, rows = 0, i; + void *mvc_data; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("tree", tree); DCHECK_TYPE("tree", tree, EWL_TREE2_TYPE); + mvc_data = ewl_mvc_data_get(EWL_MVC(tree)); + /* setup the headers */ ewl_container_reset(EWL_CONTAINER(tree->header)); ecore_list_goto_first(tree->columns); @@ -647,7 +555,7 @@ ewl_callback_append(h, EWL_CALLBACK_CLICKED, ewl_tree2_cb_column_sort, col); - c = col->view->header_fetch(tree->data, column); + c = col->view->header_fetch(mvc_data, column); ewl_object_fill_policy_set(EWL_OBJECT(c), EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_HFILL); ewl_container_child_append(EWL_CONTAINER(h), c); @@ -672,7 +580,7 @@ ewl_widget_show(c); } - r = col->model->count(tree->data); + r = col->model->count(mvc_data); if (r > rows) rows = r; column ++; @@ -708,7 +616,7 @@ ewl_container_child_append(EWL_CONTAINER(row), cell); ewl_widget_show(cell); - val = col->model->fetch(tree->data, i, column); + val = col->model->fetch(mvc_data, i, column); if (!val) { child = ewl_label_new(); @@ -864,19 +772,19 @@ /** * @param c: The Ewl_Tree2_Column to work with - * @param tree: The parent to set + * @param mvc: The parent to set * @return Returns no value - * @brief Sets @a tree as the parent of the column @a c + * @brief Sets @a mvc as the parent of the column @a c */ void -ewl_tree2_column_tree_set(Ewl_Tree2_Column *c, Ewl_Tree2 *tree) +ewl_tree2_column_mvc_set(Ewl_Tree2_Column *c, Ewl_MVC *mvc) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("c", c); - DCHECK_PARAM_PTR("tree", tree); - DCHECK_TYPE("tree", tree, EWL_TREE2_TYPE); + DCHECK_PARAM_PTR("mvc", mvc); + DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE); - c->parent = tree; + c->parent = mvc; DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- ewl_tree2.h 22 Aug 2006 21:43:34 -0000 1.29 +++ ewl_tree2.h 24 Sep 2006 20:26:50 -0000 1.30 @@ -82,14 +82,12 @@ */ struct Ewl_Tree2 { - Ewl_Box box; /**< Inherit from ewl_box. */ + Ewl_MVC mvc; /**< Inherit from ewl_mvc. */ Ewl_Widget *header; /**< The tree header */ Ewl_Widget *rows; /**< The rows of the tree */ - Ewl_View *view; /**< Holds the view of the tree */ Ecore_List *columns; /**< The tree columns. */ - void *data; /**< Data provided to the tree */ int *rowcache; /**< Cache of row sizes */ Ecore_List *selected; /**< The list of selected cells */ @@ -98,7 +96,6 @@ unsigned char fixed:1; /**< Rows are fixed height */ unsigned char headers_visible:1; /**< Are the headers visible? */ - unsigned char dirty:1; /**< Has the data changed? */ }; /** @@ -120,7 +117,7 @@ Ewl_Model *model; /**< The model for the column */ Ewl_View *view; /**< The view for the column */ - Ewl_Tree2 *parent; /**< The tree this column is for */ + Ewl_MVC *parent; /**< The mvc this column is for */ Ewl_Sort_Direction sort; /**< direction the column is sorted in */ }; @@ -130,12 +127,6 @@ Ewl_Widget *ewl_tree2_new(void); int ewl_tree2_init(Ewl_Tree2 *tree); -void ewl_tree2_view_set(Ewl_Tree2 *t, Ewl_View *view); -Ewl_View *ewl_tree2_view_get(Ewl_Tree2 *t); - -void ewl_tree2_data_set(Ewl_Tree2 *m, void *data); -void *ewl_tree2_data_get(Ewl_Tree2 *m); - void ewl_tree2_column_append(Ewl_Tree2 *t, Ewl_Model *m, Ewl_View *v); void ewl_tree2_column_prepend(Ewl_Tree2 *t, Ewl_Model *m, @@ -158,9 +149,6 @@ void ewl_tree2_fixed_rows_set(Ewl_Tree2 *tree, unsigned int fixed); unsigned int ewl_tree2_fixed_rows_get(Ewl_Tree2 *tree); -void ewl_tree2_dirty_set(Ewl_Tree2 *tree2, unsigned int dirty); -unsigned int ewl_tree2_dirty_get(Ewl_Tree2 *tree2); - Ewl_Widget *ewl_tree2_view_widget_get(Ewl_Tree2 *tree); /* @@ -182,8 +170,8 @@ void ewl_tree2_column_view_set(Ewl_Tree2_Column *c, Ewl_View *v); Ewl_View *ewl_tree2_column_view_get(Ewl_Tree2_Column *c); -void ewl_tree2_column_tree_set(Ewl_Tree2_Column *c, Ewl_Tree2 *tree); -Ewl_Tree2 *ewl_tree2_column_tree_get(Ewl_Tree2_Column *c); +void ewl_tree2_column_mvc_set(Ewl_Tree2_Column *c, Ewl_MVC *mvc); +Ewl_MVC *ewl_tree2_column_mvc_get(Ewl_Tree2_Column *c); void ewl_tree2_column_sort_direction_set(Ewl_Tree2_Column *c, Ewl_Sort_Direction sort); ------------------------------------------------------------------------- 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