]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / xforms / FormBibitem.C
1 /**
2  * \file FormBibitem.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  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "FormBibitem.h"
15 #include "ControlCommand.h"
16 #include "forms/form_bibitem.h"
17
18 #include "Tooltips.h"
19 #include "xformsBC.h"
20
21 #include "support/lstrings.h" // compare
22
23 #include "lyx_forms.h"
24
25 using std::string;
26
27
28 namespace lyx {
29
30 using support::compare;
31
32 namespace frontend {
33
34
35 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
36
37 FormBibitem::FormBibitem(Dialog & parent)
38         : base_class(parent, _("Bibliography Entry"))
39 {}
40
41
42 void FormBibitem::build()
43 {
44         dialog_.reset(build_bibitem(this));
45
46         fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
47         fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
48
49         setPrehandler(dialog_->input_key);
50         setPrehandler(dialog_->input_label);
51
52         // Manage the ok, apply, restore and cancel/close buttons
53         bcview().setOK(dialog_->button_ok);
54         bcview().setCancel(dialog_->button_close);
55
56         bcview().addReadOnly(dialog_->input_key);
57         bcview().addReadOnly(dialog_->input_label);
58
59         // set up the tooltips
60         string str = _("Key used within LyX document.");
61         tooltips().init(dialog_->input_key, str);
62         str = _("Label used for final output.");
63         tooltips().init(dialog_->input_label, str);
64 }
65
66
67 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
68 {
69         // minimal validation
70         if (!compare(fl_get_input(dialog_->input_key), ""))
71                 return ButtonPolicy::SMI_NOOP;
72
73         return ButtonPolicy::SMI_VALID;
74 }
75
76
77 void FormBibitem::update()
78 {
79         fl_set_input(dialog_->input_key,
80                      controller().params().getContents().c_str());
81         fl_set_input(dialog_->input_label,
82                      controller().params().getOptions().c_str());
83 }
84
85
86 void FormBibitem::apply()
87 {
88         controller().params().setContents(fl_get_input(dialog_->input_key));
89         controller().params().setOptions(fl_get_input(dialog_->input_label));
90 }
91
92 } // namespace frontend
93 } // namespace lyx