3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
15 #include "ControlCommand.h"
16 #include "FormBibitem.h"
18 #include "forms/form_bibitem.h"
19 #include FORMS_H_LOCATION
21 #include "support/lstrings.h" // compare
23 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
25 FormBibitem::FormBibitem(Dialog & parent)
26 : base_class(parent, _("Bibliography Entry"))
30 void FormBibitem::build()
32 dialog_.reset(build_bibitem(this));
34 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
35 fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
37 setPrehandler(dialog_->input_key);
38 setPrehandler(dialog_->input_label);
40 // Manage the ok, apply, restore and cancel/close buttons
41 bcview().setOK(dialog_->button_ok);
42 bcview().setCancel(dialog_->button_close);
44 bcview().addReadOnly(dialog_->input_key);
45 bcview().addReadOnly(dialog_->input_label);
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);
55 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
58 if (!compare(fl_get_input(dialog_->input_key), ""))
59 return ButtonPolicy::SMI_NOOP;
61 return ButtonPolicy::SMI_VALID;
65 void FormBibitem::update()
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());
74 void FormBibitem::apply()
76 controller().params().setContents(fl_get_input(dialog_->input_key));
77 controller().params().setOptions(fl_get_input(dialog_->input_label));