Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_model.c ewl_model.h ewl_tree2.c 


Log Message:
- add a highlight callback to the models. 
  - for tree2 you can now specify if a row is to be highlighted on mouse_in.
  - Note, this API may change in the future to be row/cell based depending on
    the tree selection mode.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_model.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_model.c 29 Mar 2007 23:16:01 -0000      1.19
+++ ewl_model.c 1 Apr 2007 17:03:08 -0000       1.20
@@ -187,6 +187,37 @@
 }
 
 /**
+ * @param m: The Ewl_Model to set the callback on
+ * @param highlight: The highlight callback to set on the model
+ * @return Returns no value
+ * @brief Sets the @a highlight callback into the model @a m
+ */
+void
+ewl_model_data_highlight_set(Ewl_Model *m, Ewl_Model_Data_Highlight highlight)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("m", m);
+
+       m->highlight = highlight;
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param m: The model to work with
+ * @return Returns the highlight model set in the model
+ * @brief Retrieves the highlight model set in @a m
+ */
+Ewl_Model_Data_Highlight
+ewl_model_data_highlight_get(Ewl_Model *m)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("m", m, NULL);
+
+       DRETURN_PTR(m->highlight, DLEVEL_STABLE);
+}
+
+/**
  * @param m: The Ewl_Model to set the count callback on
  * @param count: The count callback to set on the model
  * @return Returns no value.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_model.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ewl_model.h 29 Mar 2007 23:16:01 -0000      1.24
+++ ewl_model.h 1 Apr 2007 17:03:08 -0000       1.25
@@ -122,6 +122,18 @@
 typedef int (*Ewl_Model_Column_Sortable)(void *data, unsigned int col);
 
 /**
+ * @def EWL_MODEL_DATA_HIGHLIGHT(f)
+ * Model callback to check if a cell is to be highlighted
+ */
+#define EWL_MODEL_DATA_HIGHLIGHT(f) ((Ewl_Model_Data_Highlight)f)
+
+/**
+ * A typedef to shorten the definition of the data_highlight callbacks.
+ */
+typedef unsigned int (*Ewl_Model_Data_Highlight)(void *data, unsigned int row);
+                                               
+
+/**
  * @def EWL_MODEL(model)
  * Typecasts a pointer to an Ewl_Model pointer.
  */
@@ -146,6 +158,7 @@
        Ewl_Model_Data_Free data_free; /**< Free data passed to view */
        Ewl_Model_Data_Count count;    /**< Count of data items */
        Ewl_Model_Data_Sort sort;      /**< Trigger sort on column */
+       Ewl_Model_Data_Highlight highlight; /**< Highlight the cell */
 };
 
 Ewl_Model              *ewl_model_new(void);
@@ -172,6 +185,10 @@
 void                    ewl_model_data_sort_set(Ewl_Model *m, 
                                        Ewl_Model_Data_Sort sort);
 Ewl_Model_Data_Sort     ewl_model_data_sort_get(Ewl_Model *m);
+
+void                    ewl_model_data_highlight_set(Ewl_Model *m,
+                                       Ewl_Model_Data_Highlight highlight);
+Ewl_Model_Data_Highlight ewl_model_data_highlight_get(Ewl_Model *m);
 
 void                    ewl_model_data_count_set(Ewl_Model *m, 
                                        Ewl_Model_Data_Count count);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -3 -r1.74 -r1.75
--- ewl_tree2.c 29 Mar 2007 23:16:01 -0000      1.74
+++ ewl_tree2.c 1 Apr 2007 17:03:08 -0000       1.75
@@ -5,6 +5,7 @@
 #include "ewl_cell.h"
 #include "ewl_check.h"
 #include "ewl_expansion.h"
+#include "ewl_highlight.h"
 #include "ewl_label.h"
 #include "ewl_paned.h"
 #include "ewl_row.h"
@@ -22,6 +23,8 @@
                                                        void *data);
 
 static void ewl_tree2_cb_row_clicked(Ewl_Widget *w, void *ev, void *data);
+static void ewl_tree2_cb_row_highlight(Ewl_Widget *w, void *ev, void *data);
+static void ewl_tree2_cb_row_unhighlight(Ewl_Widget *w, void *ev, void *data);
 static void ewl_tree2_cb_cell_clicked(Ewl_Widget *w, void *ev, void *data);
 static void ewl_tree2_cb_selected_change(Ewl_MVC *mvc);
 static Ewl_Widget *ewl_tree2_widget_at(Ewl_MVC *mvc, void *data, 
@@ -711,6 +714,11 @@
                ewl_container_child_append(EWL_CONTAINER(node), row);
                ewl_callback_append(row, EWL_CALLBACK_CLICKED,  
                                        ewl_tree2_cb_row_clicked, node);
+
+               if (!model->highlight || model->highlight(data, i))
+                       ewl_callback_append(row, EWL_CALLBACK_MOUSE_IN,
+                                       ewl_tree2_cb_row_highlight, NULL);
+
                EWL_TREE2_NODE(node)->row = row;
                ewl_widget_show(row);
 
@@ -795,6 +803,44 @@
        ewl_mvc_handle_click(EWL_MVC(tree), ewl_mvc_model_get(EWL_MVC(node)),
                                ewl_mvc_data_get(EWL_MVC(node)),
                                node->row_num, -1);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+ewl_tree2_cb_row_highlight(Ewl_Widget *w, void *ev __UNUSED__, 
+                                               void *data __UNUSED__)
+{
+       Ewl_Widget *h;
+       
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, EWL_ROW_TYPE);
+
+       h = ewl_highlight_new();
+       ewl_highlight_follow_set(EWL_HIGHLIGHT(h), w);
+       ewl_container_child_append(EWL_CONTAINER(w), h);
+       ewl_widget_show(h);
+
+       ewl_callback_append(w, EWL_CALLBACK_MOUSE_OUT,
+                       ewl_tree2_cb_row_unhighlight, h);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+ewl_tree2_cb_row_unhighlight(Ewl_Widget *w, void *ev __UNUSED__, void *data)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_PARAM_PTR("data", data);
+       DCHECK_TYPE("w", w, EWL_ROW_TYPE);
+       DCHECK_TYPE("data", data, EWL_HIGHLIGHT_TYPE);
+
+       ewl_widget_destroy(EWL_WIDGET(data));
+
+       ewl_callback_del(w, EWL_CALLBACK_MOUSE_OUT,
+                               ewl_tree2_cb_row_unhighlight);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to