]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
mathed64.diff
[lyx.git] / src / mathed / math_inset.C
1 /*
2  *  File:        math_inset.C
3  *  Purpose:     Implementation of insets for mathed
4  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
5  *  Created:     January 1996
6  *  Description: 
7  *
8  *  Dependencies: Xlib, XForms
9  *
10  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
11  *
12  *   Version: 0.8beta.
13  *
14  *   You are free to use and modify this code under the terms of
15  *   the GNU General Public Licence version 2 or later.
16  */
17
18 #include <config.h>
19
20 #ifdef __GNUG__
21 #pragma implementation
22 #endif
23
24 #include "debug.h"
25 #include "math_iter.h"
26 #include "math_inset.h"
27 #include "symbol_def.h"
28 #include "lyxfont.h"
29 #include "mathed/support.h"
30 #include "Painter.h"
31
32
33 // Initialize some static class variables.
34 int MathedInset::df_asc;
35 int MathedInset::df_des;
36 int MathedInset::df_width;
37 int MathedInset::workWidth;
38
39
40 MathedInset::MathedInset(string const & nm, short ot, short st)
41         : name(nm), objtype(ot), width(0), ascent(0), descent(0),
42           size_(st)
43 {}
44
45
46 // In a near future maybe we use a better fonts renderer
47 void MathedInset::drawStr(Painter & pain, short type, int siz,
48                           int x, int y, string const & s)
49 {
50         string st;
51         if (MathIsBinary(type))
52                 for (string::const_iterator it = s.begin();
53                      it != s.end(); ++it) {
54                         st += ' ';
55                         st += *it;
56                         st += ' ';
57                 }
58         else
59                 st = s;
60         
61         LyXFont const mf = mathed_get_font(type, siz);
62         pain.text(x, y, st, mf);
63 }
64
65 void MathedInset::substitute(MathMacro *)
66 {
67 }
68
69
70 int MathedInset::Ascent() const
71 {
72         return ascent;
73 }
74
75
76 int MathedInset::Descent() const
77 {
78         return descent;
79 }
80
81
82 int MathedInset::Width() const
83 {
84         return width;
85 }
86
87
88 int MathedInset::Height() const
89 {
90         return ascent + descent;
91 }
92
93
94 bool MathedInset::GetLimits() const
95 {
96         return false;
97 }
98
99
100 void MathedInset::SetLimits(bool) {}   
101
102
103 string const & MathedInset::GetName() const
104 {
105         return name;
106 }
107
108
109 short MathedInset::GetType() const
110 {
111         return objtype;
112 }
113
114
115 short MathedInset::GetStyle() const
116 {
117         return size_;
118 }
119
120
121 void  MathedInset::SetType(short t)
122 {
123         objtype = t;
124 }
125
126
127 void  MathedInset::SetStyle(short st)
128 {
129         size_ = st;
130 }
131
132
133 void MathedInset::SetName(string const & n)
134 {
135         name = n;
136 }
137
138
139 void MathedInset::defaultAscent(int da)
140 {
141         df_asc = da;
142 }
143
144
145
146 void MathedInset::defaultDescent(int dd)
147 {
148         df_des = dd;
149 }
150
151
152 void MathedInset::defaultWidth(int dw)
153 {
154         df_width = dw;
155 }
156
157
158 short MathedInset::size() const
159 {
160         return size_;
161 }
162
163
164 void MathedInset::size(short s)
165 {
166         size_ = s;
167 }
168
169 void MathedInset::incSize()
170 {
171         ++size_;
172 }