use fltk::enums::Color;
use fltk::image::{BmpImage, JpegImage, PngImage, RgbImage};
use std::fmt;
use std::fmt::{Debug, Formatter};
#[derive(Clone)]
pub enum Icon {
Png(PngImage),
Jpeg(JpegImage),
Bmp(BmpImage),
Rgb(RgbImage),
}
impl Debug for Icon {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
Self::Png(_) => "PNG icon",
Self::Jpeg(_) => "JPEG icon",
Self::Bmp(_) => "BMP icon",
Self::Rgb(_) => "RGB icon",
}
)
}
}
#[derive(Debug, Clone)]
pub struct Style {
fg: Color,
bg: Color,
bg_2: Color,
title: String,
icon: Option<Icon>,
}
impl Style {
pub const fn new(fg: Color, bg: Color, bg_2: Color, title: String, icon: Option<Icon>) -> Self {
Self {
fg,
bg,
bg_2,
title,
icon,
}
}
pub fn title(&self) -> &str {
&self.title
}
pub const fn fg(&self) -> Color {
self.fg
}
pub const fn bg(&self) -> Color {
self.bg
}
pub const fn bg_2(&self) -> Color {
self.bg_2
}
pub const fn icon(&self) -> Option<&Icon> {
self.icon.as_ref()
}
pub fn set_fg(&mut self, fg: Color) {
self.fg = fg;
}
pub fn set_bg(&mut self, bg: Color) {
self.bg = bg;
}
pub fn set_bg_2(&mut self, bg_2: Color) {
self.bg_2 = bg_2;
}
pub fn set_title(&mut self, title: String) {
self.title = title;
}
pub fn set_icon(&mut self, icon: Option<Icon>) {
self.icon = icon;
}
}
impl Default for Style {
fn default() -> Self {
Self::new(
Color::from_hex(0x222222),
Color::from_hex(0xf0f0f0),
Color::from_hex(0xffffff),
"Crash Report".to_string(),
None,
)
}
}