| 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 "examplewindow.h" |
| 18 |
#include <iostream> |
| 19 |
|
| 20 |
ExampleWindow::ExampleWindow() |
| 21 |
: m_button(0.0, 100.0, 2.0) |
| 22 |
{ |
| 23 |
set_default_size(300, 200); |
| 24 |
|
| 25 |
set_title("ScaleButton Example"); |
| 26 |
|
| 27 |
// These are the icons used by the deprecated VolumeButton widget, |
| 28 |
// although it can alternatively use the corresponding symbolic icons. |
| 29 |
std::vector<Glib::ustring> icons; |
| 30 |
icons.push_back("audio-volume-muted"); // lowest value |
| 31 |
icons.push_back("audio-volume-high"); // highest value |
| 32 |
icons.push_back("audio-volume-low"); // 0% < value < 50% |
| 33 |
icons.push_back("audio-volume-medium"); // 50% < value < 100% |
| 34 |
m_button.set_icons(icons); |
| 35 |
|
| 36 |
m_grid.set_margin(12); |
| 37 |
set_child(m_grid); |
| 38 |
m_grid.set_expand(true); |
| 39 |
|
| 40 |
m_grid.attach(m_button, 1, 1); |
| 41 |
m_button.set_valign(Gtk::Align::END); |
| 42 |
m_button.set_halign(Gtk::Align::END); |
| 43 |
|
| 44 |
m_button.set_value(30.0); |
| 45 |
m_button.signal_value_changed().connect( |
| 46 |
sigc::mem_fun(*this, &ExampleWindow::on_value_changed)); |
| 47 |
} |
| 48 |
|
| 49 |
ExampleWindow::~ExampleWindow() |
| 50 |
{ |
| 51 |
} |
| 52 |
|
| 53 |
void ExampleWindow::on_value_changed(double value) |
| 54 |
{ |
| 55 |
std::cout << "Value: " << value << std::endl; |
| 56 |
} |