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.
14 #include "FormBibitem.h"
15 #include "ControlCommand.h"
16 #include "forms/form_bibitem.h"
21 #include "support/lstrings.h" // compare
23 #include "lyx_forms.h"
30 using support::compare;
35 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
37 FormBibitem::FormBibitem(Dialog & parent)
38 : base_class(parent, _("Bibliography Entry"))
42 void FormBibitem::build()
44 dialog_.reset(build_bibitem(this));
46 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
47 fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
49 setPrehandler(dialog_->input_key);
50 setPrehandler(dialog_->input_label);
52 // Manage the ok, apply, restore and cancel/close buttons
53 bcview().setOK(dialog_->button_ok);
54 bcview().setCancel(dialog_->button_close);
56 bcview().addReadOnly(dialog_->input_key);
57 bcview().addReadOnly(dialog_->input_label);
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);
67 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
70 if (!compare(fl_get_input(dialog_->input_key), ""))
71 return ButtonPolicy::SMI_NOOP;
73 return ButtonPolicy::SMI_VALID;
77 void FormBibitem::update()
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());
86 void FormBibitem::apply()
88 controller().params().setContents(fl_get_input(dialog_->input_key));
89 controller().params().setOptions(fl_get_input(dialog_->input_label));
92 } // namespace frontend