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
use crate::image::Image;
pub use crate::prelude::*;
use fltk_sys::browser::*;
use std::{
ffi::{CStr, CString},
mem,
os::raw,
};
#[derive(WidgetExt, BrowserExt, Debug)]
pub struct Browser {
_inner: *mut Fl_Browser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[repr(i32)]
#[derive(WidgetType, Debug, Copy, Clone, PartialEq)]
pub enum BrowserType {
Normal = 0,
Select = 1,
Hold = 2,
Multi = 3,
}
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum BrowserScrollbar {
None = 0,
Horizontal = 1,
Vertical = 2,
Both = 3,
AlwaysOn = 4,
HorizontalAlways = 5,
VerticalAlways = 6,
BothAlways = 7,
}
#[derive(WidgetExt, BrowserExt, Debug)]
pub struct SelectBrowser {
_inner: *mut Fl_Select_Browser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, BrowserExt, Debug)]
pub struct MultiBrowser {
_inner: *mut Fl_Multi_Browser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, BrowserExt, Debug)]
pub struct HoldBrowser {
_inner: *mut Fl_Hold_Browser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[derive(WidgetExt, BrowserExt, Debug)]
pub struct FileBrowser {
_inner: *mut Fl_File_Browser,
_tracker: *mut fltk_sys::fl::Fl_Widget_Tracker,
}
#[repr(i32)]
#[derive(Copy, Clone, Debug)]
pub enum FileType {
Files = 0,
Dirs,
}
impl FileBrowser {
pub fn iconsize(&self) -> u32 {
assert!(!self.was_deleted());
unsafe { Fl_File_Browser_iconsize(self._inner) }
}
pub fn set_iconsize(&mut self, s: u32) {
assert!(!self.was_deleted());
unsafe { Fl_File_Browser_set_iconsize(self._inner, s) }
}
pub fn set_filter(&mut self, pattern: &str) {
assert!(!self.was_deleted());
let pattern = CString::new(pattern).unwrap();
unsafe {
Fl_File_Browser_set_filter(self._inner, pattern.into_raw())
}
}
pub fn filter(&self) -> Option<String> {
assert!(!self.was_deleted());
unsafe {
let ptr = Fl_File_Browser_filter(self._inner);
if ptr.is_null() {
None
} else {
Some(CStr::from_ptr(ptr as *mut raw::c_char)
.to_string_lossy()
.to_string())
}
}
}
pub fn filetype(&self) -> FileType {
assert!(!self.was_deleted());
unsafe { mem::transmute(Fl_File_Browser_filetype(self._inner)) }
}
pub fn set_filetype(&mut self, t: FileType) {
assert!(!self.was_deleted());
unsafe { Fl_File_Browser_set_filetype(self._inner, t as i32) }
}
}