]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormBibitem.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / FormBibitem.C
index d23831c7536c46197c375b8f58baf83da0f22611..515120b334aed552984f8af8faf2c9821215e9b8 100644 (file)
@@ -1,10 +1,12 @@
 /**
  * \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 Angus Leeming 
  * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #ifdef __GNUG__
 #endif
 
 #include <config.h>
+#include "xformsBC.h"
 #include "ControlBibitem.h"
 #include "FormBibitem.h"
+#include "Tooltips.h"
+#include "forms/form_bibitem.h"
+#include FORMS_H_LOCATION
 #include "gettext.h"
-#include "xformsBC.h"
 #include "support/lstrings.h" // compare
 
-FormBibitem::FormBibitem(ControlBibitem & c)
-       : FormBase2<ControlBibitem, FD_form_bibitem>(c, _("Bibliography Entry"))
+typedef FormCB<ControlBibitem, FormDB<FD_bibitem> > base_class;
+
+FormBibitem::FormBibitem()
+       : base_class(_("Bibliography Entry"))
 {}
 
 
 void FormBibitem::build()
 {
-       dialog_.reset(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);
 
-       fl_set_input_return(dialog_->key,   FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->label, FL_RETURN_CHANGED);
+       setPrehandler(dialog_->input_key);
+       setPrehandler(dialog_->input_label);
 
-        // Manage the ok, apply, restore and cancel/close buttons
+       // Manage the ok, apply, restore and cancel/close buttons
        bc().setOK(dialog_->button_ok);
-       bc().setCancel(dialog_->button_cancel);
-       bc().refresh();
+       bc().setCancel(dialog_->button_close);
+
+       bc().addReadOnly(dialog_->input_key);
+       bc().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);
 }
 
 
 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
 {
-       // minimal validation 
-       if (!compare(fl_get_input(dialog_->key), ""))
+       // minimal validation
+       if (!compare(fl_get_input(dialog_->input_key), ""))
                return ButtonPolicy::SMI_NOOP;
 
        return ButtonPolicy::SMI_VALID;
@@ -52,15 +67,15 @@ ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
 
 void FormBibitem::update()
 {
-       fl_set_input(dialog_->key,
+       fl_set_input(dialog_->input_key,
                     controller().params().getContents().c_str());
-       fl_set_input(dialog_->label,
+       fl_set_input(dialog_->input_label,
                     controller().params().getOptions().c_str());
 }
 
 
 void FormBibitem::apply()
 {
-       controller().params().setContents(fl_get_input(dialog_->key));
-       controller().params().setOptions(fl_get_input(dialog_->label));
+       controller().params().setContents(fl_get_input(dialog_->input_key));
+       controller().params().setOptions(fl_get_input(dialog_->input_label));
 }