]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormBibitem.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / FormBibitem.C
index 887c28f7a6ed7044ed145148ea1a7c145a6084fc..51bc8ffa8356d12d3e9355ffea53856fdd8123db 100644 (file)
 /**
  * \file FormBibitem.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Angus Leeming
  * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 
-#include "Dialogs.h"
+#include <config.h>
+#include "xformsBC.h"
+#include "ControlCommand.h"
 #include "FormBibitem.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "form_bibitem.h"
-#include "lyxfunc.h"
-#include "debug.h"
-
-using std::endl;
-
-FormBibitem::FormBibitem(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Bibliography Entry"), new OkCancelReadOnlyPolicy),
-         dialog_(0)
-{
-       d->showBibitem.connect(slot(this, &FormBibitem::showInset));
-}
-
+#include "Tooltips.h"
+#include "forms/form_bibitem.h"
+#include FORMS_H_LOCATION
+#include "gettext.h"
+#include "support/lstrings.h" // compare
 
-FormBibitem::~FormBibitem()
-{
-       delete dialog_;
-}
+typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
 
+FormBibitem::FormBibitem(Dialog & parent)
+       : base_class(parent, _("Bibliography Entry"))
+{}
 
-FL_FORM * FormBibitem::form() const
-{
-       if (dialog_)
-               return dialog_->form;
-       return 0;
-}
-
-
-void FormBibitem::connect()
-{
-       fl_set_form_maxsize(form(), 2 * minw_, minh_);
-       FormCommand::connect();
-}
-       
 
 void FormBibitem::build()
 {
-       dialog_ = build_bibitem();
+       dialog_.reset(build_bibitem(this));
+
+       fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
 
-       // Workaround dumb xforms sizing bug
-       minw_ = form()->w;
-       minh_ = form()->h;
+       setPrehandler(dialog_->input_key);
+       setPrehandler(dialog_->input_label);
 
-       fl_set_input_return(dialog_->key, FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->label, FL_RETURN_CHANGED);
+       // Manage the ok, apply, restore and cancel/close buttons
+       bcview().setOK(dialog_->button_ok);
+       bcview().setCancel(dialog_->button_close);
 
-        // Manage the ok, apply, restore and cancel/close buttons
-       bc_.setOK(dialog_->button_ok);
-       bc_.setCancel(dialog_->button_cancel);
-       bc_.refresh();
+       bcview().addReadOnly(dialog_->input_key);
+       bcview().addReadOnly(dialog_->input_label);
 
-       bc_.addReadOnly(dialog_->key);
-       bc_.addReadOnly(dialog_->label);
+       // set up the tooltips
+       string str = _("Key used within LyX document.");
+       tooltips().init(dialog_->input_key, str);
+       str = _("Label used for final output.");
+       tooltips().init(dialog_->input_label, str);
 }
 
 
-bool FormBibitem::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
 {
-       // minimal validation 
-       if (!compare(fl_get_input(dialog_->key), ""))
-               return false;
+       // minimal validation
+       if (!compare(fl_get_input(dialog_->input_key), ""))
+               return ButtonPolicy::SMI_NOOP;
 
-       return true;
+       return ButtonPolicy::SMI_VALID;
 }
 
 
 void FormBibitem::update()
 {
-       fl_set_input(dialog_->key, params.getContents().c_str());
-       fl_set_input(dialog_->label, params.getOptions().c_str());
-       // Surely, this should reset the buttons to their original state?
-       // It doesn't. Instead "Restore" becomes a "Close"
-       //bc_.refresh();
-       bc_.readOnly(lv_->buffer()->isReadonly());
+       fl_set_input(dialog_->input_key,
+                    controller().params().getContents().c_str());
+       fl_set_input(dialog_->input_label,
+                    controller().params().getOptions().c_str());
 }
 
 
 void FormBibitem::apply()
 {
-       if (lv_->buffer()->isReadonly())
-               return;
-
-       params.setContents(fl_get_input(dialog_->key));
-       params.setOptions(fl_get_input(dialog_->label));
-
-       if (inset_ != 0) {
-               // Only update if contents have changed
-               if (params != inset_->params()) {
-                       // FIXME: confirm, is this only necessary for FormBibTeX ???
-                       if (params.getContents() != inset_->params().getContents())
-                               lv_->view()->ChangeCitationsIfUnique(
-                                       inset_->params().getContents(), params.getContents());
-
-               inset_->setParams(params);
-               lv_->view()->updateInset(inset_, true);
-
-               // We need to do a redraw because the maximum
-               // InsetBibKey width could have changed
-               lv_->view()->redraw();
-               lv_->view()->fitCursor(lv_->view()->getLyXText());
-               }
-       } else
-               lyxerr[Debug::GUI] << "Editing non-existent bibitem !" << endl;
+       controller().params().setContents(fl_get_input(dialog_->input_key));
+       controller().params().setOptions(fl_get_input(dialog_->input_label));
 }