aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/ChangeLog21
-rw-r--r--widgets/table/e-cell-checkbox.c24
-rw-r--r--widgets/table/e-cell-pixbuf.c43
-rw-r--r--widgets/table/e-cell-popup.c9
-rw-r--r--widgets/table/e-cell-text.c84
-rw-r--r--widgets/table/e-cell-toggle.c58
-rw-r--r--widgets/table/e-cell.c10
-rw-r--r--widgets/table/e-cell.h9
-rw-r--r--widgets/table/e-table-group-container.c157
-rw-r--r--widgets/table/e-table-item.c126
10 files changed, 255 insertions, 286 deletions
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog
index 16e42bb724..3a9d49da40 100644
--- a/widgets/table/ChangeLog
+++ b/widgets/table/ChangeLog
@@ -1,3 +1,24 @@
+2007-01-22 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** GtkPrint api migration from Ebby Wiselyn.
+
+ * e-cell-checkbox.c: (ecc_print), (e_cell_checkbox_class_init):
+ * e-cell-pixbuf.c: (gnome_print_pixbuf), (pixbuf_print),
+ (pixbuf_print_height):
+ * e-cell-popup.c: (ecp_print), (ecp_print_height):
+ * e-cell-text.c: (ect_print), (ect_print_height):
+ * e-cell-toggle.c: (etog_print), (etog_print_height):
+ * e-cell.c: (e_cell_print), (e_cell_print_height):
+ * e-cell.h:
+ * e-table-group-container.c: (gp_draw_rect),
+ (e_table_group_container_print_page),
+ (e_table_group_container_height),
+ (e_table_group_container_will_fit):
+ * e-table-item.c: (eti_realize_cell_views), (eti_draw),
+ (eti_event), (eti_printed_row_height), (gp_draw_rect),
+ (e_table_item_print_page), (e_table_item_height),
+ (e_table_item_will_fit):
+
2006-12-04 Matthew Barnes <mbarnes@redhat.com>
Fixes bug #357970
diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c
index cdeb1814de..33135b5b71 100644
--- a/widgets/table/e-cell-checkbox.c
+++ b/widgets/table/e-cell-checkbox.c
@@ -39,8 +39,32 @@
static GdkPixbuf *checks [2];
static void
+ecc_print (ECellView *ecell_view, GtkPrintContext *context,
+ int model_col, int view_col, int row,
+ double width, double height)
+{
+ cairo_t *cr;
+ cr = gtk_print_context_get_cairo_context (context);
+ const int value = GPOINTER_TO_INT (
+ e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ cairo_save (cr);
+
+ if ( value == 1) {
+
+ cairo_set_line_width (cr, 2);
+ cairo_move_to (cr, 3, 11);
+ cairo_line_to (cr, 7, 14);
+ cairo_line_to (cr, 11, 5);
+ cairo_stroke (cr);
+ }
+ cairo_restore (cr);
+}
+
+static void
e_cell_checkbox_class_init (GtkObjectClass *object_class)
{
+ ECellClass *ecc = (ECellClass *) object_class;
+ ecc->print = ecc_print;
checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm);
checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm);
}
diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c
index a87ba5887d..38fb1ae59d 100644
--- a/widgets/table/e-cell-pixbuf.c
+++ b/widgets/table/e-cell-pixbuf.c
@@ -28,7 +28,7 @@
#include <libgnomecanvas/gnome-canvas.h>
#include "e-util/e-i18n.h"
-
+#include <gtk/gtk.h>
#include "e-cell-pixbuf.h"
#define PARENT_TYPE E_CELL_TYPE
@@ -51,20 +51,14 @@ enum {
};
static int
-gnome_print_pixbuf (GnomePrintContext *pc, GdkPixbuf *pixbuf)
+gnome_print_pixbuf (GtkPrintContext *pc, GdkPixbuf *pixbuf)
{
- if (gdk_pixbuf_get_has_alpha (pixbuf))
- return gnome_print_rgbaimage (pc,
- gdk_pixbuf_get_pixels (pixbuf),
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- gdk_pixbuf_get_rowstride (pixbuf));
- else
- return gnome_print_rgbimage (pc,
- gdk_pixbuf_get_pixels (pixbuf),
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- gdk_pixbuf_get_rowstride (pixbuf));
+ cairo_t *cr = gtk_print_context_get_cairo_context (pc);
+
+ gdk_cairo_set_source_pixbuf (cr, pixbuf,
+ (double)gdk_pixbuf_get_width (pixbuf),
+ (double)gdk_pixbuf_get_height (pixbuf));
+ return TRUE;
}
/*
@@ -224,29 +218,28 @@ pixbuf_height (ECellView *ecell_view, int model_col, int view_col, int row)
* ECell::print method
*/
static void
-pixbuf_print (ECellView *ecell_view, GnomePrintContext *context,
+pixbuf_print (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width, double height)
{
GdkPixbuf *pixbuf;
int scale;
-
+ cairo_t *cr = gtk_print_context_get_cairo_context (context);
+
pixbuf = (GdkPixbuf *) e_table_model_value_at (ecell_view->e_table_model, model_col, row);
if (pixbuf == NULL)
return;
- scale = gdk_pixbuf_get_height (pixbuf);
-
- gnome_print_gsave(context);
- gnome_print_translate (context, 0, (height - scale) / 2);
- gnome_print_scale (context, scale, scale);
- gnome_print_pixbuf (context, pixbuf);
-
- gnome_print_grestore(context);
+ scale = gdk_pixbuf_get_height (pixbuf);
+ cairo_save (cr);
+ cairo_translate (cr, 0, (double)(height - scale) / (double)2);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, (double)scale, (double)scale);
+ cairo_paint (cr);
+ cairo_restore (cr);
}
static gdouble
-pixbuf_print_height (ECellView *ecell_view, GnomePrintContext *context,
+pixbuf_print_height (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width)
{
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index 613b11dae2..49a4c1e728 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -38,6 +38,7 @@
#include "e-cell-popup.h"
#include "e-table-item.h"
+#include <gtk/gtk.h>
#define E_CELL_POPUP_ARROW_WIDTH 16
#define E_CELL_POPUP_ARROW_XPAD 3
@@ -86,14 +87,14 @@ static void ecp_leave_edit (ECellView *ecv,
int row,
void *edit_context);
static void ecp_print (ECellView *ecv,
- GnomePrintContext *context,
+ GtkPrintContext *context,
int model_col,
int view_col,
int row,
double width,
double height);
static gdouble ecp_print_height (ECellView *ecv,
- GnomePrintContext *context,
+ GtkPrintContext *context,
int model_col,
int view_col,
int row,
@@ -402,7 +403,7 @@ ecp_leave_edit (ECellView *ecv, int model_col, int view_col, int row,
static void
-ecp_print (ECellView *ecv, GnomePrintContext *context,
+ecp_print (ECellView *ecv, GtkPrintContext *context,
int model_col, int view_col, int row, double width, double height)
{
ECellPopupView *ecp_view = (ECellPopupView *) ecv;
@@ -413,7 +414,7 @@ ecp_print (ECellView *ecv, GnomePrintContext *context,
static gdouble
-ecp_print_height (ECellView *ecv, GnomePrintContext *context,
+ecp_print_height (ECellView *ecv, GtkPrintContext *context,
int model_col, int view_col, int row,
double width)
{
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index dfa0f4da19..88dd215636 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -60,7 +60,6 @@
#include "e-cell-text.h"
#include "e-table-item.h"
#include "e-table-tooltip.h"
-
#define d(x)
#define DO_SELECTION 1
#define VIEW_TO_CELL(view) E_CELL_TEXT (((ECellView *)view)->ecell)
@@ -1322,45 +1321,45 @@ get_font_size (PangoLayout *layout, PangoFontDescription *font, const char *text
}
static void
-ect_print (ECellView *ecell_view, GnomePrintContext *context,
+ect_print (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width, double height)
{
- PangoFontDescription *font_des = get_font_description_for_size (16);
+ PangoFontDescription *font_des = get_font_description_for_size (12);
PangoLayout *layout;
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
- char *string;
ECellText *ect = E_CELL_TEXT(ecell_view->ecell);
- double ty, ly, text_width, text_height;
ECellTextView *ectView = (ECellTextView *)ecell_view;
GtkWidget *canvas = GTK_WIDGET(ectView->canvas);
PangoDirection dir;
gboolean strikeout, underline;
+ cairo_t *cr;
+ char *string;
+ double ty, ly, text_width, text_height;
+
+ cr = gtk_print_context_get_cairo_context (context);
string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row);
- layout = gnome_print_pango_create_layout (context);
+
+ cairo_save (cr);
+ layout = gtk_print_context_create_pango_layout (context);
+ font_des = pango_font_description_from_string ("sans 12"); /* fix me font hardcoded */
pango_layout_set_font_description (layout, font_des);
+
pango_layout_set_text (layout, string, -1);
get_font_size (layout, font_des, string, &text_width, &text_height);
- gnome_print_gsave(context);
- if (gnome_print_moveto(context, 2, 2) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width - 2, 2) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width - 2, height - 2) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 2, height - 2) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 2, 2) == -1)
- /* FIXME */;
- if (gnome_print_clip(context) == -1)
- /* FIXME */;
+
+ cairo_move_to(cr, 2, 2);
+ cairo_rectangle (cr, 2, 2, width + 2, height + 2);
+ cairo_clip(cr);
pango_context = gtk_widget_get_pango_context (canvas);
font_metrics = pango_context_get_metrics (pango_context,
- canvas->style->font_desc, pango_context_get_language(pango_context));
- ty = (double)(text_height - pango_font_metrics_get_ascent (font_metrics) - pango_font_metrics_get_descent (font_metrics)) / 2.0 /(double)PANGO_SCALE;
+ canvas->style->font_desc, pango_context_get_language(pango_context));
+ ty = (double)(text_height
+ - pango_font_metrics_get_ascent (font_metrics)
+ - pango_font_metrics_get_descent (font_metrics)) / 2.0 /(double)PANGO_SCALE;
strikeout = ect->strikeout_column >= 0 && row >= 0 &&
e_table_model_value_at (ecell_view->e_table_model, ect->strikeout_column, row);
@@ -1368,47 +1367,50 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
e_table_model_value_at(ecell_view->e_table_model, ect->underline_column, row);
dir = pango_find_base_dir (string, strlen(string));
+
if (underline) {
ly = ty + (double)pango_font_metrics_get_underline_position (font_metrics)/(double)PANGO_SCALE;
- gnome_print_newpath (context);
+ cairo_new_path (cr);
if (dir == PANGO_DIRECTION_RTL) {
- gnome_print_moveto (context, width - 2, ly + text_height - 4);
- gnome_print_lineto (context, MAX (width - 2 - text_width, 2), ly + text_height - 4);
+ cairo_move_to (cr, width - 2, ly + text_height + 6);
+ cairo_line_to (cr, MAX (width - 2 - text_width, 2), ly + text_height + 6);
}
else {
- gnome_print_moveto (context, 2, ly + text_height - 4);
- gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly + text_height - 4);
+ cairo_move_to (cr, 2, ly + text_height + 6);
+ cairo_line_to (cr, MIN (2 + text_width, width - 2), ly + text_height + 6);
}
- gnome_print_setlinewidth (context, (double)pango_font_metrics_get_underline_thickness (font_metrics)/(double)PANGO_SCALE);
- gnome_print_stroke (context);
+ cairo_set_line_width (cr, (double)pango_font_metrics_get_underline_thickness (font_metrics)/(double)PANGO_SCALE);
+ cairo_stroke (cr);
}
if (strikeout) {
ly = ty + (double)pango_font_metrics_get_strikethrough_position (font_metrics)/(double)PANGO_SCALE;
- gnome_print_newpath (context);
+ cairo_new_path (cr);
if (dir == PANGO_DIRECTION_RTL) {
- gnome_print_moveto (context, width - 2, ly + text_height - 4);
- gnome_print_lineto (context, MAX (width - 2 - text_width, 2), ly + text_height - 4);
+ cairo_move_to (cr, width - 2, ly + text_height + 6);
+ cairo_line_to (cr, MAX (width - 2 - text_width, 2), ly + text_height + 6);
}
else {
- gnome_print_moveto (context, 2, ly + text_height - 4);
- gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly + text_height - 4);
+ cairo_move_to (cr, 2, ly + text_height + 6);
+ cairo_line_to (cr, MIN (2 + text_width, width - 2), ly + text_height + 6);
}
- gnome_print_setlinewidth (context, (double)pango_font_metrics_get_strikethrough_thickness (font_metrics)/(double)PANGO_SCALE);
- gnome_print_stroke (context);
- }
+ cairo_set_line_width (cr,(double)pango_font_metrics_get_strikethrough_thickness (font_metrics)/(double)PANGO_SCALE);
+
+ cairo_stroke (cr);
+ }
+
+ cairo_move_to(cr, 2, text_height- 5);
+ pango_layout_set_width (layout, (width - 4)*PANGO_SCALE);
+ pango_cairo_show_layout(cr, layout);
+ cairo_restore (cr);
- gnome_print_moveto(context, 2, text_height + 2);
- pango_layout_set_width (layout, (width - 4)*PANGO_SCALE);
- gnome_print_pango_layout(context, layout);
pango_font_description_free (font_des);
g_object_unref (layout);
- gnome_print_grestore(context);
e_cell_text_free_text(ect, string);
}
static gdouble
-ect_print_height (ECellView *ecell_view, GnomePrintContext *context,
+ect_print_height (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width)
{
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index 971ca1f98e..dda87efcae 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -48,23 +48,6 @@ static ECellClass *parent_class;
#define CACHE_SEQ_COUNT 6
-static int
-gnome_print_pixbuf (GnomePrintContext *pc, GdkPixbuf *pixbuf)
-{
- if (gdk_pixbuf_get_has_alpha (pixbuf))
- return gnome_print_rgbaimage (pc,
- gdk_pixbuf_get_pixels (pixbuf),
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- gdk_pixbuf_get_rowstride (pixbuf));
- else
- return gnome_print_rgbimage (pc,
- gdk_pixbuf_get_pixels (pixbuf),
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf),
- gdk_pixbuf_get_rowstride (pixbuf));
-}
-
/*
* ECell::realize method
*/
@@ -145,7 +128,7 @@ check_cache (ECellToggleView *toggle_view, int image_seq, int cache_seq)
gdk_pixmap_new (toggle_view->canvas->layout.bin_window, width, height,
gtk_widget_get_visual (GTK_WIDGET (toggle_view->canvas))->depth);
-
+
switch (cache_seq % 3) {
case 0:
color = GTK_WIDGET (toggle_view->canvas)->style->bg [GTK_STATE_SELECTED];
@@ -195,7 +178,7 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
GdkPixbuf *image;
int x, y, width, height;
int cache_seq;
-
+
const int value = GPOINTER_TO_INT (
e_table_model_value_at (ecell_view->e_table_model, model_col, row));
@@ -272,7 +255,7 @@ etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
return FALSE;
#endif
- switch (event->type){
+ switch (event->type){
case GDK_KEY_PRESS:
if (event->key.keyval != GDK_space)
return FALSE;
@@ -280,7 +263,7 @@ etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
case GDK_BUTTON_PRESS:
if (!e_table_model_is_cell_editable(ecell_view->e_table_model, model_col, row))
return FALSE;
-
+
etog_set_value (toggle_view, model_col, view_col, row, value + 1);
return TRUE;
@@ -304,34 +287,41 @@ etog_height (ECellView *ecell_view, int model_col, int view_col, int row)
* ECell::print method
*/
static void
-etog_print (ECellView *ecell_view, GnomePrintContext *context,
+etog_print (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width, double height)
{
ECellToggle *toggle = E_CELL_TOGGLE(ecell_view->ecell);
GdkPixbuf *image;
+ double image_width, image_height;
const int value = GPOINTER_TO_INT (
e_table_model_value_at (ecell_view->e_table_model, model_col, row));
- if (value >= toggle->n_states){
+ cairo_t *cr;
+ if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
value, toggle->n_states);
return;
}
- gnome_print_gsave(context);
-
- image = toggle->images[value];
-
- gnome_print_translate (context, 0, (height - toggle->height) / 2);
- gnome_print_scale (context, toggle->height, toggle->height);
- gnome_print_pixbuf (context, image);
-
- gnome_print_grestore(context);
+ cr = gtk_print_context_get_cairo_context (context);
+ cairo_save(cr);
+ image = toggle->images[value];
+ cairo_translate (cr, 0 , 0);
+ image = gdk_pixbuf_add_alpha (image, TRUE, 255, 255, 255);
+ image_width = (double)gdk_pixbuf_get_width (image);
+ image_height = (double)gdk_pixbuf_get_height (image);
+ cairo_rectangle (cr, image_width / 7, image_height / 3,
+ image_width - image_width / 4,
+ image_width - image_height / 7);
+ cairo_clip (cr);
+ gdk_cairo_set_source_pixbuf (cr, image, 0, image_height / 4);
+ cairo_paint (cr);
+ cairo_restore(cr);
}
static gdouble
-etog_print_height (ECellView *ecell_view, GnomePrintContext *context,
+etog_print_height (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width)
{
@@ -414,7 +404,7 @@ e_cell_toggle_class_init (GtkObjectClass *object_class)
parent_class = g_type_class_ref (PARENT_TYPE);
gal_a11y_e_cell_registry_add_cell_type (NULL,
- E_CELL_TOGGLE_TYPE,
+ E_CELL_TOGGLE_TYPE,
gal_a11y_e_cell_toggle_new);
}
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index b27badc348..0679cffd53 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+ /*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* e-cell.c - base class for cell renderers in e-table
* Copyright 1999, 2000, 2001, Ximian, Inc.
@@ -23,7 +23,7 @@
*/
#include <config.h>
-
+#include <gtk/gtk.h>
#include "e-util/e-util.h"
#include "e-cell.h"
@@ -280,7 +280,7 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
/**
* e_cell_print:
* @ecell_view: the ECellView to redraw
- * @context: The GnomePrintContext where we output our printed data.
+ * @context: The GtkPrintContext where we output our printed data.
* @model_col: the column in the model being drawn.
* @view_col: the column in the view being drawn (what the model maps to).
* @row: the row being drawn
@@ -290,7 +290,7 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
* FIXME:
*/
void
-e_cell_print (ECellView *ecell_view, GnomePrintContext *context,
+e_cell_print (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width, double height)
{
@@ -304,7 +304,7 @@ e_cell_print (ECellView *ecell_view, GnomePrintContext *context,
* FIXME:
*/
gdouble
-e_cell_print_height (ECellView *ecell_view, GnomePrintContext *context,
+e_cell_print_height (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
double width)
{
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index fabe7bf372..526d8995e7 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -26,6 +26,7 @@
#define _E_CELL_H_
#include <gdk/gdktypes.h>
+#include <gtk/gtk.h>
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-font.h>
#include <table/e-table-model.h>
@@ -107,10 +108,10 @@ typedef struct {
void *(*save_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context);
void (*load_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context, void *save_state);
void (*free_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *save_state);
- void (*print) (ECellView *ecell_view, GnomePrintContext *context,
+ void (*print) (ECellView *ecell_view, GtkPrintContext *context,
int model_col, int view_col, int row,
gdouble width, gdouble height);
- gdouble (*print_height) (ECellView *ecell_view, GnomePrintContext *context,
+ gdouble (*print_height) (ECellView *ecell_view,GtkPrintContext *context,
int model_col, int view_col, int row, gdouble width);
int (*max_width) (ECellView *ecell_view, int model_col, int view_col);
int (*max_width_by_row) (ECellView *ecell_view, int model_col, int view_col, int row);
@@ -149,14 +150,14 @@ void e_cell_draw (ECellView *ecell_view,
int x2,
int y2);
void e_cell_print (ECellView *ecell_view,
- GnomePrintContext *context,
+ GtkPrintContext *context,
int model_col,
int view_col,
int row,
double width,
double height);
gdouble e_cell_print_height (ECellView *ecell_view,
- GnomePrintContext *context,
+ GtkPrintContext *context,
int model_col,
int view_col,
int row,
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index 86a8036450..f2060db1ad 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -1063,7 +1063,7 @@ etgc_init (GtkObject *object)
{
ETableGroupContainer *container = E_TABLE_GROUP_CONTAINER(object);
container->children = FALSE;
-
+
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgc_reflow);
container->alternating_row_colors = 1;
@@ -1110,32 +1110,18 @@ typedef struct {
EPrintable *child_printable;
} ETGCPrintContext;
-#if 0
-#define CHECK(x) if((x) == -1) return -1;
-static gint
-gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height, gdouble r, gdouble g, gdouble b)
-{
- CHECK(gnome_print_moveto(context, x, y));
- CHECK(gnome_print_lineto(context, x + width, y));
- CHECK(gnome_print_lineto(context, x + width, y - height));
- CHECK(gnome_print_lineto(context, x, y - height));
- CHECK(gnome_print_lineto(context, x, y));
- return gnome_print_fill(context);
-}
-#endif
#define CHECK(x) if((x) == -1) return -1;
static gint
-gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height)
+gp_draw_rect (GtkPrintContext *context, double x, double y, double width, double height)
{
- CHECK(gnome_print_moveto(context, x, y));
- CHECK(gnome_print_lineto(context, x + width, y));
- CHECK(gnome_print_lineto(context, x + width, y - height));
- CHECK(gnome_print_lineto(context, x, y - height));
- CHECK(gnome_print_lineto(context, x, y));
- return gnome_print_fill(context);
+ cairo_t *cr;
+ cr = gtk_print_context_get_cairo_context (context);
+ cairo_move_to (cr, x, y);
+ cairo_rectangle (cr, x, y, x + width, y + height);
+ cairo_fill (cr);
}
#define TEXT_HEIGHT (12)
@@ -1143,12 +1129,13 @@ gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, g
static void
e_table_group_container_print_page (EPrintable *ep,
- GnomePrintContext *context,
+ GtkPrintContext *context,
gdouble width,
gdouble height,
gboolean quantize,
ETGCPrintContext *groupcontext)
-{
+{
+ cairo_t *cr;
gdouble yd = height;
gdouble child_height;
ETableGroupContainerChildNode *child_node;
@@ -1159,6 +1146,8 @@ e_table_group_container_print_page (EPrintable *ep,
child_printable = groupcontext->child_printable;
child = groupcontext->child;
+ yd = 6.5 * 72;
+ height = 5 * 72;
if (child_printable) {
if (child)
@@ -1179,50 +1168,21 @@ e_table_group_container_print_page (EPrintable *ep,
}
while (1) {
- child_height = e_printable_height(child_printable, context, width - 36, yd - TEXT_AREA_HEIGHT, quantize);
-
- if (gnome_print_gsave(context) == -1)
- /* FIXME */;
- if (gnome_print_moveto(context, 0, yd - child_height - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 36, yd - child_height - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 36, yd - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width, yd - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width, yd) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, yd) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, yd - child_height - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_setrgbcolor(context, .7, .7, .7) == -1)
- /* FIXME */;
- if (gnome_print_fill(context) == -1)
- /* FIXME */;
- if (gnome_print_grestore(context) == -1)
- /* FIXME */;
-
- if (gnome_print_gsave(context) == -1)
- /* FIXME */;
- if (gnome_print_moveto(context, 0, yd - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width, yd - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width, yd) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, yd) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, yd - TEXT_AREA_HEIGHT) == -1)
- /* FIXME */;
- if (gnome_print_clip(context) == -1)
- /* FIXME */;
-
- if (gnome_print_moveto(context, 2, yd - (TEXT_AREA_HEIGHT + gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2) == -1)
- /* FIXME */;
- if (gnome_print_setfont(context, font))
- /* FIXME */;
+ child_height = e_printable_height(child_printable, context, width,yd + 2 * TEXT_AREA_HEIGHT, quantize);
+ cr = gtk_print_context_get_cairo_context (context);
+ cairo_save (cr);
+ cairo_rectangle (cr, 0, 0, width,TEXT_AREA_HEIGHT);
+ cairo_rectangle (cr, 0, 0, 2 * TEXT_AREA_HEIGHT, child_height + TEXT_AREA_HEIGHT);
+ cairo_set_source_rgb (cr, .7, .7, .7) ;
+ cairo_fill(cr) ;
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ cairo_rectangle (cr, 0, 0, width, TEXT_AREA_HEIGHT);
+ cairo_clip (cr);
+ cairo_restore (cr);
+
+ cairo_move_to(cr, 0, (gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2);
if (groupcontext->etgc->ecol->text)
string = g_strdup_printf ("%s : %s (%d item%s)",
groupcontext->etgc->ecol->text,
@@ -1234,63 +1194,38 @@ e_table_group_container_print_page (EPrintable *ep,
child_node->string,
(gint) child_node->count,
child_node->count == 1 ? "" : "s");
- if (gnome_print_show(context, string))
- /* FIXME */;
- g_free(string);
- if (gnome_print_grestore(context) == -1)
- /* FIXME */;
-
- if (gnome_print_gsave(context) == -1)
- /* FIXME */;
- if (gnome_print_translate(context, 36, yd - TEXT_AREA_HEIGHT - child_height) == -1)
- /* FIXME */;
- if (gnome_print_moveto(context, 0, 0) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width - 36, 0) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, width - 36, child_height) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, child_height) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, 0) == -1)
- /* FIXME */;
- if (gnome_print_clip(context) == -1)
- /* FIXME */;
- e_printable_print_page(child_printable, context, width - 36, child_height, quantize);
- if (gnome_print_grestore(context) == -1)
- /* FIXME */;
-
- gp_draw_rect(context, 0, yd - child_height - TEXT_AREA_HEIGHT + 1, width, 1);
- gp_draw_rect(context, width - 1, yd, 1, yd - child_height - TEXT_AREA_HEIGHT);
- gp_draw_rect(context, 0, yd, 1, yd - child_height - TEXT_AREA_HEIGHT);
-
- yd -= child_height + TEXT_AREA_HEIGHT;
+ cairo_show_text (cr, string);
+ g_free(string);
+
+ cairo_translate(cr, 2 * TEXT_AREA_HEIGHT, TEXT_AREA_HEIGHT) ;
+ cairo_move_to(cr, 0, 0);
+ cairo_rectangle (cr, 0, 0, width - 2 * TEXT_AREA_HEIGHT,child_height);
+ cairo_clip(cr);
+
+ e_printable_print_page (child_printable, context, width-2 * TEXT_AREA_HEIGHT, 0, quantize);
+ yd += child_height + TEXT_AREA_HEIGHT;
if (e_printable_data_left(child_printable))
break;
- child = child->next;
+ child = child->next;
if (!child) {
child_printable = NULL;
break;
}
- child_node = child->data;
+ child_node = child->data;
if (child_printable)
g_object_unref (child_printable);
- child_printable = e_table_group_get_printable(child_node->child);
+ child_printable = e_table_group_get_printable(child_node->child);
if (child_printable)
g_object_ref (child_printable);
- e_printable_reset(child_printable);
+ e_printable_reset(child_printable);
}
-
- gp_draw_rect(context, 0, height, width, 1);
-
if (groupcontext->child_printable)
g_object_unref (groupcontext->child_printable);
groupcontext->child_printable = child_printable;
groupcontext->child = child;
-
}
static gboolean
@@ -1313,7 +1248,7 @@ e_table_group_container_reset (EPrintable *ep,
static gdouble
e_table_group_container_height (EPrintable *ep,
- GnomePrintContext *context,
+ GtkPrintContext *context,
gdouble width,
gdouble max_height,
gboolean quantize,
@@ -1350,14 +1285,14 @@ e_table_group_container_height (EPrintable *ep,
while (1) {
child_height = e_printable_height(child_printable, context, width - 36, yd - (yd == -1 ? 0 : TEXT_AREA_HEIGHT), quantize);
- height += child_height + TEXT_AREA_HEIGHT;
+ height -= child_height + TEXT_AREA_HEIGHT;
if (yd != -1) {
if (!e_printable_will_fit(child_printable, context, width - 36, yd - (yd == -1 ? 0 : TEXT_AREA_HEIGHT), quantize)) {
break;
}
- yd -= child_height + TEXT_AREA_HEIGHT;
+ yd += child_height + TEXT_AREA_HEIGHT;
}
child = child->next;
@@ -1381,7 +1316,7 @@ e_table_group_container_height (EPrintable *ep,
static gboolean
e_table_group_container_will_fit (EPrintable *ep,
- GnomePrintContext *context,
+ GtkPrintContext *context,
gdouble width,
gdouble max_height,
gboolean quantize,
@@ -1424,7 +1359,7 @@ e_table_group_container_will_fit (EPrintable *ep,
break;
}
- yd -= child_height + TEXT_AREA_HEIGHT;
+ yd += child_height + TEXT_AREA_HEIGHT;
}
child = child->next;
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index c095b84c05..0936c03f31 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -98,7 +98,7 @@ enum {
PROP_LENGTH_THRESHOLD,
PROP_CURSOR_ROW,
PROP_UNIFORM_ROW_HEIGHT,
-
+
PROP_MINIMUM_WIDTH,
PROP_WIDTH,
PROP_HEIGHT
@@ -334,7 +334,7 @@ eti_free_save_state (ETableItem *eti)
* we might want to avoid realizing each e-cell.
*/
static void
-eti_realize_cell_views (ETableItem *eti)
+eti_realize_cell_views ( ETableItem *eti)
{
int i;
@@ -1939,7 +1939,6 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
height = ETI_ROW_HEIGHT (eti, row);
xd = x_offset;
-/* printf ("paint: %d %d\n", yd, yd + height); */
selected = e_selection_model_is_row_selected(E_SELECTION_MODEL (eti->selection), view_to_model_row(eti,row));
@@ -2084,7 +2083,7 @@ find_cell (ETableItem *eti, double x, double y, int *view_col_res, int *view_row
int col, row;
int height_extra = eti->horizontal_draw_grid ? 1 : 0;
-
+
/* FIXME: this routine is inneficient, fix later */
if (eti->grabbed_col >= 0 && eti->grabbed_row >= 0) {
@@ -2447,6 +2446,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
}
#endif
+
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
return TRUE;
@@ -2654,6 +2654,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
break;
}
+
g_signal_emit (eti, eti_signals [KEY_PRESS], 0,
model_to_view_row(eti, cursor_row), cursor_col, e, &return_val);
if ((!return_val) &&
@@ -2686,6 +2687,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if ((e->key.state & GDK_MOD1_MASK)
&& ((e->key.keyval == GDK_Down ) || (e->key.keyval == GDK_KP_Down))) {
gint view_col = model_to_view_col(eti, cursor_col);
+
if ((view_col >= 0) && (view_col < eti->cols))
if (eti_e_cell_event (eti, eti->cell_views [view_col], e, ((GdkEventKey *)e)->time, cursor_col, view_col, model_to_view_row(eti, cursor_row), E_CELL_CURSOR))
return TRUE;
@@ -3450,7 +3452,7 @@ e_table_item_calculate_print_widths (ETableHeader *eth, gdouble width)
}
static gdouble
-eti_printed_row_height (ETableItem *eti, gdouble *widths, GnomePrintContext *context, gint row)
+eti_printed_row_height (ETableItem *eti, gdouble *widths, GtkPrintContext *context, gint row)
{
int col;
int cols = eti->cols;
@@ -3468,106 +3470,106 @@ eti_printed_row_height (ETableItem *eti, gdouble *widths, GnomePrintContext *con
#define CHECK(x) if((x) == -1) return -1;
static gint
-gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height)
+gp_draw_rect (GtkPrintContext *context, double x, double y, double width, double height)
{
- CHECK(gnome_print_moveto(context, x, y));
- CHECK(gnome_print_lineto(context, x + width, y));
- CHECK(gnome_print_lineto(context, x + width, y - height));
- CHECK(gnome_print_lineto(context, x, y - height));
- CHECK(gnome_print_lineto(context, x, y));
- return gnome_print_fill(context);
+ cairo_t *cr;
+ cr = gtk_print_context_get_cairo_context (context);
+ cairo_save (cr);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_set_line_width (cr, 0.5);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+ return 0;
}
static void
e_table_item_print_page (EPrintable *ep,
- GnomePrintContext *context,
- gdouble width,
- gdouble height,
+ GtkPrintContext *context,
+ double width,
+ double height,
gboolean quantize,
ETableItemPrintContext *itemcontext)
{
ETableItem *eti = itemcontext->item;
const int rows = eti->rows;
const int cols = eti->cols;
+ gdouble max_height;
int rows_printed = itemcontext->rows_printed;
+ int row, col, next_page = 0;
+ double yd = height;
+ cairo_t *cr;
gdouble *widths;
- int row, col;
- gdouble yd = height;
-
+
+ cr = gtk_print_context_get_cairo_context (context);
+ max_height = gtk_print_context_get_height (context);
widths = e_table_item_calculate_print_widths (itemcontext->item->header, width);
/*
* Draw cells
*/
+
if (eti->horizontal_draw_grid){
gp_draw_rect(context, 0, yd, width, 1);
}
- yd--;
-
- for (row = rows_printed; row < rows; row++){
+ yd++;
+
+ for (row = rows_printed; row < rows ; row++){
gdouble xd = 1, row_height;
-
row_height = eti_printed_row_height(eti, widths, context, row);
+
if (quantize) {
- if (yd - row_height - 1 < 0 && row != rows_printed) {
+ if (yd + row_height + 1 > max_height && row != rows_printed) {
+ next_page = 1;
break;
}
} else {
- if (yd < 0) {
+ if (yd > max_height) {
+ next_page = 1;
break;
- }
- }
-
+ }
+ }
+
for (col = 0; col < cols; col++){
ECellView *ecell_view = eti->cell_views [col];
-
- if (gnome_print_gsave(context) == -1)
- /* FIXME */;
- if (gnome_print_translate(context, xd, yd - row_height) == -1)
- /* FIXME */;
-
- if (gnome_print_moveto(context, 0, 0) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, widths[col] - 1, 0) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, widths[col] - 1, row_height) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, row_height) == -1)
- /* FIXME */;
- if (gnome_print_lineto(context, 0, 0) == -1)
- /* FIXME */;
- if (gnome_print_clip(context) == -1)
- /* FIXME */;
-
- e_cell_print (ecell_view, context, view_to_model_col(eti, col), col, row,
- widths[col] - 1, row_height);
-
- if (gnome_print_grestore(context) == -1)
- /* FIXME */;
+ cairo_save(cr);
+ cairo_translate(cr, xd, yd);
+ cairo_rectangle (cr, 0, 0, widths[col] - 1, row_height);
+ cairo_clip(cr);
+
+ e_cell_print (ecell_view, context,
+ view_to_model_col(eti, col),
+ col,
+ row,
+ widths[col] - 1,
+ row_height + 2 );
+
+ cairo_restore (cr);
xd += widths[col];
}
- yd -= row_height;
-
+
+ yd += row_height;
if (eti->horizontal_draw_grid){
gp_draw_rect(context, 0, yd, width, 1);
}
- yd--;
- }
+ yd ++;
+ }
itemcontext->rows_printed = row;
-
if (eti->vertical_draw_grid){
gdouble xd = 0;
-
for (col = 0; col < cols; col++){
- gp_draw_rect(context, xd, height, 1, height - yd);
-
+ gp_draw_rect(context, xd, height, 1, yd - height);
xd += widths[col];
}
- gp_draw_rect(context, xd, height, 1, height - yd);
+ gp_draw_rect(context, xd, height, 1, yd - height);
}
+ if (next_page) {
+ cairo_show_page (cr);
+ next_page = 0;
+ }
+
g_free (widths);
}
@@ -3591,7 +3593,7 @@ e_table_item_reset (EPrintable *ep,
static gdouble
e_table_item_height (EPrintable *ep,
- GnomePrintContext *context,
+ GtkPrintContext *context,
gdouble width,
gdouble max_height,
gboolean quantize,
@@ -3641,7 +3643,7 @@ e_table_item_height (EPrintable *ep,
static gboolean
e_table_item_will_fit (EPrintable *ep,
- GnomePrintContext *context,
+ GtkPrintContext *context,
gdouble width,
gdouble max_height,
gboolean quantize,