Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_button.h etk_tree2.c etk_tree2.h etk_tree2_model.c 
        etk_tree2_model.h 


Log Message:
* [Tree2] The models can now be combined: for example, if you want a 
column containing an icon followed by a text, just add the image model 
and the text model to the column. It allows a lot more 
flexibility with the models, it makes model creation easier, and there 
is no more need for the "icon_text" model. It needs more work though 
before being usable


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_button.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- etk_button.h        6 Oct 2006 17:04:14 -0000       1.11
+++ etk_button.h        3 Jan 2007 18:10:11 -0000       1.12
@@ -6,11 +6,6 @@
 #include "etk_types.h"
 #include "etk_stock.h"
 
-/* TODO/FIXME list:
- * - More properties (stock, ...)?
- * - Should the button repeat the "clicked" signal when space is kept pressed 
(see canvas' test app)
- */
-
 /**
  * @defgroup Etk_Button Etk_Button
  * @brief The Etk_Button widget is a widget that emits a signal when it is 
pressed, released or clicked
@@ -63,7 +58,7 @@
    Etk_Stock_Size stock_size;
 };
 
-Etk_Type  *etk_button_type_get();
+Etk_Type   *etk_button_type_get();
 Etk_Widget *etk_button_new();
 Etk_Widget *etk_button_new_with_label(const char *label);
 Etk_Widget *etk_button_new_from_stock(Etk_Stock_Id stock_id);
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_tree2.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- etk_tree2.c 3 Jan 2007 00:09:31 -0000       1.6
+++ etk_tree2.c 3 Jan 2007 18:10:11 -0000       1.7
@@ -25,14 +25,14 @@
 #define COL_RESIZE_THRESHOLD 3
 #define MIN_ROW_HEIGHT 12
 #define DEFAULT_ROW_HEIGHT 24
-#define MAX_OBJECTS_PER_CELL 5
+#define MAX_OBJECTS_PER_MODEL 5
 #define CELL_HMARGINS 4
 #define CELL_VMARGINS 2
 
 
 typedef struct Etk_Tree2_Cell_Objects
 {
-   Evas_Object *objects[MAX_OBJECTS_PER_CELL];
+   Evas_Object *objects[MAX_MODELS_PER_COL][MAX_OBJECTS_PER_MODEL];
 } Etk_Tree2_Cell_Objects;
 
 typedef struct Etk_Tree2_Row_Object
@@ -428,28 +428,22 @@
  * @brief Inserts a new column into a tree
  * @param tree a tree
  * @param title the tile of the column
- * @param model the model to use for the column
  * @param width the requested width of the column. It won't be necessary the 
visible width
  * of the column since it can be expanded to fit the available space
  * @return Returns the new column
  */
-Etk_Tree2_Col *etk_tree2_col_new(Etk_Tree2 *tree, const char *title, 
Etk_Tree2_Model *model, int width)
+Etk_Tree2_Col *etk_tree2_col_new(Etk_Tree2 *tree, const char *title, int width)
 {
    Etk_Tree2_Col *new_col;
    Etk_Widget *new_header;
 
-   if (!tree || !model)
+   if (!tree)
       return NULL;
    if (tree->built)
    {
       ETK_WARNING("The tree is built, you can not add a new column");
       return NULL;
    }
-   if (model->col)
-   {
-      ETK_WARNING("The tree-model to use for that column is already used by 
another column");
-      return NULL;
-   }
 
    tree->columns = realloc(tree->columns, sizeof(Etk_Tree2_Col *) * 
(tree->num_cols + 1));
    new_col = ETK_TREE2_COL(etk_object_new(ETK_TREE2_COL_TYPE, "title", title,
@@ -458,8 +452,6 @@
 
    new_col->id = tree->num_cols;
    new_col->tree = tree;
-   new_col->model = model;
-   new_col->model->col = new_col;
    new_col->position = tree->num_cols;
 
    /* Creates the header widget */
@@ -470,9 +462,6 @@
    else
       etk_widget_parent_set(new_header, tree->scroll_content);
    new_col->header = new_header;
-   
-   /*etk_signal_connect("mouse_down", ETK_OBJECT(new_header), 
ETK_CALLBACK(_etk_tree2_header_mouse_down_cb), new_col);
-   etk_signal_connect("mouse_up", ETK_OBJECT(new_header), 
ETK_CALLBACK(_etk_tree2_header_mouse_up_cb), new_col);*/
 
    tree->num_cols++;
    _etk_tree2_col_realize(tree, tree->num_cols - 1);
@@ -507,6 +496,39 @@
 }
 
 /**
+ * @brief Adds a model to a column of the tree. You can add several models to 
the same column in order to combine them.
+ * For example, if you want the column's content to be an icon followed by a 
text, add the "image" model and then the
+ * "text" model
+ * @param col a column
+ * @param model the model to add to the column @a col
+ * @warning the number of models per column is limited to 5
+ */
+void etk_tree2_col_model_add(Etk_Tree2_Col *col, Etk_Tree2_Model *model)
+{
+   if (!col || !model || !col->tree)
+      return;
+   if (col->tree->built)
+   {
+      ETK_WARNING("You cannot add a model to a column once the tree is built");
+      return;
+   }
+   if (col->num_models >= MAX_MODELS_PER_COL)
+   {
+      ETK_WARNING("The number of models per column is limited to %d. Unable to 
add the model", MAX_MODELS_PER_COL);
+      return;
+   }
+   if (model->col)
+   {
+      ETK_WARNING("The tree-model to add to that column is already used by 
another column");
+      return;
+   }
+   
+   col->models[col->num_models] = model;
+   model->col = col;
+   col->num_models++;
+}
+
+/**
  * @brief Sets the title of the column
  * @param col a column of a tree
  * @param title the title to set
@@ -568,7 +590,7 @@
 /**
  * @brief Sets the minimum width of the column. The column can not be smaller 
than this width
  * @param col a column of a tree
- * @param min_width the minimum width to set. -1 to make etk calculate the 
min_width
+ * @param min_width the minimum width to set. -1 to use the default value
  */
 void etk_tree2_col_min_width_set(Etk_Tree2_Col *col, int min_width)
 {
@@ -735,11 +757,11 @@
 
 /**
  * @brief Sets the sorting function of a column. This function will be called 
when
- * the header of the column is clicked
+ * the header of the column is clicked or when you call etk_tree2_col_sort()
  * @param col a column of a tree
  * @param compare_cb the function to call to compare two rows. It should 
return a negative
  * value if the cell of "row1" has a lower value than the cell of "row2", 0 if 
they have the
- * same value, and a position value if the cell of "row2" has a greater value 
than the cell of "row1"
+ * same value, and a positive value if the cell of "row2" has a greater value 
than the cell of "row1"
  * @param data a pointer that will be passed to @a compare_cb when it is called
  */
 void etk_tree2_col_sort_set(Etk_Tree2_Col *col, int (*compare_cb)(Etk_Tree2 
*tree, Etk_Tree2_Row *row1, Etk_Tree2_Row *row2, Etk_Tree2_Col *col, void 
*data), void *data)
@@ -843,8 +865,9 @@
 Etk_Tree2_Row *etk_tree2_row_insert_valist(Etk_Tree2 *tree, Etk_Tree2_Row 
*parent, Etk_Tree2_Row *after, va_list args)
 {
    Etk_Tree2_Row *new_row;
+   Etk_Tree2_Col *col;
    va_list args2;
-   int i;
+   int i, j;
 
    if (!tree)
       return NULL;
@@ -900,12 +923,18 @@
    tree->total_rows++;
 
    /* Initializes the data of the row's cells */
-   new_row->cells_data = malloc(sizeof(void *) * tree->num_cols);
+   new_row->cells_data = malloc(sizeof(void **) * tree->num_cols);
    for (i = 0; i < tree->num_cols; i++)
    {
-      new_row->cells_data[i] = calloc(1, 
tree->columns[i]->model->cell_data_size);
-      if (tree->columns[i]->model->cell_data_init)
-         tree->columns[i]->model->cell_data_init(tree->columns[i]->model, 
new_row->cells_data[i]);
+      col = tree->columns[i];
+      
+      new_row->cells_data[i] = malloc(sizeof(void *) * col->num_models);
+      for (j = 0; j < col->num_models; j++)
+      {
+         new_row->cells_data[i][j] = calloc(1, col->models[j]->cell_data_size);
+         if (col->models[j]->cell_data_init)
+            col->models[j]->cell_data_init(col->models[j], 
new_row->cells_data[i][j]);
+      }
    }
    va_copy(args2, args);
    _etk_tree2_row_fields_set_valist_full(new_row, args2, ETK_FALSE);
@@ -951,7 +980,7 @@
       return;
    
    while (tree->root.first_child)
-   _etk_tree2_row_move_to_purge_pool(tree->root.first_child);
+      _etk_tree2_row_move_to_purge_pool(tree->root.first_child);
    
    etk_signal_emit_by_name("scroll_size_changed", 
ETK_OBJECT(tree->scroll_content), NULL);
    etk_widget_redraw_queue(ETK_WIDGET(tree));
@@ -960,8 +989,9 @@
 /**
  * @brief Sets the values of the cells of the row
  * @param row a row of the tree
- * @param ... an "Etk_Tree_Col *" followed by the value of the cell, then any 
number of "Etk_Tree_Col *"/Value pairs,
- * and terminated by NULL. Note that, according to the model used by the 
column, a cell value can use several parameters
+ * @param ... an "Etk_Tree_Col *" followed by the value of the cell,
+ * then any number of "Etk_Tree_Col *"/Value pairs, and terminated by NULL.
+ * Note that, according to the models used by the column, a cell value can use 
several parameters
  */
 void etk_tree2_row_fields_set(Etk_Tree2_Row *row, ...)
 {
@@ -980,7 +1010,7 @@
  * @param row a row of the tree
  * @param args an "Etk_Tree_Col *" followed by the value of the cell,
  * then any number of "Etk_Tree_Col *"/Value pairs, and terminated by NULL.
- * Note that some models may require several parameters for the cell value
+ * Note that, according to the models used by the column, a cell value can use 
several parameters
  */
 void etk_tree2_row_fields_set_valist(Etk_Tree2_Row *row, va_list args)
 {
@@ -1024,6 +1054,7 @@
 {
    Etk_Tree2_Col *col;
    va_list args2;
+   int i;
    
    if (!row)
       return;
@@ -1031,8 +1062,11 @@
    va_copy(args2, args);
    while ((col = va_arg(args, Etk_Tree2_Col *)))
    {
-      if (col->model->cell_data_get)
-         col->model->cell_data_get(col->model, row->cells_data[col->id], 
&args);
+      for (i = 0; i < col->num_models; i++)
+      {
+         if (col->models[i]->cell_data_get)
+            col->models[i]->cell_data_get(col->models[i], 
row->cells_data[col->id][i], &args);
+      }
    }
    va_end(args2);
 }
@@ -1586,6 +1620,8 @@
    }
 }
 
+/* TODO: add "align" prop */
+
 /**************************
  * Tree Col
  **************************/
@@ -1597,7 +1633,7 @@
       return;
 
    tree_col->tree = NULL;
-   tree_col->model = NULL;
+   tree_col->num_models = 0;
    tree_col->id = 0;
    tree_col->position = 0;
    tree_col->xoffset = 0;
@@ -1607,6 +1643,7 @@
    tree_col->visible = ETK_TRUE;
    tree_col->resizable = ETK_TRUE;
    tree_col->expand = ETK_FALSE;
+   tree_col->align = 0.0;
    tree_col->header = NULL;
    tree_col->clip = NULL;
    tree_col->separator = NULL;
@@ -1617,9 +1654,13 @@
 /* Destroys the tree column */
 static void _etk_tree2_col_destructor(Etk_Tree2_Col *tree_col)
 {
+   int i;
+   
    if (!tree_col)
       return;
-   etk_tree2_model_free(tree_col->model);
+   
+   for (i = 0; i < tree_col->num_models; i++)
+      etk_tree2_model_free(tree_col->models[i]);
 }
 
 /* Sets the property whose id is "property_id" to the value "value" */
@@ -1879,7 +1920,7 @@
    Evas_List *prev_visible_rows;
    Evas_List *new_visible_rows;
    Evas_List *l;
-   int i, j;
+   int i, j, k;
    
    if (!(tree = TREE_GET(widget)))
       return;
@@ -2065,9 +2106,10 @@
    {
       Etk_Tree2_Row *row;
       Etk_Tree2_Row_Object *row_object;
-      Etk_Geometry cell_geometry;
+      Etk_Geometry cell_geometry, model_geometry;
       Etk_Bool show_expanders;
       Evas_List *l2;
+      int total_width, w;
       int row_id;
       int row_y;
       int depth;
@@ -2137,13 +2179,52 @@
                   }
                   
                   /* Render the sub-objects of the cell */
-                  if (col->model->render)
-                     col->model->render(col->model, row, cell_geometry, 
row->cells_data[i], row_object->cells[i].objects);
+                  total_width = 0;
+                  model_geometry = cell_geometry;
+                  for (j = 0; j < col->num_models; j++)
+                  {
+                     if (col->models[j]->render)
+                     {
+                        col->models[j]->render(col->models[j], row, 
model_geometry,
+                           row->cells_data[i][j], 
row_object->cells[i].objects[j]);
+                        
+                        if (col->models[j]->width_get)
+                        {
+                           w = col->models[j]->width_get(col->models[j],
+                              row->cells_data[i][j], 
row_object->cells[i].objects[j]);
+                        }
+                        else
+                           w = 0;
+                        
+                        model_geometry.x += w;
+                        model_geometry.w -= w;
+                        total_width += w;
+                     }
+                  }
+                  
+                  /* Align the cell objects */
+                  if (col->align != 0.0)
+                  {
+                     for (j = 0; j < col->num_models; j++)
+                     {
+                        for (k = 0; k < MAX_OBJECTS_PER_MODEL; k++)
+                        {
+                           if (row_object->cells[i].objects[j][k])
+                              /* TODO */;
+                        }
+                     }
+                  }
                }
                else
                {
-                  for (j = 0; j < MAX_OBJECTS_PER_CELL; j++)
-                     evas_object_hide(row_object->cells[i].objects[j]);
+                  for (j = 0; j < col->num_models; j++)
+                  {
+                     for (k = 0; k < MAX_OBJECTS_PER_MODEL; k++)
+                     {
+                        if (row_object->cells[i].objects[j][k])
+                           
evas_object_hide(row_object->cells[i].objects[j][k]);
+                     }
+                  }
                }
             }
             
@@ -2154,8 +2235,14 @@
             /* If there is no more row to render, we hide the row objects */
             for (i = 0; i < tree->num_cols; i++)
             {
-               for (j = 0; j < MAX_OBJECTS_PER_CELL; j++)
-                  evas_object_hide(row_object->cells[i].objects[j]);
+               for (j = 0; j < tree->columns[i]->num_models; j++)
+               {
+                  for (k = 0; k < MAX_OBJECTS_PER_MODEL; k++)
+                  {
+                     if (row_object->cells[i].objects[j][k])
+                        evas_object_hide(row_object->cells[i].objects[j][k]);
+                  }
+               }
             }
             evas_object_hide(row_object->expander);
             evas_object_hide(row_object->background);
@@ -2548,7 +2635,8 @@
 {
    Evas_List *l;
    Etk_Tree2_Row *row, *r, *next;
-   int i;
+   Etk_Tree2_Col *col;
+   int i, j;
    
    if (!tree)
       return;
@@ -2586,8 +2674,13 @@
          {
             for (i = 0; i < tree->num_cols; i++)
             {
-               if (tree->columns[i]->model->cell_data_free)
-                  
tree->columns[i]->model->cell_data_free(tree->columns[i]->model, 
r->cells_data[i]);
+               col = tree->columns[i];
+               for (j = 0; j < col->num_models; j++)
+               {
+                  if (col->models[j]->cell_data_free)
+                     col->models[j]->cell_data_free(col->models[j], 
r->cells_data[i][j]);
+                  free(r->cells_data[i][j]);
+               }
                free(r->cells_data[i]);
             }
             free(r->cells_data);
@@ -2790,6 +2883,7 @@
 {
    Etk_Tree2_Col *col;
    va_list args2;
+   int i;
    
    if (!row)
       return;
@@ -2797,12 +2891,13 @@
    va_copy(args2, args);
    while ((col = va_arg(args2, Etk_Tree2_Col *)))
    {
-      if (col->model->cell_data_set)
+      for (i = 0; i < col->num_models; i++)
       {
-         col->model->cell_data_set(col->model, row->cells_data[col->id], 
&args2);
-         if (emit_signal)
-            
etk_signal_emit(_etk_tree2_col_signals[ETK_TREE2_COL_CELL_VALUE_CHANGED], 
ETK_OBJECT(col), NULL, row);
+         if (col->models[i]->cell_data_set)
+            col->models[i]->cell_data_set(col->models[i], 
row->cells_data[col->id][i], &args2);
       }
+      if (emit_signal)
+         
etk_signal_emit(_etk_tree2_col_signals[ETK_TREE2_COL_CELL_VALUE_CHANGED], 
ETK_OBJECT(col), NULL, row);
    }
    va_end(args2);
    
@@ -2816,7 +2911,7 @@
    Etk_Tree2_Row_Object *row_object;
    Etk_Tree2_Col *col;
    Evas *evas;
-   int i, j;
+   int i, j, k;
    
    if (!tree || !tree->built || !(evas = 
etk_widget_toplevel_evas_get(tree->grid)))
       return NULL;
@@ -2854,15 +2949,18 @@
    for (i = 0; i < tree->num_cols; i++)
    {
       col = tree->columns[i];
-      if (col->model->objects_create)
+      for (j = 0; j < col->num_models; j++)
       {
-         col->model->objects_create(col->model, row_object->cells[i].objects, 
evas);
-         for (j = 0; j < MAX_OBJECTS_PER_CELL; j++)
+         if (col->models[j]->objects_create)
          {
-            if (row_object->cells[i].objects[j])
+            col->models[j]->objects_create(col->models[j], 
row_object->cells[i].objects[j], evas);
+            for (k = 0; k < MAX_OBJECTS_PER_MODEL; k++)
             {
-               evas_object_clip_set(row_object->cells[i].objects[j], 
col->clip);
-               etk_widget_member_object_add(tree->grid, 
row_object->cells[i].objects[j]);
+               if (row_object->cells[i].objects[j][k])
+               {
+                  evas_object_clip_set(row_object->cells[i].objects[j][k], 
col->clip);
+                  etk_widget_member_object_add(tree->grid, 
row_object->cells[i].objects[j][k]);
+               }
             }
          }
       }
@@ -2875,15 +2973,18 @@
 /* Destroys the row object and its subobjects */
 static void _etk_tree2_row_object_destroy(Etk_Tree2 *tree, 
Etk_Tree2_Row_Object *row_object)
 {
-   int i, j;
+   int i, j, k;
    
    if (!tree || !row_object)
       return;
    
    for (i = 0; i < tree->num_cols; i++)
    {
-      for (j = 0; j < MAX_OBJECTS_PER_CELL; j++)
-         evas_object_del(row_object->cells[i].objects[j]);
+      for (j = 0; j < tree->columns[i]->num_models; j++)
+      {
+         for (k = 0; k < MAX_OBJECTS_PER_MODEL; k++)
+            evas_object_del(row_object->cells[i].objects[j][k]);
+      }
    }
    free(row_object->cells);
    
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_tree2.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- etk_tree2.h 3 Jan 2007 00:09:31 -0000       1.5
+++ etk_tree2.h 3 Jan 2007 18:10:11 -0000       1.6
@@ -15,6 +15,8 @@
  * @{
  */
 
+#define MAX_MODELS_PER_COL 5
+
 /** Gets the type of a tree */
 #define ETK_TREE2_TYPE       (etk_tree2_type_get())
 /** Casts the object to an Etk_Tree2 */
@@ -49,12 +51,15 @@
 
    int id;
    Etk_Tree2 *tree;
-   Etk_Tree2_Model *model;
+   
+   int num_models;
+   Etk_Tree2_Model *models[MAX_MODELS_PER_COL];
 
    int position;
    Etk_Bool resizable;
    Etk_Bool visible;
    Etk_Bool expand;
+   float align;
    
    int xoffset;
    int min_width;
@@ -72,6 +77,8 @@
    } sort;
 };
 
+/* TODO: remove this... should be etk_tree2_col_alignment_set() */
+
 /**
  * @brief A row of a tree
  * @structinfo
@@ -88,7 +95,7 @@
    int num_children;
    int num_visible_children;
    
-   void **cells_data;
+   void ***cells_data;
    void *data;
    void (*data_free_cb)(void *data);
    
@@ -162,10 +169,11 @@
 
 Etk_Scrolled_View *etk_tree2_scrolled_view_get(Etk_Tree2 *tree);
 
-Etk_Tree2_Col *etk_tree2_col_new(Etk_Tree2 *tree, const char *title, 
Etk_Tree2_Model *model, int width);
+Etk_Tree2_Col *etk_tree2_col_new(Etk_Tree2 *tree, const char *title, int 
width);
 int            etk_tree2_num_cols_get(Etk_Tree2 *tree);
 Etk_Tree2_Col *etk_tree2_nth_col_get(Etk_Tree2 *tree, int nth);
 
+void        etk_tree2_col_model_add(Etk_Tree2_Col *col, Etk_Tree2_Model 
*model);
 void        etk_tree2_col_title_set(Etk_Tree2_Col *col, const char *title);
 const char *etk_tree2_col_title_get(Etk_Tree2_Col *col);
 void        etk_tree2_col_width_set(Etk_Tree2_Col *col, int width);
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_tree2_model.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_tree2_model.c   28 Nov 2006 21:40:07 -0000      1.1
+++ etk_tree2_model.c   3 Jan 2007 18:10:11 -0000       1.2
@@ -27,13 +27,6 @@
    int icon_width;
 } Etk_Tree2_Model_Icon_Text;
 
-typedef struct _Etk_Tree2_Model_Icon_Text_Data
-{
-   char *filename;
-   char *edje_group;
-   char *text;
-} Etk_Tree2_Model_Icon_Text_Data;
-
 typedef struct _Etk_Tree2_Model_Progressbar_Data
 {
    double fraction;
@@ -60,12 +53,6 @@
 static void etk_tree2_model_image_cell_data_get(Etk_Tree2_Model *model, void 
*cell_data, va_list *args);
 static void etk_tree2_model_image_objects_create(Etk_Tree2_Model *model, 
Evas_Object **cell_objects, Evas *evas);
 static void etk_tree2_model_image_render(Etk_Tree2_Model *model, Etk_Tree2_Row 
*row, Etk_Geometry geometry, void *cell_data, Evas_Object **cell_objects);
-/* Icon Text model */
-static void etk_tree2_model_icon_text_cell_data_free(Etk_Tree2_Model *model, 
void *cell_data);
-static void etk_tree2_model_icon_text_cell_data_set(Etk_Tree2_Model *model, 
void *cell_data, va_list *args);
-static void etk_tree2_model_icon_text_cell_data_get(Etk_Tree2_Model *model, 
void *cell_data, va_list *args);
-static void etk_tree2_model_icon_text_objects_create(Etk_Tree2_Model *model, 
Evas_Object **cell_objects, Evas *evas);
-static void etk_tree2_model_icon_text_render(Etk_Tree2_Model *model, 
Etk_Tree2_Row *row, Etk_Geometry geometry, void *cell_data, Evas_Object 
**cell_objects);
 /* Checkbox model */
 static void etk_tree2_model_checkbox_cell_data_set(Etk_Tree2_Model *model, 
void *cell_data, va_list *args);
 static void etk_tree2_model_checkbox_cell_data_get(Etk_Tree2_Model *model, 
void *cell_data, va_list *args);
@@ -92,8 +79,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model));
    
    tree_model->tree = tree;
-   tree_model->xalign = 0.0;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(char *);
    tree_model->cell_data_free = etk_tree2_model_text_cell_data_free;
    tree_model->cell_data_set = etk_tree2_model_text_cell_data_set;
@@ -117,8 +102,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model));
    
    tree_model->tree = tree;
-   tree_model->xalign = 1.0;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(int);
    tree_model->cell_data_set = etk_tree2_model_int_cell_data_set;
    tree_model->cell_data_get = etk_tree2_model_int_cell_data_get;
@@ -141,8 +124,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model));
    
    tree_model->tree = tree;
-   tree_model->xalign = 1.0;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(double);
    tree_model->cell_data_set = etk_tree2_model_double_cell_data_set;
    tree_model->cell_data_get = etk_tree2_model_double_cell_data_get;
@@ -167,8 +148,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model_Image));
    
    tree_model->tree = tree;
-   tree_model->xalign = 0.0;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(Etk_Tree2_Model_Image_Data);
    tree_model->cell_data_free = etk_tree2_model_image_cell_data_free;
    tree_model->cell_data_set = etk_tree2_model_image_cell_data_set;
@@ -181,36 +160,6 @@
 }
 
 /**
- * @brief Creates a model of column whose cells contain an icon and a text 
label. @n
- * The icon can be loaded from a file or from an edje file
- * @param tree a tree
- * @param icon_type the type of the icons: ETK_TREE2_FROM_FILE if the icons 
will be loaded from a file @n
- * or ETK_TREE2_FROM_EDJE if the icons will be loaded from an edje file
- * @return Returns the new model
- * @note You don't need to free it with etk_tree2_model_free() if you use it 
in a tree. It will be freed when the tree is destroyed
- */
-Etk_Tree2_Model *etk_tree2_model_icon_text_new(Etk_Tree2 *tree, 
Etk_Tree2_Model_Image_Type icon_type)
-{
-   Etk_Tree2_Model *tree_model;
-   
-   tree_model = calloc(1, sizeof(Etk_Tree2_Model_Icon_Text));
-   
-   tree_model->tree = tree;
-   tree_model->xalign = 0.0;
-   tree_model->yalign = 0.5;
-   tree_model->cell_data_size = sizeof(Etk_Tree2_Model_Icon_Text_Data);
-   tree_model->cell_data_free = etk_tree2_model_icon_text_cell_data_free;
-   tree_model->cell_data_set = etk_tree2_model_icon_text_cell_data_set;
-   tree_model->cell_data_get = etk_tree2_model_icon_text_cell_data_get;
-   tree_model->objects_create = etk_tree2_model_icon_text_objects_create;
-   tree_model->render = etk_tree2_model_icon_text_render;
-   ((Etk_Tree2_Model_Icon_Text *)tree_model)->icon_type = icon_type;
-   ((Etk_Tree2_Model_Icon_Text *)tree_model)->icon_width = -1;
-   
-   return tree_model;
-}
-
-/**
  * @brief Creates a model of column whose cells contain a checkbox
  * @param tree a tree
  * @return Returns the new model
@@ -223,8 +172,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model));
    
    tree_model->tree = tree;
-   tree_model->xalign = 0.5;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(Etk_Bool);
    tree_model->cell_data_set = etk_tree2_model_checkbox_cell_data_set;
    tree_model->cell_data_get = etk_tree2_model_checkbox_cell_data_get;
@@ -247,8 +194,6 @@
    tree_model = calloc(1, sizeof(Etk_Tree2_Model));
    
    tree_model->tree = tree;
-   tree_model->xalign = 0.5;
-   tree_model->yalign = 0.5;
    tree_model->cell_data_size = sizeof(Etk_Tree2_Model_Progressbar_Data);
    tree_model->cell_data_set = etk_tree2_model_progress_bar_cell_data_set;
    tree_model->cell_data_get = etk_tree2_model_progress_bar_cell_data_get;
@@ -274,40 +219,6 @@
 }
 
 /**
- * @brief Sets the alignment of the objects inside the cell
- * @param model a tree model
- * @param xalign the horizontal alignment of the objects inside the cell (0.0 
for left, 1.0 for right)
- * @param yalign the vertical alignment of the objects inside the cell (0.0 
for up, 1.0 for bottom)
- */
-void etk_tree2_model_alignment_set(Etk_Tree2_Model *model, float xalign, float 
yalign)
-{
-   if (!model)
-      return;
-   
-   model->xalign = ETK_CLAMP(xalign, 0.0, 1.0);
-   model->yalign = ETK_CLAMP(yalign, 0.0, 1.0);
-   if (model->tree)
-      etk_widget_redraw_queue(ETK_WIDGET(model->tree));
-}
-
-/**
- * @brief Gets the alignment of the objects inside the cell
- * @param model a tree model
- * @param xalign the location where to set the horizontal alignment
- * @param yalign the location where to set the vertical alignment
- */
-void etk_tree2_model_alignment_get(Etk_Tree2_Model *model, float *xalign, 
float *yalign)
-{
-   if (!model)
-      return;
-   
-   if (xalign)
-      *xalign = model->xalign;
-   if (yalign)
-      *yalign = model->yalign;
-}
-
-/**
  * @brief Sets the width of the icons of the icon/text model
  * @param model a icon/text model
  * @param icon_width the width to set for the icons of the model. -1 to let 
Etk compute the width for each icon (the text could not be aligned then)
@@ -392,14 +303,14 @@
 static void etk_tree2_model_text_render(Etk_Tree2_Model *model, Etk_Tree2_Row 
*row, Etk_Geometry geometry, void *cell_data, Evas_Object **cell_objects)
 {
    char **text_data;
-   Evas_Coord tw, th;
+   Evas_Coord th;
    
    if (!(text_data = cell_data))
       return;
    
    evas_object_text_text_set(cell_objects[0], *text_data);
-   evas_object_geometry_get(cell_objects[0], NULL, NULL, &tw, &th);
-   evas_object_move(cell_objects[0], geometry.x + (geometry.w - tw) * 
model->xalign, geometry.y + (geometry.h - th) * model->yalign);
+   evas_object_geometry_get(cell_objects[0], NULL, NULL, NULL, &th);
+   evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - 
th) / 2));
    evas_object_show(cell_objects[0]);
 }
 
@@ -435,15 +346,15 @@
 {
    int *int_data;
    char string[256];
-   Evas_Coord tw, th;
+   Evas_Coord th;
    
    if (!(int_data = cell_data))
       return;
    
    snprintf(string, 255, "%d", *int_data);
    evas_object_text_text_set(cell_objects[0], string);
-   evas_object_geometry_get(cell_objects[0], NULL, NULL, &tw, &th);
-   evas_object_move(cell_objects[0], geometry.x + (geometry.w - tw) * 
model->xalign, geometry.y + (geometry.h - th) * model->yalign);
+   evas_object_geometry_get(cell_objects[0], NULL, NULL, NULL, &th);
+   evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - 
th) / 2));
    evas_object_show(cell_objects[0]);
 }
 
@@ -479,15 +390,15 @@
 {
    double *double_data;
    char string[256];
-   Evas_Coord tw, th;
+   Evas_Coord th;
    
    if (!(double_data = cell_data) || !model)
       return;
    
    snprintf(string, 255, "%.2f", *double_data);
    evas_object_text_text_set(cell_objects[0], string);
-   evas_object_geometry_get(cell_objects[0], NULL, NULL, &tw, &th);
-   evas_object_move(cell_objects[0], geometry.x + (geometry.w - tw) * 
model->xalign, geometry.y + (geometry.h - th) * model->yalign);
+   evas_object_geometry_get(cell_objects[0], NULL, NULL, NULL, &th);
+   evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - 
th) / 2));
    evas_object_show(cell_objects[0]);
 }
 
@@ -639,8 +550,8 @@
             image_geometry.h = geometry.h;
          }
       }
-      image_geometry.x = geometry.x + (geometry.w - image_geometry.w) * 
model->xalign;
-      image_geometry.y = geometry.y + (geometry.h - image_geometry.h) * 
model->yalign;
+      image_geometry.x = geometry.x;
+      image_geometry.y = geometry.y + ((geometry.h - image_geometry.h) / 2);
    
       evas_object_show(cell_objects[0]);
       if ((((Etk_Tree2_Model_Image *)model)->image_type) == 
ETK_TREE2_FROM_FILE)
@@ -651,206 +562,6 @@
 }
 
 /*---------------------
- * Icon Text Model
- *-------------------*/
-/* Icon Text: cell_data_free */
-static void etk_tree2_model_icon_text_cell_data_free(Etk_Tree2_Model *model, 
void *cell_data)
-{
-   Etk_Tree2_Model_Icon_Text_Data *icon_text_data;
-   
-   if (!(icon_text_data = cell_data))
-      return;
-   free(icon_text_data->filename);
-   free(icon_text_data->edje_group);
-   free(icon_text_data->text);
-}
-
-/* Icon Text: cell_data_set */
-static void etk_tree2_model_icon_text_cell_data_set(Etk_Tree2_Model *model, 
void *cell_data, va_list *args)
-{
-   Etk_Tree2_Model_Icon_Text_Data *icon_text_data;
-   char *string;
-   
-   if (!(icon_text_data = cell_data) || !args || !model)
-      return;
-   
-   free(icon_text_data->filename);
-   free(icon_text_data->edje_group);
-   free(icon_text_data->text);
-   icon_text_data->edje_group = NULL;
-   icon_text_data->filename = NULL;
-   icon_text_data->text = NULL;
-   
-   switch (((Etk_Tree2_Model_Icon_Text *)model)->icon_type)
-   {
-      case ETK_TREE2_FROM_FILE:
-         string = va_arg(*args, char *);
-         icon_text_data->filename = string ? strdup(string) : NULL;
-         break;
-      case ETK_TREE2_FROM_EDJE:
-         string = va_arg(*args, char *);
-         icon_text_data->filename = string ? strdup(string) : NULL;
-         string = va_arg(*args, char *);
-         icon_text_data->edje_group = string ? strdup(string) : NULL;
-         break;
-      default:
-         break;
-   }
-   
-   if ((string = va_arg(*args, char *)))
-      icon_text_data->text = strdup(string);
-}
-
-/* Icon Text: cell_data_get */
-static void etk_tree2_model_icon_text_cell_data_get(Etk_Tree2_Model *model, 
void *cell_data, va_list *args)
-{
-   Etk_Tree2_Model_Icon_Text_Data *icon_text_data;
-   char **string;
-   
-   if (!(icon_text_data = cell_data) || !args)
-      return;
-   
-   switch (((Etk_Tree2_Model_Icon_Text *)model)->icon_type)
-   {
-      case ETK_TREE2_FROM_FILE:
-         string = va_arg(*args, char **);
-         if (string)
-            *string = icon_text_data->filename;
-         break;
-      case ETK_TREE2_FROM_EDJE:
-         string = va_arg(*args, char **);
-         if (string)
-            *string = icon_text_data->filename;
-         string = va_arg(*args, char **);
-         if (string)
-            *string = icon_text_data->edje_group;
-         break;
-      default:
-         break;
-   }
-   
-   string = va_arg(*args, char **);
-   if (string)
-      *string = icon_text_data->text;
-}
-
-/* Icon Text: objects_create */
-static void etk_tree2_model_icon_text_objects_create(Etk_Tree2_Model *model, 
Evas_Object **cell_objects, Evas *evas)
-{
-   if (!cell_objects || !evas || !model)
-      return;
-   
-   switch (((Etk_Tree2_Model_Icon_Text *)model)->icon_type)
-   {
-      case ETK_TREE2_FROM_FILE:
-         cell_objects[0] = evas_object_image_add(evas);
-         break;
-      case ETK_TREE2_FROM_EDJE:
-         cell_objects[0] = edje_object_add(evas);
-         break;
-      default:
-         break;
-   }
-   evas_object_pass_events_set(cell_objects[0], 1);
-   
-   cell_objects[1] = evas_object_text_add(evas);
-   /* TODO: font and color theme */
-   evas_object_text_font_set(cell_objects[1], "Vera", 10);
-   evas_object_color_set(cell_objects[1], 0, 0, 0, 255);
-   evas_object_pass_events_set(cell_objects[1], 1);
-}
-
-/* Icon Text: render */
-static void etk_tree2_model_icon_text_render(Etk_Tree2_Model *model, 
Etk_Tree2_Row *row, Etk_Geometry geometry, void *cell_data, Evas_Object 
**cell_objects)
-{
-   Etk_Tree2_Model_Icon_Text_Data *icon_text_data;
-   int model_icon_width;
-   int icon_max_width, icon_max_height;
-   int icon_width = 0, icon_height = 0;
-   Etk_Geometry icon_geometry;
-   Etk_Bool show_icon = ETK_FALSE;
-   Evas_Coord tw, th;
-   int icon_offset = 0;
-   
-   if (!(icon_text_data = cell_data) || !model)
-      return;
-   
-   switch (((Etk_Tree2_Model_Icon_Text *)model)->icon_type)
-   {
-      case ETK_TREE2_FROM_FILE:
-         evas_object_image_file_set(cell_objects[0], icon_text_data->filename, 
NULL);
-         if (!evas_object_image_load_error_get(cell_objects[0]))
-         {
-            evas_object_image_size_get(cell_objects[0], &icon_width, 
&icon_height);
-            show_icon = ETK_TRUE;
-         }
-         break;
-      case ETK_TREE2_FROM_EDJE:
-         if (edje_object_file_set(cell_objects[0], icon_text_data->filename, 
icon_text_data->edje_group))
-         {
-            edje_object_size_min_get(cell_objects[0], &icon_width, 
&icon_height);
-            show_icon = ETK_TRUE;
-         }
-         break;
-      default:
-         break;
-   }
-   evas_object_text_text_set(cell_objects[1], icon_text_data->text);
-   evas_object_geometry_get(cell_objects[1], NULL, NULL, &tw, &th);
-   
-   model_icon_width = ((Etk_Tree2_Model_Icon_Text *)model)->icon_width;
-   if (model_icon_width >= 0)
-      icon_max_width = ((Etk_Tree2_Model_Icon_Text *)model)->icon_width;
-   else
-      icon_max_width = 10000;
-   icon_max_height = geometry.h;
-   
-   if (show_icon)
-   {
-      if (icon_width == 0 || icon_height == 0)
-      {
-         icon_geometry.w = icon_max_height;
-         icon_geometry.h = icon_max_height;
-      }
-      else if (icon_width <= icon_max_width && icon_height <= icon_max_height)
-      {
-         icon_geometry.w = icon_width;
-         icon_geometry.h = icon_height;
-      }
-      else
-      {
-         if (((float)icon_height / icon_width) * icon_max_width <= 
icon_max_height)
-         {
-            icon_geometry.w = icon_max_width;
-            icon_geometry.h = ((float)icon_height / icon_width) * 
icon_max_width;
-         }
-         else
-         {
-            icon_geometry.w = ((float)icon_width / icon_height) * 
icon_max_height;
-            icon_geometry.h = icon_max_height;
-         }
-      }
-      
-      icon_offset = ((model_icon_width >= 0) ? model_icon_width : 
icon_geometry.w) + 8;
-      icon_geometry.x = geometry.x + ((geometry.w - icon_offset - tw) * 
model->xalign);
-      if (model_icon_width >= 0)
-         icon_geometry.x += (model_icon_width - icon_geometry.w) / 2;
-      icon_geometry.y = geometry.y + (geometry.h - icon_geometry.h) * 
model->yalign;
-      
-      evas_object_show(cell_objects[0]);
-      if ((((Etk_Tree2_Model_Icon_Text *)model)->icon_type) == 
ETK_TREE2_FROM_FILE)
-         evas_object_image_fill_set(cell_objects[0], 0, 0, icon_geometry.w, 
icon_geometry.h);
-      evas_object_move(cell_objects[0], icon_geometry.x, icon_geometry.y);
-      evas_object_resize(cell_objects[0], icon_geometry.w, icon_geometry.h);
-   }
-   else
-      evas_object_hide(cell_objects[0]);
-
-   evas_object_move(cell_objects[1], geometry.x + icon_offset + (geometry.w - 
icon_offset - tw) * model->xalign, geometry.y + (geometry.h - th) * 
model->yalign);
-   evas_object_show(cell_objects[1]);
-}
-
-/*---------------------
  * Checkbox Model
  *-------------------*/
 
@@ -907,7 +618,7 @@
    
    evas_object_data_set(cell_objects[0], "_Etk_Tree2_Model_Checkbox::Row", 
row);
    edje_object_size_min_get(cell_objects[0], &w, &h);
-   evas_object_move(cell_objects[0], geometry.x + (geometry.w - w) * 
model->xalign, geometry.y + (geometry.h - h) * model->yalign);
+   evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - 
h) / 2));
    evas_object_resize(cell_objects[0], w, h);
    evas_object_show(cell_objects[0]);
 }
@@ -1008,7 +719,7 @@
    
    evas_object_data_set(cell_objects[0], "_Etk_Tree2_Model_Progressbar::Row", 
row);
    edje_object_size_min_get(cell_objects[0], &w, &h);
-   evas_object_move(cell_objects[0], geometry.x + (geometry.w - w) * 
model->xalign, geometry.y + (geometry.h - h) * model->yalign);
+   evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - 
h) / 2));
    evas_object_resize(cell_objects[0], w, h);
    evas_object_show(cell_objects[0]);
 }
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_tree2_model.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_tree2_model.h   28 Nov 2006 21:40:07 -0000      1.1
+++ etk_tree2_model.h   3 Jan 2007 18:10:11 -0000       1.2
@@ -8,6 +8,7 @@
 
 /**
  * @defgroup Etk_Tree2_Model Etk_Tree2_Model
+ * Etk_Tree2_Models are used by a tree to define the content of its columns
  * @{
  */
 
@@ -30,8 +31,6 @@
    Etk_Tree2 *tree;
    Etk_Tree2_Col *col;
    int cell_data_size;
-   float xalign;
-   float yalign;
    
    void (*model_free)(Etk_Tree2_Model *model);
    void (*cell_data_init)(Etk_Tree2_Model *model, void *cell_data);
@@ -40,23 +39,16 @@
    void (*cell_data_get)(Etk_Tree2_Model *model, void *cell_data, va_list 
*args);
    void (*objects_create)(Etk_Tree2_Model *model, Evas_Object **cell_objects, 
Evas *evas);
    void (*render)(Etk_Tree2_Model *model, Etk_Tree2_Row *row, Etk_Geometry 
geometry, void *cell_data, Evas_Object **cell_objects);
-   void (*ideal_size_calc)(Etk_Tree2_Model *model, void *cell_data, int *w, 
int *h);
+   int  (*width_get)(Etk_Tree2_Model *model, void *cell_data, Evas_Object 
**cell_objects);
 };
 
 Etk_Tree2_Model *etk_tree2_model_text_new(Etk_Tree2 *tree);
 Etk_Tree2_Model *etk_tree2_model_int_new(Etk_Tree2 *tree);
 Etk_Tree2_Model *etk_tree2_model_double_new(Etk_Tree2 *tree);
 Etk_Tree2_Model *etk_tree2_model_image_new(Etk_Tree2 *tree, 
Etk_Tree2_Model_Image_Type image_type);
-Etk_Tree2_Model *etk_tree2_model_icon_text_new(Etk_Tree2 *tree, 
Etk_Tree2_Model_Image_Type icon_type);
 Etk_Tree2_Model *etk_tree2_model_checkbox_new(Etk_Tree2 *tree);
 Etk_Tree2_Model *etk_tree2_model_progress_bar_new(Etk_Tree2 *tree);
 void etk_tree2_model_free(Etk_Tree2_Model *model);
-
-void etk_tree2_model_alignment_set(Etk_Tree2_Model *model, float xalign, float 
yalign);
-void etk_tree2_model_alignment_get(Etk_Tree2_Model *model, float *xalign, 
float *yalign);
-
-void etk_tree2_model_icon_text_icon_width_set(Etk_Tree2_Model *model, int 
icon_width);
-int etk_tree2_model_icon_text_icon_width_get(Etk_Tree2_Model *model);
 
 /** @} */
 



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