Debian Codegraph @

Source/Widgets/SpiDev.h

raw
1 #ifndef EXADRUMS_SOURCE_WIDGETS_SPIDEV_H
2 #define EXADRUMS_SOURCE_WIDGETS_SPIDEV_H
3
4 #include <libexadrums/Api/Config/SpiDevParameters_api.h>
5
6 #include <gtkmm/grid.h>
7 #include <gtkmm/spinbutton.h>
8 #include <gtkmm/adjustment.h>
9
10 #include <string>
11
12 namespace Widgets
13 {
14
15 class SpiDev : public Gtk::Grid
16 {
17 public:
18 SpiDev(const eXaDrumsApi::SpiDevParameters& params)
19 {
20 name.set_text(params.name);
21
22 cs.get_adjustment()->set_value(params.cs);
23 bus.get_adjustment()->set_value(params.bus);
24
25 this->set_column_spacing(4);
26 this->set_row_spacing(4);
27
28 this->set_margin_left(4);
29 this->set_margin_right(4);
30 this->set_margin_top(4);
31 this->set_margin_bottom(4);
32
33 this->attach(name, 0, 0, 1, 1);
34 this->attach_next_to(bus, name, Gtk::PositionType::POS_RIGHT, 1, 1);
35 this->attach_next_to(cs, bus, Gtk::PositionType::POS_RIGHT, 1, 1);
36
37 this->show_all();
38 }
39
40 auto GetName() const { return std::string{name.get_text()}; }
41 auto GetBus() const { return static_cast<int>(busAdj->get_value()); }
42 auto GetCs() const { return static_cast<int>(csAdj->get_value()); }
43
44 private:
45
46 Gtk::Entry name{};
47
48 Glib::RefPtr<Gtk::Adjustment> busAdj{Gtk::Adjustment::create(0, 0, 9)};
49 Gtk::SpinButton bus{busAdj};
50
51 Glib::RefPtr<Gtk::Adjustment> csAdj{Gtk::Adjustment::create(0, 0, 9)};
52 Gtk::SpinButton cs{csAdj};
53
54 };
55
56
57 } // namespace Widgets
58
59
60 #endif /* EXADRUMS_SOURCE_WIDGETS_SPIDEV_H */