Esempio n. 1
0
/* Use g_source_unref() when done with the returned pointer. */
GSource *
e_canvas_item_show_area_delayed_ex (GnomeCanvasItem *item,
                                 gdouble x1,
                                 gdouble y1,
                                 gdouble x2,
                                 gdouble y2,
                                 gint delay)
{
	GSource *source;
	DoubsAndCanvas *dac;

	g_return_val_if_fail (item != NULL, NULL);
	g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), NULL);

	gnome_canvas_item_i2w (item, &x1, &y1);
	gnome_canvas_item_i2w (item, &x2, &y2);

	dac = g_new (DoubsAndCanvas, 1);
	dac->x1 = x1;
	dac->y1 = y1;
	dac->x2 = x2;
	dac->y2 = y2;
	dac->canvas = g_object_ref (item->canvas);

	source = g_timeout_source_new (delay);
	g_source_set_callback (source, show_area_timeout, dac, doubs_and_canvas_free);
	g_source_set_name (source, G_STRFUNC);
	g_source_attach (source, NULL);

	return source;
}
Esempio n. 2
0
gboolean
e_canvas_item_area_shown (GnomeCanvasItem *item,
                          gdouble x1,
                          gdouble y1,
                          gdouble x2,
                          gdouble y2)
{
	g_return_val_if_fail (item != NULL, FALSE);
	g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), FALSE);

	gnome_canvas_item_i2w (item, &x1, &y1);
	gnome_canvas_item_i2w (item, &x2, &y2);

	return e_canvas_area_shown (item->canvas, x1, y1, x2, y2);
}
Esempio n. 3
0
void
e_canvas_item_show_area (GnomeCanvasItem *item,
                         gdouble x1,
                         gdouble y1,
                         gdouble x2,
                         gdouble y2)
{
	g_return_if_fail (item != NULL);
	g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));

	gnome_canvas_item_i2w (item, &x1, &y1);
	gnome_canvas_item_i2w (item, &x2, &y2);

	e_canvas_show_area (item->canvas, x1, y1, x2, y2);
}
Esempio n. 4
0
/* Recomputes the bounding box of an icon text item */
static void
recompute_bounding_box (GnomeIconTextItem *iti)
{

	GnomeCanvasItem *item;
	double x1, y1, x2, y2;
	int width_c, height_c;
	int width_w, height_w;
	int max_width_w;

	item = GNOME_CANVAS_ITEM (iti);

	width_c = iti->_priv->layout_width + 2 * MARGIN_X;
	height_c = iti->_priv->layout_height + 2 * MARGIN_Y;
	width_w = ROUND (width_c / item->canvas->pixels_per_unit);
	height_w = ROUND (height_c / item->canvas->pixels_per_unit);
	max_width_w = ROUND (iti->width / item->canvas->pixels_per_unit);

	x1 = iti->x;
	y1 = iti->y;

	gnome_canvas_item_i2w (item, &x1, &y1);

	x1 += ROUND ((max_width_w - width_w) / 2);
	x2 = x1 + width_w;
	y2 = y1 + height_w;

	gnome_canvas_w2c_d (item->canvas, x1, y1, &item->x1, &item->y1);
	gnome_canvas_w2c_d (item->canvas, x2, y2, &item->x2, &item->y2);
}
Esempio n. 5
0
static void
relation_arrow_get_bounds (PlannerRelationArrow *arrow,
			   gdouble              *x1,
			   gdouble              *y1,
			   gdouble              *x2,
			   gdouble              *y2)
{
	PlannerRelationArrowPriv *priv;
	GnomeCanvasItem          *item;
	gdouble                   wx1, wy1, wx2, wy2;
	gint                      cx1, cy1, cx2, cy2;
	gint                      i;

	item = GNOME_CANVAS_ITEM (arrow);
	priv = arrow->priv;

	/* Get the items bbox in canvas pixel coordinates. */

	/* Silence warning. */
	wx1 = G_MAXDOUBLE;
	wy1 = G_MAXDOUBLE;
	wx2 = -G_MAXDOUBLE;
	wy2 = -G_MAXDOUBLE;

	for (i = 0; i < priv->num_points; i++) {
		wx1 = MIN (wx1, priv->points[i].x);
		wy1 = MIN (wy1, priv->points[i].y);
		wx2 = MAX (wx2, priv->points[i].x);
		wy2 = MAX (wy2, priv->points[i].y);
	}

	/* We could do better here, but this is good enough. */
	wx1 -= ARROW_SIZE / 2;
	wy1 -= ARROW_SIZE / 2;
	wx2 += ARROW_SIZE / 2;
	wy2 += ARROW_SIZE / 2;

	gnome_canvas_item_i2w (item, &wx1, &wy1);
	gnome_canvas_item_i2w (item, &wx2, &wy2);
	gnome_canvas_w2c (item->canvas, wx1, wy1, &cx1, &cy1);
	gnome_canvas_w2c (item->canvas, wx2, wy2, &cx2, &cy2);

	*x1 = cx1 - 1;
	*y1 = cy1 - 1;
	*x2 = cx2 + 1;
	*y2 = cy2 + 1;
}
Esempio n. 6
0
static void
bst_canvas_source_changed (BstCanvasSource *csource)
{
  if (csource->source)
    {
      GnomeCanvasItem *item = GNOME_CANVAS_ITEM (csource);
      gdouble x = 0, y = 0;
      gnome_canvas_item_i2w (item, &x, &y);
      bse_object_set_parasite_coords (csource->source, x, y);
    }
}
Esempio n. 7
0
void
bst_canvas_source_ochannel_pos (BstCanvasSource *csource,
				guint            ichannel,
				gdouble         *x_p,
				gdouble         *y_p)
{
  gdouble x, y;
  
  g_return_if_fail (BST_IS_CANVAS_SOURCE (csource));
  
  x = OCHANNEL_X (csource) + CHANNEL_WIDTH (csource) / 2;
  if (csource->source)
    y = CHANNEL_HEIGHT (csource) / bse_source_n_ochannels (csource->source);
  y *= ichannel + 0.5;
  y += OCHANNEL_Y (csource);
  gnome_canvas_item_i2w (GNOME_CANVAS_ITEM (csource), &x, &y);
  if (x_p)
    *x_p = x;
  if (y_p)
    *y_p = y;
}
Esempio n. 8
0
void
gnucash_cursor_configure (GnucashCursor *cursor)
{
    GnomeCanvasItem *item;
    GnucashItemCursor *block_cursor;
    GnucashItemCursor *cell_cursor;
    GnomeCanvas *canvas;
    gint x, y, w, h;
    double wx, wy;

    g_return_if_fail (cursor != NULL);
    g_return_if_fail (GNUCASH_IS_CURSOR (cursor));

    canvas = GNOME_CANVAS(GNOME_CANVAS_ITEM(cursor)->canvas);

    item = GNOME_CANVAS_ITEM (cursor);

    gnucash_cursor_get_pixel_coords (cursor, &x, &y, &w, &h);
    gnome_canvas_item_set (GNOME_CANVAS_ITEM(cursor),
                           "GnomeCanvasGroup::x", (double)x,
                           "GnomeCanvasGroup::y", (double)y,
                           NULL);

    cursor->w = w;
    cursor->h = h + 1;

    item->x1 = cursor->x = x;
    item->y1 = cursor->y = y;
    item->x2 = x + w;
    item->y2 = y + h + 1;

    item = cursor->cursor[GNUCASH_CURSOR_BLOCK];
    block_cursor = GNUCASH_ITEM_CURSOR (item);

    wx = 0;
    wy = 0;

    gnome_canvas_item_i2w (item, &wx, &wy);
    gnome_canvas_w2c (canvas, wx, wy, &block_cursor->x, &block_cursor->y);
    block_cursor->w = w;
    block_cursor->h = h + 1;

    item->x1 = block_cursor->x;
    item->y1 = block_cursor->y;
    item->x2 = block_cursor->x + w;
    item->y2 = block_cursor->y + h + 1;

    item = cursor->cursor[GNUCASH_CURSOR_CELL];
    cell_cursor = GNUCASH_ITEM_CURSOR(item);

    gnucash_sheet_style_get_cell_pixel_rel_coords (cursor->style,
            cell_cursor->row,
            cell_cursor->col,
            &x, &y, &w, &h);
    wx = x - block_cursor->x;
    wy = y;

    gnome_canvas_item_i2w (item, &wx, &wy);
    gnome_canvas_w2c (canvas, wx, wy, &cell_cursor->x, &cell_cursor->y);
    cell_cursor->w = w;
    cell_cursor->h = h;

    item->x1 = cell_cursor->x;
    item->y1 = cell_cursor->y;
    item->x2 = cell_cursor->x + w;
    item->y2 = cell_cursor->y + h;
}
Esempio n. 9
0
static void
relation_arrow_draw (GnomeCanvasItem *item,
		     GdkDrawable     *drawable,
		     gint             x,
		     gint             y,
		     gint             width,
		     gint             height)
{
	PlannerRelationArrow     *arrow;
	PlannerRelationArrowPriv *priv;
#ifdef USE_AFFINE
	gdouble                   i2c[6];
	ArtPoint                  i1, i2, c1, c2;
#else
	gdouble                   i2w_dx;
	gdouble                   i2w_dy;
	gdouble                   dx1, dy1, dx2, dy2;
#endif
	gint                      cx1, cy1, cx2, cy2;
	GdkGC                    *gc;
	GdkPoint                  points[4];
	gint                      i;

	arrow = PLANNER_RELATION_ARROW (item);
	priv = arrow->priv;

	gc = gdk_gc_new (drawable);
	gdk_gc_set_line_attributes (gc,
				    1,
				    GDK_LINE_SOLID,
				    GDK_CAP_BUTT,
				    GDK_JOIN_MITER);

	/* Silence warning. */
	cx1 = 0;
	cy1 = 0;
	cx2 = 0;
	cy2 = 0;

#ifdef USE_AFFINE
	/* Get item area in canvas coordinates. */
	gnome_canvas_item_i2c_affine (item, i2c);
#endif

	for (i = 0; i < priv->num_points - 1; i++) {
#ifdef USE_AFFINE
		i1.x = priv->points[i].x;
		i1.y = priv->points[i].y;
		i2.x = priv->points[i+1].x;
		i2.y = priv->points[i+1].y;
		art_affine_point (&c1, &i1, i2c);
		art_affine_point (&c2, &i2, i2c);
		cx1 = floor (c1.x + 0.5) - x;
		cy1 = floor (c1.y + 0.5) - y;
		cx2 = floor (c2.x + 0.5) - x;
		cy2 = floor (c2.y + 0.5) - y;
#else
		i2w_dx = 0.0;
		i2w_dy = 0.0;
		gnome_canvas_item_i2w (item, &i2w_dx, &i2w_dy);

		dx1 = priv->points[i].x;
		dy1 = priv->points[i].y;
		dx2 = priv->points[i+1].x;
		dy2 = priv->points[i+1].y;

		gnome_canvas_w2c (item->canvas,
				  dx1 + i2w_dx,
				  dy1 + i2w_dy,
				  &cx1,
				  &cy1);

		gnome_canvas_w2c (item->canvas,
				  dx2 + i2w_dx,
				  dy2 + i2w_dy,
				  &cx2,
				  &cy2);

		cx1 -= x;
		cy1 -= y;
		cx2 -= x;
		cy2 -= y;
#endif

		gdk_draw_line (drawable,
			       gc,
			       cx1,
			       cy1,
			       cx2,
			       cy2);
	}

	relation_arrow_setup_arrow (priv->arrow_dir,
					points,
					cx1,
					cy1,
					cx2,
					cy2);

	gdk_draw_polygon (drawable,
			  gc,
			  TRUE,
			  (GdkPoint *) &points,
			  4);

	g_object_unref (gc);
}