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"
25 using lyx::support::compare;
28 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
30 FormBibitem::FormBibitem(Dialog & parent)
31 : base_class(parent, _("Bibliography Entry"))
35 void FormBibitem::build()
37 dialog_.reset(build_bibitem(this));
39 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
40 fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
42 setPrehandler(dialog_->input_key);
43 setPrehandler(dialog_->input_label);
45 // Manage the ok, apply, restore and cancel/close buttons
46 bcview().setOK(dialog_->button_ok);
47 bcview().setCancel(dialog_->button_close);
49 bcview().addReadOnly(dialog_->input_key);
50 bcview().addReadOnly(dialog_->input_label);
52 // set up the tooltips
53 string str = _("Key used within LyX document.");
54 tooltips().init(dialog_->input_key, str);
55 str = _("Label used for final output.");
56 tooltips().init(dialog_->input_label, str);
60 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
63 if (!compare(fl_get_input(dialog_->input_key), ""))
64 return ButtonPolicy::SMI_NOOP;
66 return ButtonPolicy::SMI_VALID;
70 void FormBibitem::update()
72 fl_set_input(dialog_->input_key,
73 controller().params().getContents().c_str());
74 fl_set_input(dialog_->input_label,
75 controller().params().getOptions().c_str());
79 void FormBibitem::apply()
81 controller().params().setContents(fl_get_input(dialog_->input_key));
82 controller().params().setOptions(fl_get_input(dialog_->input_label));