mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Get rid of current_view from the Qt math panel.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7164 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1f1762bf3a
commit
4fea79a14b
@ -1,3 +1,10 @@
|
||||
2003-06-12 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlMath2.[Ch]: new files. A work in progress towards a clean
|
||||
implementation of the math panel.
|
||||
|
||||
* Makefile.am: add files.
|
||||
|
||||
2003-06-11 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlExternal.[Ch]: changes due to InsetExternal::Params no longer
|
||||
|
65
src/frontends/controllers/ControlMath2.C
Normal file
65
src/frontends/controllers/ControlMath2.C
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* \file ControlMath2.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
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlMath2.h"
|
||||
#include "Kernel.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
|
||||
ControlMath2::ControlMath2(Dialog & dialog)
|
||||
: Dialog::Controller(dialog)
|
||||
{}
|
||||
|
||||
|
||||
void ControlMath2::dispatchInsert(string const & name) const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + name));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchSubscript() const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_SUBSCRIPT));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchSuperscript() const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_SUPERSCRIPT));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchCubeRoot() const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_INSERT_MATH, "\\root"));
|
||||
kernel().dispatch(FuncRequest(LFUN_SELFINSERT, "3"));
|
||||
kernel().dispatch(FuncRequest(LFUN_RIGHT));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchMatrix(string const & str) const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_INSERT_MATRIX, str));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchDelim(string const & str) const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_MATH_DELIM, str));
|
||||
}
|
||||
|
||||
|
||||
void ControlMath2::dispatchToggleDisplay() const
|
||||
{
|
||||
kernel().dispatch(FuncRequest(LFUN_MATH_DISPLAY));
|
||||
}
|
||||
|
82
src/frontends/controllers/ControlMath2.h
Normal file
82
src/frontends/controllers/ControlMath2.h
Normal file
@ -0,0 +1,82 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlMath2.h
|
||||
* 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
|
||||
*
|
||||
* ControlMath2 is a controller class for the Math Panel dialog.
|
||||
*/
|
||||
|
||||
#ifndef CONTROLMATH2_H
|
||||
#define CONTROLMATH2_H
|
||||
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
|
||||
class ControlMath2 : public Dialog::Controller {
|
||||
public:
|
||||
ControlMath2(Dialog &);
|
||||
|
||||
virtual bool initialiseParams(string const &) { return true; }
|
||||
virtual void clearParams() {}
|
||||
virtual void dispatchParams() {}
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
|
||||
/// Insert a math symbol into the doc.
|
||||
void dispatchInsert(string const & name) const;
|
||||
/// Insert a subscript.
|
||||
void dispatchSubscript() const;
|
||||
/// Insert a superscript.
|
||||
void dispatchSuperscript() const;
|
||||
/// Insert a cube root
|
||||
void dispatchCubeRoot() const;
|
||||
/// Insert a matrix
|
||||
void dispatchMatrix(string const & str) const;
|
||||
/// Insert a delimiter
|
||||
void dispatchDelim(string const & str) const;
|
||||
/// switch between display and inline
|
||||
void dispatchToggleDisplay() const;
|
||||
};
|
||||
|
||||
|
||||
extern char const * function_names[];
|
||||
extern int const nr_function_names;
|
||||
extern char const * latex_arrow[];
|
||||
extern int const nr_latex_arrow;
|
||||
extern char const * latex_bop[];
|
||||
extern int const nr_latex_bop;
|
||||
extern char const * latex_brel[];
|
||||
extern int const nr_latex_brel;
|
||||
extern char const * latex_dots[];
|
||||
extern int const nr_latex_dots;
|
||||
extern char const * latex_greek[];
|
||||
extern int const nr_latex_greek;
|
||||
extern char const * latex_deco[];
|
||||
extern int const nr_latex_deco;
|
||||
extern char const * latex_misc[];
|
||||
extern int const nr_latex_misc;
|
||||
extern char const * latex_varsz[];
|
||||
extern int const nr_latex_varsz;
|
||||
extern char const * latex_ams_misc[];
|
||||
extern int const nr_latex_ams_misc;
|
||||
extern char const * latex_ams_arrows[];
|
||||
extern int const nr_latex_ams_arrows;
|
||||
extern char const * latex_ams_rel[];
|
||||
extern int const nr_latex_ams_rel;
|
||||
extern char const * latex_ams_nrel[];
|
||||
extern int const nr_latex_ams_nrel;
|
||||
extern char const * latex_ams_ops[];
|
||||
extern int const nr_latex_ams_ops;
|
||||
|
||||
/**
|
||||
* Return the mangled XPM filename of the given
|
||||
* math symbol.
|
||||
*/
|
||||
string const find_xpm(string const & name);
|
||||
|
||||
#endif // NOT CONTROLMATH2
|
@ -68,6 +68,8 @@ libcontrollers_la_SOURCES= \
|
||||
ControlLog.h \
|
||||
ControlMath.C \
|
||||
ControlMath.h \
|
||||
ControlMath2.C \
|
||||
ControlMath2.h \
|
||||
ControlMinipage.C \
|
||||
ControlMinipage.h \
|
||||
ControlParagraph.C \
|
||||
|
@ -1,3 +1,15 @@
|
||||
2003-06-12 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Dialogs.C: add the math dialog.
|
||||
* Dialogs2.C: a temporary hack; keep showMathPanel() but invoke (and store)
|
||||
the new dialog.
|
||||
|
||||
* QMath.[Ch]: derive from QDialogView.
|
||||
|
||||
* QMathDialog.C:
|
||||
* QDelimiterDialog.C:
|
||||
* QMathMatrixDialog.C: the dispatch functions are now in the controller.
|
||||
|
||||
2003-06-12 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* QExternalDialog.C (editClicked): do not call form_->changed().
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "ControlGraphics.h"
|
||||
#include "ControlInclude.h"
|
||||
#include "ControlLog.h"
|
||||
#include "ControlMath2.h"
|
||||
#include "ControlMinipage.h"
|
||||
#include "ControlParagraph.h"
|
||||
#include "ControlRef.h"
|
||||
@ -55,6 +56,7 @@
|
||||
#include "QInclude.h"
|
||||
#include "QIndex.h"
|
||||
#include "QLog.h"
|
||||
#include "QMath.h"
|
||||
#include "QMinipage.h"
|
||||
#include "QParagraph.h"
|
||||
#include "QRef.h"
|
||||
@ -80,7 +82,7 @@ namespace {
|
||||
|
||||
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
|
||||
"character", "citation", "error", "errorlist", "ert", "external", "file",
|
||||
"float", "graphics", "include", "index", "label", "log", "minipage",
|
||||
"float", "graphics", "include", "index", "label", "log", "math", "minipage",
|
||||
"paragraph", "ref", "tabular", "tabularcreate",
|
||||
|
||||
#ifdef HAVE_LIBAIKSAURUS
|
||||
@ -192,6 +194,10 @@ Dialog * Dialogs::build(string const & name)
|
||||
dialog->setController(new ControlLog(*dialog));
|
||||
dialog->setView(new QLog(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
} else if (name == "math") {
|
||||
dialog->setController(new ControlMath2(*dialog));
|
||||
dialog->setView(new QMath(*dialog));
|
||||
dialog->bc().bp(new IgnorantPolicy);
|
||||
} else if (name == "minipage") {
|
||||
dialog->setController(new ControlMinipage(*dialog));
|
||||
dialog->setView(new QMinipage(*dialog));
|
||||
|
@ -120,10 +120,8 @@ void Dialogs::showForks()
|
||||
|
||||
void Dialogs::showMathPanel()
|
||||
{
|
||||
// FIXME FIXME FIXME
|
||||
extern void createMathPanel();
|
||||
|
||||
createMathPanel();
|
||||
static DialogPtr mathdialog(build("math"));
|
||||
mathdialog->show(string());
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "qt_helpers.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "ControlMath2.h"
|
||||
#include "QMath.h"
|
||||
#include "ControlMath.h"
|
||||
#include "QDelimiterDialog.h"
|
||||
|
||||
#include "iconpalette.h"
|
||||
@ -96,7 +96,7 @@ QDelimiterDialog::QDelimiterDialog(QMath * form)
|
||||
|
||||
void QDelimiterDialog::insertClicked()
|
||||
{
|
||||
form_->insertDelim(fix_name(left_) + ' ' + fix_name(right_));
|
||||
form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,98 +11,21 @@
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include "lfuns.h"
|
||||
#include "funcrequest.h"
|
||||
#include "LyXView.h"
|
||||
#include "BufferView.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#include "ControlMath2.h"
|
||||
#include "QMathDialog.h"
|
||||
#include "QMath.h"
|
||||
|
||||
#include "iconpalette.h"
|
||||
|
||||
// needless to say, this can't last for long
|
||||
#warning FIXME Current_view used here!
|
||||
extern BufferView * current_view;
|
||||
typedef QController<ControlMath2, QView<QMathDialog> > base_class;
|
||||
|
||||
|
||||
// FIXME temporary HACK !
|
||||
void createMathPanel()
|
||||
{
|
||||
static QMath * dialog = 0;
|
||||
if (!dialog) {
|
||||
dialog = new QMath;
|
||||
dialog->build_dialog();
|
||||
}
|
||||
dialog->do_show();
|
||||
}
|
||||
|
||||
|
||||
QMath::QMath()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QMath::do_show()
|
||||
{
|
||||
dialog_->show();
|
||||
}
|
||||
QMath::QMath(Dialog & parent)
|
||||
: base_class(parent, _("LyX: Math Panel"))
|
||||
{}
|
||||
|
||||
|
||||
void QMath::build_dialog()
|
||||
{
|
||||
dialog_ = new QMathDialog(this);
|
||||
}
|
||||
|
||||
|
||||
void QMath::subscript()
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_SUBSCRIPT));
|
||||
}
|
||||
|
||||
|
||||
void QMath::superscript()
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_SUPERSCRIPT));
|
||||
}
|
||||
|
||||
|
||||
void QMath::insert(string const & name)
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + name));
|
||||
}
|
||||
|
||||
|
||||
void QMath::insertCubeRoot()
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATH, "\\root"));
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "3"));
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_RIGHT));
|
||||
}
|
||||
|
||||
|
||||
void QMath::insertMatrix(string const & str)
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_INSERT_MATRIX, str));
|
||||
}
|
||||
|
||||
|
||||
void QMath::insertDelim(string const & str)
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DELIM, str));
|
||||
}
|
||||
|
||||
|
||||
void QMath::toggleDisplay()
|
||||
{
|
||||
#warning FIXME Current_view used here!
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DISPLAY));
|
||||
dialog_.reset(new QMathDialog(this));
|
||||
}
|
||||
|
@ -13,50 +13,22 @@
|
||||
#define QMATH_H
|
||||
|
||||
|
||||
#include "LString.h"
|
||||
#include "QDialogView.h"
|
||||
|
||||
class ControlMath2;
|
||||
class QMathDialog;
|
||||
|
||||
class QMath {
|
||||
class QMath : public QController<ControlMath2, QView<QMathDialog> > {
|
||||
public:
|
||||
friend class QMathDialog;
|
||||
|
||||
QMath();
|
||||
QMath(Dialog &);
|
||||
|
||||
/// temporary
|
||||
void do_show();
|
||||
|
||||
/// build the dialog (should be private)
|
||||
virtual void build_dialog();
|
||||
|
||||
/// insert a math symbol into the doc
|
||||
void insert(string const & name);
|
||||
|
||||
/// insert a cube root
|
||||
void insertCubeRoot();
|
||||
|
||||
/// insert a matrix
|
||||
void insertMatrix(string const & str);
|
||||
|
||||
/// insert delim
|
||||
void insertDelim(string const & str);
|
||||
|
||||
/// add a subscript
|
||||
void subscript();
|
||||
|
||||
/// add a superscript
|
||||
void superscript();
|
||||
|
||||
/// switch between display and inline
|
||||
void toggleDisplay();
|
||||
private:
|
||||
/// Apply changes
|
||||
virtual void apply() {}
|
||||
/// update
|
||||
virtual void update_contents() {}
|
||||
|
||||
// FIXME: temp
|
||||
QMathDialog * dialog_;
|
||||
/// Build the dialog.
|
||||
virtual void build_dialog();
|
||||
};
|
||||
|
||||
#endif // QMATH_H
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "qt_helpers.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "ControlMath.h"
|
||||
#include "ControlMath2.h"
|
||||
|
||||
#include "QMathDialog.h"
|
||||
#include "QMath.h"
|
||||
@ -196,13 +196,13 @@ void QMathDialog::addPanel(int num)
|
||||
|
||||
void QMathDialog::symbol_clicked(string const & str)
|
||||
{
|
||||
form_->insert(str);
|
||||
form_->controller().dispatchInsert(str);
|
||||
}
|
||||
|
||||
|
||||
void QMathDialog::fracClicked()
|
||||
{
|
||||
form_->insert("frac");
|
||||
form_->controller().dispatchInsert("frac");
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ void QMathDialog::expandClicked()
|
||||
|
||||
void QMathDialog::functionSelected(const QString & str)
|
||||
{
|
||||
form_->insert(fromqstr(str));
|
||||
form_->controller().dispatchInsert(fromqstr(str));
|
||||
}
|
||||
|
||||
|
||||
@ -243,19 +243,19 @@ void QMathDialog::matrixClicked()
|
||||
|
||||
void QMathDialog::equationClicked()
|
||||
{
|
||||
form_->toggleDisplay();
|
||||
form_->controller().dispatchToggleDisplay();
|
||||
}
|
||||
|
||||
|
||||
void QMathDialog::subscriptClicked()
|
||||
{
|
||||
form_->subscript();
|
||||
form_->controller().dispatchSubscript();
|
||||
}
|
||||
|
||||
|
||||
void QMathDialog::superscriptClicked()
|
||||
{
|
||||
form_->superscript();
|
||||
form_->controller().dispatchSuperscript();
|
||||
}
|
||||
|
||||
|
||||
@ -271,7 +271,7 @@ void QMathDialog::insertSpace(int id)
|
||||
case 6: str = "!"; break;
|
||||
default: return;
|
||||
}
|
||||
form_->insert(str);
|
||||
form_->controller().dispatchInsert(str);
|
||||
}
|
||||
|
||||
|
||||
@ -279,13 +279,13 @@ void QMathDialog::insertRoot(int id)
|
||||
{
|
||||
switch (id) {
|
||||
case 1:
|
||||
form_->insert("sqrt");
|
||||
form_->controller().dispatchInsert("sqrt");
|
||||
break;
|
||||
case 2:
|
||||
form_->insertCubeRoot();
|
||||
form_->controller().dispatchCubeRoot();
|
||||
break;
|
||||
case 3:
|
||||
form_->insert("root");
|
||||
form_->controller().dispatchInsert("root");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -301,7 +301,7 @@ void QMathDialog::insertStyle(int id)
|
||||
case 4: str = "scriptscriptstyle"; break;
|
||||
default: return;
|
||||
}
|
||||
form_->insert(str);
|
||||
form_->controller().dispatchInsert(str);
|
||||
}
|
||||
|
||||
|
||||
@ -320,5 +320,5 @@ void QMathDialog::insertFont(int id)
|
||||
case 9: str = "textrm"; break;
|
||||
default: return;
|
||||
}
|
||||
form_->insert(str);
|
||||
form_->controller().dispatchInsert(str);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "Lsstream.h"
|
||||
#include "ControlMath2.h"
|
||||
|
||||
#include "QMath.h"
|
||||
#include "QMathMatrixDialog.h"
|
||||
@ -81,7 +82,7 @@ void QMathMatrixDialog::slotOK()
|
||||
|
||||
ostringstream os;
|
||||
os << nx << ' ' << ny << ' ' << c << ' ' << sh;
|
||||
form_->insertMatrix(os.str().c_str());
|
||||
form_->controller().dispatchMatrix(os.str().c_str());
|
||||
|
||||
// close the dialog
|
||||
close();
|
||||
|
Loading…
Reference in New Issue
Block a user