]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_scriptinset.h
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / math_scriptinset.h
index 7a95bf60187b684fd655879e582effc02c9fdb7d..b6626f2806488700e283f27fad285fd0a304bc8b 100644 (file)
     \author André Pönitz
  */
 
-
 class MathScriptInset : public MathNestInset {
 public:
-       ///
+       /// create inset without scripts
        MathScriptInset();
-       ///
-       MathScriptInset(bool up, bool down, MathInset * = 0);
-       ///
-       MathScriptInset(MathScriptInset const &);
-       ///
-       ~MathScriptInset();
+       /// create inset with single script
+       explicit MathScriptInset(bool up);
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(WriteStream & os) const;
        ///
-       void writeNormal(std::ostream &) const;
+       void normalize(NormalStream & os) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 
        ///
-       bool idxUp(int & idx, int & pos) const;
-       ///
-       bool idxDown(int & idx, int & pos) const;
-       ///
-       bool idxLeft(int & idx, int & pos) const;
+       void metrics(MathInset const * nuc, MathMetricsInfo const & st) const;
        ///
-       bool idxRight(int & idx, int & pos) const;
+       void draw(MathInset const * nuc, Painter &, int x, int y) const;
        ///
-       bool idxFirst(int & idx, int & pos) const;
+       int ascent2(MathInset const * nuc) const;
        ///
-       bool idxFirstUp(int & idx, int & pos) const;
+       int descent2(MathInset const * nuc) const;
        ///
-       bool idxFirstDown(int & idx, int & pos) const;
-       ///
-       bool idxLast(int & idx, int & pos) const;
-       ///
-       bool idxLastUp(int & idx, int & pos) const;
-       ///
-       bool idxLastDown(int & idx, int & pos) const;
-       ///
-       void idxDelete(int & idx, bool & popit, bool & deleteit);
+       int width2(MathInset const * nuc) const;
 
        ///
-       bool up() const;
-       ///
-       bool down() const;
-       ///
-       void up(bool);
-       ///
-       void down(bool);
+       bool idxLeft(idx_type &, pos_type &) const;
        ///
-       void limits(int);
-       ///
-       int limits() const;
-       ///
-       bool isActive() const { return false; }
-       /// Identifies ScriptInsets
-       bool isScriptInset() const { return true; }
+       bool idxRight(idx_type &, pos_type &) const;
+
+       /// identifies scriptinsets
+       MathScriptInset const * asScriptInset() const;
        ///
-       int xoffset() const { return dxx_; }
+       MathScriptInset * asScriptInset();
+
+       /// set limits
+       void limits(int lim) { limits_ = lim; }
+       /// get limits
+       int limits() const { return limits_; }
+       /// true if we have an "inner" position
+       MathXArray const & up() const;
+       /// returns subscript
+       MathXArray const & down() const;
+       /// returns superscript
+       MathXArray & up();
+       /// returns subscript
+       MathXArray & down();
+       /// do we have a superscript?
+       bool hasUp() const;
+       /// do we have a subscript?
+       bool hasDown() const;
+       /// do we have a script?
+       bool has(bool up) const;
+       /// remove script
+       void removeScript(bool up);
+       /// remove script
+       void removeEmptyScripts();
+       /// make sure a script is accessible
+       void ensure(bool up);
+
+       // call these methods ...2 to make compaq cxx in anal mode happy...
+       /// suppresses empty braces if necessary
+       virtual void write2(MathInset const * nuc, WriteStream & os) const;
+       virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
+       virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
+       virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
+       virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
+
+public:
+       /// returns x offset for main part
+       int dxx(MathInset const * nuc) const;
+       /// returns width of nucleus if any
+       int nwid(MathInset const * nuc) const;
 private:
-       ///
-       bool hasLimits() const;
-       ///
-       bool up_;
-       ///
-       bool down_;
-       /// 1: \limits, -1: \nolimits, 0: use default
+       /// returns y offset for superscript
+       int dy0(MathInset const * nuc) const;
+       /// returns y offset for subscript
+       int dy1(MathInset const * nuc) const;
+       /// returns x offset for superscript
+       int dx0(MathInset const * nuc) const;
+       /// returns x offset for subscript
+       int dx1(MathInset const * nuc) const;
+       /// returns ascent of nucleus if any
+       int nasc(MathInset const * nuc) const;
+       /// returns descent of nucleus if any
+       int ndes(MathInset const * nuc) const;
+       /// where do we have to draw the scripts?
+       bool hasLimits(MathInset const * nuc) const;
+
+       /// possible subscript (index 0) and superscript (index 1)
+       bool script_[2]; 
+       /// 1 - "limits", -1 - "nolimits", 0 - "default"
        int limits_;
-       /// x offset cache for drawing the superscript
-       mutable int dx0_;
-       /// x offset cache for drawing the subscript
-       mutable int dx1_;
-       /// x offset cache for drawing the inner symbol
-       mutable int dxx_;
-       /// y offset cache for drawing the superscript
-       mutable int dy0_;
-       /// y offset cache for drawing the subscript
-       mutable int dy1_;
-       ///
-       MathInset * symbol_;
+       /// cached MathMetricsInfo
+       mutable MathMetricsInfo mi_;
 };
 
 #endif
+