]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
Introduce LFUN_PRINT.
[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 lyx::support::compare;
26
27 using std::string;
28
29
30 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
31
32 FormBibitem::FormBibitem(Dialog & parent)
33         : base_class(parent, _("Bibliography Entry"))
34 {}
35
36
37 void FormBibitem::build()
38 {
39         dialog_.reset(build_bibitem(this));
40
41         fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
42         fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
43
44         setPrehandler(dialog_->input_key);
45         setPrehandler(dialog_->input_label);
46
47         // Manage the ok, apply, restore and cancel/close buttons
48         bcview().setOK(dialog_->button_ok);
49         bcview().setCancel(dialog_->button_close);
50
51         bcview().addReadOnly(dialog_->input_key);
52         bcview().addReadOnly(dialog_->input_label);
53
54         // set up the tooltips
55         string str = _("Key used within LyX document.");
56         tooltips().init(dialog_->input_key, str);
57         str = _("Label used for final output.");
58         tooltips().init(dialog_->input_label, str);
59 }
60
61
62 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
63 {
64         // minimal validation
65         if (!compare(fl_get_input(dialog_->input_key), ""))
66                 return ButtonPolicy::SMI_NOOP;
67
68         return ButtonPolicy::SMI_VALID;
69 }
70
71
72 void FormBibitem::update()
73 {
74         fl_set_input(dialog_->input_key,
75                      controller().params().getContents().c_str());
76         fl_set_input(dialog_->input_label,
77                      controller().params().getOptions().c_str());
78 }
79
80
81 void FormBibitem::apply()
82 {
83         controller().params().setContents(fl_get_input(dialog_->input_key));
84         controller().params().setOptions(fl_get_input(dialog_->input_label));
85 }