Struct Printer
pub struct Printer { /* private fields */ }
dep_fltk
only.Expand description
Defines a printer object. Example usage:
use fltk::{prelude::*, *};
let mut but = button::Button::default();
but.set_callback(|widget| {
let mut printer = printer::Printer::default();
if printer.begin_job(1).is_ok() {
printer.begin_page().ok();
let (width, height) = printer.printable_rect();
draw::set_draw_color(enums::Color::Black);
draw::set_line_style(draw::LineStyle::Solid, 2);
draw::draw_rect(0, 0, width, height);
draw::set_font(enums::Font::Courier, 12);
printer.set_origin(width / 2, height / 2);
printer.print_widget(widget, -widget.width() / 2, -widget.height() / 2);
printer.end_page().ok();
printer.end_job();
}
});
Implementations§
§impl Printer
impl Printer
pub fn begin_job(
&mut self,
pagecount: i32,
) -> Result<(Option<i32>, Option<i32>), FltkError> ⓘ
pub fn begin_job( &mut self, pagecount: i32, ) -> Result<(Option<i32>, Option<i32>), FltkError> ⓘ
Begins a print job.
pagecount
The total number of pages to be created. Use 0 if this number is unknown
Returns a tuple (frompage, topage) indicating the chosen pages by the user
§Errors
Errors on failure to print
pub fn end_job(&mut self)
pub fn end_job(&mut self)
Ends the print job
pub fn begin_page(&mut self) -> Result<(), FltkError> ⓘ
pub fn begin_page(&mut self) -> Result<(), FltkError> ⓘ
pub fn printable_rect(&self) -> (i32, i32) ⓘ
pub fn printable_rect(&self) -> (i32, i32) ⓘ
Returns the width and height of the printable rect
pub fn margins(&self) -> (i32, i32, i32, i32) ⓘ
pub fn margins(&self) -> (i32, i32, i32, i32) ⓘ
Returns the coordinates of the printable margins. (left, top, right, bottom)
pub fn set_origin(&mut self, x: i32, y: i32)
pub fn set_origin(&mut self, x: i32, y: i32)
Set the origin coordinates of the printable rect
pub fn untranslate(&mut self)
pub fn untranslate(&mut self)
Untranslate the printable rect
pub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Check whether the printer is the current printer
pub fn set_current(&mut self)
pub fn set_current(&mut self)
Set the printer to be the current printer
pub fn print_widget<W>(&self, widget: &W, delta_x: i32, delta_y: i32)where
W: WidgetExt,
pub fn print_widget<W>(&self, widget: &W, delta_x: i32, delta_y: i32)where
W: WidgetExt,
Print a widget
pub fn print_window<W>(&self, win: &W, x_offset: i32, y_offset: i32)where
W: WindowExt,
pub fn print_window<W>(&self, win: &W, x_offset: i32, y_offset: i32)where
W: WindowExt,
Print a window
pub fn set_dialog_title(msg: &'static str)
pub fn set_dialog_title(msg: &'static str)
Set the dialog “Title”
pub fn set_dialog_printer(msg: &'static str)
pub fn set_dialog_printer(msg: &'static str)
Set the dialog “Printer”
pub fn set_dialog_range(msg: &'static str)
pub fn set_dialog_range(msg: &'static str)
Set dialog “Range”
pub fn set_dialog_copies(msg: &'static str)
pub fn set_dialog_copies(msg: &'static str)
Set dialog “Copies”
pub fn set_dialog_all(msg: &'static str)
pub fn set_dialog_all(msg: &'static str)
Set dialog “All”
pub fn set_dialog_pages(msg: &'static str)
pub fn set_dialog_pages(msg: &'static str)
Set dialog “Pages”
pub fn set_dialog_from(msg: &'static str)
pub fn set_dialog_from(msg: &'static str)
Set dialog “From”
pub fn set_dialog_to(msg: &'static str)
pub fn set_dialog_to(msg: &'static str)
Set dialog “To”
pub fn set_dialog_properties(msg: &'static str)
pub fn set_dialog_properties(msg: &'static str)
Set dialog “Properties”
pub fn set_dialog_copy_number(msg: &'static str)
pub fn set_dialog_copy_number(msg: &'static str)
Set dialog “Number of copies”
Set dialog “Print” button
Set dialog “Cancel” button
pub fn set_dialog_print_to_file(msg: &'static str)
pub fn set_dialog_print_to_file(msg: &'static str)
Set dialog “Print to file” button
pub fn set_property_title(msg: &'static str)
pub fn set_property_title(msg: &'static str)
Set property “Title”
pub fn set_property_pagesize(msg: &'static str)
pub fn set_property_pagesize(msg: &'static str)
Set property “Page Size”
pub fn set_property_mode(msg: &'static str)
pub fn set_property_mode(msg: &'static str)
Set property “Mode”
pub fn set_property_use(msg: &'static str)
pub fn set_property_use(msg: &'static str)
Set property “Use”
pub fn set_property_save(msg: &'static str)
pub fn set_property_save(msg: &'static str)
Set property “Save”
pub fn set_property_cancel(msg: &'static str)
pub fn set_property_cancel(msg: &'static str)
Set property “Cancel”
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Printer
impl RefUnwindSafe for Printer
impl !Send for Printer
impl !Sync for Printer
impl Unpin for Printer
impl UnwindSafe for Printer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more