From 25de70e75c2448528f739ce913c6ccc63e36503d Mon Sep 17 00:00:00 2001 From: Ralf Zerres Date: Wed, 22 Jul 2020 18:07:11 +0200 Subject: [PATCH] examples: remove unused code Signed-off-by: Ralf Zerres --- advotracker/examples/pdf_check.rs | 37 ---- advotracker/examples/policyholder_check.rs | 235 --------------------- 2 files changed, 272 deletions(-) delete mode 100644 advotracker/examples/pdf_check.rs delete mode 100644 advotracker/examples/policyholder_check.rs diff --git a/advotracker/examples/pdf_check.rs b/advotracker/examples/pdf_check.rs deleted file mode 100644 index fe63d53..0000000 --- a/advotracker/examples/pdf_check.rs +++ /dev/null @@ -1,37 +0,0 @@ -extern crate pdf_extract; -extern crate lopdf; - -use std::env; -use std::path::PathBuf; -use std::path; -use std::io::BufWriter; -use std::fs::File; -use pdf_extract::*; -use lopdf::*; - -fn main() { - //let output_kind = "html"; - //let output_kind = "txt"; - //let output_kind = "svg"; - let file = env::args().nth(1).unwrap(); - let output_kind = env::args().nth(2).unwrap_or_else(|| "txt".to_owned()); - println!("{}", file); - let path = path::Path::new(&file); - let filename = path.file_name().expect("expected a filename"); - let mut output_file = PathBuf::new(); - output_file.push(filename); - output_file.set_extension(&output_kind); - let mut output_file = BufWriter::new(File::create(output_file).expect("could not create output")); - let doc = Document::load(path).unwrap(); - - print_metadata(&doc); - - let mut output: Box = match output_kind.as_ref() { - "txt" => Box::new(PlainTextOutput::new(&mut output_file as &mut dyn std::io::Write)), - "html" => Box::new(HTMLOutput::new(&mut output_file)), - "svg" => Box::new(SVGOutput::new(&mut output_file)), - _ => panic!(), - }; - - output_doc(&doc, output.as_mut()); -} diff --git a/advotracker/examples/policyholder_check.rs b/advotracker/examples/policyholder_check.rs deleted file mode 100644 index dc193df..0000000 --- a/advotracker/examples/policyholder_check.rs +++ /dev/null @@ -1,235 +0,0 @@ -use orbtk::prelude::*; -use orbtk::theme::DEFAULT_THEME_CSS; -//use orbtk::theme::LIGHT_THEME_EXTENSION_CSS; - -//#[cfg(feature = "light-theme")] -static WIDGET_EXT: &'static str = include_str!("../resources/stylesheets/policyholder_check.css"); - -fn get_theme() -> ThemeValue { - //ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS) - ThemeValue::create_from_css(DEFAULT_THEME_CSS) - .extension_css(WIDGET_EXT) - .build() -} - -#[derive(Debug, Copy, Clone)] -enum Action { - ClearText, - EntryActivated(Entity), - EntryChanged(Entity), - //ValueChanged(Entity), - ValueOk, - ValueNone, -} - -#[derive(AsAny)] -pub struct MainViewState { - action: Option, -} - -impl Default for MainViewState { - fn default() -> Self { - MainViewState { action: None } - } -} - -impl MainViewState { - fn action(&mut self, action: impl Into>) { - self.action = action.into(); - } -} - -impl State for MainViewState { - fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) { - if let Some(action) = self.action { - match action { - Action::ClearText => { - ctx.widget().set("policynumber", String16::from("")); - } - Action::ValueOk => { - //let mut text_box = TextBox::get(ctx.get_widget(entity)); - //let text = text_box.text_mut(); - //ctx.widget().set("policynumber", background("#4d4c4c")); - } - Action::ValueNone => { - //let mut text_box = TextBox::get(ctx.get_widget(entity)); - //let text = text_box.text_mut(); - //ctx.widget().set("policynumber", background("#5b0f22")); - } - Action::EntryActivated(entity) => { - let mut text_box = TextBox::get(ctx.get_widget(entity)); - let text = text_box.text_mut(); - //let mut widget = ctx.get_widget(entity); - //let text = widget.get_mut::("text"); - println!("got value policynumber: {}", text); - //text.clear(); - } - Action::EntryChanged(entity) => { - let widget = ctx.get_widget(entity); - let text = widget.get::("text"); - println!("entry changed: {}", text); - } - // Action::ValueChanged(entity) => { - // let val = - // ((*ctx.get_widget(entity).get::("val")).floor() as i32).to_string(); - // ctx.child("value_text").set("text", String16::from(val)); - //} - } - - self.action = None; - } - } -} - -fn create_header(ctx: &mut BuildContext, text: &str) -> Entity { - TextBlock::new() - .text(text) - .element("text-block") - .class("h1") - .build(ctx) -} - -widget!( - MainView { - sum_policynumbers: usize, - policynumber: String16, - result: String16 - } -); - -impl Template for MainView { - fn template(self, id: Entity, ctx: &mut BuildContext) -> Self { - self.name("MainView").child( - //.result("Anzahl Versicherungsnummern: 0") - //.result("Policyholders count: 0").sum_policynumbers(0) - //.sum_policynumbers(0) - Grid::new() - .background("#fafafa") - //.width(200.0) - //.height(360.0) - .columns( - Columns::new() - .add(150.0) - .add("*") - //.add(120.0) - //.add("auto") - .add(150.0) - .build(), - ) - .rows( - Rows::new() - .add("*") - .add("*") - .build(), - ) - .child( - Grid::new() - .element("policyholder_check") - .margin((4.0, 24.0, 24.0, 4.0)) - .min_width(180.0) - .min_height(80.0) - .attach(Grid::column(1)) - .attach(Grid::row(0)) - .child( - Stack::new() - .spacing(8.0) - .orientation("vertical") - .h_align("center") - //.child(create_header(ctx, "Validation number policyholder")) - .child(create_header(ctx, "Validierung Versicherungsnummer")) - .child( - TextBox::new() - //.class("text_box") - // overwriting the class defaults - /* .background("transparent") - .foreground("#9dafbf") - .background("#fafafa") - /* .foreground(colors::LINK_WATER_COLOR) */ - .border_brush("#5b0f22") - .border_width(5) - .border_radius(15) */ - //.name("policynumber") - .focused(true) - .water_mark("Versicherungs-Nr...") - //.text("Number policyholder", id) - .text(("policynumber", id)) - .font_size(24.0) - .h_align("stretch") - .on_activate(move |states, entity| { - state(id, states).action(Action::EntryActivated(entity)); - }) - .on_changed(move |states, entity| { - state(id, states).action(Action::EntryChanged(entity)); - }) - .build(ctx), - ) - .child( - TextBlock::new() - .element("text-block") - .id("result") - .min_width(80.0) - .max_width(180.0) - //.text("Result:") - .text("Ergebnis:") - .build(ctx), - ) - .build(ctx), - ) - .build(ctx) - ) - .child( - Grid::new() - .element("logo_customer") - .margin((9.0, 16.0, 16.0, 9.0)) - .attach(Grid::column(0)) - .attach(Grid::row(1)) - .v_align("end") - .child( - ImageWidget::new() - .image("./resources/images/hiedemann_logo.png") - .build(ctx), - ) - .build(ctx), - ) - .child( - Grid::new() - .element("logo_vendor") - .margin((9.0, 16.0, 16.0, 9.0)) - .attach(Grid::column(2)) - .attach(Grid::row(1)) - .v_align("end") - .child( - ImageWidget::new() - .image("./resources/images/networkx_logo.png") - .build(ctx), - ) - .build(ctx), - ) - .build(ctx), - ) // MainView - } -} - -fn main() { - Application::new() - .window(|ctx| { - Window::new() - //.title("OrbTk - Policyholder checker example") - .name("MainWindow") - .title("AdvoTracker - Versicherungsnummern") - .position((-500.0, -100.0)) - .size(480.0, 260.0) - .min_width(460.0) - .min_height(180.0) - .resizeable(true) - .theme(get_theme()) - .child(MainView::new().build(ctx)) - .build(ctx) - }) - .run(); -} - -// helper to request MainViewState -fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState { - states.get_mut(id) -}