/**
- * \file xforms/FormRef.C
+ * \file FormRef.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#include <algorithm>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "xformsBC.h"
-#include "ControlRef.h"
#include "FormRef.h"
-#include "Tooltips.h"
+#include "ControlRef.h"
#include "forms/form_ref.h"
+
+#include "Tooltips.h"
#include "xforms_helpers.h"
+#include "xformsBC.h"
+
#include "insets/insetref.h"
-#include "helper_funcs.h" // getStringFromVector
-#include "support/lstrings.h" // frontStrip, strip
-#include FORMS_H_LOCATION
+
+#include "support/lstrings.h" // trim
+
+#include "lyx_forms.h"
+
+using lyx::support::getStringFromVector;
using std::find;
using std::max;
using std::sort;
+using std::string;
using std::vector;
-typedef FormCB<ControlRef, FormDB<FD_ref> > base_class;
-FormRef::FormRef()
- : base_class(_("Reference")),
+typedef FormController<ControlRef, FormView<FD_ref> > base_class;
+
+FormRef::FormRef(Dialog & parent)
+ : base_class(parent, _("Cross-reference")),
at_ref_(false)
{}
for (int i = 0; !InsetRef::types[i].latex_name.empty(); ++i)
fl_addto_choice(dialog_->choice_format,
- _(InsetRef::types[i].gui_name.c_str()));
+ _(InsetRef::types[i].gui_name).c_str());
// Force the user to use the browser to change refs.
fl_deactivate_object(dialog_->input_ref);
setPrehandler(dialog_->input_ref);
// Manage the ok and cancel/close buttons
- bc().setOK(dialog_->button_ok);
- bc().setApply(dialog_->button_apply);
- bc().setCancel(dialog_->button_close);
- bc().setRestore(dialog_->button_restore);
+ bcview().setOK(dialog_->button_ok);
+ bcview().setApply(dialog_->button_apply);
+ bcview().setCancel(dialog_->button_close);
+ bcview().setRestore(dialog_->button_restore);
- bc().addReadOnly(dialog_->button_update);
- bc().addReadOnly(dialog_->input_name);
- bc().addReadOnly(dialog_->input_ref);
+ bcview().addReadOnly(dialog_->button_update);
+ bcview().addReadOnly(dialog_->input_name);
+ bcview().addReadOnly(dialog_->input_ref);
// set up the tooltips
string str = _("Select a document for references.");
switch_go_button();
// Name is irrelevant to LaTeX/Literate documents
- if (controller().docType() == ControlRef::LATEX ||
- controller().docType() == ControlRef::LITERATE) {
+ Kernel::DocTypes doctype = kernel().docType();
+ if (doctype == Kernel::LATEX || doctype == Kernel::LITERATE) {
setEnabled(dialog_->input_name, false);
} else {
setEnabled(dialog_->input_name, true);
}
// type is irrelevant to LinuxDoc/DocBook.
- if (controller().docType() == ControlRef::LINUXDOC ||
- controller().docType() == ControlRef::DOCBOOK) {
+ if (doctype == Kernel::LINUXDOC || doctype == Kernel::DOCBOOK) {
fl_set_choice(dialog_->choice_format, 1);
setEnabled(dialog_->choice_format, false);
} else {
if (keys.empty()) {
fl_add_browser_line(dialog_->browser_refs,
- _("*** No labels found in document ***"));
+ _("*** No labels found in document ***").c_str());
setEnabled(dialog_->browser_refs, false);
setEnabled(dialog_->check_sort, false);
if (sel < 1 || sel > refs_.size())
return ButtonPolicy::SMI_NOOP;
- if (!controller().bufferIsReadonly()) {
+ if (!kernel().isBufferReadonly()) {
string s = fl_get_browser_line(dialog_->browser_refs, sel);
fl_set_input(dialog_->input_ref, s.c_str());
}
ob == dialog_->check_sort ||
ob == dialog_->choice_document) {
+ // No change to data
+ activate = ButtonPolicy::SMI_NOOP;
+
if (ob == dialog_->button_update ||
ob == dialog_->choice_document) {
string const name =
void FormRef::switch_go_button()
{
if (at_ref_) {
- fl_set_object_label(dialog_->button_go, _("Go back"));
- tooltips().init(dialog_->button_go, _("Go back to original place."));
+ fl_set_object_label(dialog_->button_go, _("Go back").c_str());
+ tooltips().init(dialog_->button_go, _("Go back to original place.").c_str());
} else {
- fl_set_object_label(dialog_->button_go, _("Go to"));
- tooltips().init(dialog_->button_go, _("Go to selected reference."));
+ fl_set_object_label(dialog_->button_go, _("Go to").c_str());
+ tooltips().init(dialog_->button_go, _("Go to selected reference.").c_str());
}
fl_set_button_shortcut(dialog_->button_go, "#G", 1);
fl_show_object(dialog_->button_go);