Commit 8c73e64f authored by Bruno Coudoin's avatar Bruno Coudoin

- Changed tha way we manage cursors. Now use the

	  gdk_cursor_new_from_pixbuf() which allow us to use regular png
	  images.
	- removed unused bird icon
parent 14e87ea9
2006-11-27 Bruno coudoin <bruno.coudoin@free.fr>
- Changed tha way we manage cursors. Now use the
gdk_cursor_new_from_pixbuf() which allow us to use regular png
images.
- removed unused bird icon
* boards/skins/gartoon/cursor_circle.png:
* boards/skins/gartoon/cursor_default.png:
* boards/skins/gartoon/cursor_del.png:
* boards/skins/gartoon/cursor_fill.png:
* boards/skins/gartoon/cursor_fillcircle.png:
* boards/skins/gartoon/cursor_fillrect.png:
* boards/skins/gartoon/cursor_line.png:
* boards/skins/gartoon/cursor_rect.png:
* boards/skins/gartoon/cursor_select.png:
* docs/C/python.xml: removed unused BIRD icon
* src/boards/py-mod-gcompris.c: (python_gcompris_module_init):
* src/gcompris/Makefile.am:
* src/gcompris/Makefile.mingw:
* src/gcompris/cursor.c: removed
* src/gcompris/cursor.h: removed
* src/gcompris/gcompris.c: (gc_cursor_set):
* src/gcompris/gcompris.h:
2006-11-25 Bruno coudoin <bruno.coudoin@free.fr>
- Patch by Joshua N Pritikin for parachute activity.
......
......@@ -438,9 +438,6 @@ attribute is readeable and/or writable.</para>
<tbody>
<row><entry>gcompris.CURSOR_FIRST_CUSTOM</entry>
<entry>GCOMPRIS_FIRST_CUSTOM_CURSOR</entry></row>
<row><entry>gcompris.CURSOR_BIG_RED_ARROW</entry>
<entry>GCOMPRIS_BIG_RED_ARROW_CURSOR</entry></row>
<row><entry>gcompris.CURSOR_BIRD</entry><entry>GCOMPRIS_BIRD_CURSOR</entry></row>
<row><entry>gcompris.CURSOR_LINE</entry><entry>GCOMPRIS_LINE_CURSOR</entry></row>
<row><entry>gcompris.CURSOR_FILLRECT</entry><entry>GCOMPRIS_FILLRECT_CURSOR</entry></row>
<row><entry>gcompris.CURSOR_RECT</entry><entry>GCOMPRIS_RECT_CURSOR</entry></row>
......
......@@ -1660,7 +1660,6 @@ void python_gcompris_module_init(void)
/* Cursors constants */
PyModule_AddIntConstant(gcomprisModule, "CURSOR_FIRST_CUSTOM", GCOMPRIS_FIRST_CUSTOM_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_BIG_RED_ARROW", GCOMPRIS_BIG_RED_ARROW_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_BIRD", GCOMPRIS_BIRD_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_LINE", GCOMPRIS_LINE_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_FILLRECT", GCOMPRIS_FILLRECT_CURSOR);
PyModule_AddIntConstant(gcomprisModule, "CURSOR_RECT", GCOMPRIS_RECT_CURSOR);
......
......@@ -93,7 +93,6 @@ libgcomprisinclude_HEADERS = \
binreloc.h \
bonus.h \
gc_core.h \
cursor.h \
gameutil.h \
gc_net.h \
gcompris.h \
......@@ -125,7 +124,6 @@ libgcompris_1_la_SOURCES = \
board_config.h board_config.c \
bonus.c \
config.c \
cursor.c \
dialog.c \
file_selector.c \
gameutil.c \
......
......@@ -95,7 +95,6 @@ EXE_C_SRC = \
bonus.c \
cache.c \
config.c \
cursor.c \
dialog.c \
file_selector.c \
gameutil.c \
......
/* gcompris - cursor.c
*
* Copyright (C) 2002 Pascal Georges
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gcompris.h"
/* =====================================================================
* This function is taken from stickers game
* by Paul Kienzle and Tanya Riseman <stickers@kienzle.powernet.co.uk>
* =====================================================================*/
/* A routine that ought to be in the gdk library: build a cursor from
* a text layout with '1' for foreground, '0' for background and ' '
* for transparent.
*/
/* If I got a function to generate mask, I could have used in gdk.h :
GdkCursor* gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
GdkColor *fg,
GdkColor *bg,
gint x,
gint y);*/
GdkCursor *gdk_cursor_new_from_data(const gchar *bits[],
gint width, gint height,
GdkColor *fg, GdkColor *bg,
gint hot_x, gint hot_y)
{
GdkBitmap *bitmap, *mask;
GdkCursor *cursor;
guchar *data, *ptr;
gint i, j;
/* Though it does not say so on the X11 manual pages, the bitmap
* format consists of scan lines padded to byte boundaries with the
* bits in "reverse" order within each byte (lo bits come before hi
* bits in the bitmap). I assume this representation is platform
* independent. Let me know if it doesn't work for you. */
/* Create space for the bitmap, padding the scanlines to byte boundaries. */
data = g_new(guchar, ((width+7)/8)*height);
/* Build bitmap */
ptr = data;
for (i=0; i < height; i++) {
for (j=0; j < width; j++) {
*ptr = (*ptr >> 1)|(bits[i][j]=='1'?0x80:0);
if (j%8 == 7) ptr++;
}
if (j%8) *ptr++ >>= 8-j%8;
}
bitmap = gdk_bitmap_create_from_data(NULL, (gchar *)data, width, height);
/* Build mask */
ptr = data;
for (i=0; i < height; i++) {
for (j=0; j < width; j++) {
*ptr = (*ptr >> 1)|(bits[i][j]==' '?0:0x80);
if (j%8 == 7) ptr++;
}
if (j%8) *ptr++ >>= 8-j%8;
}
mask = gdk_bitmap_create_from_data(NULL, (gchar *)data, width, height);
/* Build cursor from bitmap and mask */
cursor = gdk_cursor_new_from_pixmap(bitmap, mask, /* Image and mask */
fg, bg, /* colors */
hot_x, hot_y); /* Hot point */
/* No longer need bitmap or mask */
gdk_pixmap_unref(bitmap);
gdk_pixmap_unref(mask);
g_free(data);
return cursor;
}
/* gcompris - cursor.h
*
* Copyright (C) 2002 Pascal Georges
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CURSOR_H
#define CURSOR_H
#include <gtk/gtk.h>
#include <stdio.h>
GdkCursor *gdk_cursor_new_from_data(const gchar *bits[],
gint width, gint height,
GdkColor *fg, GdkColor *bg,
gint hot_x, gint hot_y);
/* Bitmap data of cursor */
static const gchar *big_red_arrow_cursor_bits[] = {
"111111 ",
"1000011111 ",
"1000000001111 ",
"1000000000001111 ",
"10000000000000011111 ",
"1000000000000000000111 ",
"10000000000000000000011111 ",
"10000000000000000000000001111 ",
"1000000000000000000000000000111 ",
"10000000000000000000000000000011 ",
"100000000000000000000000000000011 ",
"100000000000000000000000000000001 ",
"100000000000000000000000000000001 ",
"100000000000000000000000000000001 ",
"100000000000000000000000000000111 ",
"1000000000000000000000000011111 ",
"100000000000000000000000111 ",
"1000000000000000000001111 ",
"1000000000000000000001 ",
"1000000000000000000001 ",
"1000000000000000000001 ",
"10000000000000000000011 ",
"100000000000000000000011 ",
"1000000000000000000000011 ",
"10000000000000000000000011 ",
"1000000000000111110000000111 ",
"10000000001111 110000000011 ",
" 1000000011 100000000011 ",
" 110000111 1110000000011 ",
" 111111 100000000011 ",
" 1000000000011 ",
" 1100000000001 ",
" 100000000001 ",
" 10000000001 ",
" 11000000001 ",
" 1000000001 ",
" 1100000011 ",
" 11000011 ",
" 110011 ",
" 11 "};
static const gchar *bird_cursor_bits[] = {
" 111 ",
" 11000001 ",
" 1110001000001 ",
"110000000000001 ",
" 11100000000001 ",
" 0000000000011 ",
" 100000000011111 ",
" 000000010000111 ",
" 0000000000000111 ",
" 00000010000000011 ",
" 100000000000000011 ",
" 0000000000000000011 ",
" 10000000100000000011 ",
" 0000000000000000011 ",
" 10000001000000000011 ",
" 0000000000000000001 ",
" 10000000000000000011 ",
" 00000000000000000011 ",
" 0000000000000000011 ",
" 000000000000000011 ",
" 1000000000000000011 ",
" 10000000000000011 ",
" 1000000000000001 ",
" 100000000000011 ",
" 11000000111111 ",
" 100000000011 ",
" 11000000001 ",
" 10000001 ",
" 10001 ",
" 00001 ",
" 100001 ",
" 00000 ",
" 100001 ",
" 1000001 ",
" 1000001 ",
" 0000001",
" 0000000",
" 1000001",
" 10000 ",
" 01 "};
/* Bitmap data of a line */
static const gchar *big_red_line_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 11111 ",
"1111 111111 ",
"111 1100011 ",
"111 11000011 ",
"11 110000011 ",
"1 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011 ",
" 110000011",
" 11000011",
" 1100011",
" 111111",
" 11111"};
// Bitmap data of a rectangle
static const gchar *big_red_rectangle_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 11111111111111111111111",
"1111 11111111111111111111111",
"111 11000000000000000000011",
"111 110 011",
"11 110 011",
"1 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 11000000000000000000011",
" 11111111111111111111111",
" 11111111111111111111111"};
// Bitmap data of a rectangle
static const gchar *big_red_filledrectangle_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 11111111111111111111111",
"1111 11111111111111111111111",
"111 11000000000000000000011",
"111 11000000000000000000011",
"11 11000000000000000000011",
"1 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 11111111111111111111111",
" 11111111111111111111111"};
static const gchar *big_red_circle_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 11111 ",
"1111 111111111 ",
"111 11 11 ",
"111 11 11 ",
"11 11 11 ",
"1 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11",
" 11 11",
" 11 11",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 11 11 ",
" 111111111 ",
" 11111 "};
static const gchar *big_red_filledcircle_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 11111 ",
"1111 111111111 ",
"111 1100000000011 ",
"111 110000000000011 ",
"11 11000000000000011 ",
"1 1100000000000000011 ",
" 1100000000000000011 ",
" 110000000000000000011 ",
" 110000000000000000011 ",
" 11000000000000000000011",
" 11000000000000000000011",
" 11000000000000000000011",
" 110000000000000000011 ",
" 110000000000000000011 ",
" 1100000000000000011 ",
" 1100000000000000011 ",
" 11000000000000011 ",
" 11000000000000011 ",
" 110000000000011 ",
" 1100000000011 ",
" 111111111 ",
" 11111 "};
static const gchar *big_red_fill_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 11111111 ",
"1100011 1100011 11111111 ",
"110011 110011 11000011 ",
"110011 11111 11000011 ",
"11011 11000001 ",
"11011 11000001 ",
"1111 11111111111111111111111",
"1111 11111111111111111111111",
"11 11000000000000000000011",
"1 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110000 011",
" 110 000 011",
" 110 0000 011",
" 110 0 011",
" 110000 0 011",
" 110 000 0 011",
" 110 0000 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 110 011",
" 11000000000000000000011",
" 11111111111111111111111",
" 11111111111111111111111"};
static const gchar *big_red_del_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 ",
"1111 ",
"1111 111 111 ",
"11 1001 1001 ",
"1 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 100010001 ",
" 100000001 ",
" 100010001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 10001 10001 ",
" 1001 1001 ",
" 111 111 "};
static const gchar *big_red_select_cursor_bits[] = {
"1111111111111111111111111 ",
"111111111111111111111111 ",
"1100000000000000000111 ",
"11000000000000000111 ",
"110000000000000111 ",
"1100000000000111 ",
"11000000000111 ",
"110000000011 ",
"1100000000011 ",
"11000000000011 ",
"110000110000011 ",
"1100001110000011 ",
"1100011 11000011 ",
"1100011 1100011 ",
"110011 110011 ",
"110011 11111 ",
"11011 ",
"11011 111 ",
"1111 10001 ",
"1111 1000001 ",
"11 100000001 ",
"1 11110001111 ",
" 10001 ",
" 1 10001 1 ",
" 11 10001 11 ",
" 101 10001 101 ",
" 100111111000111111001 ",
" 10000000000000000000001 ",
" 10000000000000000000001 ",
" 10000000000000000000001 ",
" 100111111000111111001 ",
" 101 10001 101 ",
" 11 10001 11 ",
" 1 10001 1 ",
" 10001 ",
" 11110001111 ",
" 100000001 ",
" 1000001 ",
" 10001 ",
" 111 "};
#endif
......@@ -32,8 +32,6 @@
#include "about.h"
#include <locale.h>
#include "cursor.h"
#include "binreloc.h"
/* For XF86_VIDMODE Support */
......@@ -533,7 +531,7 @@ static void init_background()
void gc_cursor_set(guint gdk_cursor_type)
{
GdkCursor *cursor;
GdkCursor *cursor = NULL;
// Little hack to force gcompris to use the default cursor
if(gdk_cursor_type==GCOMPRIS_DEFAULT_CURSOR)
......@@ -545,55 +543,47 @@ void gc_cursor_set(guint gdk_cursor_type)
gdk_window_set_cursor (window->window, cursor);
gdk_cursor_destroy(cursor);
} else { // we use a custom cursor
GdkColor fg, bg;
// static const gchar * cursor;
static const gchar ** bits;
gdk_color_parse("rgb:FFFF/FFFF/FFFF",&fg);
gdk_color_parse("rgb:FFFF/3FFF/0000",&bg);
gdk_color_parse("black",&fg);
gdk_color_parse("red",&bg);
GdkPixbuf *cursor_pixbuf = NULL;
switch (gdk_cursor_type) {
case GCOMPRIS_BIG_RED_ARROW_CURSOR :
bits = big_red_arrow_cursor_bits;
break;
case GCOMPRIS_BIRD_CURSOR :
bits = bird_cursor_bits;
case GCOMPRIS_DEFAULT_CURSOR :
cursor_pixbuf = gc_skin_pixmap_load("cursor_default.png");
break;
case GCOMPRIS_LINE_CURSOR :
bits = big_red_line_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_line.png");
break;
case GCOMPRIS_RECT_CURSOR :
bits = big_red_rectangle_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_rect.png");
break;
case GCOMPRIS_FILLRECT_CURSOR :
bits = big_red_filledrectangle_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_fillrect.png");
break;
case GCOMPRIS_CIRCLE_CURSOR :
bits = big_red_circle_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_circle.png");
break;
case GCOMPRIS_FILLCIRCLE_CURSOR :
bits = big_red_filledcircle_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_fillcircle.png");
break;
case GCOMPRIS_FILL_CURSOR :
bits = big_red_fill_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_fill.png");
break;
case GCOMPRIS_DEL_CURSOR :
bits = big_red_del_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_del.png");
break;
case GCOMPRIS_SELECT_CURSOR :
bits = big_red_select_cursor_bits;
cursor_pixbuf = gc_skin_pixmap_load("cursor_select.png");
break;
default :
return;
break;
default : bits = big_red_arrow_cursor_bits;
}
cursor = gdk_cursor_new_from_data(bits, 40 , 40, &fg, &bg, 0, 0);
if(cursor)
if(cursor_pixbuf)
{
cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), cursor_pixbuf, 0, 0);
gdk_window_set_cursor(window->window, cursor);
gdk_cursor_unref(cursor);
gdk_pixbuf_unref(cursor_pixbuf);
}
}
}
......
......@@ -126,13 +126,13 @@ gchar *gc_locale_get_name(gchar *locale);
void gc_cursor_set(guint gdk_cursor_type);
typedef void (*ImageSelectorCallBack) (gchar* image);
void gc_selector_images_start (GcomprisBoard *gcomprisBoard,
gchar *dataset,
void gc_selector_images_start (GcomprisBoard *gcomprisBoard,
gchar *dataset,
ImageSelectorCallBack imscb);
void gc_selector_images_stop (void);
typedef void (*FileSelectorCallBack) (gchar *file, gchar *file_type); /* file_type is one string from file_types in the save */
void gc_selector_file_load (GcomprisBoard *gcomprisBoard,
void gc_selector_file_load (GcomprisBoard *gcomprisBoard,
gchar *rootdir,
gchar *file_types, /* A Comma separated text explaining the different file types */
FileSelectorCallBack fscb);
......@@ -152,7 +152,7 @@ void gc_dialog_close();
/* Confirm box */
typedef void (*ConfirmCallBack) (gboolean answer);
void gc_confirm_box (gchar *title,