> Can you recreate this (if needed to avoid ) so that we wont get > conflicts. I attach a new diff against my current tree. Note that two files are empty now and could be removed.. Andre' -- André Pönitz ........................................ [EMAIL PROTECTED]
? mathed22.diff ? .math_draw.C.swp ? mathedbug.diff ? mathed16.diff ? mathed21.diff ? .ChangeLog.swp ? mathed19.diff ? mathed17.diff ? mathed18.diff ? mathed20.diff Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v retrieving revision 1.29 diff -u -p -u -r1.29 ChangeLog --- ChangeLog 2001/02/15 12:22:01 1.29 +++ ChangeLog 2001/02/15 13:10:19 @@ -1,3 +1,20 @@ + +2001-02-15 André Pönitz <[EMAIL PROTECTED]> + + * math_bigopinset.C: + * math_accentinset.C: + * math_fracinset.C: + * math_matrixinset.C: + * math_panel.C: + * math_root.C: + * formula.C: reformatting + + * math_delim.C: + * math_draw.C: are empty now! + + * math_support.[Ch]: move search_deco(int code) + + 2001-02-15 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * matriz.C: clean up a bit. Index: math_bigopinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_bigopinset.C,v retrieving revision 1.3 diff -u -p -u -r1.3 math_bigopinset.C --- math_bigopinset.C 2001/02/15 12:22:01 1.3 +++ math_bigopinset.C 2001/02/15 13:10:19 @@ -39,8 +39,7 @@ MathedInset * MathBigopInset::Clone() } -void -MathBigopInset::draw(Painter & pain, int x, int y) +void MathBigopInset::draw(Painter & pain, int x, int y) { string s; short t; @@ -52,19 +51,19 @@ MathBigopInset::draw(Painter & pain, int s = name; t = LM_TC_TEXTRM; } + if (sym == LM_oint) { pain.arc(x, y - 5 * width / 4, width, width, 0, 360*64, LColor::mathline); ++x; } + pain.text(x, y, s, mathed_get_font(t, size())); } -void -MathBigopInset::Metrics() +void MathBigopInset::Metrics() { - //char c; string s; short t; @@ -76,9 +75,11 @@ MathBigopInset::Metrics() s = name; t = LM_TC_TEXTRM; } + mathed_string_height(t, size(), s, ascent, descent); width = mathed_string_width(t, size(), s); - if (sym == LM_oint) width += 2; + if (sym == LM_oint) + width += 2; } Index: math_delim.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_delim.C,v retrieving revision 1.18 diff -u -p -u -r1.18 math_delim.C --- math_delim.C 2001/02/15 12:22:01 1.18 +++ math_delim.C 2001/02/15 13:10:19 @@ -1,64 +0,0 @@ - /* - * File: math_delim.C - * Purpose: Draw delimiters and decorations - * Author: Alejandro Aguilar Sierra <[EMAIL PROTECTED]> - * Created: January 1996 - * Description: Vectorial fonts for simple and resizable objets. - * - * Dependencies: Xlib, XForms - * - * Copyright: 1996, Alejandro Aguilar Sierra - * - * Version: 0.8beta, Mathed & Lyx project. - * - * You are free to use and modify this code under the terms of - * the GNU General Public Licence version 2 or later. - */ - -#include <config.h> - -#include FORMS_H_LOCATION -#include <algorithm> -#include "symbol_def.h" -#include "math_inset.h" -#include "LColor.h" -#include "Painter.h" -#include "math_deliminset.h" -#include "mathed/support.h" - -using std::sort; -using std::lower_bound; -using std::endl; - -/* - * Internal struct of a drawing: code n x1 y1 ... xn yn, where code is: - * 0 = end, 1 = line, 2 = polyline, 3 = square line, 4= square polyline - */ - - - -//inline -//int odd(int x) { return ((x) & 1); } - -//typedef float matriz_data[2][2]; - -//const matriz_data MATIDEN= { {1, 0}, {0, 1}}; - -//extern int mathed_char_width(short type, int style, byte c); -//extern int mathed_char_height(short, int, byte, int &, int &); - -//#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data)) - - - - - - - - - - -// If we had exceptions we could return a reference in stead and not -// have to check for a null pointer in mathed_draw_deco - - Index: math_dotsinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_dotsinset.C,v retrieving revision 1.3 diff -u -p -u -r1.3 math_dotsinset.C --- math_dotsinset.C 2001/02/15 12:22:01 1.3 +++ math_dotsinset.C 2001/02/15 13:10:19 @@ -17,32 +17,31 @@ MathedInset * MathDotsInset::Clone() } -void -MathDotsInset::draw(Painter & pain, int x, int y) +void MathDotsInset::draw(Painter & pain, int x, int y) { mathed_draw_deco(pain, x + 2, y - dh, width - 2, ascent, code); - if (code == LM_vdots || code == LM_ddots) ++x; - if (code != LM_vdots) --y; + if (code == LM_vdots || code == LM_ddots) + ++x; + if (code != LM_vdots) + --y; mathed_draw_deco(pain, x + 2, y - dh, width - 2, ascent, code); } -void -MathDotsInset::Metrics() +void MathDotsInset::Metrics() { mathed_char_height(LM_TC_VAR, size(), 'M', ascent, descent); width = mathed_char_width(LM_TC_VAR, size(), 'M'); switch (code) { - case LM_ldots: dh = 0; break; - case LM_cdots: dh = ascent/2; break; - case LM_vdots: width /= 2; - case LM_ddots: dh = ascent; break; + case LM_ldots: dh = 0; break; + case LM_cdots: dh = ascent/2; break; + case LM_vdots: width /= 2; + case LM_ddots: dh = ascent; break; } } -void -MathDotsInset::Write(ostream & os, bool /* fragile */) +void MathDotsInset::Write(ostream & os, bool /* fragile */) { os << '\\' << name << ' '; } Index: math_draw.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_draw.C,v retrieving revision 1.18 diff -u -p -u -r1.18 math_draw.C --- math_draw.C 2001/02/13 19:10:18 1.18 +++ math_draw.C 2001/02/15 13:10:19 @@ -1,38 +0,0 @@ -/* - * File: math_draw.C - * Purpose: Interaction and drawing for mathed - * Author: Alejandro Aguilar Sierra <[EMAIL PROTECTED]> - * Created: January 1996 - * Description: Math drawing and interaction for a WYSIWYG math editor. - * - * Dependencies: Xlib, XForms - * - * Copyright: 1996, Alejandro Aguilar Sierra - * - * Version: 0.8beta, Mathed & Lyx project. - * - * You are free to use and modify this code under the terms of - * the GNU General Public Licence version 2 or later. - */ - -#include <config.h> -#include FORMS_H_LOCATION -#include "math_cursor.h" -#include "math_parser.h" -#include "debug.h" -#include "lyxfont.h" -#include "Painter.h" - -using std::endl; - -//extern LyXFont const mathed_get_font(short type, int size); -//extern int mathed_char_width(short type, int style, byte c); -//extern int mathed_string_width(short type, int style, string const &); -//extern int mathed_string_height(short, int, string const &, int &, int &); -//extern int mathed_char_height(short, int, byte, int &, int &); - - - - - - Index: math_fracinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_fracinset.C,v retrieving revision 1.3 diff -u -p -u -r1.3 math_fracinset.C --- math_fracinset.C 2001/02/15 12:22:01 1.3 +++ math_fracinset.C 2001/02/15 13:10:19 @@ -13,9 +13,8 @@ using std::ostream; MathFracInset::MathFracInset(short ot) : MathParInset(LM_ST_TEXT, "frac", ot) { - den = new MathParInset(LM_ST_TEXT); // this leaks - dh = 0; + dh = 0; idx = 0; if (objtype == LM_OT_STACKREL) { flag |= LMPF_SCRIPT; @@ -37,7 +36,7 @@ MathedInset * MathFracInset::Clone() MathedIter itd(den->GetData()); p->SetData(itn.Copy(), itd.Copy()); p->idx = idx; - p->dh = dh; + p->dh = dh; return p; } @@ -73,9 +72,8 @@ void MathFracInset::SetData(MathedArray { if (idx == 0) MathParInset::SetData(d); - else { + else den->SetData(d); - } } @@ -111,18 +109,19 @@ bool MathFracInset::Inside(int x, int y) void MathFracInset::SetFocus(int /*x*/, int y) { // lyxerr << "y " << y << " " << yo << " " << den->yo << " "; - idx = (y > yo()) ? 1: 0; + idx = (y > yo()) ? 1 : 0; } -void -MathFracInset::draw(Painter & pain, int x, int y) +void MathFracInset::draw(Painter & pain, int x, int y) { - short idxp = idx; + short idxp = idx; short sizex = size(); idx = 0; - if (size() == LM_ST_DISPLAY) incSize(); + if (size() == LM_ST_DISPLAY) + incSize(); + MathParInset::draw(pain, x + (width - w0) / 2, y - des0); den->draw(pain, x + (width - w1) / 2, y + den->Ascent() + 2 - dh); size(sizex); @@ -132,28 +131,32 @@ MathFracInset::draw(Painter & pain, int } -void -MathFracInset::Metrics() +void MathFracInset::Metrics() { if (!dh) { int a, b; dh = mathed_char_height(LM_TC_CONST, size(), 'I', a, b) / 2; } - short idxp = idx; + + short idxp = idx; short sizex = size(); idx = 0; - if (size() == LM_ST_DISPLAY) incSize(); + if (size() == LM_ST_DISPLAY) + incSize(); + MathParInset::Metrics(); + size(sizex); - w0 = width; - int as = Height() + 2 + dh; - des0 = Descent() + 2 + dh; + w0 = width; + int as = Height() + 2 + dh; + des0 = Descent() + 2 + dh; + den->Metrics(); - w1 = den->Width(); - width = ((w0 > w1) ? w0: w1) + 12; - ascent = as; - descent = den->Height()+ 2 - dh; - idx = idxp; + w1 = den->Width(); + width = (w0 > w1 ? w0 : w1) + 12; + ascent = as; + descent = den->Height() + 2 - dh; + idx = idxp; } Index: math_matrixinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v retrieving revision 1.2 diff -u -p -u -r1.2 math_matrixinset.C --- math_matrixinset.C 2001/02/14 15:00:50 1.2 +++ math_matrixinset.C 2001/02/15 13:10:19 @@ -11,23 +11,24 @@ extern int number_of_newlines; MathMatrixInset::MathMatrixInset(int m, int n, short st) : MathParInset(st, "array", LM_OT_MATRIX), nc(m), nr(0), ws_(m), - v_align(0), h_align(nc, 'c') + v_align(0), h_align(nc, 'c') { - row = 0; - flag = 15; - if (n > 0) { - row = new MathedRowSt(nc+1); - MathedXIter it(this); - for (int j = 1; j < n; ++j) it.addRow(); - nr = n; - if (nr == 1 && nc > 1) { - for (int j = 0; j < nc - 1; ++j) - it.Insert('T', LM_TC_TAB); + row = 0; + flag = 15; + if (n > 0) { + row = new MathedRowSt(nc + 1); + MathedXIter it(this); + for (int j = 1; j < n; ++j) + it.addRow(); + nr = n; + if (nr == 1 && nc > 1) { + for (int j = 0; j < nc - 1; ++j) + it.Insert('T', LM_TC_TAB); + } + } else if (n < 0) { + row = new MathedRowSt(nc + 1); + nr = 1; } - } else if (n < 0) { - row = new MathedRowSt(nc + 1); - nr = 1; - } } @@ -35,230 +36,266 @@ MathMatrixInset::MathMatrixInset(MathMat : MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType()), nc(mt->nc), nr(0), ws_(mt->nc), v_align(mt->v_align), h_align(mt->h_align) { - MathedIter it; - it.SetData(mt->GetData()); - array = it.Copy(); - if (mt->row != 0) { - MathedRowSt * r, * ro= 0, * mrow = mt->row; - //mrow = mt->row; // This must be redundant... - while (mrow) { - r = new MathedRowSt(nc + 1); - r->setNumbered(mrow->isNumbered()); - //if (mrow->label) - r->setLabel(mrow->getLabel()); - if (!ro) - row = r; - else - ro->setNext(r); - mrow = mrow->getNext(); - ro = r; - ++nr; - } - } else - row = 0; - flag = mt->flag; + MathedIter it; + it.SetData(mt->GetData()); + array = it.Copy(); + if (mt->row != 0) { + MathedRowSt * r; + MathedRowSt * ro = 0; + MathedRowSt * mrow = mt->row; + + while (mrow) { + r = new MathedRowSt(nc + 1); + r->setNumbered(mrow->isNumbered()); + //if (mrow->label) + r->setLabel(mrow->getLabel()); + if (!ro) + row = r; + else + ro->setNext(r); + mrow = mrow->getNext(); + ro = r; + ++nr; + } + } else + row = 0; + flag = mt->flag; } MathMatrixInset::~MathMatrixInset() { - MathedRowSt * r = row; - while (r) { - MathedRowSt * q = r->getNext(); - delete r; - r = q; - } + MathedRowSt * r = row; + while (r) { + MathedRowSt * q = r->getNext(); + delete r; + r = q; + } } MathedInset * MathMatrixInset::Clone() { - return new MathMatrixInset(this); + return new MathMatrixInset(this); } void MathMatrixInset::SetAlign(char vv, string const & hh) { - v_align = vv; - h_align = hh.substr(0, nc); // usr just h_align = hh; perhaps + v_align = vv; + h_align = hh.substr(0, nc); // usr just h_align = hh; perhaps } // Check the number of tabs and crs void MathMatrixInset::SetData(MathedArray * a) { - if (!a) return; - MathedIter it(a); - int nn = nc - 1; - nr = 1; - // count tabs per row - while (it.OK()) { - if (it.IsTab()) { - if (nn < 0) { - it.Delete(); - continue; - } else { -// it.Next(); - --nn; - } - } - if (it.IsCR()) { - while (nn > 0) { - it.Insert(' ', LM_TC_TAB); - --nn; - } - nn = nc - 1; - ++nr; - } - it.Next(); - } - it.Reset(); - - // Automatically inserts tabs around bops - // DISABLED because it's very easy to insert tabs - array = a; + if (!a) + return; + + MathedIter it(a); + int nn = nc - 1; + nr = 1; + + // count tabs per row + while (it.OK()) { + if (it.IsTab()) { + if (nn < 0) { + it.Delete(); + continue; + } else { + // it.Next(); + --nn; + } + } + + if (it.IsCR()) { + while (nn > 0) { + it.Insert(' ', LM_TC_TAB); + --nn; + } + nn = nc - 1; + ++nr; + } + + it.Next(); + } + it.Reset(); + + // Automatically inserts tabs around bops + // DISABLED because it's very easy to insert tabs + array = a; } void MathMatrixInset::draw(Painter & pain, int x, int baseline) { - MathParInset::draw(pain, x, baseline); + MathParInset::draw(pain, x, baseline); } void MathMatrixInset::Metrics() { - int i, hl, h = 0; - MathedRowSt * cprow= 0; + MathedRowSt * cprow = 0; + + if (!row) { + // lyxerr << " MIDA "; + MathedXIter it(this); + row = it.adjustVerticalSt(); + } + + // Clean the arrays + MathedRowSt * cxrow = row; + while (cxrow) { + for (int i = 0; i <= nc; ++i) + cxrow->setTab(i, 0); + cxrow = cxrow->getNext(); + } + + // Basic metrics + MathParInset::Metrics(); + + if (nc <= 1 && !row->getNext()) { + row->ascent(ascent); + row->descent(descent); + } + + // Vertical positions of each row + cxrow = row; + int h = 0; + while (cxrow) { + for (int i = 0; i < nc; ++i) { + if (cxrow == row || ws_[i] < cxrow->getTab(i)) + ws_[i] = cxrow->getTab(i); + if (cxrow->getNext() == 0 && ws_[i] == 0) + ws_[i] = df_width; + } + + cxrow->setBaseline( + cxrow == row ? + cxrow->ascent() : + cxrow->ascent() + cprow->descent() + MATH_ROWSEP + +cprow->getBaseline() + ); + + h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP; + cprow = cxrow; + cxrow = cxrow->getNext(); + } - if (!row) { -// lyxerr << " MIDA "; - MathedXIter it(this); - row = it.adjustVerticalSt(); - } - - // Clean the arrays - MathedRowSt * cxrow = row; - while (cxrow) { - for (i = 0; i <= nc; ++i) cxrow->setTab(i, 0); - cxrow = cxrow->getNext(); - } - - // Basic metrics - MathParInset::Metrics(); - - if (nc <= 1 && !row->getNext()) { - row->ascent(ascent); - row->descent(descent); - } - - // Vertical positions of each row - cxrow = row; - while (cxrow) { - for (i = 0; i < nc; ++i) { - if (cxrow == row || ws_[i] < cxrow->getTab(i)) - ws_[i] = cxrow->getTab(i); - if (cxrow->getNext() == 0 && ws_[i] == 0) ws_[i] = df_width; - } - - cxrow->setBaseline((cxrow == row) ? - cxrow->ascent() : - cxrow->ascent() + cprow->descent() - + MATH_ROWSEP + cprow->getBaseline()); - h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP; - cprow = cxrow; - cxrow = cxrow->getNext(); - } - - hl = Descent(); - h -= MATH_ROWSEP; - - // Compute vertical align - switch (v_align) { - case 't': ascent = row->getBaseline(); break; - case 'b': ascent = h - hl; break; - default: ascent = (row->getNext()) ? h / 2: h - hl; break; - } - descent = h - ascent + 2; - - // Increase ws_[i] for 'R' columns (except the first one) - for (i = 1; i < nc; ++i) - if (h_align[i] == 'R') - ws_[i] += 10*df_width; - // Increase ws_[i] for 'C' column - if (h_align[0] == 'C') - if (ws_[0] < 7*workWidth/8) - ws_[0] = 7*workWidth/8; - - // Adjust local tabs - cxrow = row; - width = MATH_COLSEP; - while (cxrow) { - int rg = MATH_COLSEP, ww, lf = 0; //, * w = cxrow->w; - for (i = 0; i < nc; ++i) { - bool isvoid = false; - if (cxrow->getTab(i) <= 0) { - cxrow->setTab(i, df_width); - isvoid = true; - } - switch (h_align[i]) { - case 'l': - lf = 0; - break; - case 'c': - lf = (ws_[i] - cxrow->getTab(i))/2; - break; - case 'r': - case 'R': - lf = ws_[i] - cxrow->getTab(i); - break; - case 'C': - if (cxrow == row) - lf = 0; - else if (!cxrow->getNext()) - lf = ws_[i] - cxrow->getTab(i); - else - lf = (ws_[i] - cxrow->getTab(i))/2; - break; - } - ww = (isvoid) ? lf : lf + cxrow->getTab(i); - cxrow->setTab(i, lf + rg); - rg = ws_[i] - ww + MATH_COLSEP; - if (cxrow == row) width += ws_[i] + MATH_COLSEP; - } - cxrow->setBaseline(cxrow->getBaseline() - ascent); - cxrow = cxrow->getNext(); - } + int hl = Descent(); + h -= MATH_ROWSEP; + + // Compute vertical align + switch (v_align) { + case 't': + ascent = row->getBaseline(); + break; + + case 'b': + ascent = h - hl; + break; + + default: + ascent = row->getNext() ? h / 2 : h - hl; + break; + } + descent = h - ascent + 2; + + // Increase ws_[i] for 'R' columns (except the first one) + for (int i = 1; i < nc; ++i) + if (h_align[i] == 'R') + ws_[i] += 10 * df_width; + + // Increase ws_[i] for 'C' column + if (h_align[0] == 'C') + if (ws_[0] < 7*workWidth/8) + ws_[0] = 7*workWidth/8; + + // Adjust local tabs + cxrow = row; + width = MATH_COLSEP; + + while (cxrow) { + int rg = MATH_COLSEP; + int lf = 0; + for (int i = 0; i < nc; ++i) { + bool isvoid = false; + if (cxrow->getTab(i) <= 0) { + cxrow->setTab(i, df_width); + isvoid = true; + } + + switch (h_align[i]) { + case 'l': + lf = 0; + break; + + case 'c': + lf = (ws_[i] - cxrow->getTab(i)) / 2; + break; + + case 'r': + case 'R': + lf = ws_[i] - cxrow->getTab(i); + break; + + case 'C': + if (cxrow == row) + lf = 0; + else if (!cxrow->getNext()) + lf = ws_[i] - cxrow->getTab(i); + else + lf = (ws_[i] - cxrow->getTab(i)) / 2; + break; + } + int ww = isvoid ? lf : lf + cxrow->getTab(i); + cxrow->setTab(i, lf + rg); + rg = ws_[i] - ww + MATH_COLSEP; + if (cxrow == row) + width += ws_[i] + MATH_COLSEP; + } + cxrow->setBaseline(cxrow->getBaseline() - ascent); + cxrow = cxrow->getNext(); + } } void MathMatrixInset::Write(ostream & os, bool fragile) { - if (GetType() == LM_OT_MATRIX){ + if (GetType() == LM_OT_MATRIX) { if (fragile) os << "\\protect"; + os << "\\begin{" << name << '}'; + if (v_align == 't' || v_align == 'b') { os << '[' << char(v_align) << ']'; } + os << '{' << h_align << "}\n"; + ++number_of_newlines; } + MathParInset::Write(os, fragile); - if (GetType() == LM_OT_MATRIX){ + + if (GetType() == LM_OT_MATRIX) { os << "\n"; + if (fragile) os << "\\protect"; + os << "\\end{" << name << '}'; + ++number_of_newlines; } } Index: math_panel.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_panel.C,v retrieving revision 1.27 diff -u -p -u -r1.27 math_panel.C --- math_panel.C 2001/02/14 19:22:41 1.27 +++ math_panel.C 2001/02/15 13:10:19 @@ -3,10 +3,10 @@ * Purpose: Mathed GUI for lyx * Author: Alejandro Aguilar Sierra <[EMAIL PROTECTED]> * Created: March 28, 1996 - * + * * Dependencies: Xlib, Xpm, XForms, Lyx * - * Copyright: 1996, Alejandro Aguilar Sierra + * Copyright: 1996, Alejandro Aguilar Sierra * * You are free to use and modify it under the terms of * the GNU General Public Licence version 2 or later. @@ -18,7 +18,7 @@ #include FORMS_H_LOCATION -#include "lyx_gui_misc.h" +#include "lyx_gui_misc.h" #include "math_panel.h" #include "symbol_def.h" #include "formula.h" @@ -42,13 +42,28 @@ static LyXFunc * lyxfunc = 0; //static FD_panel* symb_form= 0; +void BitmapMenu::Prev() +{ + Hide(); + if (prev) + prev->Show(); +} + +void BitmapMenu::Next() +{ + Hide(); + if (next) + next->Show(); +} + + FD_panel * fd_panel; FD_delim * fd_delim; FD_deco * fd_deco; FD_space * fd_space; FD_matrix * fd_matrix; -int delim_code[] = { +int delim_code[] = { '(', ')', LM_lceil, LM_rceil, LM_uparrow, LM_Uparrow, '[', ']', LM_lfloor, LM_rfloor, LM_updownarrow, LM_Updownarrow, '{', '}', '/', LM_backslash, LM_downarrow, LM_Downarrow, @@ -69,7 +84,7 @@ int delim_rversion[] = { 1,1,3,3,4,5, static char const * deco_code[] = { - "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow", + "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow", "overline", "underbrace", "underline" }; @@ -87,257 +102,285 @@ static char h_align_str[80] = "c"; /* callbacks for form panel */ void button_cb(FL_OBJECT * ob, long data) -{ - extern void free_symbols_form(); - switch (data) { - case MM_GREEK: - case MM_VARSIZE: - case MM_BRELATS: - case MM_ARROW: - case MM_BOP: - case MM_MISC: - { - BitmapMenu * menu = static_cast<BitmapMenu *>(ob->u_vdata); - menu->Show(); - break; - } - case MM_FRAC: - lyxfunc->Dispatch(LFUN_INSERT_MATH, "frac"); - break; - case MM_SQRT: - lyxfunc->Dispatch(LFUN_INSERT_MATH, "sqrt"); - break; - case MM_DELIM: - fl_show_form(fd_delim->delim, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Delimiter")); - fl_set_form_atclose(fd_delim->delim, CancelCloseBoxCB, 0); - break; - case MM_DECO: - fl_show_form(fd_deco->deco, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Decoration")); - fl_set_form_atclose(fd_deco->deco, CancelCloseBoxCB, 0); - break; - case MM_SPACE: - fl_show_form(fd_space->space, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Spacing")); - fl_set_form_atclose(fd_space->space, CancelCloseBoxCB, 0); - break; - case MM_MATRIX: - fl_show_form(fd_matrix->matrix, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Matrix")); - fl_set_form_atclose(fd_matrix->matrix, CancelCloseBoxCB, 0); - break; - case MM_EQU: - lyxfunc->Dispatch(LFUN_MATH_DISPLAY); - break; - case MM_FUNC: - { - int i = fl_get_browser(fd_panel->func_browse) - 1; - lyxfunc->Dispatch(LFUN_INSERT_MATH, func_code[i]); - break; - } - case 100: - free_symbols_form(); - break; - } +{ + extern void free_symbols_form(); + + switch (data) { + case MM_GREEK: + case MM_VARSIZE: + case MM_BRELATS: + case MM_ARROW: + case MM_BOP: + case MM_MISC: + { + BitmapMenu * menu = static_cast<BitmapMenu +*>(ob->u_vdata); + menu->Show(); + } + break; + + case MM_FRAC: + lyxfunc->Dispatch(LFUN_INSERT_MATH, "frac"); + break; + + case MM_SQRT: + lyxfunc->Dispatch(LFUN_INSERT_MATH, "sqrt"); + break; + + case MM_DELIM: + fl_show_form(fd_delim->delim, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, + _("Delimiter")); + fl_set_form_atclose(fd_delim->delim, CancelCloseBoxCB, 0); + break; + + case MM_DECO: + fl_show_form(fd_deco->deco, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, + _("Decoration")); + fl_set_form_atclose(fd_deco->deco, CancelCloseBoxCB, 0); + break; + + case MM_SPACE: + fl_show_form(fd_space->space, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, + _("Spacing")); + fl_set_form_atclose(fd_space->space, CancelCloseBoxCB, 0); + break; + + case MM_MATRIX: + fl_show_form(fd_matrix->matrix, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, + _("Matrix")); + fl_set_form_atclose(fd_matrix->matrix, CancelCloseBoxCB, 0); + break; + + case MM_EQU: + lyxfunc->Dispatch(LFUN_MATH_DISPLAY); + break; + + case MM_FUNC: + { + int i = fl_get_browser(fd_panel->func_browse) - 1; + lyxfunc->Dispatch(LFUN_INSERT_MATH, func_code[i]); + } + break; + + case 100: + free_symbols_form(); + break; + } } /* callbacks for form delim */ void delim_cb(FL_OBJECT *, long data) { - int left = fd_delim->left->u_ldata, right= fd_delim->right->u_ldata; - int side = (fl_get_button(fd_delim->right)!= 0); - - switch (data) { - case MM_APPLY: - case MM_OK: - { - std::ostringstream ost; - ost << delim_code[left] << ' ' << delim_code[right]; - lyxfunc->Dispatch(LFUN_MATH_DELIM, ost.str().c_str()); - if (data == MM_APPLY) break; - } - case MM_CLOSE: fl_hide_form(fd_delim->delim); break; - case 2: - { - int i = fl_get_bmtable(fd_delim->menu); - int button = fl_get_bmtable_numb(fd_delim->menu); - bool both = (button==FL_MIDDLE_MOUSE); - - if (i>= 0) { - - if (side || (button== FL_RIGHT_MOUSE)) { - right = i; - } else { - left = i; - if (both) - right = delim_rversion[i]; - } - } - Pixmap p1, p2; - p1 = fl_get_pixmap_pixmap(fd_delim->pix, &p1, &p2); - fl_draw_bmtable_item(fd_delim->menu, left, p1, 0, 0); - fl_draw_bmtable_item(fd_delim->menu, right, p1, 16, 0); - fl_redraw_object(fd_delim->pix); - - fd_delim->left->u_ldata = left; - fd_delim->right->u_ldata = right; - - break; - } - case 3: break; - case 4: break; - } + int left = fd_delim->left->u_ldata, right= fd_delim->right->u_ldata; + int side = (fl_get_button(fd_delim->right)!= 0); + + switch (data) { + case MM_APPLY: + case MM_OK: + { + std::ostringstream ost; + ost << delim_code[left] << ' ' << delim_code[right]; + lyxfunc->Dispatch(LFUN_MATH_DELIM, ost.str().c_str()); + if (data == MM_APPLY) + break; + } + + case MM_CLOSE: + fl_hide_form(fd_delim->delim); + break; + + case 2: + { + int i = fl_get_bmtable(fd_delim->menu); + int button = fl_get_bmtable_numb(fd_delim->menu); + bool both = (button==FL_MIDDLE_MOUSE); + + if (i >= 0) { + if (side || (button== FL_RIGHT_MOUSE)) + right = i; + else { + left = i; + if (both) + right = delim_rversion[i]; + } + } + + Pixmap p1, p2; + p1 = fl_get_pixmap_pixmap(fd_delim->pix, &p1, &p2); + fl_draw_bmtable_item(fd_delim->menu, left, p1, 0, 0); + fl_draw_bmtable_item(fd_delim->menu, right, p1, 16, 0); + fl_redraw_object(fd_delim->pix); + + fd_delim->left->u_ldata = left; + fd_delim->right->u_ldata = right; + } + break; + + case 3: + case 4: + break; + } } /* callbacks for form matrix */ void matrix_cb(FL_OBJECT *, long data) { - static char v_align_c[] = "tcb"; - - switch (data) { - case MM_APPLY: - case MM_OK: - { - char c = v_align_c[fl_get_choice(fd_matrix->valign) - 1]; - char const * sh = fl_get_input(fd_matrix->halign); - int nx = int(fl_get_slider_value(fd_matrix->columns) + 0.5); - int ny = int(fl_get_slider_value(fd_matrix->rows) + 0.5); - if (data == MM_OK) fl_hide_form(fd_matrix->matrix); - std::ostringstream ost; - ost << nx << ' ' << ny << ' ' << c << sh; - lyxfunc->Dispatch(LFUN_INSERT_MATRIX, ost.str().c_str()); - break; - } - case MM_CLOSE: fl_hide_form(fd_matrix->matrix); break; - case 2: - { - int nx = int(fl_get_slider_value(fd_matrix->columns)+0.5); - for (int i = 0; i < nx; ++i) h_align_str[i] = 'c'; - //memset(h_align_str, 'c', nx); - h_align_str[nx] = '\0'; -// fl_freeze_form(fd_form_main->form_main); -// fl_addto_form(fd_form_main->form_main); - - fl_set_input(fd_matrix->halign, h_align_str); - fl_redraw_object(fd_matrix->halign); - break; - } - } + static char v_align_c[] = "tcb"; + + switch (data) { + case MM_APPLY: + case MM_OK: + { + char c = v_align_c[fl_get_choice(fd_matrix->valign) - +1]; + char const * sh = fl_get_input(fd_matrix->halign); + int nx = int(fl_get_slider_value(fd_matrix->columns) + +0.5); + int ny = int(fl_get_slider_value(fd_matrix->rows) + +0.5); + if (data == MM_OK) + fl_hide_form(fd_matrix->matrix); + std::ostringstream ost; + ost << nx << ' ' << ny << ' ' << c << sh; + lyxfunc->Dispatch(LFUN_INSERT_MATRIX, +ost.str().c_str()); + } + break; + + case MM_CLOSE: + fl_hide_form(fd_matrix->matrix); + break; + + case 2: + { + int nx = int(fl_get_slider_value(fd_matrix->columns) + +0.5); + for (int i = 0; i < nx; ++i) + h_align_str[i] = 'c'; + h_align_str[nx] = '\0'; + //fl_freeze_form(fd_form_main->form_main); + //fl_addto_form(fd_form_main->form_main); + + fl_set_input(fd_matrix->halign, h_align_str); + fl_redraw_object(fd_matrix->halign); + } + break; + } } /* callbacks for form deco */ void deco_cb(FL_OBJECT *, long data) { - switch (data) { - case MM_APPLY: - case MM_OK: - { - int const i = fl_get_bmtable(fd_deco->menu); - int const l = sizeof(deco_code)/sizeof(deco_code[0]); - // ideally the callback should not be called if the index is - // greater than the maxitem of the bmtable, but I do not know - // how to enforce that (JMarc) - if (i <= l) { - lyxfunc->Dispatch(LFUN_INSERT_MATH, deco_code[i]); - if (data == MM_APPLY) break; - } - else break; - } - case MM_CLOSE: fl_hide_form(fd_deco->deco); break; - } + switch (data) { + case MM_APPLY: + case MM_OK: + { + int const i = fl_get_bmtable(fd_deco->menu); + int const l = sizeof(deco_code)/sizeof(deco_code[0]); + // ideally the callback should not be called if the +index is + // greater than the maxitem of the bmtable, but I do +not know + // how to enforce that (JMarc) + if (i <= l) { + lyxfunc->Dispatch(LFUN_INSERT_MATH, +deco_code[i]); + if (data == MM_APPLY) + break; + } + else + break; + } + + case MM_CLOSE: + fl_hide_form(fd_deco->deco); + break; + } } /* callbacks for form space */ void space_cb(FL_OBJECT *, long data) { - static short sp = -1; - extern char * latex_mathspace[]; - - if (data >= 0 && data < 6) - sp = short(data); - else - switch (data) { - case MM_APPLY: - case MM_OK: - { - if (sp>= 0) - lyxfunc->Dispatch(LFUN_INSERT_MATH, latex_mathspace[sp]); - if (data == MM_APPLY) break; - } - case MM_CLOSE: fl_hide_form(fd_space->space); break; - } + static short sp = -1; + extern char * latex_mathspace[]; + + if (data >= 0 && data < 6) + sp = short(data); + else + switch (data) { + case MM_APPLY: + case MM_OK: + if (sp>= 0) + lyxfunc->Dispatch(LFUN_INSERT_MATH, +latex_mathspace[sp]); + if (data == MM_APPLY) + break; + + case MM_CLOSE: + fl_hide_form(fd_space->space); + break; + } } extern "C" int align_filter(FL_OBJECT *, char const *, char const * cur, int c) { - int n = int(fl_get_slider_value(fd_matrix->columns)+0.5) - strlen(cur); - return ((c == 'c'||c == 'l'||c == 'r') && n>= 0) ? FL_VALID: FL_INVALID; + int n = int(fl_get_slider_value(fd_matrix->columns)+0.5) - strlen(cur); + return ((c == 'c'||c == 'l'||c == 'r') && n >= 0) ? FL_VALID : FL_INVALID; } char const ** mathed_get_pixmap_from_icon(int d) { - switch (d) { - case MM_FRAC: return frac; - case MM_SQRT: return sqrt_xpm; - case MM_DELIM: return delim; - case MM_MATRIX: return matrix; - case MM_EQU: return equation; - case MM_DECO: return deco; - case MM_SPACE: return space_xpm; - default: return 0; - } + switch (d) { + case MM_FRAC: return frac; + case MM_SQRT: return sqrt_xpm; + case MM_DELIM: return delim; + case MM_MATRIX: return matrix; + case MM_EQU: return equation; + case MM_DECO: return deco; + case MM_SPACE: return space_xpm; + default: return 0; + } } FD_panel * create_math_panel( ) { - fd_panel = create_form_panel(); - fd_delim = create_form_delim(); - fd_deco = create_form_deco(); - fd_space = create_form_space(); - fd_matrix = create_form_matrix(); - - /* fill-in form initialization code */ - fl_set_button(fd_delim->left, 1); - fl_set_pixmap_data(fd_delim->pix, const_cast<char**>(delim0)); - fl_set_bmtable_data(fd_delim->menu, 6, 4, delim_width, delim_height, - delim_bits); - fl_set_bmtable_maxitems(fd_delim->menu, 23); - - fl_set_pixmap_data(fd_panel->sqrt, const_cast<char**>(sqrt_xpm)); - fl_set_pixmap_data(fd_panel->frac, const_cast<char**>(frac)); - fl_set_pixmap_data(fd_panel->delim, const_cast<char**>(delim)); - fl_set_pixmap_data(fd_panel->deco, const_cast<char**>(deco)); - fl_set_pixmap_data(fd_panel->space, const_cast<char**>(space_xpm)); - fl_set_pixmap_data(fd_panel->matrix, const_cast<char**>(matrix)); - fl_set_pixmap_data(fd_panel->equation, const_cast<char**>(equation)); - - for (int i = 0; i < 32; ++i) { - fl_add_browser_line(fd_panel->func_browse, func_code[i]); - } - - fl_addto_choice(fd_matrix->valign, _("Top | Center | Bottom")); - fl_set_choice(fd_matrix->valign, 2); - fl_set_input(fd_matrix->halign, h_align_str); - fl_set_input_filter(fd_matrix->halign, align_filter); - - fl_set_bmtable_data(fd_deco->menu, 3, 3, deco_width, deco_height, - deco_bits); - fl_set_bmtable_maxitems(fd_deco->menu, 8); - - fd_delim->left->u_ldata = 0; - fd_delim->right->u_ldata = 1; - - return fd_panel; + fd_panel = create_form_panel(); + fd_delim = create_form_delim(); + fd_deco = create_form_deco(); + fd_space = create_form_space(); + fd_matrix = create_form_matrix(); + + /* fill-in form initialization code */ + fl_set_button(fd_delim->left, 1); + fl_set_pixmap_data(fd_delim->pix, const_cast<char**>(delim0)); + fl_set_bmtable_data(fd_delim->menu, 6, 4, delim_width, delim_height, + delim_bits); + fl_set_bmtable_maxitems(fd_delim->menu, 23); + + fl_set_pixmap_data(fd_panel->sqrt, const_cast<char**>(sqrt_xpm)); + fl_set_pixmap_data(fd_panel->frac, const_cast<char**>(frac)); + fl_set_pixmap_data(fd_panel->delim, const_cast<char**>(delim)); + fl_set_pixmap_data(fd_panel->deco, const_cast<char**>(deco)); + fl_set_pixmap_data(fd_panel->space, const_cast<char**>(space_xpm)); + fl_set_pixmap_data(fd_panel->matrix, const_cast<char**>(matrix)); + fl_set_pixmap_data(fd_panel->equation, const_cast<char**>(equation)); + + for (int i = 0; i < 32; ++i) { + fl_add_browser_line(fd_panel->func_browse, func_code[i]); + } + + fl_addto_choice(fd_matrix->valign, _("Top | Center | Bottom")); + fl_set_choice(fd_matrix->valign, 2); + fl_set_input(fd_matrix->halign, h_align_str); + fl_set_input_filter(fd_matrix->halign, align_filter); + + fl_set_bmtable_data(fd_deco->menu, 3, 3, deco_width, deco_height, + deco_bits); + fl_set_bmtable_maxitems(fd_deco->menu, 8); + + fd_delim->left->u_ldata = 0; + fd_delim->right->u_ldata = 1; + + return fd_panel; } extern BitmapMenu * sym_menu; @@ -346,38 +389,38 @@ extern void create_symbol_menues(FD_pan void free_symbols_form() { - if (fd_panel) { - fl_hide_form(fd_panel->panel); - fl_free_form(fd_panel->panel); - delete sym_menu; - free(fd_panel); - fd_panel = 0; - } + if (fd_panel) { + fl_hide_form(fd_panel->panel); + fl_free_form(fd_panel->panel); + delete sym_menu; + free(fd_panel); + fd_panel = 0; + } } extern "C" int AtClose_symbols_form(FL_FORM *, void *) { - free_symbols_form(); - return FL_IGNORE; + free_symbols_form(); + return FL_IGNORE; } void show_symbols_form(LyXFunc * lf) { - lyxfunc = lf; - if (!fd_panel) { - fd_panel = create_math_panel(); - fl_register_raw_callback(fd_panel->panel, - ButtonPressMask|KeyPressMask, C_peek_event); - create_symbol_menues(fd_panel); - fl_set_form_atclose(fd_panel->panel, AtClose_symbols_form, 0); - } - if (fd_panel->panel->visible) { - fl_raise_form(fd_panel->panel); - } else { - fl_show_form(fd_panel->panel, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Math Panel")); - } + lyxfunc = lf; + + if (!fd_panel) { + fd_panel = create_math_panel(); + fl_register_raw_callback( fd_panel->panel, + ButtonPressMask|KeyPressMask, C_peek_event); + create_symbol_menues(fd_panel); + fl_set_form_atclose(fd_panel->panel, AtClose_symbols_form, 0); + } + + if (fd_panel->panel->visible) + fl_raise_form(fd_panel->panel); + else + fl_show_form( fd_panel->panel, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, _("Math Panel") ); } Index: math_panel.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_panel.h,v retrieving revision 1.12 diff -u -p -u -r1.12 math_panel.h --- math_panel.h 2001/02/15 12:22:01 1.12 +++ math_panel.h 2001/02/15 13:10:19 @@ -126,24 +126,6 @@ public: extern "C" int C_peek_event(FL_FORM * form, void * ptr); -inline -void BitmapMenu::Prev() -{ - Hide(); - if (prev) - prev->Show(); -} - - -inline -void BitmapMenu::Next() -{ - Hide(); - if (next) - next->Show(); -} - - #include "math_forms.h" /// Index: math_root.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_root.C,v retrieving revision 1.17 diff -u -p -u -r1.17 math_root.C --- math_root.C 2001/02/15 12:22:01 1.17 +++ math_root.C 2001/02/15 13:10:19 @@ -1,8 +1,8 @@ // -*- C++ -*- /* * File: math_root.C - * Purpose: Implementation of the root object - * Author: Alejandro Aguilar Sierra <[EMAIL PROTECTED]> + * Purpose: Implementation of the root object + * Author: Alejandro Aguilar Sierra <[EMAIL PROTECTED]> * Created: January 1999 * Description: Root math object * @@ -29,11 +29,11 @@ MathRootInset::MathRootInset(short st) : MathSqrtInset(st) { idx = 1; - uroot = new MathParInset(LM_ST_TEXT); + uroot = new MathParInset(LM_ST_TEXT); } -MathRootInset::~MathRootInset() +MathRootInset::~MathRootInset() { delete uroot; } @@ -105,8 +105,8 @@ void MathRootInset::Metrics() wroot = uroot->Width(); dh = Height()/2; width += wroot; - // if (uroot->Ascent() > dh) - if (uroot->Height() > dh) + // if (uroot->Ascent() > dh) + if (uroot->Height() > dh) ascent += uroot->Height() - dh; dh -= descent - uroot->Descent(); idx = idxp; @@ -133,7 +133,7 @@ void MathRootInset::SetStyle(short st) void MathRootInset::SetFocus(int x, int) -{ +{ idx = (x > xo() + wroot) ? 1: 0; } @@ -141,7 +141,7 @@ void MathRootInset::SetFocus(int x, int) void MathRootInset::Write(ostream & os, bool fragile) { os << '\\' << name << '['; - uroot->Write(os, fragile); + uroot->Write(os, fragile); os << "]{"; MathParInset::Write(os, fragile); os << '}'; Index: math_sqrtinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sqrtinset.C,v retrieving revision 1.3 diff -u -p -u -r1.3 math_sqrtinset.C --- math_sqrtinset.C 2001/02/15 12:22:01 1.3 +++ math_sqrtinset.C 2001/02/15 13:10:19 @@ -31,12 +31,11 @@ bool MathSqrtInset::Inside(int x, int y) } -void -MathSqrtInset::draw(Painter & pain, int x, int y) +void MathSqrtInset::draw(Painter & pain, int x, int y) { MathParInset::draw(pain, x + hmax + 2, y); - int h = ascent; - int d = descent; + int h = ascent; + int d = descent; int h2 = Height() / 2; int w2 = (Height() > 4 * hmax) ? hmax : hmax / 2; int xp[4], yp[4]; @@ -48,15 +47,15 @@ MathSqrtInset::draw(Painter & pain, int } -void -MathSqrtInset::Metrics() +void MathSqrtInset::Metrics() { MathParInset::Metrics(); - ascent += 4; + ascent += 4; descent += 2; int a, b; hmax = mathed_char_height(LM_TC_VAR, size(), 'I', a, b); - if (hmax < 10) hmax = 10; + if (hmax < 10) + hmax = 10; wbody = width + 4; width += hmax + 4; } Index: support.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/support.C,v retrieving revision 1.4 diff -u -p -u -r1.4 support.C --- support.C 2001/02/15 12:22:01 1.4 +++ support.C 2001/02/15 13:10:19 @@ -16,6 +16,8 @@ using std::lower_bound; using std::endl; using std::max; +math_deco_struct const * search_deco(int code); + extern LyXFont WhichFont(short type, int size); char const * math_font_name[] = {