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"))
32 d->showBibtex.connect(slot(this, &FormBibtex::showInset));
36 FL_FORM * FormBibtex::form() const
44 void FormBibtex::connect()
46 fl_set_form_maxsize(form(), 2 * minw_, minh_);
47 FormCommand::connect();
51 void FormBibtex::build()
53 dialog_.reset(build_bibtex());
55 // Workaround dumb xforms sizing bug
59 fl_set_input_return(dialog_->database, FL_RETURN_CHANGED);
60 fl_set_input_return(dialog_->style, FL_RETURN_CHANGED);
62 // Manage the ok, apply, restore and cancel/close buttons
63 bc().setOK(dialog_->button_ok);
64 bc().setCancel(dialog_->button_cancel);
67 bc().addReadOnly(dialog_->database);
68 bc().addReadOnly(dialog_->style);
72 bool FormBibtex::input(FL_OBJECT *, long)
75 if (!compare(fl_get_input(dialog_->database),""))
82 void FormBibtex::update()
84 fl_set_input(dialog_->database, params.getContents().c_str());
85 fl_set_input(dialog_->style, params.getOptions().c_str());
86 // Surely, this should reset the buttons to their original state?
87 // It doesn't. Instead "Restore" becomes a "Close"
89 bc().readOnly(lv_->buffer()->isReadonly());
93 void FormBibtex::apply()
95 if (lv_->buffer()->isReadonly())
98 params.setContents(fl_get_input(dialog_->database));
99 params.setOptions(fl_get_input(dialog_->style));
102 // Only update if contents have changed
103 if (params != inset_->params()) {
104 if (params.getContents() != inset_->params().getContents())
105 lv_->view()->ChangeCitationsIfUnique(
106 inset_->params().getContents(), params.getContents());
108 inset_->setParams(params);
109 lv_->view()->updateInset(inset_, true);
111 // We need to do a redraw because the maximum
112 // InsetBibKey width could have changed
113 lv_->view()->redraw();
114 lv_->view()->fitCursor(lv_->view()->getLyXText());
117 lyxerr[Debug::GUI] << "Editing non-existent bibtex inset !" << endl;