| 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_VBox(Gtk::Orientation::VERTICAL), |
| 22 |
m_Button_Close("Close") |
| 23 |
{ |
| 24 |
set_title("Gtk::Entry"); |
| 25 |
|
| 26 |
set_child(m_VBox); |
| 27 |
|
| 28 |
m_Entry.set_max_length(50); |
| 29 |
m_Entry.set_text("Hello world"); |
| 30 |
m_VBox.append(m_Entry); |
| 31 |
|
| 32 |
//Change the progress fraction every 0.1 second: |
| 33 |
Glib::signal_timeout().connect( |
| 34 |
sigc::mem_fun(*this, &ExampleWindow::on_timeout), |
| 35 |
100 |
| 36 |
); |
| 37 |
|
| 38 |
m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this, |
| 39 |
&ExampleWindow::on_button_close) ); |
| 40 |
m_VBox.append(m_Button_Close); |
| 41 |
set_default_widget(m_Button_Close); |
| 42 |
} |
| 43 |
|
| 44 |
ExampleWindow::~ExampleWindow() |
| 45 |
{ |
| 46 |
} |
| 47 |
|
| 48 |
bool ExampleWindow::on_timeout() |
| 49 |
{ |
| 50 |
static double fraction = 0; |
| 51 |
m_Entry.set_progress_fraction(fraction); |
| 52 |
|
| 53 |
fraction += 0.01; |
| 54 |
if(fraction > 1) |
| 55 |
fraction = 0; |
| 56 |
|
| 57 |
return true; |
| 58 |
} |
| 59 |
|
| 60 |
void ExampleWindow::on_button_close() |
| 61 |
{ |
| 62 |
close(); |
| 63 |
} |