From 9c551e8b556795a640eee9d8ca6ca73dc9a43db7 Mon Sep 17 00:00:00 2001 From: zvon Date: Fri, 17 Jan 2020 14:06:31 +0100 Subject: [PATCH] Progresswindows --- progresswindow.cpp | 30 ++++++++++++++++++++++++++++++ progresswindow.hpp | 27 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 progresswindow.cpp create mode 100644 progresswindow.hpp diff --git a/progresswindow.cpp b/progresswindow.cpp new file mode 100644 index 0000000..b5fd46f --- /dev/null +++ b/progresswindow.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +#include "functions.hpp" +#include "progresswindow.hpp" + +ProgressWindow::ProgressWindow() { + set_title( "Progress" ); + + set_default_size( 500, 55 ); + + std::cout << "Layout" << std::endl; + add( *layout ); + set_size_request( 500, 55 ); + set_resizable( false ); + + pb->set_size_request( 490, 5 ); + label->set_size_request( 500, 25 ); + + // set widgets' location + layout->put( *pb, 5, 35 ); + layout->put( *label, 5, 5 ); + + // show everything + layout->show(); + layout->show_all_children(); + + label->set_text( "TEST" ); +} diff --git a/progresswindow.hpp b/progresswindow.hpp new file mode 100644 index 0000000..edd52e7 --- /dev/null +++ b/progresswindow.hpp @@ -0,0 +1,27 @@ +#ifndef GTKMM_PROGRESS_WINDOW +#define GTKMM_PROGRESS_WINDOW + +#include +#include +#include +#include +#include + +class ProgressWindow : public Gtk::Window { +public: + ProgressWindow(); + virtual ~ProgressWindow() = default; + + void setPerc( int perc ) { + pb->set_fraction( perc/100.0 ); + } + void setLabel( const std::string &text ) { + label->set_text( text ); + } +private: + std::unique_ptr< Gtk::Layout > layout{ new Gtk::Layout() }; + std::unique_ptr< Gtk::Label > label { new Gtk::Label() }; + std::unique_ptr< Gtk::ProgressBar > pb { new Gtk::ProgressBar() }; +}; + +#endif // GTKMM_MAIN_WINDOW