fltk/
misc.rs

1use crate::enums::{Color, Font, FrameType};
2use crate::prelude::*;
3use crate::utils::FlString;
4use crate::widget::Widget;
5use crate::window::Window;
6use fltk_sys::misc::*;
7use std::{
8    ffi::{CStr, CString},
9    mem,
10    os::raw,
11};
12
13/// Defines the chart types supported by fltk
14#[repr(i32)]
15#[derive(Debug, Copy, Clone, PartialEq, Eq)]
16pub enum ChartType {
17    /// Bar chart
18    Bar = 0,
19    /// Horizontal bar chart
20    HorizontalBar = 1,
21    /// Line chart
22    Line = 2,
23    /// Fill chart
24    Fill = 3,
25    /// Spike chart
26    Spike = 4,
27    /// Pie chart
28    Pie = 5,
29    /// Special pie chart
30    SpecialPie = 6,
31}
32
33crate::macros::widget::impl_widget_type!(ChartType);
34
35/// Defines the clock types supported by fltk
36#[repr(i32)]
37#[derive(Debug, Copy, Clone, PartialEq, Eq)]
38pub enum ClockType {
39    /// Square clock
40    Square = 0,
41    /// Round clock
42    Round = 1,
43}
44
45crate::macros::widget::impl_widget_type!(ClockType);
46
47/// Creates a spinner widget
48#[derive(Debug)]
49pub struct Spinner {
50    inner: crate::widget::WidgetTracker,
51    is_derived: bool,
52}
53
54crate::macros::widget::impl_widget_ext!(Spinner, Fl_Spinner);
55crate::macros::widget::impl_widget_base!(Spinner, Fl_Spinner);
56crate::macros::widget::impl_widget_default!(Spinner, Fl_Spinner);
57
58impl Spinner {
59    /// Returns the minimum value of the spinner widget
60    pub fn minimum(&self) -> f64 {
61        unsafe { Fl_Spinner_minimum(self.inner.widget() as _) }
62    }
63
64    /// Sets the minimum value of the spinner widget
65    pub fn set_minimum(&mut self, a: f64) {
66        unsafe { Fl_Spinner_set_minimum(self.inner.widget() as _, a) }
67    }
68
69    /// Returns the maximum value of the spinner widget
70    pub fn maximum(&self) -> f64 {
71        unsafe { Fl_Spinner_maximum(self.inner.widget() as _) }
72    }
73
74    /// Sets the minimum value of the spinner widget
75    pub fn set_maximum(&mut self, a: f64) {
76        unsafe { Fl_Spinner_set_maximum(self.inner.widget() as _, a) }
77    }
78
79    /// Sets the range of the spinner widget
80    pub fn set_range(&mut self, a: f64, b: f64) {
81        unsafe { Fl_Spinner_set_range(self.inner.widget() as _, a, b) }
82    }
83
84    /// Sets the step of the spinner widget
85    pub fn set_step(&mut self, a: f64) {
86        unsafe { Fl_Spinner_set_step(self.inner.widget() as _, a) }
87    }
88
89    /// Gets the range of the spinner widget
90    pub fn step(&self) -> f64 {
91        unsafe { Fl_Spinner_step(self.inner.widget() as _) }
92    }
93
94    /// Returns the maximum size supported by the spinner widget
95    pub fn maximum_size(&self) -> i32 {
96        unsafe { Fl_Spinner_maxsize(self.inner.widget() as _) }
97    }
98
99    /// Sets the maximum size supported by the spinner widget
100    pub fn set_maximum_size(&mut self, s: i32) {
101        unsafe { Fl_Spinner_set_maxsize(self.inner.widget() as _, s) }
102    }
103
104    /// Gets the text font
105    pub fn text_font(&self) -> Font {
106        unsafe { std::mem::transmute(Fl_Spinner_text_font(self.inner.widget() as _)) }
107    }
108
109    /// Sets the text font
110    pub fn set_text_font(&mut self, f: Font) {
111        unsafe { Fl_Spinner_set_text_font(self.inner.widget() as _, f.bits()) }
112    }
113
114    /// Gets the text size
115    pub fn text_size(&self) -> i32 {
116        unsafe { Fl_Spinner_text_size(self.inner.widget() as _) }
117    }
118
119    /// Sets the text size
120    pub fn set_text_size(&mut self, s: i32) {
121        unsafe { Fl_Spinner_set_text_size(self.inner.widget() as _, s) }
122    }
123
124    /// Gets the text's color
125    pub fn text_color(&self) -> Color {
126        unsafe { std::mem::transmute(Fl_Spinner_text_color(self.inner.widget() as _)) }
127    }
128
129    /// Sets the text's color
130    pub fn set_text_color(&mut self, color: Color) {
131        unsafe { Fl_Spinner_set_text_color(self.inner.widget() as _, color.bits()) }
132    }
133
134    /// Returns the value of the spinner
135    pub fn value(&self) -> f64 {
136        unsafe { Fl_Spinner_value(self.inner.widget() as _) }
137    }
138
139    /// Sets the value of the spinner
140    pub fn set_value(&mut self, arg2: f64) {
141        unsafe {
142            Fl_Spinner_set_value(self.inner.widget() as _, arg2);
143        }
144    }
145
146    /// Returns whether wrap is set
147    pub fn wrap(&self) -> bool {
148        unsafe { Fl_Spinner_wrap(self.inner.widget() as _) != 0 }
149    }
150
151    /// Sets wrap for the spinner
152    pub fn set_wrap(&mut self, flag: bool) {
153        unsafe {
154            Fl_Spinner_set_wrap(self.inner.widget() as _, flag.into());
155        }
156    }
157}
158
159/// Creates a clock widget
160#[derive(Debug)]
161pub struct Clock {
162    inner: crate::widget::WidgetTracker,
163    is_derived: bool,
164}
165
166crate::macros::widget::impl_widget_ext!(Clock, Fl_Clock);
167crate::macros::widget::impl_widget_base!(Clock, Fl_Clock);
168crate::macros::widget::impl_widget_default!(Clock, Fl_Clock);
169
170/// Creates a chart widget
171#[derive(Debug)]
172pub struct Chart {
173    inner: crate::widget::WidgetTracker,
174    is_derived: bool,
175}
176
177crate::macros::widget::impl_widget_ext!(Chart, Fl_Chart);
178crate::macros::widget::impl_widget_base!(Chart, Fl_Chart);
179crate::macros::widget::impl_widget_default!(Chart, Fl_Chart);
180
181impl Chart {
182    /// Clears the chart
183    pub fn clear(&mut self) {
184        unsafe { Fl_Chart_clear(self.inner.widget() as _) }
185    }
186
187    /// Adds an entry
188    pub fn add(&mut self, val: f64, txt: &str, col: Color) {
189        let txt = CString::safe_new(txt);
190        unsafe { Fl_Chart_add(self.inner.widget() as _, val, txt.as_ptr(), col.bits()) }
191    }
192
193    /// Inserts an entry at an index
194    pub fn insert(&mut self, idx: i32, val: f64, txt: &str, col: Color) {
195        let txt = CString::safe_new(txt);
196        unsafe { Fl_Chart_insert(self.inner.widget() as _, idx, val, txt.as_ptr(), col.bits()) }
197    }
198
199    /// Replaces an entry at an index
200    pub fn replace(&mut self, idx: i32, val: f64, txt: &str, col: Color) {
201        let txt = CString::safe_new(txt);
202        unsafe { Fl_Chart_replace(self.inner.widget() as _, idx, val, txt.as_ptr(), col.bits()) }
203    }
204
205    /// Sets the bounds of the chart
206    pub fn set_bounds(&mut self, a: f64, b: f64) {
207        unsafe { Fl_Chart_set_bounds(self.inner.widget() as _, a, b) }
208    }
209
210    /// Returns the size of the chart
211    pub fn size(&self) -> i32 {
212        unsafe { Fl_Chart_size(self.inner.widget() as _) }
213    }
214
215    /// Gets the maximum supported size of the chart
216    pub fn maximum_size(&self) -> i32 {
217        unsafe { Fl_Chart_maxsize(self.inner.widget() as _) }
218    }
219
220    /// Sets the maximum supported size of the chart
221    pub fn set_maximum_size(&mut self, s: i32) {
222        unsafe { Fl_Chart_set_maxsize(self.inner.widget() as _, s) }
223    }
224
225    /// Gets the text font
226    pub fn text_font(&self) -> Font {
227        unsafe { std::mem::transmute(Fl_Chart_text_font(self.inner.widget() as _)) }
228    }
229
230    /// Sets the text font
231    pub fn set_text_font(&mut self, f: Font) {
232        unsafe { Fl_Chart_set_text_font(self.inner.widget() as _, f.bits()) }
233    }
234
235    /// Gets the text size
236    pub fn text_size(&self) -> i32 {
237        unsafe { Fl_Chart_text_size(self.inner.widget() as _) }
238    }
239
240    /// Sets the text size
241    pub fn set_text_size(&mut self, s: i32) {
242        unsafe { Fl_Chart_set_text_size(self.inner.widget() as _, s) }
243    }
244
245    /// Gets the text's color
246    pub fn text_color(&self) -> Color {
247        unsafe { std::mem::transmute(Fl_Chart_text_color(self.inner.widget() as _)) }
248    }
249
250    /// Sets the text's color
251    pub fn set_text_color(&mut self, color: Color) {
252        unsafe { Fl_Chart_set_text_color(self.inner.widget() as _, color.bits()) }
253    }
254
255    /// Returns whether the chart is autosizable
256    pub fn is_autosize(&self) -> bool {
257        unsafe { Fl_Chart_is_autosize(self.inner.widget() as _) != 0 }
258    }
259
260    /// Sets the ability of the chart to be autosizable
261    pub fn make_autosize(&mut self, val: bool) {
262        unsafe { Fl_Chart_make_autosize(self.inner.widget() as _, i32::from(val)) }
263    }
264}
265
266/// Creates a progress bar
267#[derive(Debug)]
268pub struct Progress {
269    inner: crate::widget::WidgetTracker,
270    is_derived: bool,
271}
272
273crate::macros::widget::impl_widget_ext!(Progress, Fl_Progress);
274crate::macros::widget::impl_widget_base!(Progress, Fl_Progress);
275crate::macros::widget::impl_widget_default!(Progress, Fl_Progress);
276
277impl Progress {
278    /// Returns the minimum value of the progress bar
279    pub fn minimum(&self) -> f64 {
280        unsafe { Fl_Progress_minimum(self.inner.widget() as _) }
281    }
282
283    /// Sets the minimum value of the progress bar
284    pub fn set_minimum(&mut self, a: f64) {
285        unsafe { Fl_Progress_set_minimum(self.inner.widget() as _, a) }
286    }
287
288    /// Returns the maximum value of the progress bar
289    pub fn maximum(&self) -> f64 {
290        unsafe { Fl_Progress_maximum(self.inner.widget() as _) }
291    }
292
293    /// Sets the minimum value of the progress bar
294    pub fn set_maximum(&mut self, a: f64) {
295        unsafe { Fl_Progress_set_maximum(self.inner.widget() as _, a) }
296    }
297
298    /// Returns the value of the progress bar
299    pub fn value(&self) -> f64 {
300        unsafe { Fl_Progress_value(self.inner.widget() as _) }
301    }
302
303    /// Sets the value of the progress bar
304    pub fn set_value(&mut self, arg2: f64) {
305        unsafe {
306            Fl_Progress_set_value(self.inner.widget() as _, arg2);
307        }
308    }
309}
310
311/// Controls tooltips on an application-wide basis; use .`set_tooltip()` to add a tooltip to a particular widget
312#[derive(Clone, Debug)]
313pub struct Tooltip {}
314
315impl Tooltip {
316    /// Gets the tooltips delay
317    pub fn delay() -> f32 {
318        unsafe { Fl_Tooltip_delay() }
319    }
320
321    /// Sets the tooltips delay
322    pub fn set_delay(f: f32) {
323        unsafe { Fl_Tooltip_set_delay(f) }
324    }
325
326    /// Gets the tooltips hide delay
327    pub fn hidedelay() -> f32 {
328        unsafe { Fl_Tooltip_hidedelay() }
329    }
330
331    /// Sets the tooltips hide delay
332    pub fn set_hidedelay(f: f32) {
333        unsafe { Fl_Tooltip_set_hidedelay(f) }
334    }
335
336    /// Gets the tooltips hover delay
337    pub fn hoverdelay() -> f32 {
338        unsafe { Fl_Tooltip_hoverdelay() }
339    }
340
341    /// Sets the tooltips hover delay
342    pub fn set_hoverdelay(f: f32) {
343        unsafe { Fl_Tooltip_set_hoverdelay(f) }
344    }
345
346    /// Returns whether the tooltips are enabled
347    pub fn enabled() -> bool {
348        unsafe { Fl_Tooltip_enabled() != 0 }
349    }
350
351    /// Sets tooltips to be displayed if b is true; otherwise not to be displayed
352    pub fn enable(b: bool) {
353        unsafe { Fl_Tooltip_enable(i32::from(b)) }
354    }
355
356    /// Disables the display of all tooltips
357    pub fn disable() {
358        unsafe { Fl_Tooltip_disable() }
359    }
360
361    /// Used to provide tooltips for internal pieces of your widget.
362    /// Check FLTK's [documentation](https://www.fltk.org/doc-1.3/classFl__Tooltip.html#a55b4d5a9a98e69eef5716ca02a16d59e).
363    /// The text of the tooltip must be a static `CStr` since the data is not copied by FLTK. This also avoid memory leaks in user code.
364    pub fn enter_area<W: WidgetExt>(
365        widget: &W,
366        x: i32,
367        y: i32,
368        w: i32,
369        h: i32,
370        tip: &'static CStr,
371    ) {
372        unsafe {
373            Fl_Tooltip_enter_area(
374                widget.as_widget_ptr() as *mut Fl_Widget,
375                x,
376                y,
377                w,
378                h,
379                tip.as_ptr(),
380            );
381        }
382    }
383
384    /// Returns the current widget associated with the tooltip
385    pub fn current_widget() -> impl WidgetExt {
386        unsafe {
387            let widget_ptr = Fl_Tooltip_current_widget();
388            assert!(!widget_ptr.is_null());
389            Widget::from_widget_ptr(widget_ptr as *mut fltk_sys::widget::Fl_Widget)
390        }
391    }
392
393    /// Sets the current widget associated with the tooltip
394    pub fn current<W: WidgetExt>(w: &W) {
395        unsafe { Fl_Tooltip_current(w.as_widget_ptr() as *mut Fl_Widget) }
396    }
397
398    /// Gets the tooltips font
399    pub fn font() -> Font {
400        unsafe { mem::transmute(Fl_Tooltip_font()) }
401    }
402
403    /// Sets the tooltips font
404    pub fn set_font(font: Font) {
405        unsafe { Fl_Tooltip_set_font(font.bits()) }
406    }
407
408    /// Gets the tooltips font size
409    pub fn font_size() -> i32 {
410        unsafe { Fl_Tooltip_font_size() }
411    }
412
413    /// Sets the tooltips font size
414    pub fn set_font_size(s: i32) {
415        unsafe { Fl_Tooltip_set_font_size(s) }
416    }
417
418    /// Gets the tooltips color
419    pub fn color() -> Color {
420        unsafe { mem::transmute(Fl_Tooltip_color()) }
421    }
422
423    /// Sets the tooltips color
424    pub fn set_color(c: Color) {
425        unsafe { Fl_Tooltip_set_color(c.bits()) }
426    }
427
428    /// Gets the tooltips text color
429    pub fn text_color() -> Color {
430        unsafe { mem::transmute(Fl_Tooltip_text_color()) }
431    }
432
433    /// Sets the tooltips text color
434    pub fn set_text_color(c: Color) {
435        unsafe { Fl_Tooltip_set_text_color(c.bits()) }
436    }
437
438    /// Gets the tooltips margin width
439    pub fn margin_width() -> i32 {
440        unsafe { Fl_Tooltip_margin_width() }
441    }
442
443    /// Sets the tooltips margin width
444    pub fn set_margin_width(v: i32) {
445        unsafe { Fl_Tooltip_set_margin_width(v) }
446    }
447
448    /// Gets the tooltips margin height
449    pub fn margin_height() -> i32 {
450        unsafe { Fl_Tooltip_margin_height() }
451    }
452
453    /// Sets the tooltips margin height
454    pub fn set_margin_height(v: i32) {
455        unsafe { Fl_Tooltip_set_margin_height(v) }
456    }
457
458    /// Gets the tooltips wrap width
459    pub fn wrap_width() -> i32 {
460        unsafe { Fl_Tooltip_wrap_width() }
461    }
462
463    /// Sets the tooltips wrap width
464    pub fn set_wrap_width(v: i32) {
465        unsafe { Fl_Tooltip_set_wrap_width(v) }
466    }
467
468    /// Returns the window used for tooltips
469    pub fn current_window() -> impl WindowExt {
470        unsafe {
471            let wind = Fl_Tooltip_current_window();
472            assert!(!wind.is_null());
473            Window::from_widget_ptr(wind as *mut fltk_sys::widget::Fl_Widget)
474        }
475    }
476}
477
478/// Creates an `InputChoice` widget
479#[derive(Debug)]
480pub struct InputChoice {
481    inner: crate::widget::WidgetTracker,
482    is_derived: bool,
483}
484
485crate::macros::widget::impl_widget_ext!(InputChoice, Fl_Input_Choice);
486crate::macros::widget::impl_widget_base!(InputChoice, Fl_Input_Choice);
487crate::macros::widget::impl_widget_default!(InputChoice, Fl_Input_Choice);
488
489impl InputChoice {
490    /// Set the `down_box` of the widget
491    pub fn set_down_frame(&mut self, f: FrameType) {
492        unsafe { Fl_Input_Choice_set_down_box(self.inner.widget() as _, f.as_i32()) }
493    }
494
495    /// Get the down frame type of the widget
496    pub fn down_frame(&self) -> FrameType {
497        unsafe { FrameType::from_i32(Fl_Input_Choice_down_box(self.inner.widget() as _)) }
498    }
499
500    /// Add an element to the input choice
501    pub fn add(&mut self, s: &str) {
502        let s = CString::safe_new(s);
503        unsafe { Fl_Input_Choice_add(self.inner.widget() as _, s.as_ptr()) }
504    }
505
506    /// Clear the input choice widget
507    pub fn clear(&mut self) {
508        unsafe { Fl_Input_Choice_clear(self.inner.widget() as _) }
509    }
510
511    /// Get the value of the current input choice
512    pub fn value(&self) -> Option<String> {
513        unsafe {
514            let ptr = Fl_Input_Choice_value(self.inner.widget() as _);
515            if ptr.is_null() {
516                None
517            } else {
518                Some(CStr::from_ptr(ptr).to_string_lossy().to_string())
519            }
520        }
521    }
522
523    /// Get the value index of the current input choice
524    pub fn value_index(&self) -> i32 {
525        unsafe { Fl_Input_Choice_value_index(self.inner.widget() as _) }
526    }
527
528    /// Set the value to a string
529    pub fn set_value(&mut self, val: &str) {
530        let val = CString::safe_new(val);
531        unsafe { Fl_Input_Choice_set_value(self.inner.widget() as _, val.as_ptr()) }
532    }
533
534    /// Set the value of the input choice to the element at `idx`
535    pub fn set_value_index(&mut self, idx: i32) {
536        unsafe { Fl_Input_Choice_set_value_index(self.inner.widget() as _, idx) }
537    }
538
539    /// Get the associated input widget
540    pub fn input(&self) -> crate::input::Input {
541        unsafe {
542            let ptr = Fl_Input_Choice_input(self.inner.widget() as _);
543            assert!(!ptr.is_null());
544            crate::input::Input::from_widget_ptr(ptr as _)
545        }
546    }
547
548    /// Get the associated menu button
549    pub fn menu_button(&self) -> crate::menu::MenuButton {
550        unsafe {
551            let ptr = Fl_Input_Choice_menu_button(self.inner.widget() as _);
552            assert!(!ptr.is_null());
553            crate::menu::MenuButton::from_widget_ptr(ptr as _)
554        }
555    }
556
557    /// Gets the text font
558    pub fn text_font(&self) -> Font {
559        unsafe { std::mem::transmute(Fl_Input_Choice_text_font(self.inner.widget() as _)) }
560    }
561
562    /// Sets the text font
563    pub fn set_text_font(&mut self, f: Font) {
564        unsafe { Fl_Input_Choice_set_text_font(self.inner.widget() as _, f.bits()) }
565    }
566
567    /// Gets the text size
568    pub fn text_size(&self) -> i32 {
569        unsafe { Fl_Input_Choice_text_size(self.inner.widget() as _) }
570    }
571
572    /// Sets the text size
573    pub fn set_text_size(&mut self, s: i32) {
574        unsafe { Fl_Input_Choice_set_text_size(self.inner.widget() as _, s) }
575    }
576
577    /// Gets the text's color
578    pub fn text_color(&self) -> Color {
579        unsafe { std::mem::transmute(Fl_Input_Choice_text_color(self.inner.widget() as _)) }
580    }
581
582    /// Sets the text's color
583    pub fn set_text_color(&mut self, color: Color) {
584        unsafe { Fl_Input_Choice_set_text_color(self.inner.widget() as _, color.bits()) }
585    }
586}
587
588/**
589    Creates a `HelpView` widget which supports HTML 2 formatting
590    ```rust,no_run
591    use fltk::{prelude::*, *};
592    let mut h = misc::HelpView::new(10, 10, 380, 280, "");
593    h.set_value("Hello <b><font color=red>again</font></b>");
594
595    ```
596*/
597#[derive(Debug)]
598pub struct HelpView {
599    inner: crate::widget::WidgetTracker,
600    is_derived: bool,
601}
602
603crate::macros::widget::impl_widget_ext!(HelpView, Fl_Help_View);
604crate::macros::widget::impl_widget_base!(HelpView, Fl_Help_View);
605crate::macros::widget::impl_widget_default!(HelpView, Fl_Help_View);
606
607impl HelpView {
608    /// Return the directory
609    pub fn directory(&self) -> Option<std::path::PathBuf> {
610        unsafe {
611            let x = Fl_Help_View_directory(self.inner.widget() as _);
612            if x.is_null() {
613                None
614            } else {
615                Some(std::path::PathBuf::from(
616                    CStr::from_ptr(x as *mut raw::c_char)
617                        .to_string_lossy()
618                        .to_string(),
619                ))
620            }
621        }
622    }
623
624    /// Return the filename
625    pub fn filename(&self) -> Option<std::path::PathBuf> {
626        unsafe {
627            let x = Fl_Help_View_directory(self.inner.widget() as _);
628            if x.is_null() {
629                None
630            } else {
631                Some(std::path::PathBuf::from(
632                    CStr::from_ptr(x as *mut raw::c_char)
633                        .to_string_lossy()
634                        .to_string(),
635                ))
636            }
637        }
638    }
639
640    /// Find a string, returns the index
641    pub fn find(&self, s: &str, start_from: i32) -> Option<usize> {
642        unsafe {
643            let s = CString::safe_new(s);
644            let ret = Fl_Help_View_find(self.inner.widget() as _, s.as_ptr(), start_from);
645            match ret {
646                -1 => None,
647                _ => Some(ret as usize),
648            }
649        }
650    }
651
652    /// Get the value of the widget
653    pub fn value(&self) -> Option<String> {
654        unsafe {
655            let val = Fl_Help_View_value(self.inner.widget() as _);
656            if val.is_null() {
657                None
658            } else {
659                Some(CStr::from_ptr(val).to_string_lossy().to_string())
660            }
661        }
662    }
663
664    /// Set value of the widget
665    pub fn set_value(&mut self, val: &str) {
666        let val = CString::safe_new(val);
667        unsafe { Fl_Help_View_set_value(self.inner.widget() as _, val.as_ptr()) }
668    }
669
670    /// Clear selection
671    pub fn clear_selection(&mut self) {
672        unsafe { Fl_Help_View_clear_selection(self.inner.widget() as _) }
673    }
674
675    /// Select all
676    pub fn select_all(&mut self) {
677        unsafe { Fl_Help_View_select_all(self.inner.widget() as _) }
678    }
679
680    /// Set the top line string
681    pub fn set_top_line_string(&mut self, n: &str) {
682        let n = CString::safe_new(n);
683        unsafe { Fl_Help_View_set_topline_str(self.inner.widget() as _, n.as_ptr()) }
684    }
685
686    /// Set the top line position
687    pub fn set_top_line(&mut self, line: i32) {
688        unsafe { Fl_Help_View_set_topline(self.inner.widget() as _, line) }
689    }
690
691    /// Get the top line position
692    pub fn top_line(&self) -> i32 {
693        unsafe { Fl_Help_View_topline(self.inner.widget() as _) }
694    }
695
696    /// Set the left line position
697    pub fn set_left_line(&mut self, arg1: i32) {
698        unsafe { Fl_Help_View_set_leftline(self.inner.widget() as _, arg1) }
699    }
700
701    /// Gets the current left line in pixels
702    pub fn left_line(&self) -> i32 {
703        unsafe { Fl_Help_View_leftline(self.inner.widget() as _) }
704    }
705
706    /// Gets the text font
707    pub fn text_font(&self) -> Font {
708        unsafe { std::mem::transmute(Fl_Help_View_text_font(self.inner.widget() as _)) }
709    }
710
711    /// Sets the text font
712    pub fn set_text_font(&mut self, f: Font) {
713        unsafe { Fl_Help_View_set_text_font(self.inner.widget() as _, f.bits()) }
714    }
715
716    /// Gets the text size
717    pub fn text_size(&self) -> i32 {
718        unsafe { Fl_Help_View_text_size(self.inner.widget() as _) }
719    }
720
721    /// Sets the text size
722    pub fn set_text_size(&mut self, s: i32) {
723        unsafe { Fl_Help_View_set_text_size(self.inner.widget() as _, s) }
724    }
725
726    /// Gets the text's color
727    pub fn text_color(&self) -> Color {
728        unsafe { std::mem::transmute(Fl_Help_View_text_color(self.inner.widget() as _)) }
729    }
730
731    /// Sets the text's color
732    pub fn set_text_color(&mut self, color: Color) {
733        unsafe { Fl_Help_View_set_text_color(self.inner.widget() as _, color.bits()) }
734    }
735
736    /// Gets the scrollbar size
737    pub fn scrollbar_size(&self) -> i32 {
738        unsafe { Fl_Help_View_scrollbar_size(self.inner.widget() as _) }
739    }
740
741    /// Sets the scrollbar size
742    pub fn set_scrollbar_size(&mut self, new_size: i32) {
743        unsafe { Fl_Help_View_set_scrollbar_size(self.inner.widget() as _, new_size) }
744    }
745
746    /// Load a view from a file or URI
747    /// # Errors
748    /// Errors on non-existent path
749    pub fn load(&mut self, f: &str) -> Result<(), FltkError> {
750        let f = CString::safe_new(f);
751        unsafe {
752            match Fl_Help_View_load(self.inner.widget() as _, f.as_ptr()) {
753                0 => Ok(()),
754                _ => Err(FltkError::Internal(FltkErrorKind::ResourceNotFound)),
755            }
756        }
757    }
758}