2001-03-16 12:08:14 +00:00
|
|
|
/**
|
2007-10-07 20:34:09 +00:00
|
|
|
* \file GuiMath.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-16 12:08:14 +00:00
|
|
|
*
|
2003-06-17 12:53:35 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-16 12:08:14 +00:00
|
|
|
*/
|
|
|
|
|
2002-11-04 00:15:56 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
#include "GuiMath.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2002-11-25 18:58:15 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-07-16 22:34:31 +00:00
|
|
|
|
2008-03-05 20:11:47 +00:00
|
|
|
GuiMath::GuiMath(GuiView & lv, QString const & name, QString const & title)
|
2008-02-05 12:43:19 +00:00
|
|
|
: GuiDialog(lv, name, title)
|
2007-04-06 15:57:32 +00:00
|
|
|
{
|
|
|
|
// FIXME: Ideally, those unicode codepoints would be defined
|
2007-05-28 22:27:45 +00:00
|
|
|
// in "lib/symbols". Unfortunately, some of those are already
|
2007-04-06 15:57:32 +00:00
|
|
|
// defined with non-unicode ids for use within mathed.
|
2007-04-12 16:49:01 +00:00
|
|
|
// FIXME 2: We should fill-in this map with the parsed "symbols"
|
2007-04-25 03:01:35 +00:00
|
|
|
// file done in MathFactory.cpp.
|
2007-04-12 16:49:01 +00:00
|
|
|
math_symbols_["("] = MathSymbol('(');
|
|
|
|
math_symbols_[")"] = MathSymbol(')');
|
|
|
|
math_symbols_["{"] = MathSymbol('{');
|
|
|
|
math_symbols_["}"] = MathSymbol('}');
|
|
|
|
math_symbols_["["] = MathSymbol('[');
|
|
|
|
math_symbols_["]"] = MathSymbol(']');
|
|
|
|
math_symbols_["|"] = MathSymbol('|');
|
2007-10-28 18:51:54 +00:00
|
|
|
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);
|
2007-04-12 16:49:01 +00:00
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
|
|
|
|
map<string, MathSymbol>::const_iterator end = math_symbols_.end();
|
2007-04-06 15:57:32 +00:00
|
|
|
for (; it != end; ++it)
|
2007-04-12 16:49:01 +00:00
|
|
|
tex_names_[it->second.unicode] = it->first;
|
2007-04-06 15:57:32 +00:00
|
|
|
}
|
2002-11-25 18:58:15 +00:00
|
|
|
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
void GuiMath::dispatchFunc(FuncCode action, string const & arg) const
|
2002-11-25 18:58:15 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
dispatch(FuncRequest(action, arg));
|
2002-11-25 18:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMath::dispatchMatrix(string const & str) const
|
2002-11-25 18:58:15 +00:00
|
|
|
{
|
2006-05-05 20:23:12 +00:00
|
|
|
dispatchFunc(LFUN_MATH_MATRIX, str);
|
2002-11-25 18:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMath::dispatchDelim(string const & str) const
|
2002-11-25 18:58:15 +00:00
|
|
|
{
|
2003-06-17 12:53:35 +00:00
|
|
|
dispatchFunc(LFUN_MATH_DELIM, str);
|
2002-11-25 18:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMath::dispatchBigDelim(string const & str) const
|
2006-05-07 10:51:19 +00:00
|
|
|
{
|
|
|
|
dispatchFunc(LFUN_MATH_BIGDELIM, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMath::showDialog(string const & name) const
|
2002-11-25 18:58:15 +00:00
|
|
|
{
|
2003-06-17 12:53:35 +00:00
|
|
|
dispatchFunc(LFUN_DIALOG_SHOW, name);
|
2002-11-25 18:58:15 +00:00
|
|
|
}
|
|
|
|
|
2002-11-20 16:11:18 +00:00
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
MathSymbol const & GuiMath::mathSymbol(string tex_name) const
|
2007-04-06 15:57:32 +00:00
|
|
|
{
|
2007-04-12 16:49:01 +00:00
|
|
|
map<string, MathSymbol>::const_iterator it =
|
2007-04-06 15:57:32 +00:00
|
|
|
math_symbols_.find(tex_name);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-12 16:49:01 +00:00
|
|
|
static MathSymbol unknown_symbol;
|
2007-04-06 15:57:32 +00:00
|
|
|
if (it == math_symbols_.end())
|
2007-04-12 16:49:01 +00:00
|
|
|
return unknown_symbol;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-06 15:57:32 +00:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
string const & GuiMath::texName(char_type math_symbol) const
|
2007-04-06 15:57:32 +00:00
|
|
|
{
|
|
|
|
map<char_type, string>::const_iterator it =
|
|
|
|
tex_names_.find(math_symbol);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-06 15:57:32 +00:00
|
|
|
static string empty_string;
|
|
|
|
if (it == tex_names_.end())
|
|
|
|
return empty_string;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-06 15:57:32 +00:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|