#include <gtk/gtk.h>
+#include "score.h"
+
#define unused(foo) foo __attribute__((unused))
static int
static int
on_expose_event_draw (GtkWidget *widget,
unused (GdkEventExpose *event),
- unused (gpointer user_data))
+ void * user_data)
{
+ score_t *score = user_data;
cairo_t *cr;
GtkAllocation allocation;
+ static const int pad = 10;
+ int widget_width, staff_width;
gtk_widget_get_allocation (widget, &allocation);
+ widget_width = allocation.width;
cr = gdk_cairo_create (widget->window);
- /* Paint in medium sea green */
- cairo_set_source_rgb (cr, 60/255.0, 179/255.0, 113/255.0);
-
+ /* White background */
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_paint (cr);
+
+ /* Add some padding on the left/right */
+ cairo_translate (cr, pad, pad);
+
+ score_set_width (score, widget_width - 2 * pad);
+
+ score_draw (score, cr);
return TRUE;
}
{
GtkWidget *window;
GtkWidget *drawing_area;
+ score_t score;
gtk_init (&argc, &argv);
+ score_init (&score);
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
g_signal_connect (drawing_area, "expose-event",
- G_CALLBACK (on_expose_event_draw), NULL);
-
+ G_CALLBACK (on_expose_event_draw),
+ &score);
gtk_widget_show_all (window);