[cairo-commit]
goocanvas/demo demo.c, 1.21, 1.22 mv-demo-clipping.c,
1.1, 1.2 mv-demo-table.c, 1.1, 1.2 mv-demo.c, 1.6, 1.7
Damon Chaplin
commit at pdx.freedesktop.org
Thu Mar 8 04:32:06 PST 2007
Committed by: damon
Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv27470/demo
Modified Files:
demo.c mv-demo-clipping.c mv-demo-table.c mv-demo.c
Log Message:
2007-03-08 Damon Chaplin <damon at gnome.org>
* src/goocanvastext.[hc]: added ellipsize property, and used bit flags
to cut down on memory use a bit.
* demo/demo.c (setup_texts): added test for ellipsized text.
* demo/mv-demo.c:
* demo/mv-demo-table.c:
* demo/mv-demo-clipping.c: updated model-view demos, adding new stuff
from simple demo.
Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- demo.c 6 Mar 2007 12:08:15 -0000 1.21
+++ demo.c 8 Mar 2007 12:31:59 -0000 1.22
@@ -1098,6 +1098,17 @@
NULL);
setup_item_signals (textitem);
#endif
+
+#if 1
+ textitem = goo_canvas_text_new (root,
+ "Ellipsized text.",
+ 20, 420, 115, GTK_ANCHOR_W,
+ "font", "Sans 12",
+ "fill_color", "blue",
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
+ setup_item_signals (textitem);
+#endif
}
Index: mv-demo-clipping.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-demo-clipping.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mv-demo-clipping.c 15 Feb 2007 14:18:50 -0000 1.1
+++ mv-demo-clipping.c 8 Mar 2007 12:31:59 -0000 1.2
@@ -52,6 +52,11 @@
g_signal_connect (item, "button_press_event",
(GtkSignalFunc) on_button_press, "Yellow rectangle (unclipped)");
+ model = goo_canvas_text_model_new (root, "Sample Text", 520, 100, -1, GTK_ANCHOR_NW,
+ NULL);
+ item = goo_canvas_get_item (canvas, model);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, "Text (unclipped)");
/* Clipped items. */
@@ -82,6 +87,13 @@
g_signal_connect (item, "button_press_event",
(GtkSignalFunc) on_button_press, "Yellow rectangle");
+ model = goo_canvas_text_model_new (root, "Sample Text", 520, 300, -1, GTK_ANCHOR_NW,
+ "clip-path", "M535,300 h75 v40 h-75 z",
+ NULL);
+ item = goo_canvas_get_item (canvas, model);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, "Text (unclipped)");
+
/* Table with clipped items. */
table = goo_canvas_table_model_new (root, NULL);
@@ -121,6 +133,16 @@
item = goo_canvas_get_item (canvas, model);
g_signal_connect (item, "button_press_event",
(GtkSignalFunc) on_button_press, "Yellow rectangle");
+
+ model = goo_canvas_text_model_new (table, "Sample Text", 520, 300, -1, GTK_ANCHOR_NW,
+ "clip-path", "M535,300 h75 v40 h-75 z",
+ NULL);
+ goo_canvas_item_model_set_child_properties (table, model,
+ "column", 3,
+ NULL);
+ item = goo_canvas_get_item (canvas, model);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, "Text (unclipped)");
}
Index: mv-demo-table.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-demo-table.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mv-demo-table.c 20 Feb 2007 23:53:17 -0000 1.1
+++ mv-demo-table.c 8 Mar 2007 12:31:59 -0000 1.2
@@ -199,6 +199,64 @@
}
+static void
+create_width_for_height_table (GooCanvasItemModel *root,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gdouble rotation)
+{
+ GooCanvasItemModel *table, *model;
+ GooCanvasItem *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_model_new (root,
+#if 1
+ "width", width,
+ "height", height,
+#endif
+ NULL);
+ goo_canvas_item_model_translate (table, x, y);
+ goo_canvas_item_model_rotate (table, rotation, 0, 0);
+
+ model = goo_canvas_rect_model_new (table, 0.0, 0.0, width - 2, 10.0,
+ "fill-color", "red",
+ NULL);
+ goo_canvas_item_model_set_child_properties (table, model,
+ "row", 0,
+ "column", 0,
+ "x-shrink", TRUE,
+ NULL);
+
+#if 1
+ model = goo_canvas_text_model_new (table, text, 0, 0, -1, GTK_ANCHOR_NW, NULL);
+ goo_canvas_item_model_set_child_properties (table, model,
+ "row", 1,
+ "column", 0,
+ "x-expand", TRUE,
+ "x-fill", TRUE,
+ "x-shrink", TRUE,
+ "y-expand", TRUE,
+ "y-fill", TRUE,
+ NULL);
+ item = goo_canvas_get_item (canvas, model);
+ g_object_set_data (G_OBJECT (item), "id", "Text Item");
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
+#endif
+
+ model = goo_canvas_rect_model_new (table, 0.0, 0.0, width - 2, 10.0,
+ "fill-color", "red",
+ NULL);
+ goo_canvas_item_model_set_child_properties (table, model,
+ "row", 2,
+ "column", 0,
+ "x-shrink", TRUE,
+ NULL);
+}
+
+
GtkWidget *
create_table_page (void)
{
@@ -217,7 +275,7 @@
canvas = (GooCanvas*) goo_canvas_new ();
gtk_widget_set_size_request ((GtkWidget*) canvas, 600, 450);
- goo_canvas_set_bounds (canvas, 0, 0, 1000, 1000);
+ goo_canvas_set_bounds (canvas, 0, 0, 1000, 2000);
gtk_container_add (GTK_CONTAINER (scrolled_win), (GtkWidget*) canvas);
root = goo_canvas_group_model_new (NULL, NULL);
@@ -250,6 +308,14 @@
g_object_set (table, "width", 300.0, "height", 200.0, NULL);
#endif
+ create_width_for_height_table (root, 100, 1000, 200, -1, 0);
+#if 1
+ create_width_for_height_table (root, 100, 1200, 300, -1, 0);
+
+ create_width_for_height_table (root, 500, 1000, 200, -1, 30);
+ create_width_for_height_table (root, 500, 1200, 300, -1, 30);
+#endif
+
gtk_widget_show ((GtkWidget*) canvas);
return vbox;
Index: mv-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-demo.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mv-demo.c 24 Feb 2007 11:16:36 -0000 1.6
+++ mv-demo.c 8 Mar 2007 12:31:59 -0000 1.7
@@ -1052,6 +1052,16 @@
"fill_color", "goldenrod",
NULL);
#endif
+
+#if 1
+ textitem = goo_canvas_text_model_new (root,
+ "Ellipsized text.",
+ 20, 420, 115, GTK_ANCHOR_W,
+ "font", "Sans 12",
+ "fill_color", "blue",
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
+#endif
}
More information about the cairo-commit
mailing list