2019-01-23 19:46:03 +00:00
|
|
|
#include "seasonwindow.hpp"
|
2019-06-01 19:54:45 +00:00
|
|
|
#include <string>
|
2019-01-23 19:46:03 +00:00
|
|
|
|
|
|
|
void SeasonWindow::confirm() {
|
|
|
|
// go through all checkbuttons and save numbers
|
|
|
|
// of checked boxes into returned vector
|
|
|
|
// then quit
|
2019-02-04 16:39:48 +00:00
|
|
|
for ( auto &x : m_checks ) {
|
|
|
|
if ( x.get_active() ) {
|
|
|
|
returned.push_back( std::stoi( x.get_label() ) );
|
2019-01-23 19:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeasonWindow::select_all() {
|
|
|
|
// set all check boxes to checked
|
2019-02-04 16:39:48 +00:00
|
|
|
for ( auto &x : m_checks ) {
|
|
|
|
x.set_active( true );
|
2019-01-23 19:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SeasonWindow::select_none() {
|
|
|
|
// set all check boxes to unchecked
|
2019-02-04 16:39:48 +00:00
|
|
|
for ( auto &x : m_checks ) {
|
|
|
|
x.set_active( false );
|
2019-01-23 19:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
SeasonWindow::SeasonWindow( const std::vector< int > &seasons,
|
|
|
|
std::vector< int > &_returned )
|
|
|
|
: returned( _returned ) {
|
|
|
|
set_title( "Choose seasons" );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
set_default_size( 250, 250 );
|
|
|
|
set_resizable( false );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
add( m_layout );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
size_t x{ 5 }, y{ 25 };
|
2019-01-23 19:46:03 +00:00
|
|
|
|
|
|
|
// create a check box for each season
|
2019-02-04 16:39:48 +00:00
|
|
|
for ( auto &s : seasons ) {
|
|
|
|
m_checks.emplace_back( std::to_string( s ) );
|
|
|
|
m_layout.put( m_checks.back(), x, y );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
if ( x == 185 ) {
|
2019-01-23 19:46:03 +00:00
|
|
|
x = 5;
|
|
|
|
y += 20;
|
|
|
|
} else {
|
|
|
|
x += 60;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
m_layout.put( m_label, 5, 5 );
|
|
|
|
m_label.set_label( "Select seasons:" );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
m_layout.put( m_confirm, 165, 215 );
|
|
|
|
m_layout.put( m_all, 130, 175 );
|
|
|
|
m_layout.put( m_none, 5, 175 );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
m_confirm.set_size_request( 80, 30 );
|
|
|
|
m_all.set_size_request( 80, 30 );
|
|
|
|
m_none.set_size_request( 80, 30 );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
m_confirm.set_label( "Select" );
|
|
|
|
m_all.set_label( "Select All" );
|
|
|
|
m_none.set_label( "Unselect All" );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
m_confirm.signal_clicked().connect(
|
|
|
|
sigc::mem_fun( *this, &SeasonWindow::confirm ) );
|
|
|
|
m_all.signal_clicked().connect(
|
|
|
|
sigc::mem_fun( *this, &SeasonWindow::select_all ) );
|
|
|
|
m_none.signal_clicked().connect(
|
|
|
|
sigc::mem_fun( *this, &SeasonWindow::select_none ) );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
|
|
|
show_all_children();
|
|
|
|
}
|