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 "lyx_forms.h"
21 #include "support/lstrings.h" // compare
23 using namespace lyx::support;
25 typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
27 FormBibitem::FormBibitem(Dialog & parent)
28 : base_class(parent, _("Bibliography Entry"))
32 void FormBibitem::build()
34 dialog_.reset(build_bibitem(this));
36 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
37 fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
39 setPrehandler(dialog_->input_key);
40 setPrehandler(dialog_->input_label);
42 // Manage the ok, apply, restore and cancel/close buttons
43 bcview().setOK(dialog_->button_ok);
44 bcview().setCancel(dialog_->button_close);
46 bcview().addReadOnly(dialog_->input_key);
47 bcview().addReadOnly(dialog_->input_label);
49 // set up the tooltips
50 string str = _("Key used within LyX document.");
51 tooltips().init(dialog_->input_key, str);
52 str = _("Label used for final output.");
53 tooltips().init(dialog_->input_label, str);
57 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
60 if (!compare(fl_get_input(dialog_->input_key), ""))
61 return ButtonPolicy::SMI_NOOP;
63 return ButtonPolicy::SMI_VALID;
67 void FormBibitem::update()
69 fl_set_input(dialog_->input_key,
70 controller().params().getContents().c_str());
71 fl_set_input(dialog_->input_label,
72 controller().params().getOptions().c_str());
76 void FormBibitem::apply()
78 controller().params().setContents(fl_get_input(dialog_->input_key));
79 controller().params().setOptions(fl_get_input(dialog_->input_label));