cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2231 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-07-13 09:10:59 +00:00
parent 0de9e656a4
commit 3ce9e1228e
7 changed files with 397 additions and 643 deletions

View File

@ -68,8 +68,6 @@ libmathed_la_SOURCES = \
math_updowninset.h \ math_updowninset.h \
math_utils.C \ math_utils.C \
math_utils.h \ math_utils.h \
matriz.C \
matriz.h \
support.C \ support.C \
support.h \ support.h \
symbol_def.h symbol_def.h

View File

@ -93,16 +93,16 @@ const unsigned char LM_TK_CLOSE = '}';
enum { enum {
FLAG_BRACE = 1 << 0, // A { needed //} FLAG_BRACE = 1 << 0, // A { needed //}
FLAG_BRACE_LAST = 1 << 3, // // { Last } ends the parsing process FLAG_BRACE_LAST = 1 << 1, // // { Last } ends the parsing process
FLAG_RIGHT = 1 << 5, // Next right ends the parsing process FLAG_RIGHT = 1 << 2, // Next right ends the parsing process
FLAG_END = 1 << 6, // Next end ends the parsing process FLAG_END = 1 << 3, // Next end ends the parsing process
FLAG_BRACE_FONT = 1 << 7, // // { Next } closes a font FLAG_BRACE_FONT = 1 << 4, // // { Next } closes a font
FLAG_BRACK_END = 1 << 9, // // [ Next ] ends the parsing process FLAG_BRACK_END = 1 << 5, // // [ Next ] ends the parsing process
FLAG_AMPERSAND = 1 << 10, // Next & ends the parsing process FLAG_AMPERSAND = 1 << 6, // Next & ends the parsing process
FLAG_NEWLINE = 1 << 11, // Next \\ ends the parsing process FLAG_NEWLINE = 1 << 7, // Next \\ ends the parsing process
FLAG_ITEM = 1 << 12, // read a (possibly braced token) FLAG_ITEM = 1 << 8, // read a (possibly braced token)
FLAG_LEAVE = 1 << 13, // marker for leaving the FLAG_LEAVE = 1 << 9, // marker for leaving the
FLAG_OPTARG = 1 << 14 // reads an argument in [] FLAG_OPTARG = 1 << 10 // reads an argument in []
}; };
/// ///

View File

@ -1,73 +0,0 @@
#include <config.h>
#include <cstring> // memcpy
#include "matriz.h"
#ifndef CXX_GLOBAL_CSTD
using std::memcpy;
#endif
namespace {
inline
int odd(int x)
{
return (x & 1);
}
} // namespace anon
#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
Matriz::matriz_data const Matriz::MATIDEN = { {1, 0}, {0, 1}};
Matriz::Matriz()
{
mateq(m_, MATIDEN);
}
void Matriz::rota(int code)
{
matriz_data r;
mateq(r, MATIDEN);
float const cs = (odd(code)) ? 0 : (1 - code);
float const sn = (odd(code)) ? (2 - code) : 0;
r[0][0] = cs;
r[0][1] = sn;
r[1][0] = -r[0][1];
r[1][1] = r[0][0];
matmat(r);
}
void Matriz::escala(float x, float y)
{
matriz_data s;
mateq(s, MATIDEN);
s[0][0] = x;
s[1][1] = y;
matmat(s);
}
void Matriz::matmat(matriz_data & a)
{
matriz_data c;
c[0][0] = a[0][0] * m_[0][0] + a[0][1] * m_[1][0];
c[1][0] = a[1][0] * m_[0][0] + a[1][1] * m_[1][0];
c[0][1] = a[0][0] * m_[0][1] + a[0][1] * m_[1][1];
c[1][1] = a[1][0] * m_[0][1] + a[1][1] * m_[1][1];
mateq(m_, c);
}
void Matriz::transf(float xp, float yp, float & x, float & y)
{
x = m_[0][0] * xp + m_[0][1] * yp;
y = m_[1][0] * xp + m_[1][1] * yp;
}

View File

@ -1,28 +0,0 @@
// -*- C++ -*-
#ifndef MATH_MATRIZ_H
#define MATH_MATRIZ_H
///
class Matriz {
public:
///
typedef float matriz_data[2][2];
///
Matriz();
///
void rota(int);
///
void escala(float, float);
///
void transf(float, float, float &, float &);
private:
///
matriz_data m_;
///
void matmat(matriz_data & a);
///
static matriz_data const MATIDEN;
};
#endif

View File

@ -8,7 +8,6 @@
#include "math_defs.h" #include "math_defs.h"
#include "math_parser.h" #include "math_parser.h"
#include "Painter.h" #include "Painter.h"
#include "matriz.h"
#include "symbol_def.h" #include "symbol_def.h"
#include "debug.h" #include "debug.h"
#include "math_utils.h" #include "math_utils.h"
@ -18,6 +17,94 @@ using std::lower_bound;
using std::endl; using std::endl;
using std::max; using std::max;
///
/// rotating things
///
///
class Matrix {
public:
///
typedef float matriz_data[2][2];
///
Matrix();
///
void rota(int);
///
void escala(float, float);
///
void transf(float, float, float &, float &);
private:
///
matriz_data m_;
///
void matmat(matriz_data & a);
///
static matriz_data const MATIDEN;
};
#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
Matrix::matriz_data const Matrix::MATIDEN = { {1, 0}, {0, 1}};
Matrix::Matrix()
{
mateq(m_, MATIDEN);
}
void Matrix::rota(int code)
{
matriz_data r;
mateq(r, MATIDEN);
float const cs = (code & 1) ? 0 : (1 - code);
float const sn = (code & 1) ? (2 - code) : 0;
r[0][0] = cs;
r[0][1] = sn;
r[1][0] = -r[0][1];
r[1][1] = r[0][0];
matmat(r);
}
void Matrix::escala(float x, float y)
{
matriz_data s;
mateq(s, MATIDEN);
s[0][0] = x;
s[1][1] = y;
matmat(s);
}
void Matrix::matmat(matriz_data & a)
{
matriz_data c;
c[0][0] = a[0][0] * m_[0][0] + a[0][1] * m_[1][0];
c[1][0] = a[1][0] * m_[0][0] + a[1][1] * m_[1][0];
c[0][1] = a[0][0] * m_[0][1] + a[0][1] * m_[1][1];
c[1][1] = a[1][0] * m_[0][1] + a[1][1] * m_[1][1];
mateq(m_, c);
}
void Matrix::transf(float xp, float yp, float & x, float & y)
{
x = m_[0][0] * xp + m_[0][1] * yp;
y = m_[1][0] * xp + m_[1][1] * yp;
}
extern LyXFont WhichFont(short type, int size); extern LyXFont WhichFont(short type, int size);
char const * math_font_name[] = { char const * math_font_name[] = {
@ -205,6 +292,12 @@ float const tilde[] = {
}; };
struct math_deco_struct {
int code;
float const * data;
int angle;
};
math_deco_struct math_deco_table[] = { math_deco_struct math_deco_table[] = {
// Decorations // Decorations
{ LM_widehat, &angle[0], 3 }, { LM_widehat, &angle[0], 3 },
@ -374,34 +467,34 @@ LyXFont mathed_get_font(short type, int size)
} }
namespace {
math_deco_struct const * search_deco(int code)
{
math_deco_struct search_elem = { code, 0, 0 };
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
search_elem, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res;
return 0;
}
}
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code) void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
{ {
Matriz mt; Matrix mt;
Matriz sqmt; Matrix sqmt;
float xx; float xx;
float yy; float yy;
float x2; float x2;
float y2; float y2;
int i = 0; int i = 0;
#if USE_EXCEPTIONS
math_deco_struct mds;
try {
mds = search_deco(code);
}
catch (deco_not_found) {
// Should this ever happen?
lyxerr << "Deco was not found. Programming error?" << endl;
return;
}
int const r = mds.angle;
float const * d = mds.data;
if (h > 70 && (mds.code == int('(')
|| mds.code == int(')')))
d = parenthHigh;
#else
math_deco_struct const * mds = search_deco(code); math_deco_struct const * mds = search_deco(code);
if (!mds) { if (!mds) {
// Should this ever happen? // Should this ever happen?
@ -409,14 +502,11 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
return; return;
} }
int const r = mds->angle; int const r = mds->angle;
float const * d = mds->data; float const * d = mds->data;
if (h > 70 && (mds->code == int('(') if (h > 70 && (mds->code == int('(') || mds->code == int(')')))
|| mds->code == int(')')))
d = parenthHigh; d = parenthHigh;
#endif
mt.rota(r); mt.rota(r);
mt.escala(w, h); mt.escala(w, h);
@ -469,20 +559,6 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
} }
math_deco_struct const * search_deco(int code)
{
math_deco_struct search_elem = { code, 0, 0 };
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
search_elem, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res;
return 0;
}
bool MathIsInset(short x) bool MathIsInset(short x)
{ {

View File

@ -14,12 +14,6 @@ class Painter;
class MathArray; class MathArray;
class MathMatrixInset; class MathMatrixInset;
struct math_deco_struct {
int code;
float const * data;
int angle;
};
extern char const * math_font_name[]; extern char const * math_font_name[];
extern char const * latex_mathspace[]; extern char const * latex_mathspace[];
@ -37,8 +31,6 @@ int mathed_string_height(short type, int size, string const & s,
int & asc, int & des); int & asc, int & des);
int mathed_string_width(short type, int size, string const & s); int mathed_string_width(short type, int size, string const & s);
math_deco_struct const * search_deco(int code);
bool MathIsInset(short x); bool MathIsInset(short x);
bool MathIsAlphaFont(short x); bool MathIsAlphaFont(short x);
bool MathIsBOPS(short x); bool MathIsBOPS(short x);
@ -50,4 +42,5 @@ void drawStr(Painter & pain, short type, int siz,
int x, int y, string const & s); int x, int y, string const & s);
void drawChar(Painter & pain, short type, int siz, void drawChar(Painter & pain, short type, int siz,
int x, int y, char c); int x, int y, char c);
#endif #endif

View File

@ -1,450 +1,238 @@
// This -*- C++ -*- file was created automatically. // This -*- C++ -*- file was created automatically.
// Don't change it! [asierra18jan96] // Don't change it! [asierra18jan96]
// Why? [andre]
#ifndef SYMBOL_DEF #ifndef SYMBOL_DEF
#define SYMBOL_DEF #define SYMBOL_DEF
// Symbols that do exist in X11 symbol font enum Math_Symbols_enum {
/// // Accents
#define LM_Gamma 0x47 LM_acute = '\'',
/// LM_grave = '`',
#define LM_Delta 0x44 LM_hat = '^',
/// LM_tilde = '~',
#define LM_Theta 0x51 LM_dot = '.',
/// LM_bar = '-',
#define LM_Lambda 0x4c
///
#define LM_Xi 0x58
///
#define LM_Pi 0x50
///
#define LM_Sigma 0x53
//#define LM_Upsilon 0x55
///
#define LM_Upsilon 0xa1
///
#define LM_Phi 0x46
///
#define LM_Psi 0x59
///
#define LM_Omega 0x57
///
#define LM_alpha 0x61
///
#define LM_beta 0x62
///
#define LM_gamma 0x67
///
#define LM_delta 0x64
///
#define LM_varepsilon 0x65
///
#define LM_eta 0x68
///
#define LM_theta 0x71
///
#define LM_vartheta 0x4a
///
#define LM_iota 0x69
///
#define LM_kappa 0x6b
///
#define LM_lambda 0x6c
///
#define LM_mu 0x6d
///
#define LM_nu 0x6e
///
#define LM_xi 0x78
///
#define LM_pi 0x70
///
#define LM_varpi 0x76
///
#define LM_rho 0x72
///
#define LM_sigma 0x73
///
#define LM_tau 0x74
///
#define LM_varsigma 0x56
///
#define LM_zeta 0x7a
///
#define LM_upsilon 0x75
///
#define LM_phi 0x66
///
#define LM_varphi 0x6a
///
#define LM_chi 0x63
///
#define LM_psi 0x79
///
#define LM_omega 0x77
///
#define LM_downarrow 0xaf
///
#define LM_leftarrow 0xac
///
#define LM_Downarrow 0xdf
///
#define LM_Leftarrow 0xdc
///
#define LM_rightarrow 0xae
///
#define LM_uparrow 0xad
///
#define LM_Rightarrow 0xde
///
#define LM_Uparrow 0xdd
///
#define LM_Leftrightarrow 0xdb
///
#define LM_leftrightarrow 0xab
///
#define LM_leq 0xa3
///
#define LM_geq 0xb3
///
#define LM_equiv 0xba
///
#define LM_subset 0xcc
///
#define LM_supset 0xc9
///
#define LM_approx 0xbb
///
#define LM_subseteq 0xcd
///
#define LM_supseteq 0xca
///
#define LM_cong 0x40
///
#define LM_neq 0xb9
///
#define LM_in 0xce
///
#define LM_propto 0xb5
///
#define LM_pm 0xb1
///
#define LM_cap 0xc7
///
#define LM_diamond 0xe0
///
#define LM_oplus 0xc5
///
#define LM_cup 0xc8
///
#define LM_times 0xb4
///
#define LM_otimes 0xc4
///
#define LM_div 0xb8
///
#define LM_oslash 0xc6
///
#define LM_cdot 0xd7
///
#define LM_wedge 0xd9
///
#define LM_bullet 0xb7
///
#define LM_sum 0xe5
///
#define LM_int 0xf2
///
#define LM_prod 0xd5
///
#define LM_nabla 0xd1
///
#define LM_partial 0xb6
///
#define LM_infty 0xa5
///
#define LM_prime 0xa2
//#define LM_emptyset 0xc6
///
#define LM_exists 0x24
///
#define LM_forall 0x22
///
#define LM_Re 0xc2
///
#define LM_Im 0xc1
///
#define LM_aleph 0xc0
///
#define LM_wp 0xc3
///
#define LM_bot 0x5e
///
#define LM_neg 0xd8
///
#define LM_sharp 0x23
///
#define LM_surd 0xd6
///
#define LM_diamondsuit 0xa8
///
#define LM_heartsuit 0xa9
///
#define LM_clubsuit 0xa7
///
#define LM_spadesuit 0xaa
///
#define LM_langle 0xe1
///
#define LM_lceil 0xe9
///
#define LM_lfloor 0xeb
///
#define LM_rangle 0xf1
///
#define LM_rceil 0xf9
///
#define LM_rfloor 0xfb
///
#define LM_mid 0x7c
///
#define LM_angle 0xd0
///
#define LM_vee 0xda
//#define LM_backslash '\\' LM_quad = 4,
LM_qquad = 5,
/// Symbols that don't exist in X11 symbol font but that we fake
LM_not = 10,
// Symbols that do exist in X11 symbol font
LM_Gamma = 0x47,
LM_Delta = 0x44,
LM_Theta = 0x51,
LM_Lambda = 0x4c,
LM_Xi = 0x58,
LM_Pi = 0x50,
LM_Sigma = 0x53,
//LM_Upsilon = 0x55,
LM_Upsilon = 0xa1,
LM_Phi = 0x46,
LM_Psi = 0x59,
LM_Omega = 0x57,
LM_alpha = 0x61,
LM_beta = 0x62,
LM_gamma = 0x67,
LM_delta = 0x64,
LM_varepsilon = 0x65,
LM_eta = 0x68,
LM_theta = 0x71,
LM_vartheta = 0x4a,
LM_iota = 0x69,
LM_kappa = 0x6b,
LM_lambda = 0x6c,
LM_mu = 0x6d,
LM_nu = 0x6e,
LM_xi = 0x78,
LM_pi = 0x70,
LM_varpi = 0x76,
LM_rho = 0x72,
LM_sigma = 0x73,
LM_tau = 0x74,
LM_varsigma = 0x56,
LM_zeta = 0x7a,
LM_upsilon = 0x75,
LM_phi = 0x66,
LM_varphi = 0x6a,
LM_chi = 0x63,
LM_psi = 0x79,
LM_omega = 0x77,
LM_downarrow = 0xaf,
LM_leftarrow = 0xac,
LM_Downarrow = 0xdf,
LM_Leftarrow = 0xdc,
LM_rightarrow = 0xae,
LM_uparrow = 0xad,
LM_Rightarrow = 0xde,
LM_Uparrow = 0xdd,
LM_Leftrightarrow = 0xdb,
LM_leftrightarrow = 0xab,
LM_leq = 0xa3,
LM_geq = 0xb3,
LM_equiv = 0xba,
LM_subset = 0xcc,
LM_supset = 0xc9,
LM_approx = 0xbb,
LM_subseteq = 0xcd,
LM_supseteq = 0xca,
LM_cong = 0x40,
LM_neq = 0xb9,
LM_in = 0xce,
LM_propto = 0xb5,
LM_pm = 0xb1,
LM_cap = 0xc7,
LM_diamond = 0xe0,
LM_oplus = 0xc5,
LM_cup = 0xc8,
LM_times = 0xb4,
LM_otimes = 0xc4,
LM_div = 0xb8,
LM_oslash = 0xc6,
LM_cdot = 0xd7,
LM_wedge = 0xd9,
LM_bullet = 0xb7,
LM_sum = 0xe5,
LM_int = 0xf2,
LM_prod = 0xd5,
LM_nabla = 0xd1,
LM_partial = 0xb6,
LM_infty = 0xa5,
LM_prime = 0xa2,
//LM_emptyset = 0xc6,
LM_exists = 0x24,
LM_forall = 0x22,
LM_Re = 0xc2,
LM_Im = 0xc1,
LM_aleph = 0xc0,
LM_wp = 0xc3,
LM_bot = 0x5e,
LM_neg = 0xd8,
LM_sharp = 0x23,
LM_surd = 0xd6,
LM_diamondsuit = 0xa8,
LM_heartsuit = 0xa9,
LM_clubsuit = 0xa7,
LM_spadesuit = 0xaa,
LM_langle = 0xe1,
LM_lceil = 0xe9,
LM_lfloor = 0xeb,
LM_rangle = 0xf1,
LM_rceil = 0xf9,
LM_rfloor = 0xfb,
LM_mid = 0x7c,
LM_angle = 0xd0,
LM_vee = 0xda,
//LM_backslash '\\'
/// Symbols that don't exist in X11 symbol font /// Symbols that don't exist in X11 symbol font
enum Math_Symbols_enum {
///
LM_NoFont = 256, LM_NoFont = 256,
///
LM_epsilon, LM_epsilon,
///
LM_hookleftarrow, LM_hookleftarrow,
///
LM_hookrightarrow, LM_hookrightarrow,
///
LM_updownarrow, LM_updownarrow,
///
LM_leftharpoonup, LM_leftharpoonup,
///
LM_rightharpoonup, LM_rightharpoonup,
///
LM_rightleftharpoons, LM_rightleftharpoons,
///
LM_Updownarrow, LM_Updownarrow,
///
LM_leftharpoondown, LM_leftharpoondown,
///
LM_rightharpoondown, LM_rightharpoondown,
///
LM_mapsto, LM_mapsto,
///
LM_Longleftarrow, LM_Longleftarrow,
///
LM_Longrightarrow, LM_Longrightarrow,
///
LM_Longleftrightarrow, LM_Longleftrightarrow,
///
LM_longleftrightarrow, LM_longleftrightarrow,
///
LM_longleftarrow, LM_longleftarrow,
///
LM_longrightarrow, LM_longrightarrow,
///
LM_longmapsto, LM_longmapsto,
///
LM_nwarrow, LM_nwarrow,
///
LM_nearrow, LM_nearrow,
///
LM_swarrow, LM_swarrow,
///
LM_searrow, LM_searrow,
///
LM_models, LM_models,
///
LM_prec, LM_prec,
///
LM_succ, LM_succ,
///
LM_sim, LM_sim,
///
LM_perp, LM_perp,
///
LM_preceq, LM_preceq,
///
LM_succeq, LM_succeq,
///
LM_simeq, LM_simeq,
///
LM_ll, LM_ll,
///
LM_gg, LM_gg,
///
LM_asymp, LM_asymp,
///
LM_parallel, LM_parallel,
///
LM_smile, LM_smile,
///
LM_frown, LM_frown,
///
LM_sqsubseteq, LM_sqsubseteq,
///
LM_sqsupseteq, LM_sqsupseteq,
///
LM_doteq, LM_doteq,
///
LM_ni, LM_ni,
///
LM_notin, LM_notin,
///
LM_vdash, LM_vdash,
///
LM_dashv, LM_dashv,
///
LM_bowtie, LM_bowtie,
///
LM_mp, LM_mp,
///
LM_bigtriangleup, LM_bigtriangleup,
///
LM_ominus, LM_ominus,
///
LM_uplus, LM_uplus,
///
LM_bigtriangledown, LM_bigtriangledown,
///
LM_sqcap, LM_sqcap,
///
LM_triangleright, LM_triangleright,
///
LM_sqcup, LM_sqcup,
///
LM_triangleleft, LM_triangleleft,
///
LM_odot, LM_odot,
///
LM_star, LM_star,
///
LM_amalg, LM_amalg,
///
LM_bigcirc, LM_bigcirc,
///
LM_setminus, LM_setminus,
///
LM_dagger, LM_dagger,
///
LM_circ, LM_circ,
///
LM_wr, LM_wr,
///
LM_ddagger, LM_ddagger,
///
LM_oint, LM_oint,
///
LM_coprod, LM_coprod,
///
LM_bigsqcup, LM_bigsqcup,
///
LM_bigotimes, LM_bigotimes,
///
LM_bigodot, LM_bigodot,
///
LM_bigoplus, LM_bigoplus,
///
LM_bigcap, LM_bigcap,
///
LM_bigcup, LM_bigcup,
///
LM_biguplus, LM_biguplus,
///
LM_bigvee, LM_bigvee,
///
LM_bigwedge, LM_bigwedge,
///
LM_ell, LM_ell,
///
LM_imath, LM_imath,
///
LM_jmath, LM_jmath,
///
LM_hbar, LM_hbar,
///
LM_top, LM_top,
///
LM_Vert, LM_Vert,
///
LM_flat, LM_flat,
///
LM_natural, LM_natural,
///
LM_triangle, LM_triangle,
///
LM_widehat, LM_widehat,
///
LM_widetilde, LM_widetilde,
///
LM_underline, LM_underline,
///
LM_overline, LM_overline,
///
LM_underbrace, LM_underbrace,
///
LM_overbrace, LM_overbrace,
///
LM_overleftarrow, LM_overleftarrow,
///
LM_overightarrow, LM_overightarrow,
///
LM_ldots, LM_ldots,
///
LM_cdots, LM_cdots,
///
LM_vdots, LM_vdots,
///
LM_ddots, LM_ddots,
///
LM_backslash, LM_backslash,
///
LM_emptyset, LM_emptyset,
///
LM_last_symbol
};
// Accents /// Accents that don't exist in X11 symbol font
/// LM_ddot,
#define LM_acute '\''
///
#define LM_grave '`'
///
#define LM_hat '^'
///
#define LM_tilde '~'
///
#define LM_dot '.'
///
#define LM_bar '-'
///
enum Math_Accent_enum {
///
LM_ddot = LM_last_symbol,
///
LM_check, LM_check,
///
LM_vec, LM_vec,
/// LM_breve
LM_breve,
///
LM_not
}; };
///
#define LM_quad 4
///
#define LM_qquad 5
#endif #endif