Re: GooCanvasTable: column widths
- From: Murray Cumming <murrayc murrayc com>
- To: Damon Chaplin <damon karuna eclipse co uk>
- Cc: goocanvas-list gnome org
- Subject: Re: GooCanvasTable: column widths
- Date: Wed, 21 Sep 2011 11:48:11 +0200
On Tue, 2011-08-23 at 12:34 +0200, Murray Cumming wrote:
> However, the GooCanvasText does not seem to use all the space that it
> then has. This is a problem when aligning the text right, as you can
> see
> in the attached test. The second column has the text aligned right,
> but
> not against the right side of the column.
This also still doesn't seem to be working, as seen in this test case.
--
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>
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 50 wide.",
0.0f, 0.0f,
50.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 *size_rect = goo_canvas_rect_new (table,
0.0f, 0.0f,
50.0f, 1.0f,
"stroke-pattern", NULL,
NULL);
goo_canvas_item_set_child_properties(table, size_rect,
"row", 0,
"column", 0,
NULL);
GooCanvasItem *text2 = goo_canvas_text_new (table,
"This too.",
0.0f, 0.0f,
50.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);
g_object_set (text2,
"alignment", PANGO_ALIGN_RIGHT,
NULL);
size_rect = goo_canvas_rect_new (table,
0.0f, 0.0f,
50.0f, 1.0f,
"stroke-pattern", NULL,
NULL);
goo_canvas_item_set_child_properties(table, size_rect,
"row", 1,
"column", 1,
NULL);
GooCanvasItem *text3 = goo_canvas_text_new (table,
"This should be 400 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,
400.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);
size_rect = goo_canvas_rect_new (table,
0.0f, 0.0f,
50.0f, 1.0f,
"stroke-pattern", NULL,
NULL);
goo_canvas_item_set_child_properties(table, size_rect,
"row", 2,
"column", 2,
NULL);
gtk_main ();
return 0;
}
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]