3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
14 #include "ControlCommand.h"
15 #include "forms/form_text.h"
18 #include "forms_gettext.h"
20 #include "controllers/ButtonController.h"
22 #include "support/lstrings.h"
24 #include "lyx_forms.h"
26 using lyx::support::trim;
31 typedef FormController<ControlCommand, FormView<FD_text> > base_class;
33 FormText::FormText(Dialog & parent, string const & title, string const & label)
34 : base_class(parent, title), label_(label)
38 void FormText::build()
40 dialog_.reset(build_text(this));
42 fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
43 setPrehandler(dialog_->input_text);
45 fl_set_object_label(dialog_->input_text, idex(label_).c_str());
46 fl_set_button_shortcut(dialog_->input_text, scex(label_).c_str(), 1);
48 // Manage the ok, apply, restore and cancel/close buttons
49 bcview().setOK(dialog_->button_ok);
50 bcview().setApply(dialog_->button_apply);
51 bcview().setCancel(dialog_->button_close);
52 bcview().setRestore(dialog_->button_restore);
54 bcview().addReadOnly(dialog_->input_text);
58 void FormText::update()
60 string const contents = trim(controller().params().getContents());
61 fl_set_input(dialog_->input_text, contents.c_str());
63 bc().valid(!contents.empty());
67 void FormText::apply()
69 controller().params().setContents(fl_get_input(dialog_->input_text));