]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
If I ever see another licence blurb again, it'll be too soon...
[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
13 #include <config.h>
14 #include "xformsBC.h"
15 #include "ControlCommand.h"
16 #include "FormBibitem.h"
17 #include "Tooltips.h"
18 #include "forms/form_bibitem.h"
19 #include "lyx_forms.h"
20 #include "gettext.h"
21 #include "support/lstrings.h" // compare
22
23 using namespace lyx::support;
24
25 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
26
27 FormBibitem::FormBibitem(Dialog & parent)
28         : base_class(parent, _("Bibliography Entry"))
29 {}
30
31
32 void FormBibitem::build()
33 {
34         dialog_.reset(build_bibitem(this));
35
36         fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
37         fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
38
39         setPrehandler(dialog_->input_key);
40         setPrehandler(dialog_->input_label);
41
42         // Manage the ok, apply, restore and cancel/close buttons
43         bcview().setOK(dialog_->button_ok);
44         bcview().setCancel(dialog_->button_close);
45
46         bcview().addReadOnly(dialog_->input_key);
47         bcview().addReadOnly(dialog_->input_label);
48
49         // set up the tooltips
50         string str = _("Key used within LyX document.");
51         tooltips().init(dialog_->input_key, str);
52         str = _("Label used for final output.");
53         tooltips().init(dialog_->input_label, str);
54 }
55
56
57 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
58 {
59         // minimal validation
60         if (!compare(fl_get_input(dialog_->input_key), ""))
61                 return ButtonPolicy::SMI_NOOP;
62
63         return ButtonPolicy::SMI_VALID;
64 }
65
66
67 void FormBibitem::update()
68 {
69         fl_set_input(dialog_->input_key,
70                      controller().params().getContents().c_str());
71         fl_set_input(dialog_->input_label,
72                      controller().params().getOptions().c_str());
73 }
74
75
76 void FormBibitem::apply()
77 {
78         controller().params().setContents(fl_get_input(dialog_->input_key));
79         controller().params().setOptions(fl_get_input(dialog_->input_label));
80 }