]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormText.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / xforms / FormText.C
1 /**
2  * \file FormText.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "FormText.h"
14 #include "ControlCommand.h"
15 #include "forms/form_text.h"
16
17 #include "xformsBC.h"
18 #include "forms_gettext.h"
19
20 #include "controllers/ButtonController.h"
21
22 #include "support/lstrings.h"
23
24 #include "lyx_forms.h"
25
26 using std::string;
27
28 namespace lyx {
29
30 using support::trim;
31
32 namespace frontend {
33
34 typedef FormController<ControlCommand, FormView<FD_text> > base_class;
35
36 FormText::FormText(Dialog & parent, string const & title, string const & label)
37         : base_class(parent, title), label_(label)
38 {}
39
40
41 void FormText::build()
42 {
43         dialog_.reset(build_text(this));
44
45         fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
46         setPrehandler(dialog_->input_text);
47
48         fl_set_object_label(dialog_->input_text, idex(label_).c_str());
49         fl_set_button_shortcut(dialog_->input_text, scex(label_).c_str(), 1);
50
51         // Manage the ok, apply, restore and cancel/close buttons
52         bcview().setOK(dialog_->button_ok);
53         bcview().setApply(dialog_->button_apply);
54         bcview().setCancel(dialog_->button_close);
55         bcview().setRestore(dialog_->button_restore);
56
57         bcview().addReadOnly(dialog_->input_text);
58 }
59
60
61 void FormText::update()
62 {
63         string const contents = trim(controller().params().getContents());
64         fl_set_input(dialog_->input_text, contents.c_str());
65
66         bc().valid(!contents.empty());
67 }
68
69
70 void FormText::apply()
71 {
72         controller().params().setContents(fl_get_input(dialog_->input_text));
73 }
74
75 } // namespace frontend
76 } // namespace lyx