]> git.lyx.org Git - lyx.git/commitdiff
Get rid of GuiMath layer.
authorAbdelrazak Younes <younes@lyx.org>
Mon, 2 Jun 2008 10:05:29 +0000 (10:05 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 2 Jun 2008 10:05:29 +0000 (10:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25064 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/scons_manifest.py
src/frontends/qt4/GuiDelimiter.cpp
src/frontends/qt4/GuiDelimiter.h
src/frontends/qt4/GuiMath.cpp [deleted file]
src/frontends/qt4/GuiMath.h [deleted file]
src/frontends/qt4/GuiMathMatrix.cpp
src/frontends/qt4/GuiMathMatrix.h
src/frontends/qt4/Makefile.am

index 66023136dc68562fd8c122a7a21ded71e17aa6a2..4c9ca75e102495d69b1fccb6284d91729746b881 100644 (file)
@@ -722,7 +722,6 @@ src_frontends_qt4_header_files = Split('''
     GuiLabel.h
     GuiListings.h
     GuiLog.h
-    GuiMath.h
     GuiMathMatrix.h
     GuiNomencl.h
     GuiNote.h
@@ -812,7 +811,6 @@ src_frontends_qt4_files = Split('''
     GuiLabel.cpp
     GuiListings.cpp
     GuiLog.cpp
-    GuiMath.cpp
     GuiMathMatrix.cpp
     GuiNomencl.cpp
     GuiNote.cpp
index 96b276750a48313eab827fed371d6b36aa8c9071..2ff733554f871010be3d0c05367621232b28efe3 100644 (file)
 #include "GuiView.h"
 #include "qt_helpers.h"
 
+#include "FontEnums.h"
 #include "FontInfo.h"
+#include "FuncRequest.h"
 
 #include "support/gettext.h"
+#include "support/docstring.h"
 
 #include <QPixmap>
 #include <QCheckBox>
 #include <QListWidgetItem>
 
+#include <map>
+#include <string>
+
 using namespace std;
 
+namespace lyx {
+namespace frontend {
+
+namespace {
+
 static char const *  latex_delimiters[] = {
        "(", ")", "{", "}", "[", "]",
        "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
@@ -64,13 +75,94 @@ static QString fix_name(QString const & str, bool big)
        return "\\" + str;
 }
 
+struct MathSymbol {
+       MathSymbol(char_type uc = '?', unsigned char fc = 0,
+               FontFamily ff = SYMBOL_FAMILY)
+               : unicode(uc), fontcode(fc), fontfamily(ff)
+       {}
+       char_type unicode;
+       unsigned char fontcode;
+       FontFamily fontfamily;
+};
+
+/// TeX-name / Math-symbol map.
+static map<std::string, MathSymbol> math_symbols_;
+/// Math-symbol / TeX-name map.
+/// This one is for fast search, it contains the same data as
+/// \c math_symbols_.
+static map<char_type, string> tex_names_;
 
-namespace lyx {
-namespace frontend {
+void initMathSymbols()
+{
+       // FIXME: Ideally, those unicode codepoints would be defined
+       // in "lib/symbols". Unfortunately, some of those are already
+       // defined with non-unicode ids for use within mathed.
+       // FIXME 2: We should fill-in this map with the parsed "symbols"
+       // file done in MathFactory.cpp.
+       math_symbols_["("] = MathSymbol('(');
+       math_symbols_[")"] = MathSymbol(')');
+       math_symbols_["{"] = MathSymbol('{');
+       math_symbols_["}"] = MathSymbol('}');
+       math_symbols_["["] = MathSymbol('[');
+       math_symbols_["]"] = MathSymbol(']');
+       math_symbols_["|"] = MathSymbol('|');
+       math_symbols_["/"] = MathSymbol('/', 54, CMSY_FAMILY);
+       math_symbols_["backslash"] = MathSymbol('\\', 110, CMSY_FAMILY);
+       math_symbols_["lceil"] = MathSymbol(0x2308, 100, CMSY_FAMILY);
+       math_symbols_["rceil"] = MathSymbol(0x2309, 101, CMSY_FAMILY);
+       math_symbols_["lfloor"] = MathSymbol(0x230A, 98, CMSY_FAMILY);
+       math_symbols_["rfloor"] = MathSymbol(0x230B, 99, CMSY_FAMILY);
+       math_symbols_["langle"] = MathSymbol(0x2329, 104, CMSY_FAMILY);
+       math_symbols_["rangle"] = MathSymbol(0x232A, 105, CMSY_FAMILY);
+       math_symbols_["uparrow"] = MathSymbol(0x2191, 34, CMSY_FAMILY);
+       math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, CMSY_FAMILY);
+       math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, CMSY_FAMILY);
+       math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, CMSY_FAMILY);
+       math_symbols_["downarrow"] = MathSymbol(0x2193, 35, CMSY_FAMILY);
+       math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, CMSY_FAMILY);
+       math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, MSA_FAMILY);
+       math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, MSA_FAMILY);
+       math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, MSA_FAMILY);
+       math_symbols_["vert"] = MathSymbol(0x007C, 106, CMSY_FAMILY);
+       math_symbols_["Vert"] = MathSymbol(0x2016, 107, CMSY_FAMILY);
+
+       map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
+       map<string, MathSymbol>::const_iterator end = math_symbols_.end();
+       for (; it != end; ++it)
+               tex_names_[it->second.unicode] = it->first;
+}
+
+/// \return the math unicode symbol associated to a TeX name.
+MathSymbol const & mathSymbol(string tex_name)
+{
+       map<string, MathSymbol>::const_iterator it =
+               math_symbols_.find(tex_name);
+
+       static MathSymbol unknown_symbol;
+       if (it == math_symbols_.end())
+               return unknown_symbol;
+
+       return it->second;
+}
+
+/// \return the TeX name associated to a math unicode symbol.
+string const & texName(char_type math_symbol)
+{
+       map<char_type, string>::const_iterator it =
+               tex_names_.find(math_symbol);
+
+       static string empty_string;
+       if (it == tex_names_.end())
+               return empty_string;
+
+       return it->second;
+}
+
+} // anon namespace
 
 
 GuiDelimiter::GuiDelimiter(GuiView & lv)
-       : GuiMath(lv, "mathdelimiter", qt_("Math Delimiter"))
+       : GuiDialog(lv, "mathdelimiter", qt_("Math Delimiter"))
 {
        setupUi(this);
 
@@ -81,6 +173,8 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
        leftLW->setViewMode(QListView::IconMode);
        rightLW->setViewMode(QListView::IconMode);
 
+       initMathSymbols();
+
        typedef map<char_type, QListWidgetItem *> ListItems;
        ListItems list_items;
        // The last element is the empty one.
@@ -185,11 +279,11 @@ void GuiDelimiter::updateTeXCode(int size)
 void GuiDelimiter::on_insertPB_clicked()
 {
        if (sizeCO->currentIndex() == 0)
-               dispatchFunc(LFUN_MATH_DELIM, fromqstr(tex_code_));
+               dispatch(FuncRequest(LFUN_MATH_DELIM, fromqstr(tex_code_)));
        else {
                QString command = '"' + tex_code_ + '"';
                command.replace(' ', "\" \"");
-               dispatchFunc(LFUN_MATH_BIGDELIM, fromqstr(command));
+               dispatch(FuncRequest(LFUN_MATH_BIGDELIM, fromqstr(command)));
        }
  }
 
index 62843742b70447424960e427d7f2d2f9c935bf53..fa2ebda264632453e32bfc4908ce7bd1c780e6b5 100644 (file)
@@ -12,7 +12,8 @@
 #ifndef GUIDELIMITERDIALOG_H
 #define GUIDELIMITERDIALOG_H
 
-#include "GuiMath.h"
+#include "GuiDialog.h"
+
 #include "ui_DelimiterUi.h"
 
 class QListWidgetItem;
@@ -20,13 +21,18 @@ class QListWidgetItem;
 namespace lyx {
 namespace frontend {
 
-class GuiDelimiter : public GuiMath, public Ui::DelimiterUi
+class GuiDelimiter : public GuiDialog, public Ui::DelimiterUi
 {
        Q_OBJECT
 
 public:
        GuiDelimiter(GuiView & lv);
 
+       bool initialiseParams(std::string const &) { return true; }
+       void clearParams() {}
+       void dispatchParams() {}
+       bool isBufferDependent() const { return true; }
+
 public Q_SLOTS:
        void on_leftLW_itemActivated(QListWidgetItem *);
        void on_rightLW_itemActivated(QListWidgetItem *);
diff --git a/src/frontends/qt4/GuiMath.cpp b/src/frontends/qt4/GuiMath.cpp
deleted file mode 100644 (file)
index f3d3a98..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * \file GuiMath.cpp
- * 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 "GuiMath.h"
-
-#include "FuncRequest.h"
-
-#include "support/debug.h"
-
-using namespace std;
-
-namespace lyx {
-namespace frontend {
-
-GuiMath::GuiMath(GuiView & lv, QString const & name, QString const & title)
-       : GuiDialog(lv, name, title)
-{
-       // FIXME: Ideally, those unicode codepoints would be defined
-       // in "lib/symbols". Unfortunately, some of those are already
-       // defined with non-unicode ids for use within mathed.
-       // FIXME 2: We should fill-in this map with the parsed "symbols"
-       // file done in MathFactory.cpp.
-       math_symbols_["("] = MathSymbol('(');
-       math_symbols_[")"] = MathSymbol(')');
-       math_symbols_["{"] = MathSymbol('{');
-       math_symbols_["}"] = MathSymbol('}');
-       math_symbols_["["] = MathSymbol('[');
-       math_symbols_["]"] = MathSymbol(']');
-       math_symbols_["|"] = MathSymbol('|');
-       math_symbols_["/"] = MathSymbol('/', 54, CMSY_FAMILY);
-       math_symbols_["backslash"] = MathSymbol('\\', 110, CMSY_FAMILY);
-       math_symbols_["lceil"] = MathSymbol(0x2308, 100, CMSY_FAMILY);
-       math_symbols_["rceil"] = MathSymbol(0x2309, 101, CMSY_FAMILY);
-       math_symbols_["lfloor"] = MathSymbol(0x230A, 98, CMSY_FAMILY);
-       math_symbols_["rfloor"] = MathSymbol(0x230B, 99, CMSY_FAMILY);
-       math_symbols_["langle"] = MathSymbol(0x2329, 104, CMSY_FAMILY);
-       math_symbols_["rangle"] = MathSymbol(0x232A, 105, CMSY_FAMILY);
-       math_symbols_["uparrow"] = MathSymbol(0x2191, 34, CMSY_FAMILY);
-       math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, CMSY_FAMILY);
-       math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, CMSY_FAMILY);
-       math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, CMSY_FAMILY);
-       math_symbols_["downarrow"] = MathSymbol(0x2193, 35, CMSY_FAMILY);
-       math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, CMSY_FAMILY);
-       math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, MSA_FAMILY);
-       math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, MSA_FAMILY);
-       math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, MSA_FAMILY);
-       math_symbols_["vert"] = MathSymbol(0x007C, 106, CMSY_FAMILY);
-       math_symbols_["Vert"] = MathSymbol(0x2016, 107, CMSY_FAMILY);
-
-       map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
-       map<string, MathSymbol>::const_iterator end = math_symbols_.end();
-       for (; it != end; ++it)
-               tex_names_[it->second.unicode] = it->first;
-}
-
-
-void GuiMath::dispatchFunc(FuncCode action, string const & arg) const
-{
-       dispatch(FuncRequest(action, arg));
-}
-
-
-MathSymbol const & GuiMath::mathSymbol(string tex_name) const
-{
-       map<string, MathSymbol>::const_iterator it =
-               math_symbols_.find(tex_name);
-
-       static MathSymbol unknown_symbol;
-       if (it == math_symbols_.end())
-               return unknown_symbol;
-
-       return it->second;
-}
-
-
-string const & GuiMath::texName(char_type math_symbol) const
-{
-       map<char_type, string>::const_iterator it =
-               tex_names_.find(math_symbol);
-
-       static string empty_string;
-       if (it == tex_names_.end())
-               return empty_string;
-
-       return it->second;
-}
-
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/qt4/GuiMath.h b/src/frontends/qt4/GuiMath.h
deleted file mode 100644 (file)
index b7bbeed..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-// -*- C++ -*-
-/**
- * \file GuiMath.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.
- */
-
-#ifndef GUIMATH_H
-#define GUIMATH_H
-
-#include "GuiDialog.h"
-#include "FuncCode.h"
-#include "FontEnums.h"
-
-#include <map>
-#include <string>
-
-
-namespace lyx {
-namespace frontend {
-
-struct MathSymbol {
-       MathSymbol(char_type uc = '?', unsigned char fc = 0,
-               FontFamily ff = SYMBOL_FAMILY)
-               : unicode(uc), fontcode(fc), fontfamily(ff)
-       {}
-       char_type unicode;
-       unsigned char fontcode;
-       FontFamily fontfamily;
-};
-
-
-class GuiMath : public GuiDialog
-{
-public:
-       GuiMath(GuiView & lv, QString const & name, QString const & title);
-
-       /// Nothing to initialise in this case.
-       bool initialiseParams(std::string const &) { return true; }
-       void clearParams() {}
-       void dispatchParams() {}
-       bool isBufferDependent() const { return true; }
-
-       /// dispatch an LFUN
-       void dispatchFunc(FuncCode action,
-               std::string const & arg = std::string()) const;
-
-       /// \return the math unicode symbol associated to a TeX name.
-       MathSymbol const & mathSymbol(std::string tex_name) const;
-       /// \return the TeX name associated to a math unicode symbol.
-       std::string const & texName(char_type math_symbol) const;
-
-private:
-       /// TeX-name / Math-symbol map.
-       std::map<std::string, MathSymbol> math_symbols_;
-       /// Math-symbol / TeX-name map.
-       /// This one is for fast search, it contains the same data as
-       /// \c math_symbols_.
-       std::map<char_type, std::string> tex_names_;
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // GUIMATH_H
index b92765251f166f849ac5c0bf130ea4437a90df74..24722b00e835bfb21a62391083e015e6fa027478 100644 (file)
@@ -15,6 +15,8 @@
 #include "EmptyTable.h"
 #include "qt_helpers.h"
 
+#include "FuncRequest.h"
+
 #include <QLineEdit>
 #include <QPushButton>
 #include <QSpinBox>
@@ -25,7 +27,7 @@ namespace lyx {
 namespace frontend {
 
 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
-       : GuiMath(lv, "mathmatrix", qt_("Math Matrix"))
+       : GuiDialog(lv, "mathmatrix", qt_("Math Matrix"))
 {
        setupUi(this);
 
@@ -90,7 +92,7 @@ void GuiMathMatrix::slotOK()
        int const ny = rowsSB->value();
        string const str = fromqstr(
                QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh));
-       dispatchFunc(LFUN_MATH_MATRIX, str);
+       dispatch(FuncRequest(LFUN_MATH_MATRIX, str));
        close();
 }
 
index cbe11c17d2eaa737c39930ae430c8b774448f3c2..df9a27603260df5730f91876bfd2b095ed8dae53 100644 (file)
 #ifndef GUIMATHMATRIX_H
 #define GUIMATHMATRIX_H
 
-#include "GuiMath.h"
-#include "ui_MathMatrixUi.h"
+#include "GuiDialog.h"
 
-#include <QDialog>
+#include "ui_MathMatrixUi.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiMathMatrix : public GuiMath, public Ui::MathMatrixUi
+class GuiMathMatrix : public GuiDialog, public Ui::MathMatrixUi
 {
        Q_OBJECT
 
 public:
        GuiMathMatrix(GuiView & lv);
 
+       bool initialiseParams(std::string const &) { return true; }
+       void clearParams() {}
+       void dispatchParams() {}
+       bool isBufferDependent() const { return true; }
+
 public Q_SLOTS:
        void slotOK();
        void slotClose();
index 1ad2e1e5d22265457e68e491c7cb8fbff67f5dd4..6cba0cee25f84365ec2bd0c4e5a245d62e6bf95c 100644 (file)
@@ -93,7 +93,6 @@ SOURCEFILES = \
        GuiLabel.cpp \
        GuiListings.cpp \
        GuiLog.cpp \
-       GuiMath.cpp \
        GuiMathMatrix.cpp \
        GuiNomencl.cpp \
        GuiNote.cpp \
@@ -146,7 +145,6 @@ NOMOCHEADER = \
        GuiIdListModel.h \
        GuiImage.h \
        GuiKeySymbol.h \
-       GuiMath.h \
        GuiPainter.h \
        LaTeXHighlighter.h \
        qt_i18n.h \