Debian Codegraph @

examples/book/buttons/button/buttons.cc

raw
1 /* gtkmm example Copyright (C) 2002 gtkmm development team
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include "buttons.h"
18 #include <gtkmm/box.h>
19 #include <gtkmm/image.h>
20 #include <gtkmm/label.h>
21 #include <iostream>
22
23 Buttons::Buttons()
24 {
25 // This corresponds to Gtk::Bin::add_pixlabel("info.xpm", "cool button") in gtkmm3.
26 //Create Image and Label widgets:
27 auto pmap = Gtk::make_managed<Gtk::Image>("info.xpm");
28 auto label = Gtk::make_managed<Gtk::Label>("cool button");
29 label->set_expand(true);
30
31 //Put them in a Box:
32 auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 5);
33 hbox->append(*pmap);
34 hbox->append(*label);
35
36 //And put that Box in the button:
37 m_button.set_child(*hbox);
38
39 set_title("Pixmap'd buttons!");
40
41 m_button.signal_clicked().connect( sigc::mem_fun(*this,
42 &Buttons::on_button_clicked) );
43
44 m_button.set_margin(10);
45 set_child(m_button);
46 }
47
48 Buttons::~Buttons()
49 {
50 }
51
52 void Buttons::on_button_clicked()
53 {
54 std::cout << "The Button was clicked." << std::endl;
55 }