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