aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-02-12 08:27:22 +0800
committerChris Lahey <clahey@src.gnome.org>2000-02-12 08:27:22 +0800
commit04bb0a4fb01448394533a80850370448a2f3aadf (patch)
tree847a8b541f2597a80e2bfdc73b3401a288368128 /widgets/table
parent07d9ddab8e2b6759bbe1b2364371bf5c7b6fe6de (diff)
downloadgsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar.gz
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar.bz2
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar.lz
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar.xz
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.tar.zst
gsoc2013-evolution-04bb0a4fb01448394533a80850370448a2f3aadf.zip
Test column header image.
2000-02-11 Christopher James Lahey <clahey@helixcode.com> * clip.png: Test column header image. * test-check.c: Test pixbuf column headers. * e-table-col.h, e-table-col.c: Added pixbufs for column headers. * e-table-header-item.c (draw_button): Draw pixbuf column headers properly. svn path=/trunk/; revision=1739
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/clip.pngbin0 -> 192 bytes
-rw-r--r--widgets/table/e-table-col.c39
-rw-r--r--widgets/table/e-table-col.h20
-rw-r--r--widgets/table/e-table-header-item.c50
-rw-r--r--widgets/table/test-check.c5
5 files changed, 90 insertions, 24 deletions
diff --git a/widgets/table/clip.png b/widgets/table/clip.png
new file mode 100644
index 0000000000..27aa5f072f
--- /dev/null
+++ b/widgets/table/clip.png
Binary files differ
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
index 6f475158a5..ba5c131078 100644
--- a/widgets/table/e-table-col.c
+++ b/widgets/table/e-table-col.c
@@ -21,7 +21,10 @@ etc_destroy (GtkObject *object)
{
ETableCol *etc = E_TABLE_COL (object);
- g_free (etc->text);
+ if ( etc->is_pixbuf )
+ gdk_pixbuf_unref( etc->pixbuf );
+ else
+ g_free (etc->text);
(*parent_class->destroy)(object);
}
@@ -47,9 +50,12 @@ e_table_col_new (int col_idx, const char *text, int width, int min_width,
g_return_val_if_fail (compare != NULL, NULL);
etc = gtk_type_new (E_TABLE_COL_TYPE);
+
+ etc->is_pixbuf = FALSE;
etc->col_idx = col_idx;
etc->text = g_strdup (text);
+ etc->pixbuf = NULL;
etc->width = width;
etc->min_width = min_width;
etc->ecell = ecell;
@@ -61,4 +67,35 @@ e_table_col_new (int col_idx, const char *text, int width, int min_width,
return etc;
}
+ETableCol *
+e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, int width, int min_width,
+ ECell *ecell, GCompareFunc compare, gboolean resizable)
+{
+ ETableCol *etc;
+
+ g_return_val_if_fail (width >= 0, NULL);
+ g_return_val_if_fail (min_width >= 0, NULL);
+ g_return_val_if_fail (width >= min_width, NULL);
+ g_return_val_if_fail (compare != NULL, NULL);
+
+ etc = gtk_type_new (E_TABLE_COL_TYPE);
+
+ etc->is_pixbuf = TRUE;
+
+ etc->col_idx = col_idx;
+ etc->text = NULL;
+ etc->pixbuf = pixbuf;
+ etc->width = width;
+ etc->min_width = min_width;
+ etc->ecell = ecell;
+ etc->compare = compare;
+
+ etc->selected = 0;
+ etc->resizeable = resizable;
+
+ gdk_pixbuf_ref(etc->pixbuf);
+
+ return etc;
+}
+
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
index 54f03ae237..7356820b7a 100644
--- a/widgets/table/e-table-col.h
+++ b/widgets/table/e-table-col.h
@@ -1,7 +1,9 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef _E_TABLE_COL_H_
#define _E_TABLE_COL_H_
#include "e-cell.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
#define E_TABLE_COL_TYPE (e_table_col_get_type ())
#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
@@ -17,10 +19,12 @@ typedef struct _ETableCol ETableCol;
struct _ETableCol {
GtkObject base;
char *text;
+ GdkPixbuf *pixbuf;
short width;
short min_width;
short x;
GCompareFunc compare;
+ unsigned int is_pixbuf:1;
unsigned int selected:1;
unsigned int resizeable:1;
int col_idx;
@@ -32,12 +36,16 @@ typedef struct {
GtkObjectClass parent_class;
} ETableColClass;
-GtkType e_table_col_get_type (void);
-ETableCol *e_table_col_new (int col_idx, const char *text,
- int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-void e_table_col_destroy (ETableCol *etc);
+GtkType e_table_col_get_type (void);
+ETableCol *e_table_col_new (int col_idx, const char *text,
+ int width, int min_width,
+ ECell *ecell, GCompareFunc compare,
+ gboolean resizable);
+ETableCol *e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf,
+ int width, int min_width,
+ ECell *ecell, GCompareFunc compare,
+ gboolean resizable);
+void e_table_col_destroy (ETableCol *etc);
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index 72f78453d9..bd78d8ef71 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -14,6 +14,7 @@
#include <libgnomeui/gnome-canvas-util.h>
#include <libgnomeui/gnome-canvas-polygon.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include "e-util/e-cursors.h"
#include "e-table-header.h"
#include "e-table-header-item.h"
@@ -36,6 +37,9 @@
static GnomeCanvasItemClass *ethi_parent_class;
+static void ethi_request_redraw (ETableHeaderItem *ethi);
+
+
/*
* DnD icons
*/
@@ -60,8 +64,7 @@ static GtkTargetEntry ethi_drop_types [] = {
};
static void
-ethi_destroy (GtkObject *object)
-{
+ethi_destroy (GtkObject *object){
ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object);
gtk_object_unref (GTK_OBJECT (ethi->eth));
@@ -482,19 +485,34 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
gdk_gc_set_clip_rectangle (ethi->gc, &clip);
- /* Center the thing */
- xtra = (clip.width - gdk_string_measure (ethi->font, col->text))/2;
+ if ( col->is_pixbuf ) {
+ xtra = (clip.width - gdk_pixbuf_get_width(col->pixbuf))/2;
+
+ x += xtra + PADDING / 2;
+
+ gdk_pixbuf_render_to_drawable_alpha(col->pixbuf,
+ drawable,
+ 0, 0,
+ x, 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;
- if (xtra < 0)
- xtra = 0;
-
- /* Skip over border */
- x += xtra + 2;
+ x += xtra + PADDING / 2;
- gdk_draw_text (
- drawable, ethi->font,
- ethi->gc, x, y + ethi->height - PADDING,
- col->text, strlen (col->text));
+ gdk_draw_text (
+ drawable, ethi->font,
+ ethi->gc, x, y + ethi->height - ethi->font->descent - PADDING / 2,
+ col->text, strlen (col->text));
+ }
}
static void
@@ -707,12 +725,12 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
}
new_width = x - ethi->resize_start_pos;
+
if (new_width <= 0)
- break;
+ new_width = 1;
if (new_width < ethi->resize_min_width)
- break;
-
+ new_width = ethi->resize_min_width;
ethi_request_redraw (ethi);
ethi->resize_width = new_width;
diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c
index 61fe161ca1..86c01cf202 100644
--- a/widgets/table/test-check.c
+++ b/widgets/table/test-check.c
@@ -92,6 +92,7 @@ check_test (void)
ETableHeader *e_table_header;
ETableCol *col_0, *col_1;
ECell *cell_left_just, *cell_image_check;
+ GdkPixbuf *pixbuf;
gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
@@ -108,7 +109,9 @@ check_test (void)
cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT, TRUE);
cell_image_check = e_cell_checkbox_new ();
- col_0 = e_table_col_new (0, "", 18, 18, cell_image_check, g_int_equal, TRUE);
+ pixbuf = gdk_pixbuf_new_from_file("clip.png");
+ col_0 = e_table_col_new_with_pixbuf (0, pixbuf, 18, 18, cell_image_check, g_int_equal, TRUE);
+ gdk_pixbuf_unref(pixbuf);
e_table_header_add_column (e_table_header, col_0, 0);
col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);