aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-02-12 12:13:14 +0800
committerChris Lahey <clahey@src.gnome.org>2000-02-12 12:13:14 +0800
commit4ddf8af33a9dbbdc5ce946da54ee228403ff577f (patch)
tree88c35086789edb574c1bc11270f8b7bf5c84227b /widgets
parentd2fe58c56857e9e4b2e37f87174da6956b0d985c (diff)
downloadgsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar.gz
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar.bz2
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar.lz
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar.xz
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.tar.zst
gsoc2013-evolution-4ddf8af33a9dbbdc5ce946da54ee228403ff577f.zip
Added test of sort arrows.
2000-02-11 Christopher James Lahey <clahey@helixcode.com> * test-check.c: Added test of sort arrows. * e-table-col.h, e-table-col.c: Added sort arrows for column headers (It doesn't actually sort. It just displays the arrows.) * e-table-header-item.c: Added display of arrows. svn path=/trunk/; revision=1743
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table/ChangeLog9
-rw-r--r--widgets/e-table/e-table-col.c17
-rw-r--r--widgets/e-table/e-table-col.h40
-rw-r--r--widgets/e-table/e-table-header-item.c40
-rw-r--r--widgets/e-table/test-check.c1
-rw-r--r--widgets/table/e-table-col.c17
-rw-r--r--widgets/table/e-table-col.h40
-rw-r--r--widgets/table/e-table-header-item.c40
-rw-r--r--widgets/table/test-check.c1
9 files changed, 163 insertions, 42 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index bffb8151bd..5b1077a7ab 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,14 @@
2000-02-11 Christopher James Lahey <clahey@helixcode.com>
+ * test-check.c: Added test of sort arrows.
+
+ * e-table-col.h, e-table-col.c: Added sort arrows for column
+ headers (It doesn't actually sort. It just displays the arrows.)
+
+ * e-table-header-item.c: Added display of arrows.
+
+2000-02-11 Christopher James Lahey <clahey@helixcode.com>
+
* clip.png: Test column header image.
* test-check.c: Test pixbuf column headers.
diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c
index ba5c131078..e2e12caf63 100644
--- a/widgets/e-table/e-table-col.c
+++ b/widgets/e-table/e-table-col.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* E-table-col.c: ETableCol implementation
*
@@ -61,6 +62,8 @@ e_table_col_new (int col_idx, const char *text, int width, int min_width,
etc->ecell = ecell;
etc->compare = compare;
+ etc->arrow = E_TABLE_COL_ARROW_NONE;
+
etc->selected = 0;
etc->resizeable = resizable;
@@ -90,6 +93,8 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, int width, int min_
etc->ecell = ecell;
etc->compare = compare;
+ etc->arrow = E_TABLE_COL_ARROW_NONE;
+
etc->selected = 0;
etc->resizeable = resizable;
@@ -98,4 +103,16 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, int width, int min_
return etc;
}
+void
+e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow)
+{
+ col->arrow = arrow;
+}
+
+ETableColArrow
+e_table_col_get_arrow (ETableCol *col)
+{
+ return col->arrow;
+}
+
diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h
index 7356820b7a..c6f9c9dfb5 100644
--- a/widgets/e-table/e-table-col.h
+++ b/widgets/e-table/e-table-col.h
@@ -12,6 +12,14 @@
#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
typedef struct _ETableCol ETableCol;
+typedef struct _ETableColClass ETableColClass;
+typedef enum _ETableColArrow ETableColArrow;
+
+enum _ETableColArrow {
+ E_TABLE_COL_ARROW_NONE,
+ E_TABLE_COL_ARROW_UP,
+ E_TABLE_COL_ARROW_DOWN
+};
/*
* Information about a single column
@@ -29,23 +37,27 @@ struct _ETableCol {
unsigned int resizeable:1;
int col_idx;
- ECell *ecell;
+ ETableColArrow arrow;
+
+ ECell *ecell;
};
-typedef struct {
+struct _ETableColClass {
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);
-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);
+};
+
+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);
+void e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow);
+ETableColArrow e_table_col_get_arrow (ETableCol *col);
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index bd78d8ef71..039015b3ec 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -26,6 +26,8 @@
/* Padding above and below of the string in the header display */
#define PADDING 4
+#define MIN_ARROW_SIZE 10
+
/* Defines the tolerance for proximity of the column division to the cursor position */
#define TOLERANCE 2
@@ -100,6 +102,8 @@ ethi_font_load (ETableHeaderItem *ethi, char *font)
ethi->font = gdk_font_load ("fixed");
ethi->height = ethi->font->ascent + ethi->font->descent + PADDING;
+ if ( ethi->height < MIN_ARROW_SIZE + 4 + PADDING )
+ ethi->height = MIN_ARROW_SIZE + 4 + PADDING;
}
static void
@@ -468,6 +472,7 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
{
GdkRectangle clip;
int xtra;
+ int arrowx;
gdk_draw_rectangle (
drawable, gc, TRUE,
@@ -478,9 +483,9 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
x , y, width, height);
- clip.x = x + 2;
- clip.y = y + 2;
- clip.width = width - 4;
+ clip.x = x + PADDING / 2;
+ clip.y = y + PADDING / 2;
+ clip.width = width - PADDING;
clip.height = ethi->height;
gdk_gc_set_clip_rectangle (ethi->gc, &clip);
@@ -488,12 +493,12 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
if ( col->is_pixbuf ) {
xtra = (clip.width - gdk_pixbuf_get_width(col->pixbuf))/2;
- x += xtra + PADDING / 2;
+ 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,
+ 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,
@@ -506,13 +511,34 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
if (xtra < 0)
xtra = 0;
- x += xtra + PADDING / 2;
+ xtra += PADDING / 2;
gdk_draw_text (
drawable, ethi->font,
- ethi->gc, x, y + ethi->height - ethi->font->descent - PADDING / 2,
+ ethi->gc, x + xtra, y + ethi->height - ethi->font->descent - PADDING / 2,
col->text, strlen (col->text));
}
+
+ switch ( e_table_col_get_arrow(col) ) {
+ case E_TABLE_COL_ARROW_NONE:
+ break;
+ case E_TABLE_COL_ARROW_UP:
+ case E_TABLE_COL_ARROW_DOWN:
+ gtk_paint_arrow (gtk_widget_get_style(GTK_WIDGET(GNOME_CANVAS_ITEM(ethi)->canvas)),
+ drawable,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ &clip,
+ GTK_WIDGET(GNOME_CANVAS_ITEM(ethi)->canvas),
+ "header",
+ e_table_col_get_arrow(col) == E_TABLE_COL_ARROW_UP ? GTK_ARROW_UP : GTK_ARROW_DOWN,
+ TRUE,
+ x + PADDING / 2 + clip.width - MIN_ARROW_SIZE - 2,
+ y + (ethi->height - MIN_ARROW_SIZE) / 2,
+ MIN_ARROW_SIZE,
+ MIN_ARROW_SIZE);
+ break;
+ }
}
static void
diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c
index 86c01cf202..380da8048e 100644
--- a/widgets/e-table/test-check.c
+++ b/widgets/e-table/test-check.c
@@ -116,6 +116,7 @@ check_test (void)
col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
+ e_table_col_set_arrow ( col_1, E_TABLE_COL_ARROW_DOWN );
/*
* GUI
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
index ba5c131078..e2e12caf63 100644
--- a/widgets/table/e-table-col.c
+++ b/widgets/table/e-table-col.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* E-table-col.c: ETableCol implementation
*
@@ -61,6 +62,8 @@ e_table_col_new (int col_idx, const char *text, int width, int min_width,
etc->ecell = ecell;
etc->compare = compare;
+ etc->arrow = E_TABLE_COL_ARROW_NONE;
+
etc->selected = 0;
etc->resizeable = resizable;
@@ -90,6 +93,8 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, int width, int min_
etc->ecell = ecell;
etc->compare = compare;
+ etc->arrow = E_TABLE_COL_ARROW_NONE;
+
etc->selected = 0;
etc->resizeable = resizable;
@@ -98,4 +103,16 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, int width, int min_
return etc;
}
+void
+e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow)
+{
+ col->arrow = arrow;
+}
+
+ETableColArrow
+e_table_col_get_arrow (ETableCol *col)
+{
+ return col->arrow;
+}
+
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
index 7356820b7a..c6f9c9dfb5 100644
--- a/widgets/table/e-table-col.h
+++ b/widgets/table/e-table-col.h
@@ -12,6 +12,14 @@
#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
typedef struct _ETableCol ETableCol;
+typedef struct _ETableColClass ETableColClass;
+typedef enum _ETableColArrow ETableColArrow;
+
+enum _ETableColArrow {
+ E_TABLE_COL_ARROW_NONE,
+ E_TABLE_COL_ARROW_UP,
+ E_TABLE_COL_ARROW_DOWN
+};
/*
* Information about a single column
@@ -29,23 +37,27 @@ struct _ETableCol {
unsigned int resizeable:1;
int col_idx;
- ECell *ecell;
+ ETableColArrow arrow;
+
+ ECell *ecell;
};
-typedef struct {
+struct _ETableColClass {
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);
-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);
+};
+
+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);
+void e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow);
+ETableColArrow e_table_col_get_arrow (ETableCol *col);
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index bd78d8ef71..039015b3ec 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -26,6 +26,8 @@
/* Padding above and below of the string in the header display */
#define PADDING 4
+#define MIN_ARROW_SIZE 10
+
/* Defines the tolerance for proximity of the column division to the cursor position */
#define TOLERANCE 2
@@ -100,6 +102,8 @@ ethi_font_load (ETableHeaderItem *ethi, char *font)
ethi->font = gdk_font_load ("fixed");
ethi->height = ethi->font->ascent + ethi->font->descent + PADDING;
+ if ( ethi->height < MIN_ARROW_SIZE + 4 + PADDING )
+ ethi->height = MIN_ARROW_SIZE + 4 + PADDING;
}
static void
@@ -468,6 +472,7 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
{
GdkRectangle clip;
int xtra;
+ int arrowx;
gdk_draw_rectangle (
drawable, gc, TRUE,
@@ -478,9 +483,9 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
x , y, width, height);
- clip.x = x + 2;
- clip.y = y + 2;
- clip.width = width - 4;
+ clip.x = x + PADDING / 2;
+ clip.y = y + PADDING / 2;
+ clip.width = width - PADDING;
clip.height = ethi->height;
gdk_gc_set_clip_rectangle (ethi->gc, &clip);
@@ -488,12 +493,12 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
if ( col->is_pixbuf ) {
xtra = (clip.width - gdk_pixbuf_get_width(col->pixbuf))/2;
- x += xtra + PADDING / 2;
+ 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,
+ 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,
@@ -506,13 +511,34 @@ draw_button (ETableHeaderItem *ethi, ETableCol *col,
if (xtra < 0)
xtra = 0;
- x += xtra + PADDING / 2;
+ xtra += PADDING / 2;
gdk_draw_text (
drawable, ethi->font,
- ethi->gc, x, y + ethi->height - ethi->font->descent - PADDING / 2,
+ ethi->gc, x + xtra, y + ethi->height - ethi->font->descent - PADDING / 2,
col->text, strlen (col->text));
}
+
+ switch ( e_table_col_get_arrow(col) ) {
+ case E_TABLE_COL_ARROW_NONE:
+ break;
+ case E_TABLE_COL_ARROW_UP:
+ case E_TABLE_COL_ARROW_DOWN:
+ gtk_paint_arrow (gtk_widget_get_style(GTK_WIDGET(GNOME_CANVAS_ITEM(ethi)->canvas)),
+ drawable,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ &clip,
+ GTK_WIDGET(GNOME_CANVAS_ITEM(ethi)->canvas),
+ "header",
+ e_table_col_get_arrow(col) == E_TABLE_COL_ARROW_UP ? GTK_ARROW_UP : GTK_ARROW_DOWN,
+ TRUE,
+ x + PADDING / 2 + clip.width - MIN_ARROW_SIZE - 2,
+ y + (ethi->height - MIN_ARROW_SIZE) / 2,
+ MIN_ARROW_SIZE,
+ MIN_ARROW_SIZE);
+ break;
+ }
}
static void
diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c
index 86c01cf202..380da8048e 100644
--- a/widgets/table/test-check.c
+++ b/widgets/table/test-check.c
@@ -116,6 +116,7 @@ check_test (void)
col_1 = e_table_col_new (1, "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
+ e_table_col_set_arrow ( col_1, E_TABLE_COL_ARROW_DOWN );
/*
* GUI