X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdialog.cpp;h=5e5e390e7cadadf91d3e5af4e978d4e3f333dc33;hb=b4d0a86b77fb5146f5a4f6c76690c16204210f1a;hp=5a03102f463dd8b551e5606253c2b0426aa683a4;hpb=91997dd3189b93a67179822ec2fed5f2a7bddb74;p=libs%2Fgltk.git diff --git a/source/dialog.cpp b/source/dialog.cpp index 5a03102..5e5e390 100644 --- a/source/dialog.cpp +++ b/source/dialog.cpp @@ -1,45 +1,49 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "button.h" #include "dialog.h" +using namespace std; + 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)); } -void Dialog::button_release(int x, int y, unsigned button) -{ - Panel::button_release(x, y, button); - if(stale) - delete this; -} - -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::response(int code) { on_response(code); signal_response.emit(code); - stale = true; + set_visible(false); +} + + +Dialog::Loader::Loader(Dialog &d, WidgetMap &wm): + DerivedObjectLoader(d, wm) +{ + add("action_button", &Loader::action_button); +} + +void Dialog::Loader::action_button(const string &n, int c) +{ + unique_ptr