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