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;
30 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
32 FormBibitem::FormBibitem(Dialog & parent)
33 : base_class(parent, _("Bibliography Entry"))
37 void FormBibitem::build()
39 dialog_.reset(build_bibitem(this));
41 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
42 fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
44 setPrehandler(dialog_->input_key);
45 setPrehandler(dialog_->input_label);
47 // Manage the ok, apply, restore and cancel/close buttons
48 bcview().setOK(dialog_->button_ok);
49 bcview().setCancel(dialog_->button_close);
51 bcview().addReadOnly(dialog_->input_key);
52 bcview().addReadOnly(dialog_->input_label);
54 // set up the tooltips
55 string str = _("Key used within LyX document.");
56 tooltips().init(dialog_->input_key, str);
57 str = _("Label used for final output.");
58 tooltips().init(dialog_->input_label, str);
62 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
65 if (!compare(fl_get_input(dialog_->input_key), ""))
66 return ButtonPolicy::SMI_NOOP;
68 return ButtonPolicy::SMI_VALID;
72 void FormBibitem::update()
74 fl_set_input(dialog_->input_key,
75 controller().params().getContents().c_str());
76 fl_set_input(dialog_->input_label,
77 controller().params().getOptions().c_str());
81 void FormBibitem::apply()
83 controller().params().setContents(fl_get_input(dialog_->input_key));
84 controller().params().setOptions(fl_get_input(dialog_->input_label));