241
241
gnome_print_setrgbcolor (ctx,
242
style->color / (double) 0xffff,
243
style->color / (double) 0xffff,
244
style->color / (double) 0xffff);
242
DOUBLE_RGBA_R (style->color),
243
DOUBLE_RGBA_G (style->color),
244
DOUBLE_RGBA_B (style->color));
246
246
if (sol->end_arrow.c > 0.) {
277
277
#endif /* WITH_GTK */
280
gnm_so_line_draw_cairo (SheetObject const *so, gpointer data,
281
double width, double height)
283
#ifdef GOFFICE_WITH_CAIRO
284
GnmSOLine *sol = GNM_SO_LINE (so);
285
cairo_t *cairo = (cairo_t*) data;
286
GogStyleLine const *style = &sol->style->line;
287
double x1, y1, x2, y2;
289
if (style->color == 0 || style->width < 0 || style->pattern == 0)
292
switch (so->anchor.base.direction) {
293
case GOD_ANCHOR_DIR_UP_RIGHT:
294
case GOD_ANCHOR_DIR_DOWN_RIGHT:
298
case GOD_ANCHOR_DIR_UP_LEFT:
299
case GOD_ANCHOR_DIR_DOWN_LEFT:
304
g_warning ("Cannot guess direction!");
308
switch (so->anchor.base.direction) {
309
case GOD_ANCHOR_DIR_UP_LEFT:
310
case GOD_ANCHOR_DIR_UP_RIGHT:
314
case GOD_ANCHOR_DIR_DOWN_LEFT:
315
case GOD_ANCHOR_DIR_DOWN_RIGHT:
320
g_warning ("Cannot guess direction!");
324
cairo_set_line_width (cairo, (style->width)? style->width: 1.);
325
cairo_set_source_rgba (cairo,
326
UINT_RGBA_R(style->color),
327
UINT_RGBA_B(style->color),
328
UINT_RGBA_G(style->color),
329
UINT_RGBA_A(style->color));
331
if (sol->end_arrow.c > 0.) {
334
phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
337
cairo_translate (cairo, x2, y2);
338
cairo_rotate (cairo, phi);
339
cairo_set_line_width (cairo, 1.0);
340
cairo_new_path (cairo);
341
cairo_move_to (cairo, 0.0, 0.0);
342
cairo_line_to (cairo, -sol->end_arrow.c, -sol->end_arrow.b);
343
cairo_line_to (cairo, 0.0, -sol->end_arrow.a);
344
cairo_line_to (cairo, sol->end_arrow.c, -sol->end_arrow.b);
345
cairo_close_path (cairo);
347
cairo_restore (cairo);
349
/* Make the line shorter so that the arrow won't be
350
* on top of a (perhaps quite fat) line. */
351
x2 += sol->end_arrow.a * sin (phi);
352
y2 -= sol->end_arrow.a * cos (phi);
355
cairo_set_line_width (cairo, style->width);
356
cairo_new_path (cairo);
357
cairo_move_to (cairo, x1, y1);
358
cairo_line_to (cairo, x2, y2);
359
cairo_stroke (cairo);
280
364
gnm_so_line_read_xml_dom (SheetObject *so, char const *typename,
281
365
XmlParseContext const *ctxt,
439
524
go_arrow_init (&sol->start_arrow, 0., 0., 0.);
440
525
go_arrow_init (&sol->end_arrow, 0., 0., 0.);
442
SHEET_OBJECT (obj)->anchor.direction = SO_DIR_NONE_MASK;
527
SHEET_OBJECT (obj)->anchor.base.direction = GOD_ANCHOR_DIR_NONE_MASK;
445
530
GSF_CLASS (GnmSOLine, gnm_so_line,