X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Finput.cpp;h=e2b0ae0e06a175f8215b8299248fd07709ddfd49;hb=17c219cff8f859978ec1274786319478cc99450c;hp=42cc0783dd994f72c75d6db755a19cfb9950ea74;hpb=444c7efb2fadb10e98197a62b791829d821370c0;p=r2c2.git diff --git a/source/designer/input.cpp b/source/designer/input.cpp index 42cc078..e2b0ae0 100644 --- a/source/designer/input.cpp +++ b/source/designer/input.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2008, 2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -15,8 +15,9 @@ Distributed under the GPL using namespace std; using namespace Msp; -::Input::Input(Designer &d, const string &title, const string &text): - Panel(d.get_ui_resources()), +InputDialog::InputDialog(Designer &d, const string &title, const string &text): + GLtk::Widget(d.get_ui_resources()), + GLtk::Dialog(d.get_ui_resources()), designer(d) { set_size(300, 100); @@ -30,15 +31,13 @@ using namespace Msp; GLtk::Button *btn; - add(*(btn=new GLtk::Button(res, "Cncl"))); + add_button(*(btn=new GLtk::Button(res, "Cncl")), 0); btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24)); btn->set_style("red"); - btn->signal_clicked.connect(signal_cancel); - add(*(btn=new GLtk::Button(res, "OK"))); + add_button(*(btn=new GLtk::Button(res, "OK")), 1); btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24)); btn->set_style("green"); - btn->signal_clicked.connect(signal_accept); designer.get_root().add(*this); const GLtk::Geometry &rgeom=designer.get_root().get_geometry(); @@ -46,17 +45,18 @@ using namespace Msp; entry->set_focus(); } -const string &::Input::get_text() const -{ - return entry->get_text(); -} - -void ::Input::key_press(unsigned key, unsigned mod, wchar_t ch) +void InputDialog::key_press(unsigned key, unsigned mod, wchar_t ch) { if(key==Msp::Input::KEY_ENTER) - signal_accept.emit(); + response(1); else if(key==Msp::Input::KEY_ESC) - signal_cancel.emit(); + response(0); else - Panel::key_press(key, mod, ch); + Dialog::key_press(key, mod, ch); +} + +void InputDialog::on_response(int code) +{ + if(code) + signal_accept.emit(entry->get_text()); }