Re: GooCanvasTable: column widths



On Wed, 2011-09-14 at 11:08 +0100, Damon Chaplin wrote:
> > Yes, I think I've got a fix for it. I just need to add some tests.
> 
> This is hopefully fixed in git now.

Thanks. It seems to be much improved, but the first two columns in this
test case are still not quite the same width. Any ideas?


-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com
// Build with, for instance:
// gcc test_table_text_width.c `pkg-config goocanvas-2.0 --libs --cflags`
#include <gtk/gtk.h>
#include <goocanvas.h>

gdouble drag_x = 0;
gdouble drag_y = 0;
gdouble dragging = FALSE;

static gboolean
on_delete_event (GtkWidget *window,
		 GdkEvent *event,
		 gpointer unused_data)
{
  gtk_main_quit ();
  return FALSE;
}

int
main (int argc, char *argv[])
{
  GtkWidget *window = 0;

  gtk_init (&argc, &argv);

  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);

  GtkWidget *canvas = goo_canvas_new ();
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 10000, 10000);
  gtk_container_add (GTK_CONTAINER(window), canvas);
  gtk_widget_show (canvas);

  GooCanvasItem *root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Note: "If the "width" and "height" properties are set to positive values then the group is clipped to the given size." */
  GooCanvasItem *table = goo_canvas_table_new (root,
    "x", 10.0f, 
    "y", 10.0f,
    "width", 500.0f,
    "horz-grid-line-width", 1.0f,
    "vert-grid-line-width", 1.0f,
    NULL);

  GooCanvasItem *text = goo_canvas_text_new (table,
    "This should be 100 wide.",
    0.0f, 0.0f,
    100.0f, GOO_CANVAS_ANCHOR_NW,
    NULL);
  goo_canvas_item_set_child_properties(table, text,
                                       "row", 0,
                                       "column", 0,
                                       "x-fill", TRUE, 
                                       "x-expand", TRUE, 
                                       NULL);
                                       
  GooCanvasItem *text2 = goo_canvas_text_new (table,
    "This too.",
    0.0f, 0.0f,
    100.0f, GOO_CANVAS_ANCHOR_NW,
    NULL);
  goo_canvas_item_set_child_properties(table, text2,
                                       "row", 1,
                                       "column", 1,
                                       "x-fill", TRUE, 
                                       "x-expand", TRUE, 
                                       NULL);
                                       

  GooCanvasItem *text3 = goo_canvas_text_new (table,
    "This should be 200 wide. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum",
    0.0f, 0.0f,
    200.0f, GOO_CANVAS_ANCHOR_NW,
    NULL);
  goo_canvas_item_set_child_properties(table, text3,
                                       "row", 2,
                                       "column", 2,
                                       "x-fill", TRUE, 
                                       "x-expand", TRUE, 
                                       NULL);
  g_object_set (text3,
   "wrap", TRUE,
    NULL);

  gtk_main ();
  return 0;
}


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