1 #define __SP_CURSOR_C__
3 /*
4 * Use a pixmap to make a cursor.
5 *
6 * Authors:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * James ----
9 *
10 * Copyright (C) 1999-2006 authors
11 * Copyright (C) 2001-2002 Ximian, Inc.
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #include <cstdio>
17 #include <string.h>
18 #include <ctype.h>
19 #include "sp-cursor.h"
21 GdkCursor *sp_cursor_new (GdkDisplay *display, GdkPixbuf *pixbuf, gchar **xpm, gint hot_x, gint hot_y)
22 {
23 GdkCursor *new_cursor=NULL;
25 if ((!pixbuf && xpm) || !gdk_display_supports_cursor_alpha(display))
26 //if there is no pixbuf, but there is xpm data, or the display
27 //doesn't support alpha, use bitmap cursor.
28 {
29 pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)xpm);
30 }
31 if(pixbuf) {
32 new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
33 }
34 return new_cursor;
35 }
39 GdkCursor *sp_cursor_new_from_xpm (gchar **xpm, gint hot_x, gint hot_y)
40 {
41 GdkDisplay *display=gdk_display_get_default();
42 GdkPixbuf *pixbuf=NULL;
43 GdkCursor *new_cursor=NULL;
44 pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)xpm);
45 if (pixbuf != NULL){
46 new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
47 g_message("xpm cursor defined\n");
48 return new_cursor;
49 }
50 g_warning("xpm cursor not defined\n");
52 return NULL;
53 }
57 GdkCursor *sp_cursor_new_from_pixbuf (GdkPixbuf *pixbuf, gint hot_x, gint hot_y)
58 {
59 GdkDisplay *display=gdk_display_get_default();
60 GdkCursor *new_cursor=NULL;
61 if (pixbuf) {
62 new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
63 g_message("pixbuf cursor defined\n");
64 return new_cursor;
65 }
66 g_warning("pixbuf cursor not defined\n");
67 return new_cursor;
68 return NULL;
69 }
71 /*
72 Local Variables:
73 mode:c++
74 c-file-style:"stroustrup"
75 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76 indent-tabs-mode:nil
77 fill-column:99
78 End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :