]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_metricsinfo.h
Fix.
[lyx.git] / src / mathed / math_metricsinfo.h
index 9c2e720547ac3d7fc1e6339f737461639459e7a2..e9bbd9d7dd516ca0811a909ae2b920dd308daa7c 100644 (file)
@@ -1,10 +1,11 @@
-#ifndef MATH_METRICSINFO
-#define MATH_METRICSINFO
+#ifndef MATH_METRICSINFO_H
+#define MATH_METRICSINFO_H
+
 
 #include "lyxfont.h"
+#include "LString.h"
 
-class BufferView;
-class MathNestInset;
+class Painter;
 
 
 /// Standard Math Sizes (Math mode styles)
@@ -20,26 +21,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(), style(LM_ST_TEXT), inset(0)
-       {}
+       MathMetricsInfo();
+
+       ///
+       MathMetricsBase base;
        ///
-       MathMetricsInfo(BufferView * v, LyXFont const & f, MathStyles s)
-               : view(v), font(f), style(s), inset(0)
-       {}
+       bool fullredraw;
+};
+
 
+struct MathPainterInfo {
        ///
-       BufferView * view;
+       MathPainterInfo(Painter & pain);
        ///
-       LyXFont font;
+       void draw(int x, int y, char c);
+
        ///
-       MathStyles style;
-       /// used to pass some info down
-       MathNestInset const * inset;
+       MathMetricsBase base;
        ///
-       int idx;
+       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 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