aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog5
-rw-r--r--widgets/e-table/Makefile.am2
-rw-r--r--widgets/e-table/e-cell-toggle.c47
-rw-r--r--widgets/e-table/e-cell-toggle.h2
-rw-r--r--widgets/e-table/e-table-col.c2
-rw-r--r--widgets/e-table/e-table-header-item.c14
-rw-r--r--widgets/e-table/e-table-header-item.h4
7 files changed, 62 insertions, 14 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index fbb2ed0a86..02cb902aea 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,10 @@
1999-11-29 Miguel de Icaza <miguel@gnu.org>
+ * e-table-col.c (e_table_col_new): Set etc->resizeable.
+
+ * e-table-header-item.c (ethi_event): Handle non-resizeables
+ columns; Add support for minimum width.
+
* e-cell-toggle.c, e-cell-toggle.h: New file. Implement a
multi-state image toggle cell object.
diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am
index d9748531d5..ae5cfae4be 100644
--- a/widgets/e-table/Makefile.am
+++ b/widgets/e-table/Makefile.am
@@ -11,6 +11,8 @@ libevolutionwidgets_a_SOURCES = \
e-cell.h \
e-cell-text.c \
e-cell-text.h \
+ e-cell-toggle.c \
+ e-cell-toggle.h \
e-cursors.c \
e-cursors.h \
e-table-col.c \
diff --git a/widgets/e-table/e-cell-toggle.c b/widgets/e-table/e-cell-toggle.c
index 33e4d283ee..b12db945b3 100644
--- a/widgets/e-table/e-cell-toggle.c
+++ b/widgets/e-table/e-cell-toggle.c
@@ -19,7 +19,7 @@
#define PARENT_TYPE e_cell_get_type()
-Typedef struct {
+typedef struct {
ECellView cell_view;
GdkGC *gc;
GnomeCanvas *canvas;
@@ -71,10 +71,13 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
int col, int row, gboolean selected,
int x1, int y1, int x2, int y2)
{
- ECellToggle *toggle = E_CELL_TOGGLE (e_cell_view->ecell);
+ ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
GdkPixbuf *image;
- const int value = e_table_model_value_at (ecell_view->ecell->table_model, col, row);
+ ArtPixBuf *art;
+ int x, y, width, height;
+ const int value = GPOINTER_TO_INT (
+ e_table_model_value_at (ecell_view->ecell->table_model, col, row));
if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
@@ -83,19 +86,43 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
}
image = toggle->images [value];
+ art = image->art_pixbuf;
+
+ if ((x2 - x1) < art->width){
+ x = x1;
+ width = x2 - x1;
+ } else {
+ x = x1 + ((x2 - x1) - art->width) / 2;
+ width = art->width;
+ }
+
+ if ((y2 - y1) < art->height){
+ y = y1;
+ height = y2 - y1;
+ } else {
+ y = y1 + ((y2 - y1) - art->height) / 2;
+ height = art->height;
+ }
+ width = y2 - y1;
+ gdk_pixbuf_render_to_drawable_alpha (
+ image, drawable, 0, 0, x, y,
+ width, height,
+ GDK_PIXBUF_ALPHA_FULL, 0,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
}
static void
etog_set_value (ECellToggleView *toggle_view, int col, int row, int value)
{
- ECell *ecell = toggle_view->cell_view.ecell
+ ECell *ecell = toggle_view->cell_view.ecell;
ECellToggle *toggle = E_CELL_TOGGLE (ecell);
- if (value >= toggle->n_vals)
+ if (value >= toggle->n_states)
value = 0;
- e_table_model_set_value_at (ecell->table_model, col, row, value);
+ e_table_model_set_value_at (ecell->table_model, col, row, GINT_TO_POINTER (value));
etog_queue_redraw (toggle_view, col, row);
}
@@ -105,9 +132,10 @@ etog_set_value (ECellToggleView *toggle_view, int col, int row, int value)
static gint
etog_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
{
- ECellToggle *toggle = E_CELL_TOGGLE (e_cell_view->ecell);
+ ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
- int value = e_table_model_value_at (e_cell_view->ecell->table_model, col, row);
+ void *_value = e_table_model_value_at (ecell_view->ecell->table_model, col, row);
+ const int value = GPOINTER_TO_INT (_value);
switch (event->type){
case GDK_BUTTON_RELEASE:
@@ -133,7 +161,7 @@ etog_event (ECellView *ecell_view, GdkEvent *event, int col, int row)
static int
etog_height (ECellView *ecell_view, int col, int row)
{
- ECellToggle *toggle = E_CELL_TOGGLE (e_cell_view->ecell);
+ ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
return toggle->height;
}
@@ -174,6 +202,7 @@ void
e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm, int border, int n_states, GdkPixbuf **images)
{
int max_height = 0;
+ int i;
E_CELL (etog)->table_model = etm;
diff --git a/widgets/e-table/e-cell-toggle.h b/widgets/e-table/e-cell-toggle.h
index 3cd99f5d04..2a5b6adc18 100644
--- a/widgets/e-table/e-cell-toggle.h
+++ b/widgets/e-table/e-cell-toggle.h
@@ -28,7 +28,7 @@ typedef struct {
GtkType e_cell_toggle_get_type (void);
ECell *e_cell_toggle_new (ETableModel *model, int border,
int n_states,
- GdkPibux **images);
+ GdkPixbuf **images);
void e_cell_toggle_construct (ECellToggle *etog, ETableModel *etm,
int border, int n_states, GdkPixbuf **images);
diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c
index 3ffc45a2ed..3d940fce04 100644
--- a/widgets/e-table/e-table-col.c
+++ b/widgets/e-table/e-table-col.c
@@ -32,7 +32,7 @@ e_table_col_new (const char *id, int width, int min_width,
etc->compare = compare;
etc->selected = 0;
- etc->resizeable = 0;
+ etc->resizeable = resizable;
return etc;
}
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index 1be7e7097b..52e01abef6 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -383,6 +383,8 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
case GDK_MOTION_NOTIFY:
convert (canvas, e->motion.x, e->motion.y, &x, &y);
if (resizing){
+ int new_width;
+
if (ethi->resize_guide == NULL){
/* Quick hack until I actually bind the views */
ethi->resize_guide = GINT_TO_POINTER (1);
@@ -393,12 +395,16 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
e->button.time);
}
- if (x - ethi->resize_start_pos <= 0)
+ new_width = x - ethi->resize_start_pos;
+ if (new_width <= 0)
break;
+ if (new_width < ethi->resize_min_width)
+ break;
+
ethi_request_redraw (ethi);
- ethi->resize_width = x - ethi->resize_start_pos;
+ ethi->resize_width = new_width;
e_table_header_set_size (ethi->eth, ethi->resize_col, ethi->resize_width);
ethi_request_redraw (ethi);
@@ -420,9 +426,13 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
* other event handlers).
*/
ecol = e_table_header_get_column (ethi->eth, col);
+
+ if (!ecol->resizeable)
+ break;
ethi->resize_col = col;
ethi->resize_width = ecol->width;
ethi->resize_start_pos = start - ecol->width;
+ ethi->resize_min_width = ecol->min_width;
}
break;
diff --git a/widgets/e-table/e-table-header-item.h b/widgets/e-table/e-table-header-item.h
index d6b7d64a9f..ea2082018f 100644
--- a/widgets/e-table/e-table-header-item.h
+++ b/widgets/e-table/e-table-header-item.h
@@ -21,11 +21,13 @@ typedef struct {
GdkFont *font;
/*
- * Used during resizing
+ * Used during resizing; Could be shorts
*/
int resize_col;
int resize_width;
int resize_start_pos;
+ int resize_min_width;
+
GtkObject *resize_guide;
/*