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