]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.h
first go at mathed file cleanup
[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 "math_defs.h"
31 #include "symbol_def.h"
32
33 /** Abstract base class for all math objects.
34     A math insets is for use of the math editor only, it isn't a
35     general LyX inset. It's used to represent all the math objects.
36     The formulaInset (a LyX inset) encapsulates a math inset.
37  */
38 class MathedInset  {
39  public: 
40     /// A math inset has a name (usually its LaTeX name), type and font-size
41     MathedInset(string const & nm, short ot, short st);
42     ///
43     explicit
44     MathedInset(MathedInset *);
45     ///
46     virtual ~MathedInset() {}
47     /// Draw the object
48     virtual void draw(Painter &, int x, int baseline) = 0;      
49     /// Write LaTeX and Lyx code
50     virtual void Write(std::ostream &, bool fragile) = 0;
51     /// Reproduces itself
52     virtual MathedInset * Clone() = 0;
53     /// Compute the size of the object
54     virtual void Metrics() = 0; 
55     /// 
56     virtual int Ascent() const { return ascent; }
57     ///
58     virtual int Descent() const { return descent; }
59     ///
60     virtual int Width() const { return width; }
61     ///
62     virtual int Height() const { return ascent + descent; }
63     ///
64     virtual bool GetLimits() const { return false; }
65     ///
66     virtual void SetLimits(bool) {}   
67     ///
68     string const & GetName() const { return name; }
69     ///
70     short GetType() const { return objtype; }
71     ///
72     short GetStyle() const { return size; }
73     //Man:  Avoid to use these functions if it's not strictly necessary 
74     ///
75     virtual void  SetType(short t) { objtype = t; }
76     ///
77     virtual void  SetStyle(short st) { size = st; } // Metrics();
78     ///
79     virtual void  SetName(string const & n) { name = n; }
80     ///
81     static int workWidth;
82          protected:
83     ///
84     string name;
85     ///
86     short objtype;
87     ///
88     int width;
89     ///
90     int ascent;
91     ///
92     int descent;
93     ///
94     short size;
95     /// Default metrics
96     static int df_asc;
97     ///
98     static int df_des;
99     ///
100     static int df_width;
101     /// In a near future maybe we use a better fonts renderer than X
102     void drawStr(Painter &, short, int, int, int, string const &);
103     ///
104     friend class MathedCursor;
105     ///
106     friend void mathed_init_fonts();
107 };
108 #endif