-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathColorDialog.cpp
41 lines (34 loc) · 984 Bytes
/
ColorDialog.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
#include <gtkmm.h>
using namespace Glib;
using namespace Gtk;
class WindowMain : public Window {
public:
WindowMain() {
add(scrolledWindow);
scrolledWindow.add(fixed);
button.set_label("Color...");
fixed.add(button);
fixed.move(button, 10, 10);
button.signal_button_release_event().connect([&](GdkEventButton*) {
ColorChooserDialog colorDialog("");
colorDialog.set_rgba(get_style_context()->get_background_color());
colorDialog.set_transient_for(*this);
colorDialog.set_modal(true);
if (colorDialog.run() == RESPONSE_OK)
override_background_color(colorDialog.get_rgba());
return true;
});
set_title("ColorDialog example");
resize(300, 300);
show_all();
}
private:
Fixed fixed;
ScrolledWindow scrolledWindow;
Button button;
};
int main(int argc, char* argv[]) {
auto application = Application::create(argc, argv);
WindowMain window;
return application->run(window);
}