namespace Msp {
namespace GLtk {
-Dialog::Dialog():
- stale(false)
-{ }
-
void Dialog::add_button(Button &button, int code)
{
add(button);
- button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
+ connect_button(button, code);
+}
+
+void Dialog::add_button(unique_ptr<Button> button, int code)
+{
+ Button &b = *button;
+ add(move(button));
+ connect_button(b, code);
}
-void Dialog::button_release(int x, int y, unsigned button)
+Button &Dialog::add_button(const string &text, int code)
{
- Panel::button_release(x, y, button);
- if(stale)
- delete this;
+ Button &b = add_new<Button>(text);
+ connect_button(b, code);
+ return b;
}
-void Dialog::key_release(unsigned key, unsigned mod)
+void Dialog::set_modal(bool m)
{
- Panel::key_release(key, mod);
- if(stale)
- delete this;
+ if(m)
+ {
+ set_focus();
+ if(state&FOCUS)
+ signal_grab_pointer.emit();
+ }
+ else
+ signal_ungrab_pointer.emit();
+}
+
+void Dialog::connect_button(Button &button, int code)
+{
+ button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
}
void Dialog::response(int code)
{
on_response(code);
signal_response.emit(code);
- stale = true;
+ set_visible(false);
}
void Dialog::Loader::action_button(const string &n, int c)
{
- RefPtr<Button> btn = new Button();
+ unique_ptr<Button> btn = make_unique<Button>();
load_sub(*btn);
- obj.add_button(*btn.get(), c);
- last_widget = wdg_map[n] = btn.release();
+ Widget *wdg = btn.get();
+ obj.add_button(move(btn), c);
+ last_widget = wdg_map[n] = wdg;
}
} // namespace GLtk