]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_metricsinfo.h
Fix reading of math macros
[lyx.git] / src / mathed / math_metricsinfo.h
index db5a3c2caf2a2cd125f08ec0a184ffb5c2c6d140..4f52237fd9de10fd7c0afd0f7dbff74e003d7448 100644 (file)
@@ -1,8 +1,14 @@
-#ifndef MATH_METRICSINFO
-#define MATH_METRICSINFO
+#ifndef MATH_METRICSINFO_H
+#define MATH_METRICSINFO_H
 
-class BufferView;
-class LyXFont;
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "lyxfont.h"
+#include "LString.h"
+
+class Painter;
 
 
 /// Standard Math Sizes (Math mode styles)
@@ -18,22 +24,124 @@ enum MathStyles {
 };
 
 
+struct MathMetricsBase {
+       ///
+       MathMetricsBase();
+
+       ///
+       LyXFont font;
+       ///
+       MathStyles style;
+       ///
+       string fontname;
+       /// if this is set...
+       bool restrictwidth;
+       /// ... this is valid
+       int textwidth;
+};
+
+
 struct MathMetricsInfo {
        ///
-       MathMetricsInfo()
-               : view(0), font(0), style(LM_ST_TEXT)
-       {}
+       MathMetricsInfo();
+
+       ///
+       MathMetricsBase base;
+       ///
+       bool fullredraw;
+};
+
+
+struct MathPainterInfo {
+       ///
+       MathPainterInfo(Painter & pain);
        ///
-       MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
-               : view(v), font(f), style(s)
-       {}
+       void draw(int x, int y, char c);
 
        ///
-       BufferView * view;
+       MathMetricsBase base;
        ///
-       LyXFont const * font;
+       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 {
        ///
-       MathStyles style;
+       MathChanger(Struct & orig) : orig_(orig) {}
+protected:
+       ///
+       Struct & orig_;
+       ///
+       Temp save_;
+};
+
+
+
+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 MathScriptChanger : public MathStyleChanger {
+       ///
+       MathScriptChanger(MathMetricsBase & mb);
+};
+
+
+struct MathFracChanger : public MathStyleChanger {
+       ///
+       MathFracChanger(MathMetricsBase & mb);
+};
+
+
+struct MathArrayChanger : public MathStyleChanger {
+       ///
+       MathArrayChanger(MathMetricsBase & mb);
+};
+
+
+
+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