2 #include <gcontainer/gcontainer.h>
6 static void draw_shape (AdgPath
*path
);
7 static void drawing_expose (GtkWidget
*widget
,
13 main(gint argc
, gchar
** argv
)
20 gtk_init(&argc
, &argv
);
22 /* Create the canvas */
23 canvas
= adg_canvas_new();
25 /* Add the shape to quote */
26 entity
= adg_path_new(ADG_CALLBACK(draw_shape
), NULL
);
27 adg_container_add(ADG_CONTAINER(canvas
), entity
);
29 /* Add the north quotes */
30 entity
= adg_ldim_new_full_explicit(2., -10., 8., -10., CPML_DIR_UP
,
32 adg_container_add(ADG_CONTAINER(canvas
), entity
);
34 entity
= adg_ldim_new_full_explicit(0., -5., 10., -5., CPML_DIR_UP
,
36 adg_dim_set_level(ADG_DIM(entity
), 2);
37 adg_container_add(ADG_CONTAINER(canvas
), entity
);
39 /* User interface stuff */
40 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
41 g_signal_connect(window
, "delete-event", G_CALLBACK(gtk_main_quit
), NULL
);
43 widget
= gtk_drawing_area_new();
44 g_signal_connect(widget
, "expose-event", G_CALLBACK(drawing_expose
),
46 gtk_container_add(GTK_CONTAINER(window
), widget
);
48 gtk_widget_show_all(window
);
55 draw_shape(AdgPath
*path
)
57 adg_path_move_to(path
, 0., 0.);
58 adg_path_line_to(path
, 0., -5.);
59 adg_path_line_to(path
, 2., -5.);
60 adg_path_line_to(path
, 2., -10.);
61 adg_path_line_to(path
, 8., -10.);
62 adg_path_line_to(path
, 8., -5.);
63 adg_path_line_to(path
, 10., -5.);
64 adg_path_line_to(path
, 10., 0.);
69 drawing_expose(GtkWidget
*widget
, GdkEventExpose
*event
, AdgCanvas
*canvas
)
76 cr
= gdk_cairo_create(widget
->window
);
77 width
= widget
->allocation
.width
;
78 height
= widget
->allocation
.height
;
79 scale
= (double) (width
- 10.) / 10.;
81 cairo_matrix_init(&matrix
, scale
, 0., 0., scale
, 5.,
83 adg_container_set_model_transformation(ADG_CONTAINER(canvas
), &matrix
);
85 /* Rendering process */
86 adg_entity_render(ADG_ENTITY(canvas
), cr
);