-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathButton.cpp
60 lines (51 loc) · 1.73 KB
/
Button.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
#include <gtkmm.h>
using namespace Glib;
using namespace Gtk;
class WindowMain : public Window {
public:
WindowMain() {
add(scrolledWindow);
scrolledWindow.add(fixed);
button1.set_label("button1");
button1.signal_button_release_event().connect([&](GdkEventButton*) {
label1.set_text(ustring::compose("button1 clicked %1 times", ++button1Clicked));
return true;
});
fixed.add(button1);
fixed.move(button1, 50, 50);
button2.set_label("button2");
button2.set_size_request(200, 75);
button2.signal_button_release_event().connect([&](GdkEventButton*) {
label2.set_text(ustring::compose("button2 clicked %1 times", ++button2Clicked));
return true;
});
fixed.add(button2);
fixed.move(button2, 50, 100);
label1.set_text(ustring::compose("button1 clicked %1 times", button1Clicked));
fixed.add(label1);
fixed.move(label1, 50, 200);
label2.set_text(ustring::compose("button2 clicked %1 times", button2Clicked));
fixed.add(label2);
fixed.move(label2, 50, 230);
set_title("Button example");
resize(300, 300);
show_all();
}
private:
Fixed fixed;
ScrolledWindow scrolledWindow;
Button button1;
Button button2;
Label label1;
Label label2;
int button1Clicked = 0;
int button2Clicked = 0;
};
int main(int argc, char* argv[]) {
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", true, NULL);
g_object_set(gtk_settings_get_default(), "gtk-button-images", true, NULL);
//gtk_settings_set_long_property(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", 0, nullptr);
auto application = Application::create(argc, argv);
WindowMain window;
return application->run(window);
}