fltk/app/
cairo.rs

1use crate::prelude::WidgetExt;
2use fltk_sys::fl::*;
3use std::os::raw::c_void;
4
5/// Makes the cairo context current
6pub fn make_current(w: &impl WidgetExt) -> *mut c_void {
7    unsafe { Fl_cairo_make_current(w.window().unwrap().as_widget_ptr() as _) }
8}
9
10/// Sets autolink
11pub fn set_autolink_context(alink: bool) {
12    unsafe { Fl_set_cairo_autolink_context(i32::from(alink)) }
13}
14
15/// Gets autolink
16pub fn autolink_context() -> bool {
17    unsafe { Fl_cairo_autolink_context() != 0 }
18}
19
20/// Gets the cairo context
21pub fn cc() -> *mut c_void {
22    unsafe { Fl_cairo_cc() }
23}
24
25/// Sets the cairo context
26/// # Safety
27/// Doesn't check the passed context for validity
28pub unsafe fn set_cc(c: *mut c_void, own: bool) {
29    unsafe { Fl_set_cairo_cc(c, i32::from(own)) }
30}
31
32/// Flushes the cairo context
33/// # Safety
34/// Doesn't check the passed context for validity
35pub unsafe fn flush(c: *mut c_void) {
36    unsafe { Fl_cairo_flush(c) }
37}