1 /* drawtimesig.cpp
2  *
3  * Function for drawing the time signature
4  *
5  * for Denemo, a gtk+ frontend to GNU Lilypond
6  * (c) 1999, 2000, 2001, 2002 Matthew Hiller
7  */
8 
9 #include "core/utils.h"              /* Includes <gdk.h> */
10 
11 /**
12  * Draw timesig on the score
13  *
14  */
15 void
draw_timesig(cairo_t * cr,gint xx,gint y,gint time1,gint time2,timesig * timesig)16 draw_timesig (cairo_t * cr, gint xx, gint y, gint time1, gint time2, timesig * timesig)
17 {
18   static GString *timesigtop;
19   static GString *timesigbottom;
20 
21   if (!timesigtop)
22     {
23       timesigtop = g_string_new (NULL);
24       timesigbottom = g_string_new (NULL);
25     }
26   g_string_sprintf (timesigtop, "%d", time1);
27   g_string_sprintf (timesigbottom, "%d", time2);
28 
29   gint override = 0;
30   if (timesig->directives)
31     {
32       gint count = 0;
33       GList *g = timesig->directives;
34       for (; g; g = g->next, count++)
35         {
36           DenemoDirective *directive = g->data;
37           override = override | directive->override;
38           if (directive->display)
39             {
40               drawnormaltext_cr (cr, directive->display->str, xx + directive->tx, y + count * 10);
41             }
42           if (directive->graphic)
43             {
44               drawbitmapinverse_cr (cr, directive->graphic, xx + directive->gx + count, y + directive->gy, FALSE);
45             }
46         }
47     }
48   if (!(DENEMO_OVERRIDE_GRAPHIC & override))
49     {
50       cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
51       cairo_set_font_size (cr, 24.0);
52 
53       cairo_move_to (cr, xx, y + 20);
54       cairo_show_text (cr, timesigtop->str);
55 
56       cairo_move_to (cr, xx, y + 40);
57       cairo_show_text (cr, timesigbottom->str);
58     }
59 }
60