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
81
82
83
84
85
86
87
88
89
90
91
use CursorType;
use Display;
use cairo;
use ffi;
use gdk_pixbuf;
use glib::translate::*;
use std::fmt;
use std::mem;
glib_wrapper! {
pub struct Cursor(Object<ffi::GdkCursor, CursorClass>);
match fn {
get_type => || ffi::gdk_cursor_get_type(),
}
}
impl Cursor {
#[cfg_attr(feature = "v3_16", deprecated)]
pub fn new(cursor_type: CursorType) -> Cursor {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gdk_cursor_new(cursor_type.to_glib()))
}
}
pub fn new_for_display(display: &Display, cursor_type: CursorType) -> Cursor {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gdk_cursor_new_for_display(display.to_glib_none().0, cursor_type.to_glib()))
}
}
pub fn new_from_name(display: &Display, name: &str) -> Option<Cursor> {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gdk_cursor_new_from_name(display.to_glib_none().0, name.to_glib_none().0))
}
}
pub fn new_from_pixbuf(display: &Display, pixbuf: &gdk_pixbuf::Pixbuf, x: i32, y: i32) -> Cursor {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gdk_cursor_new_from_pixbuf(display.to_glib_none().0, pixbuf.to_glib_none().0, x, y))
}
}
pub fn new_from_surface(display: &Display, surface: &cairo::Surface, x: f64, y: f64) -> Cursor {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gdk_cursor_new_from_surface(display.to_glib_none().0, mut_override(surface.to_glib_none().0), x, y))
}
}
pub fn get_cursor_type(&self) -> CursorType {
unsafe {
from_glib(ffi::gdk_cursor_get_cursor_type(self.to_glib_none().0))
}
}
pub fn get_display(&self) -> Display {
unsafe {
from_glib_none(ffi::gdk_cursor_get_display(self.to_glib_none().0))
}
}
pub fn get_image(&self) -> Option<gdk_pixbuf::Pixbuf> {
unsafe {
from_glib_full(ffi::gdk_cursor_get_image(self.to_glib_none().0))
}
}
pub fn get_surface(&self) -> (Option<cairo::Surface>, f64, f64) {
unsafe {
let mut x_hot = mem::uninitialized();
let mut y_hot = mem::uninitialized();
let ret = from_glib_full(ffi::gdk_cursor_get_surface(self.to_glib_none().0, &mut x_hot, &mut y_hot));
(ret, x_hot, y_hot)
}
}
}
impl fmt::Display for Cursor {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Cursor")
}
}