Commit 9e9a37f9 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

translate to the upper left corner of the object and pass in its width and


2003-07-02  Jody Goldberg <jody@gnome.org>

	* src/print.c (print_sheet_objects) : translate to the upper left
	  corner of the object and pass in its width and height.
	* src/sheet-object.c (sheet_object_print) : adjust print interface to
	  only pass width and height in pts.  print context is already at 0,0
	  and scaled.
	* src/sheet-object-graph.c (sheet_object_graph_print) : Use new
	  cleaner interface.
	* src/sheet-object-image.c (sheet_object_image_print) : ditto.
	* src/sheet-object-graphic.c (sheet_object_graphic_print) :
	  Save the graphics context before filling and just resuse it for the
	  outline.  Fix the direction handling for the new interface
	  semantics.
	(sheet_object_filled_print) : ditto.
parent ee943a94
2003-07-02 Jody Goldberg <jody@gnome.org>
* src/print.c (print_sheet_objects) : translate to the upper left
corner of the object and pass in its width and height.
* src/sheet-object.c (sheet_object_print) : adjust print interface to
only pass width and height in pts. print context is already at 0,0
and scaled.
* src/sheet-object-graph.c (sheet_object_graph_print) : Use new
cleaner interface.
* src/sheet-object-image.c (sheet_object_image_print) : ditto.
* src/sheet-object-graphic.c (sheet_object_graphic_print) :
Save the graphics context before filling and just resuse it for the
outline. Fix the direction handling for the new interface
semantics.
(sheet_object_filled_print) : ditto.
2003-07-01 Morten Welinder <terra@gnome.org>
* src/datetime.c (yearfrac): New function.
......
......@@ -22,6 +22,9 @@ Emmanuel Pacaud:
* New format selector for stf.
* support Ring plots
Gustavo Carneiro:
* Use gnome-common detection for libtool version
Jean Brefort:
* Support image files in chart areas (background, bar/col or pie)
......@@ -37,6 +40,8 @@ Jody:
* Add XML persistence for charts
* Misc Charting improvements & fixes
* Add YEARFRAC to put us at 100% coverage
* Fix some format generation bugs
* Rationalize and document the SheetObject::print interface
Jon Kåre:
* Improve color combo.
......
2003-07-02 Jody Goldberg <jody@gnome.org>
* src/print.c (print_sheet_objects) : translate to the upper left
corner of the object and pass in its width and height.
* src/sheet-object.c (sheet_object_print) : adjust print interface to
only pass width and height in pts. print context is already at 0,0
and scaled.
* src/sheet-object-graph.c (sheet_object_graph_print) : Use new
cleaner interface.
* src/sheet-object-image.c (sheet_object_image_print) : ditto.
* src/sheet-object-graphic.c (sheet_object_graphic_print) :
Save the graphics context before filling and just resuse it for the
outline. Fix the direction handling for the new interface
semantics.
(sheet_object_filled_print) : ditto.
2003-07-01 Morten Welinder <terra@gnome.org>
* src/datetime.c (yearfrac): New function.
......
2003-07-02 Jody Goldberg <jody@gnome.org>
* src/print.c (print_sheet_objects) : translate to the upper left
corner of the object and pass in its width and height.
* src/sheet-object.c (sheet_object_print) : adjust print interface to
only pass width and height in pts. print context is already at 0,0
and scaled.
* src/sheet-object-graph.c (sheet_object_graph_print) : Use new
cleaner interface.
* src/sheet-object-image.c (sheet_object_image_print) : ditto.
* src/sheet-object-graphic.c (sheet_object_graphic_print) :
Save the graphics context before filling and just resuse it for the
outline. Fix the direction handling for the new interface
semantics.
(sheet_object_filled_print) : ditto.
2003-07-01 Morten Welinder <terra@gnome.org>
* src/datetime.c (yearfrac): New function.
......
......@@ -152,7 +152,6 @@ print_sheet_objects (PrintJobInfo const *pj, Sheet const *sheet, Range *range,
for (l = sheet->sheet_objects; l; l = l->next) {
SheetObject *so = SHEET_OBJECT (l->data);
double coords [4];
double obj_base_x = 0.0, obj_base_y = 0.0;
/* First check if we need to print this object */
if (!so->is_visible ||
......@@ -160,21 +159,18 @@ print_sheet_objects (PrintJobInfo const *pj, Sheet const *sheet, Range *range,
continue;
sheet_object_position_pts_get (so, coords);
switch (pj->pi->scaling.type) {
case PERCENTAGE:
obj_base_x = base_x + (MIN (coords [0], coords [2])
- sheet_col_get_distance_pts (sheet, 0, range->start.col));
obj_base_y = base_y - (MIN (coords [3], coords [1])
- sheet_row_get_distance_pts (sheet, 0, range->start.row));
break;
case SIZE_FIT:
g_warning ("SIZE_FIT not implemented for "
"objects!");
continue;
}
gnome_print_gsave (pj->print_context);
/* move to top left */
gnome_print_translate (pj->print_context,
base_x + (MIN (coords [0], coords [2])
- sheet_col_get_distance_pts (sheet, 0, range->start.col)),
base_y - (MIN (coords [3], coords [1])
- sheet_row_get_distance_pts (sheet, 0, range->start.row)));
sheet_object_print (so, pj->print_context,
obj_base_x, obj_base_y);
fabs (coords[2] - coords[0]),
fabs (coords[3] - coords[1]));
gnome_print_grestore (pj->print_context);
}
gnome_print_grestore (pj->print_context);
......
......@@ -224,14 +224,10 @@ sheet_object_graph_clone (SheetObject const *so, Sheet *sheet)
static void
sheet_object_graph_print (SheetObject const *so, GnomePrintContext *ctx,
double base_x, double base_y)
double width, double height)
{
SheetObjectGraph *sog = SHEET_OBJECT_GRAPH (so);
double coords [4];
sheet_object_position_pts_get (so, coords);
gog_graph_print_to_gnome_print (sog->graph, ctx,
base_x, base_y, coords);
gog_graph_print_to_gnome_print (sog->graph, ctx, width, height);
}
static void
......
......@@ -281,94 +281,82 @@ sheet_object_graphic_clone (SheetObject const *so, Sheet *sheet)
static void
sheet_object_graphic_print (SheetObject const *so, GnomePrintContext *ctx,
double base_x, double base_y)
double width, double height)
{
SheetObjectGraphic *sog;
double coords [4];
double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
g_return_if_fail (IS_SHEET_OBJECT_GRAPHIC (so));
g_return_if_fail (GNOME_IS_PRINT_CONTEXT (ctx));
sog = SHEET_OBJECT_GRAPHIC (so);
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (so);
double x1, y1, x2, y2;
sheet_object_position_pts_get (so, coords);
if (sog->fill_color == NULL)
return;
gnome_print_gsave (ctx);
switch (so->anchor.direction) {
case SO_DIR_UP_RIGHT:
case SO_DIR_DOWN_RIGHT:
x1 = 0.;
x2 = width;
break;
case SO_DIR_UP_LEFT:
case SO_DIR_DOWN_LEFT:
x1 = width;
x2 = 0.;
break;
default:
g_warning ("Cannot guess direction!");
return;
}
if (sog->fill_color) {
switch (so->anchor.direction) {
case SO_DIR_UP_RIGHT:
case SO_DIR_DOWN_RIGHT:
x1 = base_x;
x2 = base_x + (coords [2] - coords [0]);
break;
case SO_DIR_UP_LEFT:
case SO_DIR_DOWN_LEFT:
x1 = base_x + (coords [2] - coords [0]);
x2 = base_x;
break;
default:
g_warning ("Cannot guess direction!");
gnome_print_grestore (ctx);
return;
}
switch (so->anchor.direction) {
case SO_DIR_UP_LEFT:
case SO_DIR_UP_RIGHT:
y1 = -height;
y2 = 0.;
break;
case SO_DIR_DOWN_LEFT:
case SO_DIR_DOWN_RIGHT:
y1 = 0.;
y2 = -height;
break;
default:
g_warning ("Cannot guess direction!");
return;
}
switch (so->anchor.direction) {
case SO_DIR_UP_LEFT:
case SO_DIR_UP_RIGHT:
y1 = base_y;
y2 = base_y + (coords [3] - coords [1]);
break;
case SO_DIR_DOWN_LEFT:
case SO_DIR_DOWN_RIGHT:
y1 = base_y + (coords [3] - coords [1]);
y2 = base_y;
break;
default:
g_warning ("Cannot guess direction!");
gnome_print_grestore (ctx);
return;
}
gnome_print_setrgbcolor (ctx,
sog->fill_color->color.red / (double) 0xffff,
sog->fill_color->color.green / (double) 0xffff,
sog->fill_color->color.blue / (double) 0xffff);
gnome_print_setrgbcolor (ctx,
sog->fill_color->color.red / (double) 0xffff,
sog->fill_color->color.green / (double) 0xffff,
sog->fill_color->color.blue / (double) 0xffff);
if (sog->type == SHEET_OBJECT_ARROW) {
double phi;
if (sog->type == SHEET_OBJECT_ARROW) {
double phi;
phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
gnome_print_gsave (ctx);
gnome_print_translate (ctx, x2, y2);
gnome_print_rotate (ctx, phi / (2 * M_PI) * 360);
gnome_print_setlinewidth (ctx, 1.0);
gnome_print_newpath (ctx);
gnome_print_moveto (ctx, 0.0, 0.0);
gnome_print_lineto (ctx, -sog->c, -sog->b);
gnome_print_lineto (ctx, 0.0, -sog->a);
gnome_print_lineto (ctx, sog->c, -sog->b);
gnome_print_closepath (ctx);
gnome_print_fill (ctx);
gnome_print_grestore (ctx);
/*
* Make the line shorter so that the arrow won't be
* on top of a (perhaps quite fat) line.
*/
x2 += sog->a * sin (phi);
y2 -= sog->a * cos (phi);
}
phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
gnome_print_setlinewidth (ctx, sog->width);
gnome_print_gsave (ctx);
gnome_print_translate (ctx, x2, y2);
gnome_print_rotate (ctx, phi / (2 * M_PI) * 360);
gnome_print_setlinewidth (ctx, 1.0);
gnome_print_newpath (ctx);
gnome_print_moveto (ctx, x1, y1);
gnome_print_lineto (ctx, x2, y2);
gnome_print_stroke (ctx);
gnome_print_moveto (ctx, 0.0, 0.0);
gnome_print_lineto (ctx, -sog->c, -sog->b);
gnome_print_lineto (ctx, 0.0, -sog->a);
gnome_print_lineto (ctx, sog->c, -sog->b);
gnome_print_closepath (ctx);
gnome_print_fill (ctx);
gnome_print_grestore (ctx);
/*
* Make the line shorter so that the arrow won't be
* on top of a (perhaps quite fat) line.
*/
x2 += sog->a * sin (phi);
y2 -= sog->a * cos (phi);
}
gnome_print_grestore (ctx);
gnome_print_setlinewidth (ctx, sog->width);
gnome_print_newpath (ctx);
gnome_print_moveto (ctx, x1, y1);
gnome_print_lineto (ctx, x2, y2);
gnome_print_stroke (ctx);
}
typedef struct {
......@@ -1091,57 +1079,35 @@ make_ellipse (GnomePrintContext *ctx,
static void
sheet_object_filled_print (SheetObject const *so, GnomePrintContext *ctx,
double base_x, double base_y)
double width, double height)
{
SheetObjectFilled *sof;
SheetObjectGraphic *sog;
double coords [4];
double start_x, start_y;
double end_x, end_y;
g_return_if_fail (IS_SHEET_OBJECT_FILLED (so));
g_return_if_fail (GNOME_IS_PRINT_CONTEXT (ctx));
sof = SHEET_OBJECT_FILLED (so);
sog = SHEET_OBJECT_GRAPHIC (so);
sheet_object_position_pts_get (so, coords);
start_x = base_x;
start_y = base_y;
end_x = start_x + (coords [2] - coords [0]);
end_y = start_y + (coords [3] - coords [1]);
SheetObjectFilled *sof = SHEET_OBJECT_FILLED (so);
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (so);
gnome_print_gsave (ctx);
gnome_print_newpath (ctx);
if (sog->type == SHEET_OBJECT_OVAL)
make_ellipse (ctx, 0., width, 0., -height);
else
make_rect (ctx, 0., width, 0., -height);
gnome_print_closepath (ctx);
if (sog->fill_color) {
gnome_print_gsave (ctx);
gnome_print_setrgbcolor (ctx,
sog->fill_color->color.red / (double) 0xffff,
sog->fill_color->color.green / (double) 0xffff,
sog->fill_color->color.blue / (double) 0xffff);
gnome_print_fill (ctx);
gnome_print_grestore (ctx);
}
if (sof->outline_color) {
gnome_print_setlinewidth (ctx, sog->width);
gnome_print_setrgbcolor (ctx,
sof->outline_color->color.red / (double) 0xffff,
sof->outline_color->color.green / (double) 0xffff,
sof->outline_color->color.blue / (double) 0xffff);
gnome_print_newpath (ctx);
if (sog->type == SHEET_OBJECT_OVAL)
make_ellipse (ctx, start_x, end_x, start_y, end_y);
else
make_rect (ctx, start_x, end_x, start_y, end_y);
gnome_print_closepath (ctx);
gnome_print_stroke (ctx);
}
if (sog->fill_color) {
gnome_print_setrgbcolor (ctx,
sog->fill_color->color.red / (double) 0xffff,
sog->fill_color->color.green / (double) 0xffff,
sog->fill_color->color.blue / (double) 0xffff);
gnome_print_newpath (ctx);
if (sog->type == SHEET_OBJECT_OVAL)
make_ellipse (ctx, start_x, end_x, start_y, end_y);
else
make_rect (ctx, start_x, end_x, start_y, end_y);
gnome_print_fill (ctx);
}
gnome_print_grestore (ctx);
}
static void
......
......@@ -304,32 +304,25 @@ sheet_object_image_clone (SheetObject const *so, Sheet *sheet)
static void
sheet_object_image_print (SheetObject const *so, GnomePrintContext *ctx,
double base_x, double base_y)
double width, double height)
{
SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so);
GdkPixbuf *pixbuf = soi_get_pixbuf (soi, 1.);
if (pixbuf != NULL) {
guchar *raw_image = gdk_pixbuf_get_pixels (pixbuf);
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
char *raw_image = (char *)gdk_pixbuf_get_pixels (pixbuf);
gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
double coords [4];
gint w = gdk_pixbuf_get_width (pixbuf);
gint h = gdk_pixbuf_get_height (pixbuf);
sheet_object_position_pts_get (so, coords);
gnome_print_gsave (ctx);
gnome_print_translate (ctx,
base_x, base_y - fabs (coords[3] - coords[1]));
gnome_print_scale (ctx,
fabs (coords[2] - coords[0]),
fabs (coords[3] - coords[1]));
gnome_print_translate (ctx, 0, -height);
gnome_print_scale (ctx, width, height);
if (gdk_pixbuf_get_has_alpha (pixbuf))
gnome_print_rgbaimage (ctx, (char *)raw_image,
width, height, rowstride);
gnome_print_rgbaimage (ctx, raw_image, w, h, rowstride);
else
gnome_print_rgbimage (ctx, (char *)raw_image,
width, height, rowstride);
gnome_print_rgbimage (ctx, raw_image, w, h, rowstride);
g_object_unref (G_OBJECT (pixbuf));
gnome_print_grestore (ctx);
......
......@@ -48,10 +48,12 @@ typedef struct {
gboolean (*write_xml) (SheetObject const *so,
XmlParseContext const *ctxt,
xmlNodePtr tree);
/* Called with 0,0 set to the top, left corner of the object, and the
* graphics context saved */
void (*print) (SheetObject const *so,
GnomePrintContext *ctx,
double base_x,
double base_y);
double width, double height);
SheetObject * (*clone) (SheetObject const *so,
Sheet *sheet);
......@@ -59,7 +61,6 @@ typedef struct {
void (*default_size) (SheetObject const *so,
double *width_pts, double *height_pts);
gboolean stipple_border;
gboolean rubber_band_directly; /* If false, we draw a rectangle where
* the object is going to be layed out
* If true, we draw the object while
......
......@@ -278,7 +278,6 @@ sheet_object_class_init (GObjectClass *klass)
sheet_object_class->populate_menu = sheet_object_populate_menu;
sheet_object_class->print = NULL;
sheet_object_class->user_config = NULL;
sheet_object_class->stipple_border = FALSE;
sheet_object_class->rubber_band_directly = FALSE;
sheet_object_class->default_size = so_default_size;
}
......@@ -495,10 +494,10 @@ sheet_object_new_view (SheetObject *so, SheetControl *sc, gpointer key)
void
sheet_object_print (SheetObject const *so, GnomePrintContext *ctx,
double base_x, double base_y)
double width, double height)
{
if (SO_CLASS (so)->print)
SO_CLASS (so)->print (so, ctx, base_x, base_y);
SO_CLASS (so)->print (so, ctx, width, height);
}
SheetObject *
......
......@@ -57,7 +57,7 @@ xmlNodePtr sheet_object_write_xml (SheetObject const *so,
XmlParseContext const *ctxt);
void sheet_object_print (SheetObject const *so,
GnomePrintContext *ctx,
double base_x, double base_y);
double width, double height);
void sheet_object_clone_sheet (Sheet const *src, Sheet *dst, Range *range);
void sheet_object_update_bounds (SheetObject *so, CellPos const *p);
void sheet_object_default_size (SheetObject *so,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment