From 7f6bd7f12d1f084a3b7435b811ceb0020309c3cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 28 Feb 2001 11:56:36 +0000 Subject: [PATCH] mathed cleanup, change mask for tmpdir git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1641 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 1 + src/ChangeLog | 4 ++ src/Makefile.am | 1 - src/mathed/ChangeLog | 44 +++++++++++++++++ src/mathed/Makefile.am | 2 +- src/mathed/math_accentinset.C | 16 +++--- src/mathed/math_accentinset.h | 12 +++-- src/mathed/math_bigopinset.C | 88 ++++++++++++++++----------------- src/mathed/math_bigopinset.h | 8 +-- src/mathed/math_dotsinset.C | 4 ++ src/mathed/math_dotsinset.h | 7 ++- src/mathed/math_draw.C | 38 -------------- src/mathed/math_fracinset.C | 35 +++++-------- src/mathed/math_fracinset.h | 6 +-- src/mathed/math_funcinset.C | 49 ++++++++---------- src/mathed/math_funcinset.h | 17 +++---- src/mathed/math_hash.C | 4 +- src/mathed/math_inset.C | 26 ++-------- src/mathed/math_inset.h | 41 +++++++++------ src/mathed/math_macro.C | 26 +++++----- src/mathed/math_macro.h | 5 +- src/mathed/math_macrotemplate.C | 4 -- src/mathed/math_macrotemplate.h | 2 - src/mathed/math_root.C | 49 +++++++----------- src/mathed/math_root.h | 4 +- src/mathed/math_spaceinset.C | 53 +++++++++++--------- src/mathed/math_spaceinset.h | 11 +++-- src/mathed/math_sqrtinset.C | 26 +++++----- src/support/ChangeLog | 4 ++ src/support/filetools.C | 2 +- 30 files changed, 293 insertions(+), 296 deletions(-) delete mode 100644 src/mathed/math_draw.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ddc32735da..48c36c73c7 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1,5 +1,6 @@ #include +#include #include #include diff --git a/src/ChangeLog b/src/ChangeLog index c549ab874d..f9211fc1d2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-02-28 Lars Gullik Bjønnes + + * BufferView_pimpl.C: add + 2001-02-27 Lars Gullik Bjønnes * BufferView_pimpl.C: add using std::find_if diff --git a/src/Makefile.am b/src/Makefile.am index 89bfd7189c..360de916e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,7 +123,6 @@ lyx_SOURCES = \ gettext.h \ importer.C \ importer.h \ - include_form.h \ intl.C \ intl.h \ kbmap.C \ diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 2cdd809a06..3d14a12094 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,49 @@ +2001-02-28 Lars Gullik Bjønnes + + * math_spaceinset.[Ch]: add pragma, make variables private add + '_', change order of method definitions. + + * math_root.h (~MathRootInset): delete + Change uroot_ to be a real object instead of a pointer + * math_root.C: changes because of the above + + * math_macro.C (MathMacro(MathMacro*)): delete constructor + (MathMacro(MathMacro const &)): new copy constructor + + * math_inset.h: delete constructor taking a pointer to MathedInset + (size, incSize): move inline method + + * math_funcinset.h: add pragma, remove class vars ln and fname, + change protected to private, add '_' to priv vars. + (~MathFuncInset): remove + + * math_fracinset.h: make MathParInset den_ a real object and not a + pointer. + + * math_fracinset.C (MathFracInset): clean up, move initalization + to initialization list + (~MathFracInset): remove + (Clone): remove leak + + * math_draw.C: delete file + + * math_dotsinset.[Ch]: add pragma + + * math_bigopinset.h: make protected variables private add '_' to vars. + + * math_bigopinset.C: move methods to follow class definition order + + * math_accentinset.h (getAccentCode): move inline here + + * math_accentinset.C (MathAccentInset): cleanup + (draw): constify dw + 2001-02-27 Lars Gullik Bjønnes + * math_inset.[Ch] (MathedInset): remove method + + * Makefile.am (libmathed_la_SOURCES): correct typo + * math_parinset.C (draw): move MathedXiter data(this) up. and remove it two other places. diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index aa96a4e0d3..2dd298b51f 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -21,7 +21,7 @@ libmathed_la_SOURCES = \ math_accentinset.C \ math_accentinset.h \ math_bigopinset.C \ - math_bibopinset.h \ + math_bigopinset.h \ math_cursor.C \ math_cursor.h \ math_decorationinset.C \ diff --git a/src/mathed/math_accentinset.C b/src/mathed/math_accentinset.C index 8e5268fce4..632d4c2786 100644 --- a/src/mathed/math_accentinset.C +++ b/src/mathed/math_accentinset.C @@ -8,15 +8,15 @@ using std::ostream; MathAccentInset::MathAccentInset(byte cx, MathedTextCodes f, int cd, short st) - : MathedInset("", LM_OT_ACCENT, st), c(cx), fn(f), code(cd) -{ - inset = 0; -} + : MathedInset("", LM_OT_ACCENT, st), + c(cx), fn(f), code(cd), inset(0) +{} -MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st) +MathAccentInset::MathAccentInset(MathedInset * ins, int cd, short st) : MathedInset("", LM_OT_ACCENT, st), - c(0), fn(LM_TC_MIN), code(cd), inset(ins) {} + c(0), fn(LM_TC_MIN), code(cd), inset(ins) +{} MathAccentInset::~MathAccentInset() @@ -41,7 +41,7 @@ MathedInset * MathAccentInset::Clone() void MathAccentInset::draw(Painter & pain, int x, int y) { - int dw = width - 2; + int const dw = width - 2; if (inset) inset->draw(pain, x, y); @@ -50,7 +50,7 @@ MathAccentInset::draw(Painter & pain, int x, int y) s += c; drawStr(pain, fn, size(), x, y, s); } - x += (code == LM_not) ? (width-dw) / 2 : 2; + x += (code == LM_not) ? (width - dw) / 2 : 2; mathed_draw_deco(pain, x, y - dy, dw, dh, code); } diff --git a/src/mathed/math_accentinset.h b/src/mathed/math_accentinset.h index d2b71402a2..6e920b266c 100644 --- a/src/mathed/math_accentinset.h +++ b/src/mathed/math_accentinset.h @@ -7,7 +7,7 @@ #include "math_defs.h" /// Accents -class MathAccentInset: public MathedInset { +class MathAccentInset : public MathedInset { public: /// MathAccentInset(byte, MathedTextCodes, int, short st = LM_ST_TEXT); @@ -24,8 +24,7 @@ public: /// void Metrics(); /// - int getAccentCode() const { return code; } - + int getAccentCode() const; protected: /// byte c; @@ -38,4 +37,11 @@ protected: /// int dh, dy; }; + + +inline +int MathAccentInset::getAccentCode() const +{ + return code; +} #endif diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C index c43d421609..ca3b913860 100644 --- a/src/mathed/math_bigopinset.C +++ b/src/mathed/math_bigopinset.C @@ -8,34 +8,14 @@ using std::ostream; -bool MathBigopInset::GetLimits() const -{ - // Default case - if (lims < 0) { - return sym != LM_int && sym != LM_oint && GetStyle() == LM_ST_DISPLAY; - } - - // Custom - return lims > 0; -} - - -void MathBigopInset::SetLimits(bool ls) -{ - lims = ls ? 1 : 0; -} - - MathBigopInset::MathBigopInset(string const & nam, int id, short st) - : MathedInset(nam, LM_OT_BIGOP, st), sym(id) -{ - lims = -1; -} + : MathedInset(nam, LM_OT_BIGOP, st), lims_(-1), sym_(id) +{} MathedInset * MathBigopInset::Clone() { - return new MathBigopInset(name, sym, GetStyle()); + return new MathBigopInset(name, sym_, GetStyle()); } @@ -45,15 +25,15 @@ MathBigopInset::draw(Painter & pain, int x, int y) string s; short t; - if (sym < 256 || sym == LM_oint) { - s += (sym == LM_oint) ? LM_int : sym; + if (sym_ < 256 || sym_ == LM_oint) { + s += (sym_ == LM_oint) ? LM_int : sym_; t = LM_TC_BSYM; } else { s = name; t = LM_TC_TEXTRM; } - if (sym == LM_oint) { - pain.arc(x, y - 5 * width / 4, width, width, 0, 360*64, + if (sym_ == LM_oint) { + pain.arc(x, y - 5 * width / 4, width, width, 0, 360 * 64, LColor::mathline); ++x; } @@ -61,6 +41,24 @@ MathBigopInset::draw(Painter & pain, int x, int y) } +void MathBigopInset::Write(ostream & os, bool /* fragile */) +{ + bool const limp = GetLimits(); + + os << '\\' << name; + + if (limp && !(sym_ != LM_int && sym_ != LM_oint + && (GetStyle() == LM_ST_DISPLAY))) + os << "\\limits "; + else + if (!limp && (sym_ != LM_int && sym_ != LM_oint + && (GetStyle() == LM_ST_DISPLAY))) + os << "\\nolimits "; + else + os << ' '; +} + + void MathBigopInset::Metrics() { @@ -68,8 +66,8 @@ MathBigopInset::Metrics() string s; short t; - if (sym < 256 || sym == LM_oint) { - char c = (sym == LM_oint) ? LM_int: sym; + if (sym_ < 256 || sym_ == LM_oint) { + char const c = (sym_ == LM_oint) ? LM_int: sym_; s += c; t = LM_TC_BSYM; } else { @@ -78,23 +76,25 @@ MathBigopInset::Metrics() } 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; } -void MathBigopInset::Write(ostream & os, bool /* fragile */) -{ - bool limp = GetLimits(); - - os << '\\' << name; +bool MathBigopInset::GetLimits() const +{ + // Default case + if (lims_ < 0) { + return sym_ != LM_int && + sym_ != LM_oint && + GetStyle() == LM_ST_DISPLAY; + } - if (limp && !(sym != LM_int && sym != LM_oint - && (GetStyle() == LM_ST_DISPLAY))) - os << "\\limits "; - else - if (!limp && (sym != LM_int && sym != LM_oint - && (GetStyle() == LM_ST_DISPLAY))) - os << "\\nolimits "; - else - os << ' '; + // Custom + return lims_ > 0; +} + + +void MathBigopInset::SetLimits(bool ls) +{ + lims_ = ls ? 1 : 0; } diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h index 68aa22964e..c4e32a52d3 100644 --- a/src/mathed/math_bigopinset.h +++ b/src/mathed/math_bigopinset.h @@ -6,7 +6,7 @@ #include "math_defs.h" /// big operators -class MathBigopInset: public MathedInset { +class MathBigopInset : public MathedInset { public: /// MathBigopInset(string const &, int, short st = LM_ST_TEXT); @@ -22,10 +22,10 @@ public: bool GetLimits() const; /// void SetLimits(bool); -protected: +private: /// - int lims; + int lims_; /// - int sym; + int sym_; }; #endif diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index ffbe2d1377..6bca4d1e19 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -1,5 +1,9 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + #include "math_dotsinset.h" #include "mathed/support.h" #include "support/LOstream.h" diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index 03b6327cbf..83767a74cb 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -1,11 +1,16 @@ +// -*- C++ -*- #ifndef MATH_DOTSINSET_H #define MATH_DOTSINSET_H #include "math_inset.h" #include "math_defs.h" +#ifdef __GNUG__ +#pragma interface +#endif + /// The different kinds of ellipsis -class MathDotsInset: public MathedInset { +class MathDotsInset : public MathedInset { public: /// MathDotsInset(string const &, int, short st = LM_ST_TEXT); diff --git a/src/mathed/math_draw.C b/src/mathed/math_draw.C deleted file mode 100644 index 05decd171d..0000000000 --- a/src/mathed/math_draw.C +++ /dev/null @@ -1,38 +0,0 @@ -/* - * File: math_draw.C - * Purpose: Interaction and drawing for mathed - * Author: Alejandro Aguilar Sierra - * 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 -#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 &); - - - - - - diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index f38b009f90..6ee7debf1f 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -15,12 +15,9 @@ using std::ostream; MathFracInset::MathFracInset(short ot) - : MathParInset(LM_ST_TEXT, "frac", ot) + : MathParInset(LM_ST_TEXT, "frac", ot), + idx_(0), den_(LM_ST_TEXT), dh_(0) { - - den_ = new MathParInset(LM_ST_TEXT); // this leaks - dh_ = 0; - idx_ = 0; if (objtype == LM_OT_STACKREL) { flag |= LMPF_SCRIPT; SetName("stackrel"); @@ -28,17 +25,9 @@ MathFracInset::MathFracInset(short ot) } -MathFracInset::~MathFracInset() -{ - delete den_; -} - - MathedInset * MathFracInset::Clone() { MathFracInset * p = new MathFracInset(*this); - // this cast will go again... - p->den_ = static_cast(p->den_->Clone()); return p; } @@ -57,7 +46,7 @@ void MathFracInset::SetStyle(short st) { MathParInset::SetStyle(st); dh_ = 0; - den_->SetStyle((size() == LM_ST_DISPLAY) ? + den_.SetStyle((size() == LM_ST_DISPLAY) ? static_cast(LM_ST_TEXT) : size()); } @@ -65,7 +54,7 @@ void MathFracInset::SetStyle(short st) void MathFracInset::SetData(MathedArray const & n, MathedArray const & d) { - den_->setData(d); + den_.setData(d); MathParInset::setData(n); } @@ -75,7 +64,7 @@ void MathFracInset::setData(MathedArray const & d) if (idx_ == 0) MathParInset::setData(d); else { - den_->setData(d); + den_.setData(d); } } @@ -85,7 +74,7 @@ void MathFracInset::GetXY(int & x, int & y) const if (idx_ == 0) MathParInset::GetXY(x, y); else - den_->GetXY(x, y); + den_.GetXY(x, y); } @@ -94,7 +83,7 @@ MathedArray & MathFracInset::GetData() if (idx_ == 0) return array; else - return den_->GetData(); + return den_.GetData(); } @@ -125,7 +114,7 @@ MathFracInset::draw(Painter & pain, int x, int y) idx_ = 0; 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_); + den_.draw(pain, x + (width - w1_) / 2, y + den_.Ascent() + 2 - dh_); size(sizex); if (objtype == LM_OT_FRAC) pain.line(x + 2, y - dh_, @@ -151,11 +140,11 @@ MathFracInset::Metrics() w0_ = width; int const as = Height() + 2 + dh_; des0_ = Descent() + 2 + dh_; - den_->Metrics(); - w1_ = den_->Width(); + den_.Metrics(); + w1_ = den_.Width(); width = ((w0_ > w1_) ? w0_: w1_) + 12; ascent = as; - descent = den_->Height()+ 2 - dh_; + descent = den_.Height()+ 2 - dh_; idx_ = idxp; } @@ -165,6 +154,6 @@ void MathFracInset::Write(ostream & os, bool fragile) os << '\\' << name << '{'; MathParInset::Write(os, fragile); os << "}{"; - den_->Write(os, fragile); + den_.Write(os, fragile); os << '}'; } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 621bf932fa..83011783f2 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -11,13 +11,11 @@ /** Fraction like objects (frac, stackrel, binom) \author Alejandro Aguilar Sierra */ -class MathFracInset: public MathParInset { +class MathFracInset : public MathParInset { public: /// MathFracInset(short ot = LM_OT_FRAC); /// - ~MathFracInset(); - /// MathedInset * Clone(); /// void draw(Painter &, int x, int baseline); @@ -52,7 +50,7 @@ private: /// int idx_; /// - MathParInset * den_; + MathParInset den_; /// int w0_; /// diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index 5fe22ba83e..d7e3598de0 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -1,5 +1,9 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + #include "math_funcinset.h" #include "lyxfont.h" #include "font.h" @@ -7,39 +11,16 @@ #include "mathed/support.h" #include "support/LOstream.h" -using std::ostream; +using std::ostream; extern LyXFont WhichFont(short type, int size); -MathFuncInset::~MathFuncInset() -{} - - -bool MathFuncInset::GetLimits() const -{ - return bool(lims && (GetStyle() == LM_ST_DISPLAY)); -} - - -void MathFuncInset::Write(std::ostream & os, bool /* fragile */) -{ - os << "\\" << name << ' '; -} - MathFuncInset::MathFuncInset(string const & nm, short ot, short st) - : MathedInset("", ot, st) + : MathedInset(nm, ot, st) { - ln = 0; - lims = (GetType() == LM_OT_FUNCLIM); - if (GetType() == LM_OT_UNDEF) { - fname = nm; - SetName(fname); - } else { - //fname = 0; - SetName(nm); - } + lims_ = (GetType() == LM_OT_FUNCLIM); } @@ -49,7 +30,6 @@ MathedInset * MathFuncInset::Clone() } - void MathFuncInset::draw(Painter & pain, int x, int y) { @@ -62,10 +42,14 @@ MathFuncInset::draw(Painter & pain, int x, int y) } +void MathFuncInset::Write(std::ostream & os, bool /* fragile */) +{ + os << "\\" << name << ' '; +} + void MathFuncInset::Metrics() { - //ln = (name) ? strlen(name): 0; LyXFont font = WhichFont(LM_TC_TEXTRM, size()); font.setLatex(LyXFont::ON); if (name.empty()) { @@ -75,6 +59,13 @@ void MathFuncInset::Metrics() } else { width = lyxfont::width(name, font) + lyxfont::width('I', font) / 2; - mathed_string_height(LM_TC_TEXTRM, size(), name, ascent, descent); + mathed_string_height(LM_TC_TEXTRM, size(), + name, ascent, descent); } } + + +bool MathFuncInset::GetLimits() const +{ + return bool(lims_ && (GetStyle() == LM_ST_DISPLAY)); +} diff --git a/src/mathed/math_funcinset.h b/src/mathed/math_funcinset.h index 3758907e88..e9b80aadaf 100644 --- a/src/mathed/math_funcinset.h +++ b/src/mathed/math_funcinset.h @@ -1,21 +1,24 @@ +// -*- C++ -*- #ifndef MATH_FUNCINSET_H #define MATH_FUNCINSET_H #include "math_inset.h" #include "math_defs.h" +#ifdef __GNUG__ +#pragma interface +#endif + /** Functions or LaTeX names for objects that I don't know how to draw. */ -class MathFuncInset: public MathedInset { +class MathFuncInset : public MathedInset { public: /// explicit MathFuncInset(string const & nm, short ot = LM_OT_FUNC, short st = LM_ST_TEXT); /// - ~MathFuncInset(); - /// MathedInset * Clone(); /// void draw(Painter &, int, int); @@ -25,12 +28,8 @@ public: void Metrics(); /// bool GetLimits() const; -protected: - /// - int ln; - /// - bool lims; +private: /// - string fname; + bool lims_; }; #endif diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 6f48b59322..da769dff67 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -314,7 +314,9 @@ latexkeys const wordlist[] = {"vdash", LM_TK_SYM, LM_vdash}, }; -static short lookup[] = + +static +short lookup[] = { -1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, -1, -1, -1, -1, 9, 10, -1, 11, -1, -1, -1, 12, -1, -1, 491, -13, -2, diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 87bb14e34d..ade5ec2db1 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -28,35 +28,17 @@ #include "mathed/support.h" #include "Painter.h" + +// Initialize some static class variables. int MathedInset::df_asc; int MathedInset::df_des; int MathedInset::df_width; int MathedInset::workWidth; -MathedInset::MathedInset(MathedInset * inset) -{ - if (inset) { - name = inset->GetName(); - objtype = inset->GetType(); - size_ = inset->GetStyle(); - width = inset->Width(); - ascent = inset->Ascent(); - descent = inset->Descent(); - } else { - objtype = LM_OT_UNDEF; - size_ = LM_ST_TEXT; - width = ascent = descent = 0; - //name = 0; - } -} - - MathedInset::MathedInset(string const & nm, short ot, short st) - : name(nm), objtype(ot), size_(st) -{ - width = ascent = descent = 0; -} + : name(nm), objtype(ot), width(0), ascent(0), descent(0), size_(st) +{} // In a near future maybe we use a better fonts renderer diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index dd1cb92e0f..d292e53ac6 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -36,16 +36,13 @@ class Painter; general LyX inset. It's used to represent all the math objects. The formulaInset (a LyX inset) encapsulates a math inset. */ -class MathedInset { +class MathedInset { public: /** A math inset has a name (usually its LaTeX name), type and font-size */ MathedInset(string const & nm, short ot, short st); - /// - explicit - MathedInset(MathedInset *); - /// + /// The virtual base destructor virtual ~MathedInset() {} /// Draw the object virtual void draw(Painter &, int x, int baseline) = 0; @@ -89,9 +86,7 @@ public: /// static void defaultWidth(int dw); /// - short size() const { - return size_; - } + short size() const; protected: /// string name; @@ -112,14 +107,32 @@ protected: /// In a near future maybe we use a better fonts renderer than X void drawStr(Painter &, short, int, int, int, string const &); /// - void size(short s) { - size_ = s; - } - void incSize() { - ++size_; - } + void size(short s); + /// + void incSize(); private: /// short size_; }; + + +inline +short MathedInset::size() const +{ + return size_; +} + + +inline +void MathedInset::size(short s) +{ + size_ = s; +} + + +inline +void MathedInset::incSize() +{ + ++size_; +} #endif diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 606caf9e70..e59452baa3 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -58,27 +58,31 @@ MathMacro::MathMacro(MathMacroTemplate * t) } -MathMacro::MathMacro(MathMacro * m) - : MathParInset(LM_ST_TEXT, m->GetName(), LM_OT_MACRO) +MathMacro::MathMacro(MathMacro const & m) + : MathParInset(LM_ST_TEXT, m.GetName(), LM_OT_MACRO), + tmplate_(m.tmplate_), idx_(0) { - tmplate_ = m->tmplate_; nargs_ = tmplate_->getNoArgs(); tcode_ = tmplate_->getTCode(); - args_.resize(nargs_); - idx_ = 0; SetName(tmplate_->GetName()); - for (int i = 0; i < tmplate_->getNoArgs(); ++i) { - //m->setArgumentIdx(i); - args_[i].row = m->args_[i].row; - //args_[i].array = m->GetData(); - args_[i].array = m->args_[i].array; + + std::vector::const_iterator cit = m.args_.begin(); + std::vector::const_iterator end = m.args_.end(); + + //args_.resize(nargs_); + //for (int i = 0; i < tmplate_->getNoArgs(); ++i) { + // args_[i].row = m->args_[i].row; + // args_[i].array = m->args_[i].array; + //} + for (; cit != end; ++cit) { + args_.push_back(*cit); } } MathedInset * MathMacro::Clone() { - return new MathMacro(this); + return new MathMacro(*this); } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index beabf01eb1..63421ef3b8 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -31,15 +31,14 @@ class MathMacroTemplate; \author Alejandro Aguilar Sierra \version November 1996 */ -class MathMacro : public MathParInset -{ +class MathMacro : public MathParInset { public: /// A macro can only be builded from an existing template explicit MathMacro(MathMacroTemplate *); /// or from another macro. explicit - MathMacro(MathMacro *); + MathMacro(MathMacro const &); /// void draw(Painter &, int, int); /// diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 4e78366363..1a640df8de 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -30,10 +30,6 @@ MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg): } -//MathMacroTemplate::~MathMacroTemplate() -//{} - - void MathMacroTemplate::setTCode(MathedTextCodes t) { tcode_ = t; diff --git a/src/mathed/math_macrotemplate.h b/src/mathed/math_macrotemplate.h index 9844ecce2d..6552ac0b7e 100644 --- a/src/mathed/math_macrotemplate.h +++ b/src/mathed/math_macrotemplate.h @@ -22,8 +22,6 @@ public: explicit MathMacroTemplate(string const &, int na = 0, int f = 0); /// - //~MathMacroTemplate(); - /// void draw(Painter &, int, int); /// void Metrics(); diff --git a/src/mathed/math_root.C b/src/mathed/math_root.C index 96583fd590..605d153788 100644 --- a/src/mathed/math_root.C +++ b/src/mathed/math_root.C @@ -26,23 +26,13 @@ using std::ostream; MathRootInset::MathRootInset(short st) - : MathSqrtInset(st) -{ - idx_ = 1; - uroot_ = new MathParInset(LM_ST_TEXT); -} - - -MathRootInset::~MathRootInset() -{ - delete uroot_; -} + : MathSqrtInset(st), idx_(1), uroot_(LM_ST_TEXT) +{} MathedInset * MathRootInset::Clone() { MathRootInset * p = new MathRootInset(*this); - p->uroot_ = static_cast(p->uroot_->Clone()); p->setArgumentIdx(0); return p; } @@ -52,9 +42,8 @@ void MathRootInset::setData(MathedArray const & d) { if (idx_ == 1) MathParInset::setData(d); - else { - uroot_->setData(d); - } + else + uroot_.setData(d); } @@ -73,7 +62,7 @@ void MathRootInset::GetXY(int & x, int & y) const if (idx_ == 1) MathParInset::GetXY(x, y); else - uroot_->GetXY(x, y); + uroot_.GetXY(x, y); } @@ -82,40 +71,40 @@ MathedArray & MathRootInset::GetData() if (idx_ == 1) return array; else - return uroot_->GetData(); + return uroot_.GetData(); } bool MathRootInset::Inside(int x, int y) { - return (uroot_->Inside(x, y) || MathSqrtInset::Inside(x, y)); + return (uroot_.Inside(x, y) || MathSqrtInset::Inside(x, y)); } void MathRootInset::Metrics() { - int idxp = idx_; + int const idxp = idx_; idx_ = 1; MathSqrtInset::Metrics(); - uroot_->Metrics(); - wroot_ = uroot_->Width(); - dh_ = Height()/2; + uroot_.Metrics(); + wroot_ = uroot_.Width(); + dh_ = Height() / 2; width += wroot_; - // if (uroot->Ascent() > dh) - if (uroot_->Height() > dh_) - ascent += uroot_->Height() - dh_; - dh_ -= descent - uroot_->Descent(); + // if (uroot_.Ascent() > dh) + if (uroot_.Height() > dh_) + ascent += uroot_.Height() - dh_; + dh_ -= descent - uroot_.Descent(); idx_ = idxp; } void MathRootInset::draw(Painter & pain, int x, int y) { - int idxp = idx_; + int const idxp = idx_; idx_ = 1; - uroot_->draw(pain, x, y - dh_); + uroot_.draw(pain, x, y - dh_); MathSqrtInset::draw(pain, x + wroot_, y); idx_ = idxp; } @@ -125,7 +114,7 @@ void MathRootInset::SetStyle(short st) { MathSqrtInset::SetStyle(st); - uroot_->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size()); + uroot_.SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size()); } @@ -138,7 +127,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 << '}'; diff --git a/src/mathed/math_root.h b/src/mathed/math_root.h index 474c81c363..aeba4e5660 100644 --- a/src/mathed/math_root.h +++ b/src/mathed/math_root.h @@ -32,8 +32,6 @@ public: explicit MathRootInset(short st = LM_ST_TEXT); /// - ~MathRootInset(); - /// MathedInset * Clone(); /// void draw(Painter &, int x, int baseline); @@ -63,7 +61,7 @@ private: /// int idx_; /// - MathParInset * uroot_; + MathParInset uroot_; /// int wroot_; /// diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index a36fef44a9..226dd3334b 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -1,5 +1,9 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + #include "math_spaceinset.h" #include "LColor.h" #include "Painter.h" @@ -9,31 +13,14 @@ using std::ostream; -void MathSpaceInset::Metrics() -{ - width = space ? space * 2 : 2; - if (space > 3) width *= 2; - if (space == 5) width *= 2; - width += 4; - ascent = 4; descent = 0; -} - - -void MathSpaceInset::SetSpace(int sp) -{ - space = sp; - Metrics(); -} - - MathSpaceInset::MathSpaceInset(int sp, short ot, short st) - : MathedInset("", ot, st), space(sp) + : MathedInset("", ot, st), space_(sp) {} MathedInset * MathSpaceInset::Clone() { - return new MathSpaceInset(space, GetType(), GetStyle()); + return new MathSpaceInset(space_, GetType(), GetStyle()); } @@ -53,20 +40,38 @@ MathSpaceInset::draw(Painter & pain, int x, int y) xp[2] = x + width - 2; yp[2] = y; xp[3] = x + width - 2; yp[3] = y - 3; - pain.lines(xp, yp, 4, (space) ? LColor::latex : LColor::math); + pain.lines(xp, yp, 4, (space_) ? LColor::latex : LColor::math); } void MathSpaceInset::Write(ostream & os, bool /* fragile */) { - if (space >= 0 && space < 6) { - os << '\\' << latex_mathspace[space] << ' '; - } + if (space_ >= 0 && space_ < 6) { + os << '\\' << latex_mathspace[space_] << ' '; + } +} + + +void MathSpaceInset::Metrics() +{ + width = space_ ? space_ * 2 : 2; + if (space_ > 3) width *= 2; + if (space_ == 5) width *= 2; + width += 4; + ascent = 4; + descent = 0; +} + + +void MathSpaceInset::SetSpace(int sp) +{ + space_ = sp; + Metrics(); } int MathSpaceInset::GetSpace() { - return space; + return space_; } diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index 31343c3fed..9ec1c5aff8 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -1,11 +1,16 @@ +// -*- C++ -*- #ifndef MATH_SPACEINSET_H #define MATH_SPACEINSET_H #include "math_inset.h" #include "math_defs.h" +#ifdef __GNUG__ +#pragma interface +#endif + /// Smart spaces -class MathSpaceInset: public MathedInset { +class MathSpaceInset : public MathedInset { public: /// MathSpaceInset(int sp, short ot = LM_OT_SPACE, short st = LM_ST_TEXT); @@ -21,8 +26,8 @@ public: void SetSpace(int sp); /// int GetSpace(); -protected: +private: /// - int space; + int space_; }; #endif diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index 0d868c63a6..3109454127 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -24,15 +24,6 @@ MathedInset * MathSqrtInset::Clone() } -bool MathSqrtInset::Inside(int x, int y) -{ - return x >= xo() - hmax_ - && x <= xo() + width - hmax_ - && y <= yo() + descent - && y >= yo() - ascent; -} - - void MathSqrtInset::draw(Painter & pain, int x, int y) { @@ -51,6 +42,14 @@ MathSqrtInset::draw(Painter & pain, int x, int y) } +void MathSqrtInset::Write(ostream & os, bool fragile) +{ + os << '\\' << name << '{'; + MathParInset::Write(os, fragile); + os << '}'; +} + + void MathSqrtInset::Metrics() { @@ -66,9 +65,10 @@ MathSqrtInset::Metrics() } -void MathSqrtInset::Write(ostream & os, bool fragile) +bool MathSqrtInset::Inside(int x, int y) { - os << '\\' << name << '{'; - MathParInset::Write(os, fragile); - os << '}'; + return x >= xo() - hmax_ + && x <= xo() + width - hmax_ + && y <= yo() + descent + && y >= yo() - ascent; } diff --git a/src/support/ChangeLog b/src/support/ChangeLog index f1016aa81c..fee26038b3 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2001-02-27 Lars Gullik Bjønnes + + * filetools.C (CreateTmpDir): change umask to 0700. + 2001-02-27 José Matos * filetools.h (BasePath): diff --git a/src/support/filetools.C b/src/support/filetools.C index 146641f46e..725e1557a1 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -442,7 +442,7 @@ string const CreateTmpDir(string const & tempdir, string const & mask) // safe because of the gap between unlink and mkdir. (Lgb) lyx::unlink(tmpfl.c_str()); - if (tmpfl.empty() || lyx::mkdir(tmpfl, 0777)) { + if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) { WriteFSAlert(_("Error! Couldn't create temporary directory:"), tempdir); return string(); -- 2.39.2