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"
16 #include "forms/form_text.h"
18 #include "support/lstrings.h"
20 #include FORMS_H_LOCATION
22 typedef FormController<ControlCommand, FormView<FD_text> > base_class;
24 FormText::FormText(Dialog & parent, string const & title)
25 : base_class(parent, title)
29 void FormText::build()
31 dialog_.reset(build_text(this));
33 fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
34 setPrehandler(dialog_->input_text);
36 // Manage the ok, apply, restore and cancel/close buttons
37 bc().setOK(dialog_->button_ok);
38 bc().setApply(dialog_->button_apply);
39 bc().setCancel(dialog_->button_close);
40 bc().setRestore(dialog_->button_restore);
42 bc().addReadOnly(dialog_->input_text);
46 void FormText::update()
48 string const contents = trim(controller().params().getContents());
49 fl_set_input(dialog_->input_text, contents.c_str());
51 bc().valid(!contents.empty());
55 void FormText::apply()
57 controller().params().setContents(fl_get_input(dialog_->input_text));