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"
29 FormBibtex::FormBibtex(LyXView * lv, Dialogs * d)
30 : FormCommand(lv, d, _("BibTeX Database"), new OkCancelReadOnlyPolicy),
33 d->showBibtex.connect(slot(this, &FormBibtex::showInset));
37 FormBibtex::~FormBibtex()
43 FL_FORM * FormBibtex::form() const
51 void FormBibtex::connect()
53 fl_set_form_maxsize(form(), 2 * minw_, minh_);
54 FormCommand::connect();
58 void FormBibtex::build()
60 dialog_ = build_bibtex();
62 // Workaround dumb xforms sizing bug
66 fl_set_input_return(dialog_->database, FL_RETURN_CHANGED);
67 fl_set_input_return(dialog_->style, FL_RETURN_CHANGED);
69 // Manage the ok, apply, restore and cancel/close buttons
70 bc_.setOK(dialog_->button_ok);
71 bc_.setCancel(dialog_->button_cancel);
74 bc_.addReadOnly(dialog_->database);
75 bc_.addReadOnly(dialog_->style);
79 bool FormBibtex::input(FL_OBJECT *, long)
82 if (!compare(fl_get_input(dialog_->database),""))
89 void FormBibtex::update()
91 fl_set_input(dialog_->database, params.getContents().c_str());
92 fl_set_input(dialog_->style, params.getOptions().c_str());
93 // Surely, this should reset the buttons to their original state?
94 // It doesn't. Instead "Restore" becomes a "Close"
96 bc_.readOnly(lv_->buffer()->isReadonly());
100 void FormBibtex::apply()
102 if (lv_->buffer()->isReadonly())
105 params.setContents(fl_get_input(dialog_->database));
106 params.setOptions(fl_get_input(dialog_->style));
109 // Only update if contents have changed
110 if (params != inset_->params()) {
111 if (params.getContents() != inset_->params().getContents())
112 lv_->view()->ChangeCitationsIfUnique(
113 inset_->params().getContents(), params.getContents());
115 inset_->setParams(params);
116 lv_->view()->updateInset(inset_, true);
118 // We need to do a redraw because the maximum
119 // InsetBibKey width could have changed
120 lv_->view()->redraw();
121 lv_->view()->fitCursor(lv_->view()->getLyXText());
124 lyxerr[Debug::GUI] << "Editing non-existent bibtex inset !" << endl;