pub struct TableLayout { /* private fields */ }
Expand description

Arranges elements in columns and rows.

This struct can be used to layout arbitrary elements in columns in rows, or to draw typical tables. You can customize the cell style by providing a CellDecorator implementation. If you want to print a typical table with borders around the cells, use the FrameCellDecorator.

The column widths are determined by the weights that have been set in the constructor. The table always uses the full width of the provided area.

Examples

With setters:

use rckive_genpdf::elements;
let mut table = elements::TableLayout::new(vec![1, 1]);
table.set_cell_decorator(elements::FrameCellDecorator::new(true, true, false));
let mut row = table.row();
row.push_element(elements::Paragraph::new("Cell 1"));
row.push_element(elements::Paragraph::new("Cell 2"));
row.push().expect("Invalid table row");

Chained:

use rckive_genpdf::elements;
let table = elements::TableLayout::new(vec![1, 1])
    .row()
    .element(elements::Paragraph::new("Cell 1"))
    .element(elements::Paragraph::new("Cell 2"))
    .push()
    .expect("Invalid table row");

Implementations§

Creates a new table layout with the given column weights.

The column weights are used to determine the relative width of the columns. The number of column weights determines the number of columns in the table.

Sets the cell decorator for this table.

Adds a row to this table using the TableLayoutRow helper struct.

Adds a row to this table.

The number of elements in the given vector must match the number of columns. Otherwise, an error is returned.

Trait Implementations§

Renders this element to the given area using the given style and font cache. Read more
Draws a frame around this element using the given line style.
Adds a padding to this element.
Sets the default style for this element and its children.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Creates a boxed element from this element.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.