From f4892a2d334b8421999b03f70b962a0aaeab018d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 3 Jan 2002 12:02:54 +0000 Subject: [PATCH] visual support for \displaystyle git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3280 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 ++++++++ src/mathed/formulabase.C | 4 ++-- src/mathed/math_boxinset.C | 11 +++-------- src/mathed/math_cursor.C | 1 + src/mathed/math_factory.C | 3 +++ src/mathed/math_hash.C | 3 ++- src/mathed/math_lefteqninset.C | 9 ++------- src/mathed/math_parser.C | 21 ++++++++------------- src/mathed/math_sizeinset.C | 10 ++++++---- src/mathed/math_support.C | 9 +++++++++ src/mathed/math_support.h | 3 +++ 11 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 1738fc7090..8d9b99f5d2 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ + +2002-01-03 André Pönitz + + * formulabase.[Ch]: implement simple search + + * math_sizeinset.[Ch]: support for \displaystyle etc + + 2001-12-18 Dekel Tsur * math_macrotable.C (builtinMacros): Adjust kern values. diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 26a4f1b526..5c275b1ddf 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -280,8 +280,8 @@ void InsetFormulaBase::insetButtonPress(BufferView * bv, return; } - //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_ - // << " but: " << button << "\n"; + lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_ + << " but: " << button << "\n"; switch (button) { default: case 1: diff --git a/src/mathed/math_boxinset.C b/src/mathed/math_boxinset.C index b2ed64015f..8065cd136d 100644 --- a/src/mathed/math_boxinset.C +++ b/src/mathed/math_boxinset.C @@ -5,13 +5,11 @@ #endif #include "math_boxinset.h" -#include "support/LOstream.h" -#include "debug.h" -#include "Painter.h" -#include "math_cursor.h" +#include "math_support.h" #include "math_mathmlstream.h" #include "math_streamstr.h" + MathBoxInset::MathBoxInset(string const & name) : MathGridInset(1, 1), name_(name) {} @@ -46,8 +44,5 @@ void MathBoxInset::rebreak() void MathBoxInset::draw(Painter & pain, int x, int y) const { MathGridInset::draw(pain, x, y); - if (mathcursor && mathcursor->isInside(this)) { - pain.rectangle(x - 1, y - ascent() - 1, width(), height(), - LColor::mathframe); - } + mathed_draw_framebox(pain, x, y, this); } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 24e53be570..2cc8113baf 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1275,6 +1275,7 @@ bool MathCursor::interpret(string const & s) return true; } + bool MathCursor::script(bool up) { macroModeClose(); diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index 327624ec0d..7e09a0abcc 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -15,6 +15,7 @@ #include "math_macroarg.h" #include "math_notinset.h" #include "math_rootinset.h" +#include "math_sizeinset.h" #include "math_spaceinset.h" #include "math_specialcharinset.h" #include "math_sqrtinset.h" @@ -68,6 +69,8 @@ MathAtom createMathInset(latexkeys const * l) return MathAtom(new MathBoxInset(l->name)); case LM_TK_FUNC: return MathAtom(new MathFuncInset(l->name)); + case LM_TK_STY: + return MathAtom(new MathSizeInset(l)); } return MathAtom(new MathUnknownInset(l->name)); } diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 1f22147ab4..99956ad3fd 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -1,6 +1,7 @@ #include #include "math_parser.h" +#include "math_metricsinfo.h" #include "lyxlex.h" #include "debug.h" #include "support/filetools.h" // LibFileSearch @@ -65,7 +66,7 @@ key_type wordlist_array[] = {"deg", LM_TK_FUNC, 0}, {"det", LM_TK_FUNCLIM, 0}, {"dim", LM_TK_FUNC, 0}, - //{"displaystyle", LM_TK_STY, LM_ST_DISPLAY}, + {"displaystyle", LM_TK_STY, LM_ST_DISPLAY}, {"dot", LM_TK_DECORATION, 0}, {"end", LM_TK_END, 0}, {"exp", LM_TK_FUNC, 0}, diff --git a/src/mathed/math_lefteqninset.C b/src/mathed/math_lefteqninset.C index 99eb3159a2..318a634549 100644 --- a/src/mathed/math_lefteqninset.C +++ b/src/mathed/math_lefteqninset.C @@ -3,10 +3,8 @@ #endif #include "math_lefteqninset.h" -#include "LColor.h" -#include "Painter.h" -#include "math_cursor.h" #include "math_mathmlstream.h" +#include "math_support.h" MathLefteqnInset::MathLefteqnInset() @@ -32,10 +30,7 @@ void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const void MathLefteqnInset::draw(Painter & pain, int x, int y) const { xcell(0).draw(pain, x + 2, y); - if (mathcursor && mathcursor->isInside(this)) { - pain.rectangle(x, y - ascent(), xcell(0).width(), height(), - LColor::mathframe); - } + //mathed_draw_framebox(pain, x, y, this); } diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 7538fce72c..b67ea0112e 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -64,6 +64,7 @@ point to write some macros: #include "math_macrotemplate.h" #include "math_hullinset.h" #include "math_rootinset.h" +#include "math_sizeinset.h" #include "math_sqrtinset.h" #include "math_scriptinset.h" #include "math_specialcharinset.h" @@ -899,19 +900,6 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) return; } -/* - case LM_TK_STY: - { - lyxerr[Debug::MATHED] << "LM_TK_STY not implemented\n"; - //MathArray tmp = array; - //MathSizeInset * p = new MathSizeInset(MathStyles(lval_->id)); - //array.push_back(p); - //parse_into(p->cell(0), FLAG_BRACE_FONT); - break; - } - -*/ - else if (t.cs() == "begin") { string const name = getArg('{', '}'); if (name == "array") { @@ -1000,6 +988,13 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) array.push_back(p); } + else if (l->token == LM_TK_STY) { + MathAtom p = createMathInset(t.cs()); + parse_into(p->cell(0), flags, code); + array.push_back(p); + return; + } + else { MathAtom p = createMathInset(t.cs()); for (MathInset::idx_type i = 0; i < p->nargs(); ++i) diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index 02f45c00af..0f4eb4667a 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -8,6 +8,7 @@ #include "math_parser.h" #include "math_mathmlstream.h" #include "math_streamstr.h" +#include "math_support.h" MathSizeInset::MathSizeInset(latexkeys const * l) @@ -23,7 +24,8 @@ MathInset * MathSizeInset::clone() const void MathSizeInset::draw(Painter & pain, int x, int y) const { - xcell(0).draw(pain, x, y); + xcell(0).draw(pain, x + 1, y); + mathed_draw_framebox(pain, x, y, this); } @@ -32,9 +34,9 @@ void MathSizeInset::metrics(MathMetricsInfo const & mi) const MathMetricsInfo m = mi; m.style = MathStyles(key_->id); xcell(0).metrics(m); - ascent_ = xcell(0).ascent_; - descent_ = xcell(0).descent_; - width_ = xcell(0).width_; + ascent_ = xcell(0).ascent_ + 1; + descent_ = xcell(0).descent_ + 1; + width_ = xcell(0).width_ + 2; } diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index 3f6ee22868..a7ffa7949c 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -6,6 +6,7 @@ #include "lyxfont.h" #include "FontLoader.h" #include "font.h" +#include "math_cursor.h" #include "math_defs.h" #include "math_inset.h" #include "math_parser.h" @@ -709,6 +710,14 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, } +void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const * p) +{ + if (mathcursor && mathcursor->isInside(p)) + pain.rectangle(x, y - p->ascent(), p->width(), p->height(), + LColor::mathframe); +} + + // In the future maybe we use a better fonts renderer void drawStr(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz, int x, int y, string const & s) diff --git a/src/mathed/math_support.h b/src/mathed/math_support.h index 2b219a39a5..5be27bc06d 100644 --- a/src/mathed/math_support.h +++ b/src/mathed/math_support.h @@ -9,6 +9,7 @@ class Painter; class latexkeys; class MathMetricsInfo; +class MathInset; extern char const * latex_mathspace[]; @@ -26,6 +27,8 @@ int mathed_char_descent(MathTextCodes type, MathMetricsInfo const & size, void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, string const & name); +void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const *); + void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size, string const & s, int & asc, int & des, int & wid); int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size, -- 2.39.2