]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
move inlines out of line
[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 "math_iter.h"
25 #include "math_inset.h"
26 #include "symbol_def.h"
27 #include "lyxfont.h"
28 #include "mathed/support.h"
29 #include "Painter.h"
30
31
32 // Initialize some static class variables.
33 int MathedInset::df_asc;
34 int MathedInset::df_des;
35 int MathedInset::df_width;
36 int MathedInset::workWidth;
37
38
39 MathedInset::MathedInset(string const & nm, short ot, short st)
40         : name(nm), objtype(ot), width(0), ascent(0), descent(0), size_(st) 
41 {}
42
43
44 // In a near future maybe we use a better fonts renderer
45 void MathedInset::drawStr(Painter & pain, short type, int siz,
46                           int x, int y, string const & s)
47 {
48         string st;
49         if (MathIsBinary(type))
50                 for (string::const_iterator it = s.begin();
51                      it != s.end(); ++it) {
52                         st += ' ';
53                         st += *it;
54                         st += ' ';
55                 }
56         else
57                 st = s;
58         
59         LyXFont const mf = mathed_get_font(type, siz);
60         pain.text(x, y, st, mf);
61 }
62
63
64 int MathedInset::Ascent() const
65 {
66         return ascent;
67 }
68
69
70 int MathedInset::Descent() const
71 {
72         return descent;
73 }
74
75
76 int MathedInset::Width() const
77 {
78         return width;
79 }
80
81
82 int MathedInset::Height() const
83 {
84         return ascent + descent;
85 }
86
87
88 bool MathedInset::GetLimits() const
89 {
90         return false;
91 }
92
93
94 void MathedInset::SetLimits(bool) {}   
95
96
97 string const & MathedInset::GetName() const
98 {
99         return name;
100 }
101
102
103 short MathedInset::GetType() const
104 {
105         return objtype;
106 }
107
108
109 short MathedInset::GetStyle() const
110 {
111         return size_;
112 }
113
114
115 void  MathedInset::SetType(short t)
116 {
117         objtype = t;
118 }
119
120
121 void  MathedInset::SetStyle(short st)
122 {
123         size_ = st;
124 }
125
126
127 void MathedInset::SetName(string const & n)
128 {
129         name = n;
130 }
131
132
133 void MathedInset::defaultAscent(int da)
134 {
135         df_asc = da;
136 }
137
138
139
140 void MathedInset::defaultDescent(int dd)
141 {
142         df_des = dd;
143 }
144
145
146 void MathedInset::defaultWidth(int dw)
147 {
148         df_width = dw;
149 }
150
151
152 short MathedInset::size() const
153 {
154         return size_;
155 }
156
157
158 void MathedInset::size(short s)
159 {
160         size_ = s;
161 }
162
163
164 void MathedInset::incSize()
165 {
166         ++size_;
167 }