-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (43 loc) · 1.04 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (43 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <gtkmm.h>
class HelloWorld : public Gtk::Window {
public:
HelloWorld();
virtual ~HelloWorld();
protected:
//Signal handlers:
void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
private:
int counter = 0;
};
int main (int argc, char *argv[]) {
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
HelloWorld helloworld;
//Shows the window and returns when it is closed.
return app->run(helloworld);
}
HelloWorld::HelloWorld()
: m_button("Hello World") { //lable button
// Window border width
set_border_width(10);
// Signal handler
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&HelloWorld::on_button_clicked));
//Add button to window
add(m_button);
// Shows the widget
m_button.show();
}
HelloWorld::~HelloWorld() {
}
void HelloWorld::on_button_clicked() {
counter++;
if(counter > 3) {
std::cout << "Bye, bye!" << std::endl;
hide();
}else{
std::cout << "Hello World" << std::endl;
}
}