3
* Time-stamp: <2001/12/02 22:19:10 bruno>
5
* Copyright (C) 2000 Bruno Coudoin
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
* This includes an API to count scores in gcompris
29
static GnomeCanvasGroup *boardRootItem = NULL;
31
static guint x, y, max;
32
static ScoreStyleList currentStyle;
35
* Forward declarations
37
static void display_number(GnomeCanvasGroup *parent,
50
* Do all the score display
52
void gcompris_score_start (ScoreStyleList style, guint gx, guint gy, guint gmax)
61
switch(currentStyle) {
62
case SCORESTYLE_NOTE :
70
void gcompris_score_end()
72
if(boardRootItem!=NULL)
73
gtk_object_destroy (GTK_OBJECT(boardRootItem));
78
void gcompris_score_set(guint value)
81
if(boardRootItem!=NULL)
82
gtk_object_destroy (GTK_OBJECT(boardRootItem));
84
boardRootItem = GNOME_CANVAS_GROUP(
85
gnome_canvas_item_new (
86
gnome_canvas_root(get_current_gcompris_board()->canvas),
87
gnome_canvas_group_get_type (),
92
switch(currentStyle) {
93
case SCORESTYLE_NOTE :
96
GdkPixbuf *button_pixmap = NULL;
98
button_pixmap = gcompris_load_pixmap("gcompris/buttons/button_large.png");
99
gnome_canvas_item_new (boardRootItem,
100
gnome_canvas_pixbuf_get_type (),
101
"pixbuf", button_pixmap,
103
"y", (double) -gdk_pixbuf_get_height(button_pixmap)/2,
105
gdk_pixbuf_unref(button_pixmap);
107
tmp = g_strdup_printf("%d:%d", value, max);
108
display_number(boardRootItem, gdk_pixbuf_get_width(button_pixmap)+20, 0, tmp);
117
/*-------------------------------------------------------------------------------*/
118
/*-------------------------------------------------------------------------------*/
119
/*-------------------------------------------------------------------------------*/
120
/*-------------------------------------------------------------------------------*/
123
#define NUMBERSWIDTH 35
125
#define ZOOMFACTOR 0.8
127
static void display_number(GnomeCanvasGroup *parent,
132
GdkPixbuf *algebra_pixmap = NULL;
133
GnomeCanvasItem *item;
136
x -= NUMBERSWIDTH/2 + 15;
138
for(i=strlen(operand_str)-1; i>=0; i--)
142
algebra_pixmap = gcompris_load_number_pixmap(operand_str[i]);
144
// Calculate a gap to center the text
145
gap = (5-strlen(operand_str))*(NUMBERSWIDTH+NUMBERGAP)/2;
147
item = gnome_canvas_item_new (parent,
148
gnome_canvas_pixbuf_get_type (),
149
"pixbuf", algebra_pixmap,
150
"x", (double)x-gap-((strlen(operand_str)-i)*(NUMBERSWIDTH+NUMBERGAP)),
151
"y", (double)y - gdk_pixbuf_get_height(algebra_pixmap)*ZOOMFACTOR/2,
152
"width", (double) NUMBERSWIDTH,
153
"height", (double) gdk_pixbuf_get_height(algebra_pixmap)*ZOOMFACTOR,
157
gdk_pixbuf_unref(algebra_pixmap);
163
/* Local Variables: */
165
/* eval:(load-library "time-stamp") */
166
/* eval:(make-local-variable 'write-file-hooks) */
167
/* eval:(add-hook 'write-file-hooks 'time-stamp) */
168
/* eval:(setq time-stamp-format '(time-stamp-yyyy/mm/dd time-stamp-hh:mm:ss user-login-name)) */