5c70d9d85a6f690ae5c591b7d884677efad7fbaa
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

1) /*
2)  * EtherPix simulator
3)  *
4)  * Copyright 2017 Stefan Schuermans <stefan schuermans info>
5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <gtkmm.h>
21) 
Stefan Schuermans implement drawing pixels

Stefan Schuermans authored 7 years ago

22) #include "config.h"
23) #include "draw.h"
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

24) #include "main_window.h"
25) 
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

26) #define TIMER_MS (40)
27) 
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

28) /**
29)  * @brief constructor
30)  * @param[in] Gtk Window object (a C object)
31)  * @param[in] builder reference to GTK builder object
32)  */
33) MainWindow::MainWindow(BaseObjectType *cobject,
34)                        const Glib::RefPtr<Gtk::Builder> &builder):
35)   Gtk::Window(cobject),
Stefan Schuermans implement drawing pixels

Stefan Schuermans authored 7 years ago

36)   m_builder(builder),
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

37)   m_config(NULL),
38)   m_packets(0),
39)   m_time_ms(0)
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

40) {
41)   // get widgets
42)   builder->get_widget_derived("Draw", m_draw);
43)   builder->get_widget("Status", m_status);
44) 
45)   // connect callbacks
46)   signal_hide().connect(sigc::mem_fun(*this, &MainWindow::on_hide));
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

47) 
48)   // start timer
49)   sigc::slot<bool> timer_slot = sigc::bind(
50)       sigc::mem_fun(*this, &MainWindow::on_timer), 0);
51)   m_timer = Glib::signal_timeout().connect(timer_slot, TIMER_MS);
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

52) }
53) 
54) /// virtual destructor
55) MainWindow::~MainWindow()
56) {
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

57)   // stop timer
58)   m_timer.disconnect();
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

59) }
60) 
Stefan Schuermans implement drawing pixels

Stefan Schuermans authored 7 years ago

61) /// set configuration object
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

62) void MainWindow::setConfig(Config &config)
Stefan Schuermans implement drawing pixels

Stefan Schuermans authored 7 years ago

63) {
64)   m_config = &config;
65)   m_draw->setConfig(config);
66) }
67) 
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

68) /// window is being hidden
69) void MainWindow::on_hide()
70) {
71)   // leave main loop
72)   Gtk::Main::quit();
73) }
74) 
75) /// set status bar text
76) void MainWindow::set_status(std::string const &txt)
77) {
78)   m_status->pop();
79)   m_status->push(txt);
80) }
81)