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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#![feature(unsafe_destructor)]
extern crate libc;
pub use events::{Event, Element, PositionChanged, SizeChanged, Closed, CursorPositionChanged, Focused};
pub use events::{Iconified, NeedRefresh, Pressed, Released};
pub use hints::{Hints, ClientAPI, Profile};
#[cfg(windows)]
use winimpl = win32;
#[cfg(unix)]
use winimpl = x11;
#[cfg(windows)]
mod win32;
#[cfg(unix)]
mod x11;
mod events;
mod hints;
pub struct MonitorID(uint);
pub struct Window {
window: winimpl::Window,
nosend: std::kinds::marker::NoSend,
}
impl Window {
#[inline]
pub fn new(dimensions: Option<(uint, uint)>, title: &str,
hints: &Hints, monitor: Option<MonitorID>)
-> Result<Window, String>
{
let win = try!(winimpl::Window::new(dimensions, title, hints, monitor));
Ok(Window{
window: win,
nosend: std::kinds::marker::NoSend,
})
}
/// Returns true if the window has been closed by the user.
#[inline]
pub fn should_close(&self) -> bool {
self.window.should_close()
}
/// Modifies the title of the window.
#[inline]
pub fn set_title(&self, title: &str) {
self.window.set_title(title)
}
#[inline]
pub fn get_position(&self) -> (int, int) {
self.window.get_position()
}
#[inline]
pub fn set_position(&self, x: uint, y: uint) {
self.window.set_position(x, y)
}
#[inline]
pub fn get_inner_size(&self) -> (uint, uint) {
self.window.get_inner_size()
}
#[inline]
pub fn get_outer_size(&self) -> (uint, uint) {
self.window.get_outer_size()
}
#[inline]
pub fn set_inner_size(&self, x: uint, y: uint) {
self.window.set_inner_size(x, y)
}
// TODO: return iterator
#[inline]
pub fn poll_events(&self) -> Vec<Event> {
self.window.poll_events()
}
// TODO: return iterator
#[inline]
pub fn wait_events(&self) -> Vec<Event> {
self.window.wait_events()
}
#[inline]
pub fn make_current(&self) {
self.window.make_current()
}
#[inline]
pub fn get_proc_address(&self, addr: &str) -> *const () {
self.window.get_proc_address(addr)
}
#[inline]
pub fn swap_buffers(&self) {
self.window.swap_buffers()
}
}
|