3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Angus Leeming
12 #include FORMS_H_LOCATION
15 #pragma implementation
20 #include "FormBibtex.h"
23 #include "form_bibtex.h"
30 FormBibtex::FormBibtex(LyXView * lv, Dialogs * d)
31 : FormCommand(lv, d, _("BibTeX Database"))
33 d->showBibtex.connect(slot(this, &FormBibtex::showInset));
37 FL_FORM * FormBibtex::form() const
45 void FormBibtex::connect()
47 fl_set_form_maxsize(form(), 2 * minw_, minh_);
48 FormCommand::connect();
52 void FormBibtex::build()
54 dialog_.reset(build_bibtex());
56 fl_set_input_return(dialog_->database, FL_RETURN_CHANGED);
57 fl_set_input_return(dialog_->style, FL_RETURN_CHANGED);
59 // Manage the ok, apply, restore and cancel/close buttons
60 bc().setOK(dialog_->button_ok);
61 bc().setCancel(dialog_->button_cancel);
64 bc().addReadOnly(dialog_->database);
65 bc().addReadOnly(dialog_->style);
69 bool FormBibtex::input(FL_OBJECT *, long)
72 if (!compare(fl_get_input(dialog_->database),""))
79 void FormBibtex::update()
81 fl_set_input(dialog_->database, params.getContents().c_str());
82 fl_set_input(dialog_->style, params.getOptions().c_str());
83 // Surely, this should reset the buttons to their original state?
84 // It doesn't. Instead "Restore" becomes a "Close"
86 bc().readOnly(lv_->buffer()->isReadonly());
90 void FormBibtex::apply()
92 if (lv_->buffer()->isReadonly())
95 params.setContents(fl_get_input(dialog_->database));
96 params.setOptions(fl_get_input(dialog_->style));
99 // Only update if contents have changed
100 if (params != inset_->params()) {
101 if (params.getContents() != inset_->params().getContents())
102 lv_->view()->ChangeCitationsIfUnique(
103 inset_->params().getContents(), params.getContents());
105 inset_->setParams(params);
106 lv_->view()->updateInset(inset_, true);
108 // We need to do a redraw because the maximum
109 // InsetBibKey width could have changed
110 lv_->view()->redraw();
111 lv_->view()->fitCursor(lv_->view()->getLyXText());
114 lyxerr[Debug::GUI] << "Editing non-existent bibtex inset !" << endl;