]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormText.C
A real, LyX label dialog. Part 2: xforms.
[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 "xformsBC.h"
14 #include "ControlCommand.h"
15 #include "FormText.h"
16 #include "forms/form_text.h"
17
18 #include "support/lstrings.h"
19
20 #include FORMS_H_LOCATION
21
22 typedef FormController<ControlCommand, FormView<FD_text> > base_class;
23
24 FormText::FormText(Dialog & parent, string const & title)
25         : base_class(parent, title)
26 {}
27
28
29 void FormText::build()
30 {
31         dialog_.reset(build_text(this));
32
33         fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
34         setPrehandler(dialog_->input_text);
35
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);
41
42         bc().addReadOnly(dialog_->input_text);
43 }
44
45
46 void FormText::update()
47 {
48         string const contents = trim(controller().params().getContents());
49         fl_set_input(dialog_->input_text, contents.c_str());
50
51         bc().valid(!contents.empty());
52 }
53
54
55 void FormText::apply()
56 {
57         controller().params().setContents(fl_get_input(dialog_->input_text));
58 }