aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-cell-toggle.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-11-30 17:34:50 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-11-30 17:34:50 +0800
commit0177093e774a519891d4432bf87f5fa6e6c9656d (patch)
tree341b4172e7680a77314457304d554a7041143242 /widgets/table/e-cell-toggle.c
parentc50636dba333983e99deeb76338bbec3390a1fbe (diff)
downloadgsoc2013-evolution-0177093e774a519891d4432bf87f5fa6e6c9656d.tar.gz
gsoc2013-evolution-0177093e774a519891d4432bf87f5fa6e6c9656d.tar.zst
gsoc2013-evolution-0177093e774a519891d4432bf87f5fa6e6c9656d.zip
New cell-toggle stuff compiles -miguel
svn path=/trunk/; revision=1446
Diffstat (limited to 'widgets/table/e-cell-toggle.c')
-rw-r--r--widgets/table/e-cell-toggle.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index 33e4d283ee..b12db945b3 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/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;