summaryrefslogtreecommitdiffstats
path: root/src/sp-cursor.cpp
blob: b60d481b872c0086589e455fcdcd6980db7cc845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#define __SP_CURSOR_C__

/*
 * Use a pixmap to make a cursor.
 *
 * Authors:
 *   Lauris Kaplinski <lauris@kaplinski.com>
 *   James ----
 *
 * Copyright (C) 1999-2006 authors
 * Copyright (C) 2001-2002 Ximian, Inc.
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include <cstdio>
#include <string.h>
#include <ctype.h>
#include "sp-cursor.h"

GdkCursor *sp_cursor_new (GdkDisplay *display, GdkPixbuf *pixbuf, gchar **xpm, gint hot_x, gint hot_y)
{
    GdkCursor *new_cursor=NULL;

    if ((!pixbuf && xpm) || !gdk_display_supports_cursor_alpha(display)) 
        //if there is no pixbuf, but there is xpm data, or the display 
        //doesn't support alpha, use bitmap cursor.
    {
        pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)xpm);
    }
    if(pixbuf) {
        new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
    }
    return new_cursor;
}



GdkCursor *sp_cursor_new_from_xpm (gchar **xpm, gint hot_x, gint hot_y)
{
    GdkDisplay *display=gdk_display_get_default();
    GdkPixbuf *pixbuf=NULL;
    GdkCursor *new_cursor=NULL;
    pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)xpm);
    if (pixbuf != NULL){
        new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
        g_message("xpm cursor defined\n");
        return new_cursor;
    }
    g_warning("xpm cursor not defined\n");

    return NULL;
}



GdkCursor *sp_cursor_new_from_pixbuf (GdkPixbuf *pixbuf, gint hot_x, gint hot_y)
{
    GdkDisplay *display=gdk_display_get_default();
    GdkCursor *new_cursor=NULL;
    if (pixbuf) {
        new_cursor = gdk_cursor_new_from_pixbuf(display,pixbuf,hot_x,hot_y);
        g_message("pixbuf cursor defined\n");
        return new_cursor;
     }
    g_warning("pixbuf cursor not defined\n");
        return new_cursor;
    return NULL;
}

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :