use crate::text::{JustifyMethod, OverflowMethod};
use crate::utils::align_widget::VerticalAlign;
use crate::widgets::table::CellContent;
#[derive(Debug, Clone)]
pub struct Column {
pub header: String,
pub footer: String,
pub header_style: String,
pub footer_style: String,
pub style: String,
pub justify: JustifyMethod,
pub vertical: VerticalAlign,
pub overflow: OverflowMethod,
pub width: Option<usize>,
pub min_width: Option<usize>,
pub max_width: Option<usize>,
pub ratio: Option<usize>,
pub no_wrap: bool,
pub highlight: bool,
pub index: usize,
pub cells: Vec<CellContent>,
}
impl Column {
pub fn flexible(&self) -> bool {
self.ratio.is_some()
}
pub fn copy(&self) -> Column {
Column {
header: self.header.clone(),
footer: self.footer.clone(),
header_style: self.header_style.clone(),
footer_style: self.footer_style.clone(),
style: self.style.clone(),
justify: self.justify,
vertical: self.vertical,
overflow: self.overflow,
width: self.width,
min_width: self.min_width,
max_width: self.max_width,
ratio: self.ratio,
no_wrap: self.no_wrap,
highlight: self.highlight,
index: self.index,
cells: Vec::new(),
}
}
}
impl Default for Column {
fn default() -> Self {
Column {
header: String::new(),
footer: String::new(),
header_style: String::new(),
footer_style: String::new(),
style: String::new(),
justify: JustifyMethod::Left,
vertical: VerticalAlign::Top,
overflow: OverflowMethod::Ellipsis,
width: None,
min_width: None,
max_width: None,
ratio: None,
no_wrap: false,
highlight: false,
index: 0,
cells: Vec::new(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct ColumnOptions {
pub header_style: Option<String>,
pub footer_style: Option<String>,
pub style: Option<String>,
pub justify: Option<JustifyMethod>,
pub vertical: Option<VerticalAlign>,
pub overflow: Option<OverflowMethod>,
pub width: Option<usize>,
pub min_width: Option<usize>,
pub max_width: Option<usize>,
pub ratio: Option<usize>,
pub no_wrap: bool,
pub highlight: Option<bool>,
}