Progresswindows

This commit is contained in:
zvon 2020-01-17 14:06:31 +01:00
parent af1355ca93
commit 9c551e8b55
2 changed files with 57 additions and 0 deletions

30
progresswindow.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <gtkmm/liststore.h>
#include <iostream>
#include <mutex>
#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" );
}

27
progresswindow.hpp Normal file
View File

@ -0,0 +1,27 @@
#ifndef GTKMM_PROGRESS_WINDOW
#define GTKMM_PROGRESS_WINDOW
#include <gtkmm/label.h>
#include <gtkmm/layout.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/window.h>
#include <iostream>
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