예제 #1
0
static VALUE
rg_initialize(VALUE self, VALUE parent)
{
    GooCanvasItem *item;
    item = goo_canvas_table_new(RVAL2GCI(parent), NULL);
    RB_GOO_CANVAS_ITEM_INITIALIZE(self, item);
    G_CHILD_ADD(parent, self);
    return Qnil;
}
예제 #2
0
static void
create_width_for_height_table (GooCanvasItem *root,
			       gdouble        x,
			       gdouble        y,
			       gdouble        width,
			       gdouble        height,
			       gdouble        rotation)
{
  GooCanvasItem *table, *item;
  gchar *text = "This is a long paragraph that will have to be split over a few lines so we can see if its allocated height changes when its allocated width is changed.";

  table = goo_canvas_table_new (root,
#if 1
				"width", width,
				"height", height,
#endif
                                NULL);
  goo_canvas_item_translate (table, x, y);
  goo_canvas_item_rotate (table, rotation, 0, 0);

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 0,
					"column", 0,
					"x-shrink", TRUE,
					NULL);

#if 1
  item = goo_canvas_text_new (table, text, 0, 0, -1, GOO_CANVAS_ANCHOR_NW, NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 1,
					"column", 0,
					"x-expand", TRUE,
					"x-fill", TRUE,
					"x-shrink", TRUE,
					"y-expand", TRUE,
					"y-fill", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (item), "id", "Text Item");
  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
#endif

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 2,
					"column", 0,
					"x-shrink", TRUE,
					NULL);
}
예제 #3
0
static void
create_demo_table (GooCanvasItem *root,
		   gdouble        x,
		   gdouble        y,
		   gdouble        width,
		   gdouble        height)
{
  GooCanvasItem *table, *square, *circle, *triangle;

  table = goo_canvas_table_new (root,
                                "row-spacing", 4.0,
                                "column-spacing", 4.0,
				"width", width,
				"height", height,
                                NULL);
  goo_canvas_item_translate (table, x, y);

  square = goo_canvas_rect_new (table, 0.0, 0.0, 50.0, 50.0,
				"fill-color", "red",
				NULL);
  goo_canvas_item_set_child_properties (table, square,
					"row", 0,
					"column", 0,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (square), "id", "Red square");
  g_signal_connect (square, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  circle = goo_canvas_ellipse_new (table, 0.0, 0.0, 25.0, 25.0,
				   "fill-color", "blue",
				   NULL);
  goo_canvas_item_set_child_properties (table, circle,
					"row", 0,
					"column", 1,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (circle), "id", "Blue circle");
  g_signal_connect (circle, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  triangle = goo_canvas_polyline_new (table, TRUE, 3,
				      25.0, 0.0, 0.0, 50.0, 50.0, 50.0,
				      "fill-color", "yellow",
				      NULL);
  goo_canvas_item_set_child_properties (table, triangle,
					"row", 0,
					"column", 2,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (triangle), "id", "Yellow triangle");
  g_signal_connect (triangle, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
}
예제 #4
0
static GooCanvasItem*
create_table (GooCanvasItem *parent,
	      gint           row,
	      gint           column,
	      gint           embedding_level,
	      gdouble        x,
	      gdouble        y,
	      gdouble        rotation,
	      gdouble        scale,
	      gint           demo_item_type,
	      gboolean       show_grid_lines)
{
  GooCanvasItem *table;

  /* Add a few simple items. */
  table = goo_canvas_table_new (parent,
				"row-spacing", 4.0,
				"column-spacing", 4.0,
				NULL);

  if (show_grid_lines)
    g_object_set (table,
		  "horz-grid-line-width", 1.0f,
		  "vert-grid-line-width", 1.0f,
		  NULL);

  goo_canvas_item_translate (table, x, y);
#if 1
  goo_canvas_item_rotate (table, rotation, 0, 0);
#endif
#if 1
  goo_canvas_item_scale (table, scale, scale);
#endif

  if (row != -1)
    goo_canvas_item_set_child_properties (parent, table,
					  "row", row,
					  "column", column,
#if 1
					  "x-expand", TRUE,
					  "x-fill", TRUE,
#endif
#if 0
					  "y-expand", TRUE,
					  "y-fill", TRUE,
#endif
					  NULL);

  if (embedding_level)
    {
      gint level = embedding_level - 1;
      create_table (table, 0, 0, level, 50, 50, 0, 0.7, demo_item_type,
		    show_grid_lines);
      create_table (table, 0, 1, level, 50, 50, 45, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 0, 2, level, 50, 50, 90, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 0, level, 50, 50, 135, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 1, level, 50, 50, 180, 1.5, demo_item_type,
		    show_grid_lines);
      create_table (table, 1, 2, level, 50, 50, 225, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 0, level, 50, 50, 270, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 1, level, 50, 50, 315, 1.0, demo_item_type,
		    show_grid_lines);
      create_table (table, 2, 2, level, 50, 50, 360, 2.0, demo_item_type,
		    show_grid_lines);
    }
  else if (demo_item_type == DEMO_TEXT_ITEM_2)
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1,
			"(0.0,0.0)\nleft\naligned",
			-1, 0, 0, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1,
			"(0.5,0.0)\ncenter\naligned",
			-1, 0.5, 0, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1,
			"(1.0,0.0)\nright\naligned",
			-1, 1, 0, PANGO_ALIGN_RIGHT);

      /* The layout width shouldn't really make any difference in this test. */
      create_demo_item (table, demo_item_type, 1, 0, 1, 1,
			"(0.5,0.5)\ncenter\naligned",
			50, 0.5, 0.5, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1,
			"(0.0,1.0)\nright\naligned",
			100, 0, 1.0, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1,
			"(0.0,0.5)\nleft\naligned",
			200, 0, 0.5, PANGO_ALIGN_LEFT);

      create_demo_item (table, demo_item_type, 2, 0, 1, 1,
			"(1.0,1.0)\ncenter\naligned",
			-1, 1, 1, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1,
			"(1,0.5)\nright\naligned",
			-1, 1.0, 0.5, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1,
			"(0.0,0.0)\nleft\naligned",
			-1, 0, 0, PANGO_ALIGN_LEFT);
    }
  else if (demo_item_type == DEMO_TEXT_ITEM_3)
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1,
			"width 50 align 0.0, 0.0 text left aligned",
			50, 0, 0, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1,
			"width 100 align 0.5, 0.0 text center aligned",
			100, 0.5, 0, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1,
			"width 150 align 1.0, 0.0 text right aligned",
			150, 1, 0, PANGO_ALIGN_RIGHT);

      create_demo_item (table, demo_item_type, 1, 0, 1, 1,
			"width 50 align 0.5, 0.5 text center aligned",
			50, 0.5, 0.5, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1,
			"width 100 align 0.0, 1.0 text right aligned",
			100, 0, 1.0, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1,
			"width 200 align 0.0, 0.5 text left aligned",
			200, 0, 0.5, PANGO_ALIGN_LEFT);

      create_demo_item (table, demo_item_type, 2, 0, 1, 1,
			"width 50 align 1.0, 1.0 text center aligned",
			50, 1, 1, PANGO_ALIGN_CENTER);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1,
			"width 100 align 1, 0.5 text right aligned",
			100, 1.0, 0.5, PANGO_ALIGN_RIGHT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1,
			"width 50 align 0.0, 0.0 text left aligned",
			50, 0, 0, PANGO_ALIGN_LEFT);
    }
  else
    {
      create_demo_item (table, demo_item_type, 0, 0, 1, 1, "(0,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 1, 1, 1, "(1,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 0, 2, 1, 1, "(2,0)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 0, 1, 1, "(0,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 1, 1, 1, "(1,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 1, 2, 1, 1, "(2,1)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 0, 1, 1, "(0,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 1, 1, 1, "(1,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
      create_demo_item (table, demo_item_type, 2, 2, 1, 1, "(2,2)",
			-1, 0, 0.5, PANGO_ALIGN_LEFT);
    }

  return table;
}