/* AtkComponet interface */ static AtkObject * ecv_ref_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type) { gint x0, y0, width, height; gint subcell_height, i; GalA11yECell *gaec = GAL_A11Y_E_CELL (component); ECellVboxView *ecvv = (ECellVboxView *) (gaec->cell_view); atk_component_get_extents (component, &x0, &y0, &width, &height, coord_type); x -= x0; y -= y0; if (x < 0 || x > width || y < 0 || y > height) return NULL; for (i = 0; i < ecvv->subcell_view_count; i++) { subcell_height = e_cell_height ( ecvv->subcell_views[i], ecvv->model_cols[i], gaec->view_col, gaec->row); if ( 0 <= y && y <= subcell_height) { return ecv_ref_child ((AtkObject *) component, i); } else y -= subcell_height; } return NULL; }
/* * ECell::height method */ static gint ect_height (ECellView *ecell_view, gint model_col, gint view_col, gint row) { ECellTreeView *tree_view = (ECellTreeView *) ecell_view; return (((e_cell_height (tree_view->subcell_view, model_col, view_col, row)) + 1) / 2) * 2; }
/* * ECell::height method */ static int ecv_height (ECellView *ecell_view, int model_col, int view_col, int row) { ECellHboxView *hbox_view = (ECellHboxView *)ecell_view; int height = 0, max_height = 0; int i; for (i = 0; i < hbox_view->subcell_view_count; i++) { height = e_cell_height (hbox_view->subcell_views[i], hbox_view->model_cols[i], view_col, row); max_height = MAX(max_height, height); } return max_height; }
/* * ECell::height method */ static gint ecv_height (ECellView *ecell_view, gint model_col, gint view_col, gint row) { ECellVboxView *vbox_view = (ECellVboxView *) ecell_view; gint height = 0; gint i; for (i = 0; i < vbox_view->subcell_view_count; i++) { height += e_cell_height (vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row); } return height; }
/* * ECell::draw method */ static void ecv_draw (ECellView *ecell_view, cairo_t *cr, gint model_col, gint view_col, gint row, ECellFlags flags, gint x1, gint y1, gint x2, gint y2) { ECellVboxView *vbox_view = (ECellVboxView *) ecell_view; gint subcell_offset = 0; gint i; for (i = 0; i < vbox_view->subcell_view_count; i++) { /* Now cause our subcells to draw their contents, * shifted by subcell_offset pixels */ gint height; height = e_cell_height ( vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row); e_cell_draw ( vbox_view->subcell_views[i], cr, vbox_view->model_cols[i], view_col, row, flags, x1, y1 + subcell_offset, x2, y1 + subcell_offset + height); subcell_offset += e_cell_height ( vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row); } }
/* * ECell::event method */ static gint ecv_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col, gint row, ECellFlags flags, ECellActions *actions) { ECellVboxView *vbox_view = (ECellVboxView *) ecell_view; gint y = 0; gint i; gint subcell_offset = 0; switch (event->type) { case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: y = event->button.y; break; case GDK_MOTION_NOTIFY: y = event->motion.y; break; default: /* nada */ break; } for (i = 0; i < vbox_view->subcell_view_count; i++) { gint height = e_cell_height (vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row); if (y < subcell_offset + height) return e_cell_event (vbox_view->subcell_views[i], event, vbox_view->model_cols[i], view_col, row, flags, actions); subcell_offset += height; } return 0; }
/* * ECell::event method */ static gint ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col, gint row, ECellFlags flags, ECellActions *actions) { GtkLayout *layout; GdkWindow *window; ECellTreeView *tree_view = (ECellTreeView *) ecell_view; ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row); ETreeTableAdapter *etta = e_cell_tree_get_tree_table_adapter (ecell_view->e_table_model, row); ETreePath node = e_cell_tree_get_node (ecell_view->e_table_model, row); gint offset = offset_of_node (ecell_view->e_table_model, row); gint result; layout = GTK_LAYOUT (tree_view->canvas); window = gtk_layout_get_bin_window (layout); switch (event->type) { case GDK_BUTTON_PRESS: if (event_in_expander (event, offset, 0)) { if (e_tree_model_node_is_expandable (tree_model, node)) { gboolean expanded = e_tree_table_adapter_node_is_expanded (etta, node); gint tmp_row = row; GdkRectangle area; animate_closure_t *closure = g_new0 (animate_closure_t, 1); cairo_t *cr; gint hgt; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; hgt = e_cell_height (ecell_view, model_col, view_col, row); if (hgt != area.height) /* Composite cells */ area.height += hgt; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, expanded ? GTK_EXPANDER_SEMI_EXPANDED : GTK_EXPANDER_SEMI_COLLAPSED, GTK_STATE_NORMAL, &area); cairo_destroy (cr); closure->ectv = tree_view; closure->etta = etta; closure->node = node; closure->expanded = expanded; closure->area = area; tree_view->animate_timeout = e_named_timeout_add ( 50, animate_expander, closure); return TRUE; } } else if (event->button.x < (offset - INDENT_AMOUNT)) return FALSE; break; case GDK_MOTION_NOTIFY: if (e_tree_model_node_is_expandable (tree_model, node)) { gint height = ect_height (ecell_view, model_col, view_col, row); GdkRectangle area; gboolean in_expander = event_in_expander (event, offset, height); if (tree_view->prelit ^ in_expander) { gint tmp_row = row; cairo_t *cr; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, in_expander ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, &area); cairo_destroy (cr); tree_view->prelit = in_expander; return TRUE; } } break; case GDK_LEAVE_NOTIFY: if (tree_view->prelit) { gint tmp_row = row; GdkRectangle area; cairo_t *cr; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &area); cairo_destroy (cr); tree_view->prelit = FALSE; } return TRUE; default: break; } adjust_event_position (event, -offset); result = e_cell_event (tree_view->subcell_view, event, model_col, view_col, row, flags, actions); adjust_event_position (event, offset); return result; }