X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdialog.cpp;h=0b22e9874a8d1578266fe6b98a95ddca84cf3cc5;hb=32d668c967c881ed386be22f17e3477a4405436b;hp=3e09783dcb5eb36350d4c4158b9139ae33ed7fd0;hpb=0af3c2393bd00f39db3bfaf5b78a7a44f0fd5ff1;p=libs%2Fgltk.git diff --git a/source/dialog.cpp b/source/dialog.cpp index 3e09783..0b22e98 100644 --- a/source/dialog.cpp +++ b/source/dialog.cpp @@ -1,19 +1,12 @@ -/* $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(const Resources &r): - Widget(r), - Panel(r), +Dialog::Dialog(): stale(false) { } @@ -23,6 +16,18 @@ void Dialog::add_button(Button &button, int code) button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code)); } +void Dialog::set_modal(bool m) +{ + if(m) + { + set_focus(); + if(state&FOCUS) + signal_grab_pointer.emit(); + } + else + signal_ungrab_pointer.emit(); +} + void Dialog::button_release(int x, int y, unsigned button) { Panel::button_release(x, y, button); @@ -30,11 +35,12 @@ void Dialog::button_release(int x, int y, unsigned button) delete this; } -void Dialog::key_release(unsigned key, unsigned mod) +bool Dialog::key_release(unsigned key, unsigned mod) { - Panel::key_release(key, mod); + bool result = Panel::key_release(key, mod); if(stale) delete this; + return result; } void Dialog::response(int code) @@ -44,5 +50,20 @@ void Dialog::response(int code) stale = true; } + +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) +{ + RefPtr