From 7699b8996aa2d9ae3fea0e94981637c98e89a273 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 24 Feb 2000 06:51:23 +0000 Subject: This were moved to widgets/e-text/ a while ago but never removed. They 2000-02-24 Christopher James Lahey * widgets/e-text.c, widgets/e-text.h, e-text-event-processor.c, e-text-event-processor.h, e-text-event-processor-emacs-like.c, e-text-event-processor-emacs-like.h, e-text-event-processor-types.h: This were moved to widgets/e-text/ a while ago but never removed. They have now been removed. * widgets/e-text/e-text.c, widgets/e-text/e-text.h: Removed some warnings from this file. Made tooltips disappear when you're finished with them. * widgets/e-minicard/test-reflow.c, widgets/e-minicard/test-minicard.c, widgets/e-minicard/test-minicard-label.c: Commented out unused about_callback functions. * widgets/e-minicard/e-reflow.c: Made e-reflow pass an EFocus to its e-minicard children. * widgets/e-minicard/e-minicard.c: Made e-minicard take and return an EFocus for its "has_focus" argument. This makes shift-tab work properly. * widgets/e-minicard/e-minicard-label.c: Made e-minicard-label take and return an EFocus for its "has_focus" argument. Made the font that e-minicard-label uses only be allocated once. * e-util/e-canvas-utils.h: Fixed the comment at the top and added #ifndef __E_CANVAS_UTILS__. * e-util/Makefile.am: Added e-xml-utils.c and e-xml-utils.h. * e-util/e-xml-utils.h, e-util/e-xml-utils.c: Added files for some xml utilities. * e-util/e-util.h: Added type EFocus which describes which direction the focus will be coming from. in mail: 2000-02-24 Christopher James Lahey * message-list.c: Changed this to not use the "x" and "y" arguments to e-table-item. in widgets/e-table: 2000-02-24 Christopher James Lahey * e-table-subset-variable.c, e-table-subset-variable.h: A new model which is a subset, but you can add and remove rows. * test-table.c: Added a thaw method for use with the e-table-subset (emits model_changed.) Adapted to the changes to e_table_item. Properly parse headers. Adapted to the changes to e_table, including creating example xml spec data. * test-cols.c, test-check.c: Added a thaw method for use with the e-table-subset (emits model_changed.) Adapted to the changes to e_table_item. * e-table.c, e-table.h: Reworked e-table to use the ETable grouping system. The only difference for the interface is that instead of passing in a column_spec and a grouping_spec, you pass in a single string that is an xml format that includes both pieces of information. * e-table-subset.h: Added rules for emacs to do correct indentation. * e-table-subset.c: Implemented freezing. No signals are emitted while frozen and "model_changed" is emitted when thawed. * e-table-sorted.h: ETableSortedClass has ETableSubset as its parent object instead of ETableSubsetClass. Fixed this. * e-table-simple.c, e-table-simple.h: Implemented the thaw method. Use of simple now requires an extra argument (the thaw method.) * e-table-model.h, e-table-model.c: Added e_table_model_freeze and e_table_model_thaw. * e-table-item.h, e-table-item.c: Reworked this a bit to make it provide some things the new group system needed and to make inter-item keyboard focus work. Changed the external interface only in the list of arguments it recognizes and signals it emits. Instead of "x" and "y", you have to use e_canvas_item_move_absolute and instead of emitting a "height_changed" signal, it emits a "resize" signal. There's new "has_focus", "width", and "height" arguments and a function to get the currently focused column. * e-table-header-item.c: Got rid of some warnings here. Changed the * e-table-group-leaf.h, e-table-group-leaf.c, e-table-group-container.h, e-table-group-container.c: New types to make e_table_group work properly. * e-table-group.h, e-table-group.c: Completely reworked e-table grouping. e-table-group now uses a hierarchical structure. * e-cell.h: Added e_cell_print. This doesn't work yet. * e-cell.c: Made e_cell_realize exist. (It was improperly named e_cell_view_realize in the .c.) * e-cell-text.c: Made the blinking cursor disappear properly. * check-filled.xpm, check-empty.xpm: Made these const char *[] instead of char *[] to avoid compiler warnings. * Makefile.am: Added e-table-group-container.c, e-table-group-container.h, e-table-group-leaf.c, e-table-group-leaf.h, e-table-subset-variable.c, e-table-subset-variable.h. svn path=/trunk/; revision=1915 --- widgets/table/e-table-group.c | 419 ++++++++++++++++++++++++------------------ 1 file changed, 241 insertions(+), 178 deletions(-) (limited to 'widgets/table/e-table-group.c') diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c index 5652d2623f..68bc3e7abf 100644 --- a/widgets/table/e-table-group.c +++ b/widgets/table/e-table-group.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * E-Table-Group.c: Implements the grouping objects for elements on a table * @@ -10,8 +11,11 @@ #include #include #include "e-table-group.h" +#include "e-table-group-container.h" +#include "e-table-group-leaf.h" #include "e-table-item.h" #include +#include #include "e-util/e-util.h" #define TITLE_HEIGHT 16 @@ -19,88 +23,30 @@ #define PARENT_TYPE gnome_canvas_group_get_type () +#define ETG_CLASS(e) (E_TABLE_GROUP_CLASS(GTK_OBJECT(e)->klass)) + static GnomeCanvasGroupClass *etg_parent_class; enum { - HEIGHT_CHANGED, + RESIZE, LAST_SIGNAL }; static gint etg_signals [LAST_SIGNAL] = { 0, }; -static void -etg_destroy (GtkObject *object) -{ - ETableGroup *etg = E_TABLE_GROUP (object); - - GTK_OBJECT_CLASS (etg_parent_class)->destroy (object); -} - -static void -etg_dim (ETableGroup *etg, int *width, int *height) -{ - GSList *l; - - *width = *height = 0; - - for (l = etg->children; l; l = l->next){ - GnomeCanvasItem *child = l->data; - - *height += child->y2 - child->y1; - *width += child->x2 - child->x1; - } - - if (!etg->transparent){ - *height += TITLE_HEIGHT; - *width += GROUP_INDENT; - } -} +/* The arguments we take */ +enum { + ARG_0, + ARG_HEIGHT, + ARG_WIDTH, + ARG_FROZEN +}; -void -e_table_group_construct (GnomeCanvasGroup *parent, ETableGroup *etg, - ETableCol *ecol, gboolean open, - gboolean transparent) -{ - gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL); - - etg->ecol = ecol; - etg->open = open; - etg->transparent = transparent; - - etg_dim (etg, &etg->width, &etg->height); - - if (!etg->transparent) - etg->rect = gnome_canvas_item_new ( - GNOME_CANVAS_GROUP (etg), - gnome_canvas_rect_get_type (), - "fill_color", "gray", - "outline_color", "gray20", - "x1", 0.0, - "y1", 0.0, - "x2", (double) etg->width, - "y2", (double) etg->height, - NULL); +static void etg_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static void etg_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static gboolean etg_get_focus (ETableGroup *etg); #if 0 - /* - * Reparent the child into our space. - */ - gnome_canvas_item_reparent (child, GNOME_CANVAS_GROUP (etg)); - - gnome_canvas_item_set ( - child, - "x", (double) GROUP_INDENT, - "y", (double) TITLE_HEIGHT, - NULL); - - /* - * Force dimension computation - */ - GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update ( - GNOME_CANVAS_ITEM (etg), NULL, NULL, GNOME_CANVAS_UPDATE_REQUESTED); -#endif -} - GnomeCanvasItem * e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol, gboolean open, gboolean transparent) @@ -116,158 +62,275 @@ e_table_group_new (GnomeCanvasGroup *parent, ETableCol *ecol, return GNOME_CANVAS_ITEM (etg); } +#endif -static void -etg_relayout (GnomeCanvasItem *eti, ETableGroup *etg) +ETableGroup * +e_table_group_new (GnomeCanvasGroup *parent, + ETableHeader *full_header, + ETableHeader *header, + ETableModel *model, + xmlNode *rules) { - GSList *l; - int height = etg->transparent ? 0 : GROUP_INDENT; - gboolean move = FALSE; + g_return_val_if_fail (model != NULL, NULL); - printf ("Relaying out\n"); - - for (l = etg->children; l->next; l = l->next){ - GnomeCanvasItem *child = l->data; + if(rules && !xmlStrcmp(rules->name, "group")) { + gint col_idx = atoi(xmlGetProp(rules, "column")); + ETableCol *col; + if ( col_idx > e_table_header_count(full_header) ) + return e_table_group_leaf_new(parent, full_header, header, model); + col = e_table_header_get_columns(full_header)[col_idx]; + return e_table_group_container_new(parent, full_header, header, model, col, rules->childs); + } else { + return e_table_group_leaf_new(parent, full_header, header, model); + } + return NULL; +} + +void +e_table_group_construct (GnomeCanvasGroup *parent, + ETableGroup *etg, + ETableHeader *full_header, + ETableHeader *header, + ETableModel *model) +{ + gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL); + etg->full_header = full_header; + etg->header = header; + etg->model = model; +} + +void +e_table_group_add (ETableGroup *etg, + gint row) +{ + g_return_if_fail (etg != NULL); + g_return_if_fail (E_IS_TABLE_GROUP (etg)); - height += child->y2 - child->y1; + if ( ETG_CLASS (etg)->add ) + ETG_CLASS (etg)->add (etg, row); +} - if (child == eti) - move = TRUE; +gboolean +e_table_group_remove (ETableGroup *etg, + gint row) +{ + g_return_val_if_fail (etg != NULL, FALSE); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), FALSE); - if (move){ - printf ("Moving item %p\n", child); - gnome_canvas_item_set ( - child, - "y", (double) height, - NULL); - } - } - if (height != etg->height){ - etg->height = height; - gtk_signal_emit (GTK_OBJECT (etg), etg_signals [HEIGHT_CHANGED]); - } + if ( ETG_CLASS (etg)->remove ) + return ETG_CLASS (etg)->remove (etg, row); + else + return FALSE; +} + +gint +e_table_group_get_count (ETableGroup *etg) +{ + g_return_val_if_fail (etg != NULL, 0); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), 0); + + if ( ETG_CLASS (etg)->get_count ) + return ETG_CLASS (etg)->get_count (etg); + else + return 0; } void -e_table_group_add (ETableGroup *etg, GnomeCanvasItem *item) +e_table_group_increment (ETableGroup *etg, + gint position, + gint amount) { - double x1, y1, x2, y2; - g_return_if_fail (etg != NULL); - g_return_if_fail (item != NULL); g_return_if_fail (E_IS_TABLE_GROUP (etg)); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - etg->children = g_slist_append (etg->children, item); - - GNOME_CANVAS_ITEM_CLASS (GTK_OBJECT (etg)->klass)->bounds (etg, &x1, &y1, &x2, &y2); - - if (GTK_OBJECT (etg)->flags & GNOME_CANVAS_ITEM_REALIZED){ - GSList *l; - int height = etg->transparent ? 0 : TITLE_HEIGHT; - int x = etg->transparent ? 0 : GROUP_INDENT; - - for (l = etg->children; l->next; l = l->next){ - GnomeCanvasItem *child = l->data; - - height += child->y2 - child->y1; - - printf ("Height\n"); - if (E_IS_TABLE_ITEM (item)){ - printf (" Item: "); - } else { - printf (" Group: "); - } - printf ("%d\n", child->y2-child->y1); - } - gnome_canvas_item_set ( - item, - "y", (double) height, - "x", (double) x, - NULL); - - - if (E_IS_TABLE_ITEM (item)){ - - printf ("Table item! ---------\n"); - gtk_signal_connect (GTK_OBJECT (item), "height_changed", - GTK_SIGNAL_FUNC (etg_relayout), etg); - } - } + if ( ETG_CLASS (etg)->increment ) + ETG_CLASS (etg)->increment (etg, position, amount); } -static void -etg_realize (GnomeCanvasItem *item) +void +e_table_group_set_focus (ETableGroup *etg, + EFocus direction, + gint row) +{ + g_return_if_fail (etg != NULL); + g_return_if_fail (E_IS_TABLE_GROUP (etg)); + + if ( ETG_CLASS (etg)->set_focus ) + ETG_CLASS (etg)->set_focus (etg, direction, row); +} + +gboolean +e_table_group_get_focus (ETableGroup *etg) +{ + g_return_val_if_fail (etg != NULL, FALSE); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), FALSE); + + if ( ETG_CLASS (etg)->get_focus ) + return ETG_CLASS (etg)->get_focus (etg); + else + return FALSE; +} + +gboolean +e_table_group_get_focus_column (ETableGroup *etg) +{ + g_return_val_if_fail (etg != NULL, FALSE); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), FALSE); + + if ( ETG_CLASS (etg)->get_focus_column ) + return ETG_CLASS (etg)->get_focus_column (etg); + else + return FALSE; +} + +ETableCol * +e_table_group_get_ecol (ETableGroup *etg) +{ + g_return_val_if_fail (etg != NULL, NULL); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), NULL); + + if ( ETG_CLASS (etg)->get_ecol ) + return ETG_CLASS (etg)->get_ecol (etg); + else + return NULL; +} + +void +e_table_group_resize (ETableGroup *e_table_group) +{ + g_return_if_fail (e_table_group != NULL); + g_return_if_fail (E_IS_TABLE_GROUP (e_table_group)); + + gtk_signal_emit (GTK_OBJECT (e_table_group), + etg_signals [RESIZE]); +} + +static int +etg_event (GnomeCanvasItem *item, GdkEvent *event) { ETableGroup *etg = E_TABLE_GROUP (item); - GSList *l; - int height = 0; - - GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->realize (item); + gboolean return_val = TRUE; - for (l = etg->children; l; l = l->next){ - GnomeCanvasItem *child = l->data; + switch (event->type) { - printf ("During realization for child %p -> %d\n", child, height); - gnome_canvas_item_set ( - child, - "y", (double) height, - NULL); + case GDK_FOCUS_CHANGE: + etg->has_focus = event->focus_change.in; + return_val = FALSE; - height += child->y2 - child->y1; + default: + return_val = FALSE; } + if ( return_val == FALSE ) { + if ( GNOME_CANVAS_ITEM_CLASS(etg_parent_class)->event ) + return GNOME_CANVAS_ITEM_CLASS(etg_parent_class)->event(item, event); + } + return return_val; + } static void -etg_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) +etg_thaw(ETableGroup *etg) { - ETableGroup *etg = E_TABLE_GROUP (item); + g_return_if_fail (etg != NULL); + g_return_if_fail (E_IS_TABLE_GROUP (etg)); + + if ( ETG_CLASS (etg)->thaw ) + ETG_CLASS (etg)->thaw (etg); +} + +static void +etg_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + ETableGroup *etg = E_TABLE_GROUP (object); - GNOME_CANVAS_ITEM_CLASS (etg_parent_class)->update (item, affine, clip_path, flags); - - if (!etg->transparent){ - int current_width, current_height; - - etg_dim (etg, ¤t_width, ¤t_height); - - if ((current_height != etg->height) || (current_width != etg->width)){ - etg->width = current_width; - etg->height = current_height; - - gnome_canvas_item_set ( - etg->rect, - "x1", 0.0, - "y1", 0.0, - "x2", (double) etg->width, - "y2", (double) etg->height, - NULL); + switch (arg_id) { + case ARG_FROZEN: + if ( GTK_VALUE_BOOL (*arg) ) + etg->frozen = TRUE; + else { + etg->frozen = FALSE; + etg_thaw(etg); } + break; + case ARG_WIDTH: + if ( ETG_CLASS(etg)->set_width ) + ETG_CLASS(etg)->set_width(etg, GTK_VALUE_DOUBLE (*arg)); + break; + default: + break; } } +static void +etg_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + ETableGroup *etg = E_TABLE_GROUP (object); + + switch (arg_id) { + case ARG_FROZEN: + GTK_VALUE_BOOL (*arg) = etg->frozen; + break; + case ARG_HEIGHT: + if ( ETG_CLASS(etg)->get_height ) + GTK_VALUE_DOUBLE (*arg) = ETG_CLASS(etg)->get_height(etg); + else + arg->type = GTK_TYPE_INVALID; + break; + case ARG_WIDTH: + if ( ETG_CLASS(etg)->get_width ) + GTK_VALUE_DOUBLE (*arg) = ETG_CLASS(etg)->get_width(etg); + else + arg->type = GTK_TYPE_INVALID; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static gboolean +etg_get_focus (ETableGroup *etg) +{ + return etg->has_focus; +} + static void etg_class_init (GtkObjectClass *object_class) { GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; + ETableGroupClass *klass = (ETableGroupClass *) object_class; + + object_class->set_arg = etg_set_arg; + object_class->get_arg = etg_get_arg; - object_class->destroy = etg_destroy; + item_class->event = etg_event; - item_class->realize = etg_realize; - item_class->update = etg_update; + klass->resize = NULL; + + klass->add = NULL; + klass->remove = NULL; + klass->get_count = NULL; + klass->increment = NULL; + klass->set_focus = NULL; + klass->get_focus = etg_get_focus; + klass->get_ecol = NULL; + + klass->thaw = NULL; + klass->get_height = NULL; + klass->get_width = NULL; + klass->set_width = NULL; etg_parent_class = gtk_type_class (PARENT_TYPE); - etg_signals [HEIGHT_CHANGED] = - gtk_signal_new ("height_changed", + etg_signals [RESIZE] = + gtk_signal_new ("resize", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (ETableGroupClass, height_changed), + GTK_SIGNAL_OFFSET (ETableGroupClass, resize), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, etg_signals, LAST_SIGNAL); - } E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE); -- cgit v1.2.3