]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_metricsinfo.h
using previews might be a good alternative to hard coding such diagrams...
[lyx.git] / src / mathed / math_metricsinfo.h
index db5a3c2caf2a2cd125f08ec0a184ffb5c2c6d140..f4d6ab6275d06a309d7e5548ad891935ff11058d 100644 (file)
@@ -1,8 +1,12 @@
-#ifndef MATH_METRICSINFO
-#define MATH_METRICSINFO
+#ifndef MATH_METRICSINFO_H
+#define MATH_METRICSINFO_H
+
+#include "lyxfont.h"
+#include "LString.h"
 
 class BufferView;
-class LyXFont;
+class Painter;
+class MathNestInset;
 
 
 /// Standard Math Sizes (Math mode styles)
@@ -18,22 +22,123 @@ enum MathStyles {
 };
 
 
-struct MathMetricsInfo {
+struct MathMetricsBase {
        ///
-       MathMetricsInfo()
-               : view(0), font(0), style(LM_ST_TEXT)
-       {}
+       MathMetricsBase();
+
        ///
-       MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
-               : view(v), font(f), style(s)
-       {}
+       LyXFont font;
+       ///
+       MathStyles style;
+       ///
+       string fontname;
+       /// if this is set...
+       bool restrictwidth;
+       /// ... this is valid
+       int textwidth;
+};
 
+
+struct MathMetricsInfo {
+       ///
+       MathMetricsInfo();
+
+       ///
+       MathMetricsBase base;
        ///
        BufferView * view;
        ///
-       LyXFont const * font;
+       bool fullredraw;
+};
+
+
+struct MathPainterInfo {
+       ///
+       MathPainterInfo(Painter & p);
        ///
-       MathStyles style;
+       void draw(int x, int y, char c);
+
+       ///
+       MathMetricsBase base;
+       ///
+       Painter & pain;
+};
+
+
+struct TextMetricsInfo {};
+
+
+// Generic base for temporarily changing things.
+// The original state gets restored when the Changer is destructed
+template <class Struct, class Temp = Struct>
+struct MathChanger {
+       ///
+       MathChanger(Struct & orig) : orig_(orig) {}
+protected:
+       ///
+       Struct & orig_;
+       ///
+       Temp save_;
+};
+
+
+
+struct MathScriptChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathScriptChanger(MathMetricsBase & orig);
+       ///
+       ~MathScriptChanger();
+};
+
+
+struct MathFracChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathFracChanger(MathMetricsBase & orig);
+       ///
+       ~MathFracChanger();
+};
+
+
+
+struct MathFontChanger : public MathChanger<LyXFont> {
+       ///
+       MathFontChanger(LyXFont & orig, char const * font);
+       ///
+       ~MathFontChanger();
+};
+
+
+struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathFontSetChanger(MathMetricsBase & mb, char const * font);
+       ///
+       ~MathFontSetChanger();
 };
 
+
+struct MathStyleChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
+       ///
+       ~MathStyleChanger();
+};
+
+
+struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
+       ///
+       MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
+       ///
+       ~MathShapeChanger();
+};
+
+
+struct MathWidthChanger : public MathChanger<MathMetricsBase>
+{
+       ///
+       MathWidthChanger(MathMetricsBase & mb, int width);
+       ///
+       ~MathWidthChanger();
+};
+
+
 #endif