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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
use crate::app::*;
use crate::image::Image;
pub use crate::prelude::*;
use crate::widget::*;
use fltk_sys::window::*;
use std::{
ffi::{CStr, CString},
mem,
os::raw,
};
#[derive(WidgetExt, GroupExt, WindowExt, Debug)]
pub struct Window {
_inner: *mut Fl_Window,
}
#[repr(i32)]
#[derive(WidgetType, Debug, Copy, Clone, PartialEq)]
pub enum WindowType {
NormalWindow = 240,
DoubleWindow = 241,
}
#[derive(WidgetExt, GroupExt, WindowExt, Debug)]
pub struct DoubleWindow {
_inner: *mut Fl_Double_Window,
}
#[derive(WidgetExt, GroupExt, WindowExt, Debug)]
pub struct MenuWindow {
_inner: *mut Fl_Menu_Window,
}
#[cfg(feature = "gl-window")]
#[derive(Debug)]
pub struct GlContext {
_inner: *mut raw::c_void,
}
#[cfg(feature = "gl-window")]
impl GlContext {
pub unsafe fn from_raw(ptr: *mut raw::c_void) -> GlContext {
GlContext { _inner: ptr, }
}
}
#[cfg(feature = "gl-window")]
#[derive(WidgetExt, GroupExt, WindowExt, Debug)]
pub struct GlWindow {
_inner: *mut Fl_Gl_Window,
}
#[cfg(feature = "gl-window")]
impl GlWindow {
pub fn flush(&mut self) {
unsafe { Fl_Gl_Window_flush(self._inner) }
}
pub fn valid(&self) -> bool {
unsafe {
match Fl_Gl_Window_valid(self._inner) {
0 => false,
_ => true,
}
}
}
pub fn set_valid(&mut self, v: bool) {
unsafe { Fl_Gl_Window_set_valid(self._inner, v as i8) }
}
pub fn context_valid(&self) -> bool {
unsafe {
match Fl_Gl_Window_context_valid(self._inner) {
0 => false,
_ => true,
}
}
}
pub fn set_context_valid(&mut self, v: bool) {
unsafe { Fl_Gl_Window_set_context_valid(self._inner, v as i8) }
}
pub fn context(&self) -> Option<GlContext> {
unsafe {
let x = Fl_Gl_Window_context(self._inner);
if x.is_null() {
None
} else {
Some(GlContext { _inner: x })
}
}
}
pub fn set_context(&mut self, ctx: GlContext, destroy_flag: bool) {
unsafe { Fl_Gl_Window_set_context(self._inner, ctx._inner, destroy_flag as i32) }
}
pub fn swap_buffers(&mut self) {
unsafe { Fl_Gl_Window_swap_buffers(self._inner) }
}
pub fn ortho(&mut self) {
unsafe { Fl_Gl_Window_ortho(self._inner) }
}
pub fn can_do_overlay(&mut self) -> bool {
unsafe {
match Fl_Gl_Window_can_do_overlay(self._inner) {
0 => false,
_ => true,
}
}
}
pub fn redraw_overlay(&mut self) {
unsafe { Fl_Gl_Window_redraw_overlay(self._inner) }
}
pub fn hide_overlay(&mut self) {
unsafe { Fl_Gl_Window_hide_overlay(self._inner) }
}
pub fn make_overlay_current(&mut self) {
unsafe { Fl_Gl_Window_make_overlay_current(self._inner) }
}
pub fn pixels_per_unit(&mut self) -> f32 {
unsafe { Fl_Gl_Window_pixels_per_unit(self._inner) }
}
pub fn pixel_w(&mut self) -> i32 {
unsafe { Fl_Gl_Window_pixel_w(self._inner) }
}
pub fn pixel_h(&mut self) -> i32 {
unsafe { Fl_Gl_Window_pixel_h(self._inner) }
}
}