+2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * ControlBibtex.[Ch]: new files; controller for an InsetBibtex popup.
+
+ * Makefile.am: added ControlBibtex.[Ch].
+
2001-03-16 Angus Leeming <a.leeming@ic.ac.uk>
* ControlBibitem.C:
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlBibtex.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#include <algorithm>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "ControlBibtex.h"
+#include "Dialogs.h"
+#include "LyXView.h"
+#include "BufferView.h"
+
+using SigC::slot;
+
+ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
+ : ControlCommand(lv, d)
+{
+ d_.showBibtex.connect(slot(this, &ControlBibtex::showInset));
+}
+
+void ControlBibtex::apply()
+{
+ view().apply();
+
+ if (inset_ && params() != inset_->params()) {
+ 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());
+ }
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlBibtex.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef CONTROLBIBTEX_H
+#define CONTROLBIBTEX_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlCommand.h"
+#include "ButtonController.h"
+#include "ViewBase.h"
+
+/** A controller for Bibtex dialogs.
+ */
+class ControlBibtex : public ControlCommand
+{
+public:
+ ///
+ ControlBibtex(LyXView &, Dialogs &);
+
+protected:
+ /// Get changed parameters and Dispatch them to the kernel.
+ virtual void apply();
+};
+
+/** This class instantiates and makes available the GUI-specific
+ ButtonController and View.
+ */
+template <class GUIview, class GUIbc>
+class GUIBibtex : public ControlBibtex {
+public:
+ ///
+ GUIBibtex(LyXView &, Dialogs &);
+ ///
+ virtual ButtonControllerBase & bc() { return bc_; }
+ ///
+ virtual ViewBase & view() { return view_; }
+
+private:
+ ///
+ ButtonController<OkCancelReadOnlyPolicy, GUIbc> bc_;
+ ///
+ GUIview view_;
+};
+
+template <class GUIview, class GUIbc>
+GUIBibtex<GUIview, GUIbc>::GUIBibtex(LyXView & lv, Dialogs & d)
+ : ControlBibtex(lv, d),
+ view_(*this)
+{}
+
+#endif // CONTROLBIBTEX_H
ControlBase.h \
ControlBibitem.C \
ControlBibitem.h \
+ ControlBibtex.C \
+ ControlBibtex.h \
ControlCitation.C \
ControlCitation.h \
ControlCommand.C \
public:
///
ViewBC(ControlBase & c) : ViewBase(c) {}
+
+protected:
///
GUIbc & bc() const
{
+2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * FormBibtex.[Ch]:
+ * forms/form_bibtex.fd: implemented controller-view split.
+
+ * Dialogs.C: associated changes.
+
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
* FormBaseDeprecated.[Ch]: rename title as title_.
*/
#include <config.h>
-#include FORMS_H_LOCATION
#ifdef __GNUG__
#pragma implementation
#include "Dialogs.h"
#include "ControlBibitem.h"
+#include "ControlBibtex.h"
#include "ControlCitation.h"
#include "xformsBC.h"
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
+ add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
- add(new FormBibtex(lv, this));
add(new FormCharacter(lv, this));
add(new FormCopyright(lv, this));
add(new FormCredits(lv, this));
#define FORMBASE_H
#include <boost/smart_ptr.hpp>
+#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
#ifdef __GNUG__
#pragma interface
#endif
-#include FORMS_H_LOCATION // Can't forward-declare FL_FORM
#include "ViewBase.h"
#include "LString.h"
#include "ButtonPolicies.h"
#include <config.h>
#include "ControlBibitem.h"
#include "FormBibitem.h"
-#include "form_bibitem.h"
#include "gettext.h"
#include "xformsBC.h"
#include "support/lstrings.h" // compare
#include "FormBase.h"
-/**
- * For bibliography entry editing
- */
-
#include "form_bibitem.h"
+
class ControlBibitem;
+/**
+ * For bibliography entry editing
+ */
class FormBibitem : public FormBase2<ControlBibitem, FD_form_bibitem> {
public:
///
* \author John Levon
*/
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
#ifdef __GNUG__
#pragma implementation
#endif
-
-#include "Dialogs.h"
+#include <config.h>
+#include "ControlBibtex.h"
#include "FormBibtex.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "form_bibtex.h"
-#include "lyxfunc.h"
+#include "gettext.h"
+#include "xformsBC.h"
#include "debug.h"
-using std::endl;
-using SigC::slot;
-
-FormBibtex::FormBibtex(LyXView * lv, Dialogs * d)
- : FormCommand(lv, d, _("BibTeX Database"))
-{
- d->showBibtex.connect(slot(this, &FormBibtex::showInset));
-}
+FormBibtex::FormBibtex(ControlBibtex & c)
+ : FormBase2<ControlBibtex, FD_form_bibtex>(c, _("BibTeX Database"))
+{}
-FL_FORM * FormBibtex::form() const
-{
- if (dialog_.get())
- return dialog_->form;
- return 0;
-}
-
-
-void FormBibtex::connect()
-{
- fl_set_form_maxsize(form(), 2 * minw_, minh_);
- FormCommand::connect();
-}
-
-
void FormBibtex::build()
{
dialog_.reset(build_bibtex());
}
-bool FormBibtex::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT *, long)
{
// minimal validation
if (!compare(fl_get_input(dialog_->database),""))
- return false;
+ return ButtonPolicy::SMI_NOOP;
- return true;
+ return ButtonPolicy::SMI_VALID;
}
void FormBibtex::update()
{
- fl_set_input(dialog_->database, params.getContents().c_str());
- fl_set_input(dialog_->style, 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_->database,
+ controller().params().getContents().c_str());
+ fl_set_input(dialog_->style,
+ controller().params().getOptions().c_str());
}
void FormBibtex::apply()
{
- if (lv_->buffer()->isReadonly())
- return;
-
- params.setContents(fl_get_input(dialog_->database));
- params.setOptions(fl_get_input(dialog_->style));
-
- if (inset_ != 0) {
- // Only update if contents have changed
- if (params != inset_->params()) {
- 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 bibtex inset !" << endl;
+ controller().params().setContents(fl_get_input(dialog_->database));
+ controller().params().setOptions(fl_get_input(dialog_->style));
}
#ifndef FORMBIBTEX_H
#define FORMBIBTEX_H
-#include <boost/smart_ptr.hpp>
-
#ifdef __GNUG__
#pragma interface
#endif
-#include "FormInset.h"
+#include "FormBase.h"
+
+#include "form_bibtex.h"
-struct FD_form_bibtex;
+class ControlBibtex;
/**
* For bibtex database setting
*/
-class FormBibtex : public FormCommand {
+class FormBibtex : public FormBase2<ControlBibtex, FD_form_bibtex> {
public:
///
- FormBibtex(LyXView *, Dialogs *);
-private:
- /// Pointer to the actual instantiation of the ButtonController.
- virtual xformsBC & bc();
- /// Connect signals etc. Set form's max size.
- virtual void connect();
- /// Build the dialog
+ FormBibtex(ControlBibtex &);
+
+ // Functions accessible to the Controller.
+
+ /// Set the Params variable for the Controller.
+ virtual void apply();
+ /// Build the dialog.
virtual void build();
- /// Update dialog before showing it
+ /// Update dialog before/whilst showing it.
virtual void update();
- /// input handler
- virtual bool input(FL_OBJECT *, long);
- /// Apply from dialog (modify or create inset)
- virtual void apply();
- /// Pointer to the actual instantiation of the xforms form
- virtual FL_FORM * form() const;
+
+private:
+ /// Filter the inputs on callback from xforms
+ virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
///
FD_form_bibtex * build_bibtex();
- /// Real GUI implementation.
- boost::scoped_ptr<FD_form_bibtex> dialog_;
- /// The ButtonController
- ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
};
-
-inline
-xformsBC & FormBibtex::bc()
-{
- return bc_;
-}
#endif // FORMBIBTEX_H
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 20, 90, 90, 30, _("OK"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 3);
+ fl_set_object_callback(obj, C_FormBaseOKCB, 3);
{
char const * const dummy = N_("Cancel|^[");
fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 120, 90, 90, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 2);
+ fl_set_object_callback(obj, C_FormBaseCancelCB, 2);
{
char const * const dummy = N_("Style:|#S");
fdui->style = obj = fl_add_input(FL_NORMAL_INPUT, 80, 50, 130, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
#define FD_form_bibtex_h_
/** Callbacks, globals and object handlers **/
-extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
-extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
-extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
/**** Forms and Objects ****/
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: database
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
-callback: C_FormBaseDeprecatedOKCB
+callback: C_FormBaseOKCB
argument: 3
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
argument: 2
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: style
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
argument: 0
==============================
-#include <config.h>
+/**
+ * \file xformsBC.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Allan Rae <rae@lyx.org>
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
-#include FORMS_H_LOCATION
+#include <config.h>
#ifdef __GNUG__
#pragma implementation
#ifndef XFORMSBC_H
#define XFORMSBC_H
-#include "ButtonController.h"
+#include FORMS_H_LOCATION
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
+#include "ButtonController.h"
+
/** General purpose button controller for up to four buttons.
Controls the activation of the OK, Apply and Cancel buttons.
Actually supports 4 buttons in all and it's up to the user to decide on