Struct fltk::printer::Printer[][src]

pub struct Printer { /* fields omitted */ }
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[src]

pub fn default() -> Self[src]

Creates a printer object

pub fn begin_job(
    &mut self,
    pagecount: i32
) -> Result<(Option<i32>, Option<i32>), FltkError>
[src]

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_page(&mut self) -> Result<(), FltkError>[src]

End the print page

Errors

Errors on failure to end the page

pub fn end_job(&mut self)[src]

Ends the print job

pub fn begin_page(&mut self) -> Result<(), FltkError>[src]

Begins a print page

Errors

Errors on failure to begin the page

pub fn printable_rect(&self) -> (i32, i32)[src]

Returns the width and height of the printable rect

pub fn margins(&self) -> (i32, i32, i32, i32)[src]

Returns the coordinates of the printable margins. (left, top, right, bottom)

pub fn origin(&self) -> (i32, i32)[src]

Get the origin coordinates of the printable rect

pub fn set_origin(&mut self, x: i32, y: i32)[src]

Set the origin coordinates of the printable rect

pub fn scale(&mut self, scale_x: f32, scale_y: f32)[src]

Scale the printable rect

pub fn rotate(&mut self, angle: f32)[src]

Rotate the printable rect

pub fn translate(&mut self, x: i32, y: i32)[src]

Translate the printable rect

pub fn untranslate(&mut self)[src]

Untranslate the printable rect

pub fn is_current(&self) -> bool[src]

Check whether the printer is the current printer

pub fn set_current(&mut self)[src]

Set the printer to be the current printer

pub fn print_widget<W: WidgetExt>(&self, widget: &W, delta_x: i32, delta_y: i32)[src]

Print a widget

pub fn print_window<W: WindowExt>(&self, win: &W, x_offset: i32, y_offset: i32)[src]

Print a window

pub fn set_dialog_title(msg: &'static str)[src]

Set the dialog “Title”

pub fn set_dialog_printer(msg: &'static str)[src]

Set the dialog “Printer”

pub fn set_dialog_range(msg: &'static str)[src]

Set dialog “Range”

pub fn set_dialog_copies(msg: &'static str)[src]

Set dialog “Copies”

pub fn set_dialog_all(msg: &'static str)[src]

Set dialog “All”

pub fn set_dialog_pages(msg: &'static str)[src]

Set dialog “Pages”

pub fn set_dialog_from(msg: &'static str)[src]

Set dialog “From”

pub fn set_dialog_to(msg: &'static str)[src]

Set dialog “To”

pub fn set_dialog_properties(msg: &'static str)[src]

Set dialog “Properties”

pub fn set_dialog_copy_number(msg: &'static str)[src]

Set dialog “Number of copies”

pub fn set_dialog_print_button(msg: &'static str)[src]

Set dialog “Print” button

pub fn set_dialog_cancel_button(msg: &'static str)[src]

Set dialog “Cancel” button

pub fn set_dialog_print_to_file(msg: &'static str)[src]

Set dialog “Print to file” button

pub fn set_property_title(msg: &'static str)[src]

Set property “Title”

pub fn set_property_pagesize(msg: &'static str)[src]

Set property “Page Size”

pub fn set_property_mode(msg: &'static str)[src]

Set property “Mode”

pub fn set_property_use(msg: &'static str)[src]

Set property “Use”

pub fn set_property_save(msg: &'static str)[src]

Set property “Save”

pub fn set_property_cancel(msg: &'static str)[src]

Set property “Cancel”

Trait Implementations

impl Drop for Printer[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl RefUnwindSafe for Printer

impl !Send for Printer

impl !Sync for Printer

impl Unpin for Printer

impl UnwindSafe for Printer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.