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 // Workaround dumb xforms sizing bug
60 fl_set_input_return(dialog_->database, FL_RETURN_CHANGED);
61 fl_set_input_return(dialog_->style, FL_RETURN_CHANGED);
63 // Manage the ok, apply, restore and cancel/close buttons
64 bc().setOK(dialog_->button_ok);
65 bc().setCancel(dialog_->button_cancel);
68 bc().addReadOnly(dialog_->database);
69 bc().addReadOnly(dialog_->style);
73 bool FormBibtex::input(FL_OBJECT *, long)
76 if (!compare(fl_get_input(dialog_->database),""))
83 void FormBibtex::update()
85 fl_set_input(dialog_->database, params.getContents().c_str());
86 fl_set_input(dialog_->style, params.getOptions().c_str());
87 // Surely, this should reset the buttons to their original state?
88 // It doesn't. Instead "Restore" becomes a "Close"
90 bc().readOnly(lv_->buffer()->isReadonly());
94 void FormBibtex::apply()
96 if (lv_->buffer()->isReadonly())
99 params.setContents(fl_get_input(dialog_->database));
100 params.setOptions(fl_get_input(dialog_->style));
103 // Only update if contents have changed
104 if (params != inset_->params()) {
105 if (params.getContents() != inset_->params().getContents())
106 lv_->view()->ChangeCitationsIfUnique(
107 inset_->params().getContents(), params.getContents());
109 inset_->setParams(params);
110 lv_->view()->updateInset(inset_, true);
112 // We need to do a redraw because the maximum
113 // InsetBibKey width could have changed
114 lv_->view()->redraw();
115 lv_->view()->fitCursor(lv_->view()->getLyXText());
118 lyxerr[Debug::GUI] << "Editing non-existent bibtex inset !" << endl;