]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.h
update libtool
[lyx.git] / src / mathed / math_inset.h
1 // -*- C++ -*-
2 /*
3  *  File:        math_inset.h
4  *  Purpose:     Declaration of insets for mathed 
5  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
6  *  Created:     January 1996
7  *  Description: Math paragraph and objects for a WYSIWYG math editor.
8  *
9  *  Dependencies: Xlib, XForms
10  *
11  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
12  *
13  *   Version: 0.8beta, Mathed & Lyx project.
14  *
15  *   You are free to use and modify this code under the terms of
16  *   the GNU General Public Licence version 2 or later.
17  */
18
19 //  Note: These math insets are internal to Mathed and are not derived
20 //        from lyx inset.
21
22 #ifndef MATH_INSET
23 #define MATH_INSET
24
25 #ifdef __GNUG__
26 #pragma interface
27 #endif
28
29 #include "LString.h"
30 #include "symbol_def.h"
31
32 class Painter;
33 class MathMacro;
34
35 /** Abstract base class for all math objects.
36     A math insets is for use of the math editor only, it isn't a
37     general LyX inset. It's used to represent all the math objects.
38     The formulaInset (a LyX inset) encapsulates a math inset.
39 */
40 class MathedInset {
41 public: 
42         /** A math inset has a name (usually its LaTeX name),
43             type and font-size
44         */
45         MathedInset(string const & nm, short ot, short st);
46         /// The virtual base destructor
47         virtual ~MathedInset() {}
48         /// Draw the object
49         virtual void draw(Painter &, int x, int baseline) = 0;  
50         /// Write LaTeX and Lyx code
51         virtual void Write(std::ostream &, bool fragile) = 0;
52         /// Write normalized content
53         virtual void WriteNormal(std::ostream &) = 0;
54         /// Reproduces itself
55         virtual MathedInset * Clone() = 0;
56         /// Reproduces itself with macro arguments substituted
57         virtual void substitute(MathMacro * macro);
58         /// Compute the size of the object
59         virtual void Metrics() = 0; 
60         /// 
61         virtual int Ascent() const;
62         ///
63         virtual int Descent() const;
64         ///
65         virtual int Width() const;
66         ///
67         virtual int Height() const;
68         ///
69         virtual bool GetLimits() const;
70         ///
71         virtual void SetLimits(bool);
72         ///
73         string const & GetName() const;
74         ///
75         short GetType() const;
76         ///
77         short GetStyle() const;
78         //Man:  Avoid to use these functions if it's not strictly necessary 
79         ///
80         virtual void  SetType(short t);
81         ///
82         virtual void  SetStyle(short st);
83         ///
84         virtual void  SetName(string const & n);
85         ///
86         static int workWidth;
87         ///
88         static void defaultAscent(int da);
89         ///
90         static void defaultDescent(int dd);
91         ///
92         static void defaultWidth(int dw);
93         ///
94         short size() const;
95 protected:
96         ///
97         string name;
98         ///
99         short objtype;
100         ///
101         int width;
102         ///
103         int ascent;
104         ///
105         int descent;
106         /// Default metrics
107         static int df_asc;
108         ///
109         static int df_des;
110         ///
111         static int df_width;
112         /// In a near future maybe we use a better fonts renderer than X
113         void drawStr(Painter &, short, int, int, int, string const &);
114         ///
115         void size(short s);
116         ///
117         void incSize();
118 private:
119         ///
120         short size_;
121 };
122 #endif