diff options
author | Iain Holmes <iain@helixcode.com> | 2000-09-16 05:42:38 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2000-09-16 05:42:38 +0800 |
commit | 6e4ae07fbfce5845d48e8ba1992f64376a885ac4 (patch) | |
tree | cdf00c9707a7de41e34f4b3ba48ea695224ca0eb /widgets/table/e-table-header-item.c | |
parent | ce3c18afd96cc9fb91fca4dfabc440206aa2f99e (diff) | |
download | gsoc2013-evolution-6e4ae07fbfce5845d48e8ba1992f64376a885ac4.tar.gz gsoc2013-evolution-6e4ae07fbfce5845d48e8ba1992f64376a885ac4.tar.zst gsoc2013-evolution-6e4ae07fbfce5845d48e8ba1992f64376a885ac4.zip |
If the cursor is inside the subcell, call the show_tooltip on it.
2000-09-15 Iain Holmes <iain@helixcode.com>
* e-cell-tree.c (ect_show_tooltip): If the cursor is inside
the subcell, call the show_tooltip on it.
* e-table-header-item.c (draw_button): Draw the arrow first,
then take it's size into account when calculating how to draw
the text. Use ellipsis if the text it too long.
2000-09-15 Iain Holmes <iain@helixcode.com>
* e-table-header-item.c (draw_button): Fix a crash by passing
the canvas widget to gtk_paint_box. Reported by Radek.
2000-09-14 Iain Holmes <iain@helixcode.com>
* e-table-header-item.c (set_cursor): The column isn't resizable
if it is the last, or if all other columns after it are not
resizable.
* e-cell-text.c (ect_max_width): Correctly calculate the width
of the line of text. Unbuild the current cell and unref the lines
as well.
(build_current_cell): Initialize cell->style to 0;
2000-09-14 Iain Holmes <iain@helixcode.com>
* e-table-item.c: Start timers for the tooltip to appear, on motion
events.
* e-cell.[ch]: Add a new show_tooltip method.
* e-cell-text.c (ect_show_tooltip): Show the tooltip.
svn path=/trunk/; revision=5466
Diffstat (limited to 'widgets/table/e-table-header-item.c')
-rw-r--r-- | widgets/table/e-table-header-item.c | 136 |
1 files changed, 97 insertions, 39 deletions
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index ec25e0d0f0..903d6b954f 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -740,40 +740,6 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col, gdk_gc_set_clip_rectangle (ethi->gc, &clip); - if (col->is_pixbuf){ - xtra = (clip.width - gdk_pixbuf_get_width (col->pixbuf))/2; - - xtra += HEADER_PADDING / 2; - - gdk_pixbuf_render_to_drawable_alpha (col->pixbuf, - drawable, - 0, 0, - x + xtra, y + (clip.height - gdk_pixbuf_get_height (col->pixbuf)) / 2, - gdk_pixbuf_get_width (col->pixbuf), gdk_pixbuf_get_height(col->pixbuf), - GDK_PIXBUF_ALPHA_FULL, 128, - GDK_RGB_DITHER_NORMAL, - 0, 0); - } else { - /* Center the thing */ - xtra = (clip.width - gdk_string_measure (ethi->font, col->text))/2; - - /* Skip over border */ - if (xtra < 0) - xtra = 0; - - xtra += HEADER_PADDING / 2; - - gdk_draw_text ( - drawable, ethi->font, - ethi->gc, x + xtra, y + ethi->height - ethi->font->descent - HEADER_PADDING / 2, - col->text, strlen (col->text)); - } - - if (col->pixbuf){ - if ((gdk_pixbuf_get_width (col->pixbuf) + MIN_ARROW_SIZE + 4) > width) - return; - } - switch (arrow){ case E_TABLE_COL_ARROW_NONE: break; @@ -794,8 +760,81 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col, y + (ethi->height - MIN_ARROW_SIZE) / 2, MIN_ARROW_SIZE, MIN_ARROW_SIZE); + + clip.width -= (MIN_ARROW_SIZE + 2 + HEADER_PADDING); break; } + + if (col->is_pixbuf){ + xtra = (clip.width - gdk_pixbuf_get_width (col->pixbuf))/2; + + xtra += HEADER_PADDING / 2; + + gdk_pixbuf_render_to_drawable_alpha (col->pixbuf, + drawable, + 0, 0, + x + xtra, y + (clip.height - gdk_pixbuf_get_height (col->pixbuf)) / 2, + gdk_pixbuf_get_width (col->pixbuf), gdk_pixbuf_get_height(col->pixbuf), + GDK_PIXBUF_ALPHA_FULL, 128, + GDK_RGB_DITHER_NORMAL, + 0, 0); + } else { + int str_width, ellipsis_width, text_len; + + text_len = strlen (col->text); + ellipsis_width = gdk_text_width (ethi->font, "...", 3); + + str_width = gdk_text_width (ethi->font, col->text, text_len); + + if (str_width < clip.width) { + /* Center the thing */ + xtra = (clip.width - gdk_string_measure (ethi->font, col->text))/2; + + /* Skip over border */ + if (xtra < 0) + xtra = 0; + + xtra += HEADER_PADDING / 2; + + gdk_draw_text ( + drawable, ethi->font, + ethi->gc, x + xtra, y + ethi->height - ethi->font->descent - HEADER_PADDING / 2, + col->text, text_len); + } else { + /* Need ellipsis */ + gchar *p; + int ellipsis_length = 0; + + for (p = col->text; p && *p && (p - col->text) < text_len; p++) { + if (gdk_text_width (ethi->font, col->text, p - col->text) + ellipsis_width <= clip.width) + ellipsis_length = p - col->text; + else + break; + } + + xtra = (clip.width - gdk_text_measure (ethi->font, col->text, ellipsis_length) - gdk_string_measure (ethi->font, "..."))/2; + + if (xtra < 0) + xtra = 0; + + xtra += HEADER_PADDING / 2; + + gdk_draw_text (drawable, ethi->font, ethi->gc, + x + xtra, y + ethi->height - ethi->font->descent - HEADER_PADDING / 2, + col->text, ellipsis_length); + gdk_draw_string (drawable, ethi->font, ethi->gc, + x + xtra + gdk_text_width (ethi->font, + col->text, + ellipsis_length), + y + ethi->height - ethi->font->descent - HEADER_PADDING / 2, + "..."); + } + } + + if (col->pixbuf){ + if ((gdk_pixbuf_get_width (col->pixbuf) + MIN_ARROW_SIZE + 4) > width) + return; + } } static void @@ -912,19 +951,37 @@ set_cursor (ETableHeaderItem *ethi, int pos) { int col; GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); + gboolean resizeable = FALSE; /* We might be invoked before we are realized */ if (!canvas->window) return; if (is_pointer_on_division (ethi, pos, NULL, &col)) { + int last_col = ethi->eth->col_count - 1; ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - if (ecol->resizeable) - e_cursor_set (canvas->window, E_CURSOR_SIZE_X); - else - e_cursor_set (canvas->window, E_CURSOR_ARROW); - } else + /* Last column is not resizable */ + if (ecol->resizeable && col != last_col) { + int c = col + 1; + + /* Column is not resizable if all columns after it + are also not resizable */ + for (; c <= last_col; c++){ + ETableCol *ecol2; + + ecol2 = e_table_header_get_column (ethi->eth, c); + if (ecol2->resizeable) { + resizeable = TRUE; + break; + } + } + } + } + + if (resizeable) + e_cursor_set (canvas->window, E_CURSOR_SIZE_X); + else e_cursor_set (canvas->window, E_CURSOR_ARROW); } @@ -1325,6 +1382,7 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) e_table_header_set_size (ethi->eth, ethi->resize_col, width + 10); gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(ethi)); + ethi->maybe_drag = FALSE; } break; |