Problems with x-, y-coordinates > 8388307



Hi all,

i like to use high coordinate-values (like x(y)-center), but for
ellipses and lines, coordinates greater than  8388307 do not work for
me. I have extended the simple-demo.c example to demonstrate the
problem. If I set the variable "shft" to 8388307.0, I get the
rectangle, the circle and the text. But with 8388308.0 the circle
vanishes.

Joachim Geyer

#include <stdlib.h>
#include <goocanvas.h>


static gboolean on_rect_button_press (GooCanvasItem  *view,
				      GooCanvasItem  *target,
				      GdkEventButton *event,
				      gpointer        data);

static gboolean on_delete_event      (GtkWidget      *window,
				      GdkEvent       *event,
				      gpointer        unused_data);


int
main (int argc, char *argv[])
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item, *crcle_item;

  double shft = 8388307.0; // 8388308.0;

  /* Initialize GTK+. */
  gtk_set_locale ();
  gtk_init (&argc, &argv);

  /* Create the window and widgets. */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
  gtk_widget_show (window);
  g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event),
		    NULL);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_container_add (GTK_CONTAINER (window), scrolled_win);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Add a few simple items. */
  rect_item = goo_canvas_rect_new (root, 100.0+shft, 100.0+shft, 400, 400,
				   "line-width", 10.0,
				   "radius-x", 20.0,
				   "radius-y", 10.0,
				   "stroke-color", "yellow",
				   "fill-color", "red",
				   NULL);
  goo_canvas_item_translate(rect_item,-shft,-shft);
  crcle_item = goo_canvas_ellipse_new (root, 300.0+shft, 300.0+shft, 100, 100,
				   "line-width", 5.0,
				   "stroke-color", "green",
				   "fill-color", "blue",
				   NULL);
  goo_canvas_item_translate(crcle_item,-shft,-shft);
  text_item = goo_canvas_text_new (root, "Hello World", 300.0+shft,
300.0+shft, -1,
				   GTK_ANCHOR_CENTER,
				   "font", "Sans 24",
				   NULL);
  goo_canvas_item_rotate (text_item, 45, 300, 300);
  goo_canvas_item_translate(text_item,-shft,-shft);

  /* Connect a signal handler for the rectangle item. */
  g_signal_connect (rect_item, "button_press_event",
		    G_CALLBACK (on_rect_button_press), NULL);

  /* Pass control to the GTK+ main event loop. */
  gtk_main ();

  return 0;
}


/* This handles button presses in item views. We simply output a message to
   the console. */
static gboolean
on_rect_button_press (GooCanvasItem  *item,
		      GooCanvasItem  *target,
		      GdkEventButton *event,
		      gpointer        data)
{
  g_print ("rect item received button press event\n");
  return TRUE;
}


/* This is our handler for the "delete-event" signal of the window, which
   is emitted when the 'x' close button is clicked. We just exit here. */
static gboolean
on_delete_event (GtkWidget *window,
		 GdkEvent  *event,
		 gpointer   unused_data)
{
  exit (0);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]