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
165
166
167
168
169
170
171
172
173
174
use crate::image::Image;
pub use crate::prelude::*;
use crate::widget::*;
use fltk_sys::group::*;
use std::{
ffi::{CStr, CString},
mem,
os::raw,
};
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Group {
_inner: *mut Fl_Group,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Pack {
_inner: *mut Fl_Pack,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[repr(i32)]
#[derive(WidgetType, Debug, Copy, Clone, PartialEq)]
pub enum PackType {
Vertical = 0,
Horizontal = 1,
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Scroll {
_inner: *mut Fl_Scroll,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
impl Scroll {
pub fn xposition(&self) -> u32 {
assert!(!self.was_deleted());
unsafe { Fl_Scroll_xposition(self._inner) as u32 }
}
pub fn yposition(&self) -> u32 {
assert!(!self.was_deleted());
unsafe { Fl_Scroll_yposition(self._inner) as u32 }
}
pub fn scroll_to(&mut self, from: u32, to: u32) {
debug_assert!(
from <= std::i32::MAX as u32,
"u32 entries have to be < std::i32::MAX for compatibility!"
);
debug_assert!(
to <= std::i32::MAX as u32,
"u32 entries have to be < std::i32::MAX for compatibility!"
);
assert!(!self.was_deleted());
unsafe { Fl_Scroll_scroll_to(self._inner, from as i32, to as i32) }
}
pub fn scrollbar_size(&self) -> u32 {
assert!(!self.was_deleted());
unsafe { Fl_Scroll_scrollbar_size(self._inner) as u32 }
}
pub fn set_scrollbar_size(&mut self, new_size: u32) {
debug_assert!(
new_size <= std::i32::MAX as u32,
"u32 entries have to be < std::i32::MAX for compatibility!"
);
assert!(!self.was_deleted());
unsafe { Fl_Scroll_set_scrollbar_size(self._inner, new_size as i32) }
}
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Tabs {
_inner: *mut Fl_Tabs,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Tile {
_inner: *mut Fl_Tile,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct Wizard {
_inner: *mut Fl_Wizard,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
impl Wizard {
pub fn next(&mut self) {
assert!(!self.was_deleted());
unsafe { Fl_Wizard_next(self._inner) }
}
pub fn prev(&mut self) {
assert!(!self.was_deleted());
unsafe { Fl_Wizard_prev(self._inner) }
}
pub fn current_widget(&mut self) -> Widget {
unsafe {
assert!(!self.was_deleted());
Widget::from_raw(Fl_Wizard_value(self._inner) as *mut fltk_sys::widget::Fl_Widget)
}
}
pub fn set_current_widget<W: WidgetExt>(&mut self, w: &W) {
unsafe {
assert!(!self.was_deleted());
Fl_Wizard_set_value(
self._inner,
w.as_widget_ptr() as *mut fltk_sys::group::Fl_Widget,
)
}
}
}
#[derive(WidgetExt, GroupExt, Debug)]
pub struct ColorChooser {
_inner: *mut Fl_Color_Chooser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
impl ColorChooser {
pub fn rgb_color(&self) -> (u8, u8, u8) {
unsafe {
assert!(!self.was_deleted());
let r = (Fl_Color_Chooser_r(self._inner) * 255.0) as u8;
let g = (Fl_Color_Chooser_g(self._inner) * 255.0) as u8;
let b = (Fl_Color_Chooser_b(self._inner) * 255.0) as u8;
(r, g, b)
}
}
pub fn hex_color(&self) -> u32 {
let c = self.rgb_color();
let x = Color::from_rgb(c.0, c.1, c.2);
x.to_u32()
}
}
impl Pack {
pub fn spacing(&self) -> i32 {
assert!(!self.was_deleted());
unsafe { Fl_Pack_spacing(self._inner) }
}
pub fn set_spacing(&mut self, spacing: i32) {
unsafe {
assert!(!self.was_deleted());
Fl_Pack_set_spacing(self._inner, spacing);
}
}
}