]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormText.C
Set the label on the FormText input widget from Dialogs3.C.
[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 #include "forms_gettext.h"
18
19 #include "support/lstrings.h"
20
21 #include FORMS_H_LOCATION
22
23 typedef FormController<ControlCommand, FormView<FD_text> > base_class;
24
25 FormText::FormText(Dialog & parent, string const & title, string const & label)
26         : base_class(parent, title), label_(label)
27 {}
28
29
30 void FormText::build()
31 {
32         dialog_.reset(build_text(this));
33
34         fl_set_input_return(dialog_->input_text, FL_RETURN_CHANGED);
35         setPrehandler(dialog_->input_text);
36
37         fl_set_object_label(dialog_->input_text, idex(label_).c_str());
38         fl_set_button_shortcut(dialog_->input_text, scex(label_).c_str(), 1);
39
40         // Manage the ok, apply, restore and cancel/close buttons
41         bc().setOK(dialog_->button_ok);
42         bc().setApply(dialog_->button_apply);
43         bc().setCancel(dialog_->button_close);
44         bc().setRestore(dialog_->button_restore);
45
46         bc().addReadOnly(dialog_->input_text);
47 }
48
49
50 void FormText::update()
51 {
52         string const contents = trim(controller().params().getContents());
53         fl_set_input(dialog_->input_text, contents.c_str());
54
55         bc().valid(!contents.empty());
56 }
57
58
59 void FormText::apply()
60 {
61         controller().params().setContents(fl_get_input(dialog_->input_text));
62 }