# ECell

## Name

ECell --

## Synopsis

    #define     E_CELL_TYPE
    typedef     ECellView;
    enum        ECellFlags;
    typedef     ECell;
    #define     E_CELL_IS_FOCUSED               (ecell_view)
    ECellView*  e_cell_new_view                 (ECell *ecell,
                                                 ETableModel *table_model,
                                                 void *e_table_item_view);
    void        e_cell_kill_view                (ECellView *ecell_view);
    gint        e_cell_event                    (ECellView *ecell_view,
                                                 GdkEvent *event,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 ECellFlags flags);
    void        e_cell_realize                  (ECellView *ecell_view);
    void        e_cell_unrealize                (ECellView *ecell_view);
    void        e_cell_draw                     (ECellView *ecell_view,
                                                 GdkDrawable *drawable,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 ECellFlags flags,
                                                 int x1,
                                                 int y1,
                                                 int x2,
                                                 int y2);
    void        e_cell_print                    (ECellView *ecell_view,
                                                 GnomePrintContext *context,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 double width,
                                                 double height);
    gdouble     e_cell_print_height             (ECellView *ecell_view,
                                                 GnomePrintContext *context,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 gdouble width);
    int         e_cell_max_width                (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col);
    void        e_cell_show_tooltip             (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 int col_width,
                                                 ETableTooltip *tooltip);
    void        e_cell_focus                    (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 int x1,
                                                 int y1,
                                                 int x2,
                                                 int y2);
    void        e_cell_unfocus                  (ECellView *ecell_view);
    int         e_cell_height                   (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row);
    void*       e_cell_enter_edit               (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row);
    void        e_cell_leave_edit               (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 void *edit_context);

## Object Hierarchy

      GtkObject
       +----ECell
             +----ECellToggle
             +----ECellText
             +----ECellTree

## Description

## Details

### E_CELL_TYPE

    #define E_CELL_TYPE        (e_cell_get_type ())

### ECellView

    typedef struct {
    	ECell *ecell;
    	ETableModel *e_table_model;
    	void        *e_table_item_view;

    	gint   focus_x1, focus_y1, focus_x2, focus_y2;
    	gint   focus_col, focus_row;
    } ECellView;

### enum ECellFlags

    typedef enum {
    	E_CELL_SELECTED       = 1 << 0,

    	E_CELL_JUSTIFICATION  = 3 << 1,
    	E_CELL_JUSTIFY_CENTER = 0 << 1,
    	E_CELL_JUSTIFY_LEFT   = 1 << 1,
    	E_CELL_JUSTIFY_RIGHT  = 2 << 1,
    	E_CELL_JUSTIFY_FILL   = 3 << 1,

    	E_CELL_ALIGN_LEFT     = 1 << 1,
    	E_CELL_ALIGN_RIGHT    = 1 << 2,

    	E_CELL_FOCUSED        = 1 << 3,

    	E_CELL_EDITING        = 1 << 4,
    } ECellFlags;

### ECell

    typedef struct {
    	GtkObject       object;
    } ECell;

### E_CELL_IS_FOCUSED()

    #define E_CELL_IS_FOCUSED(ecell_view) (ecell_view->focus_x1 != -1)

`ecell_view` : |

### e_cell_new_view ()

    ECellView*  e_cell_new_view                 (ECell *ecell,
                                                 ETableModel *table_model,
                                                 void *e_table_item_view);

ECell renderers new to be bound to a table_model and to the actual view during their life time to actually render the data. This method is invoked by the ETableItem canvas item to instatiate a new view of the ECell.

This is invoked when the ETableModel is attached to the ETableItem (a CanvasItem that can render ETableModels in the screen).

`ecell` : | the Ecell that will create the new view
`table_model` : | the table model the ecell is bound to
`e_table_item_view` : | An ETableItem object (the CanvasItem that reprensents the view of the table)
Returns : | a new ECellView for this `ecell` on the `table_model` displayed on the `e_table_item_view`.

### e_cell_kill_view ()

    void        e_cell_kill_view                (ECellView *ecell_view);

This method it used to destroy a view of an ECell renderer

`ecell_view` : | view to be destroyed.

### e_cell_event ()

    gint        e_cell_event                    (ECellView *ecell_view,
                                                 GdkEvent *event,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 ECellFlags flags);

Dispatches the event `event` to the `ecell_view` for.

`ecell_view` : | The ECellView where the event will be dispatched
`event` : | The GdkEvent.
`model_col` : | the column in the model
`view_col` : | the column in the view
`row` : | the row
`flags` : | flags about the current state
Returns : | processing state from the GdkEvent handling.

### e_cell_realize ()

    void        e_cell_realize                  (ECellView *ecell_view);

This function is invoked to give a chance to the ECellView to allocate any resources it needs from Gdk, equivalent to the GtkWidget::realize signal.

`ecell_view` : | The ECellView to be realized.

### e_cell_unrealize ()

    void        e_cell_unrealize                (ECellView *ecell_view);

This function is invoked to give a chance to the ECellView to release any resources it allocated during the realize method, equivalent to the GtkWidget::unrealize signal.

`ecell_view` : | The ECellView to be unrealized.

### e_cell_draw ()

    void        e_cell_draw                     (ECellView *ecell_view,
                                                 GdkDrawable *drawable,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 ECellFlags flags,
                                                 int x1,
                                                 int y1,
                                                 int x2,
                                                 int y2);

This instructs the ECellView to render itself into the drawable. The region to be drawn in given by (x1,y1)-(x2,y2).

The most important flags are `E_CELL_SELECTED` and `E_CELL_FOCUSED`, other flags include alignments and justifications.

`ecell_view` : | the ECellView to redraw
`drawable` : | draw desination
`model_col` : | the column in the model being drawn.
`view_col` : | the column in the view being drawn (what the model maps to).
`row` : | the row being drawn
`flags` : | rendering flags.
`x1` : | boudary for the rendering
`y1` : | boudary for the rendering
`x2` : | boudary for the rendering
`y2` : | boudary for the rendering

### e_cell_print ()

    void        e_cell_print                    (ECellView *ecell_view,
                                                 GnomePrintContext *context,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 double width,
                                                 double height);

FIXME:

`ecell_view` : |
`context` : |
`model_col` : |
`view_col` : |
`row` : |
`width` : |
`height` : |

### e_cell_print_height ()

    gdouble     e_cell_print_height             (ECellView *ecell_view,
                                                 GnomePrintContext *context,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 gdouble width);

`ecell_view` : |
`context` : |
`model_col` : |
`view_col` : |
`row` : |
`width` : |
Returns : |

### e_cell_max_width ()

    int         e_cell_max_width                (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col);

`ecell_view` : | the ECellView that will leave editing
`model_col` : | the column in the model
`view_col` : | the column in the view.
Returns : | the maximum width for the ECellview at `model_col` which is being rendered as `view_col`

### e_cell_show_tooltip ()

    void        e_cell_show_tooltip             (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 int col_width,
                                                 ETableTooltip *tooltip);

`ecell_view` : |
`model_col` : |
`view_col` : |
`row` : |
`col_width` : |
`tooltip` : |

### e_cell_focus ()

    void        e_cell_focus                    (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 int x1,
                                                 int y1,
                                                 int x2,
                                                 int y2);

`ecell_view` : |
`model_col` : |
`view_col` : |
`row` : |
`x1` : |
`y1` : |
`x2` : |
`y2` : |

### e_cell_unfocus ()

    void        e_cell_unfocus                  (ECellView *ecell_view);

`ecell_view` : |

### e_cell_height ()

    int         e_cell_height                   (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row);

`ecell_view` : | the ECellView.
`model_col` : | the column in the model
`view_col` : | the column in the view.
`row` : | the row to me measured
Returns : | the height of the cell at `model_col`, `row` rendered at `view_col`, `row`.

### e_cell_enter_edit ()

    void*       e_cell_enter_edit               (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row);

Notifies the ECellView that it is about to enter editing mode for `model_col`, `row` rendered at `view_col`, `row`.

`ecell_view` : | the ECellView that will enter editing
`model_col` : | the column in the model
`view_col` : | the column in the view
`row` : | the row

### e_cell_leave_edit ()

    void        e_cell_leave_edit               (ECellView *ecell_view,
                                                 int model_col,
                                                 int view_col,
                                                 int row,
                                                 void *edit_context);

Notifies the ECellView that editing is finished at `model_col`, `row` rendered at `view_col`, `row`.

`ecell_view` : | the ECellView that will leave editing
`model_col` : | the column in the model
`view_col` : | the column in the view
`row` : | the row
`edit_context` : | the editing context