]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsPanel.C
dont use pragma impementation and interface anymore
[lyx.git] / src / frontends / xforms / FormMathsPanel.C
1 /**
2  * \file FormMathsPanel.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Pablo De Napoli
8  * \author John Levon
9  * \author Angus Leeming
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #include <config.h>
15
16
17 #include "ControlMath.h"
18 #include "FormMathsPanel.h"
19 #include "forms/form_maths_panel.h"
20 #include "xformsBC.h"
21
22 #include "FormMathsBitmap.h"
23 #include "FormMathsDelim.h"
24 #include "FormMathsMatrix.h"
25 #include "FormMathsSpace.h"
26 #include "FormMathsStyle.h"
27
28 #include "forms/form_maths_delim.h"
29 #include "forms/form_maths_matrix.h"
30 #include "forms/form_maths_space.h"
31 #include "forms/form_maths_style.h"
32
33 #include FORMS_H_LOCATION
34
35 #include "deco.xpm"
36 #include "delim.xpm"
37 #include "equation.xpm"
38 #include "frac.xpm"
39 #include "matrix.xpm"
40 #include "space.xpm"
41 #include "style.xpm"
42 #include "sqrt.xpm"
43 #include "sub.xpm"
44 #include "super.xpm"
45
46 #include "arrows.xbm"
47 #include "bop.xbm"
48 #include "brel.xbm"
49 #include "deco.xbm"
50 #include "dots.xbm"
51 #include "greek.xbm"
52 #include "misc.xbm"
53 #include "varsz.xbm"
54
55 #include "ams_misc.xbm"
56 #include "ams_arrows.xbm"
57 #include "ams_rel.xbm"
58 #include "ams_nrel.xbm"
59 #include "ams_ops.xbm"
60
61
62 typedef FormCB<ControlMath, FormDB<FD_maths_panel> > base_class;
63
64 FormMathsPanel::FormMathsPanel()
65         : base_class(_("Maths Panel"))
66 {}
67
68
69 FormMathsBitmap * FormMathsPanel::addDaughter(void * key,
70                                               string const & title,
71                                               char const * const * data,
72                                               int size)
73 {
74         char const * const * const end = data + size;
75         FormMathsBitmap * const view =
76                 new FormMathsBitmap(title, std::vector<string>(data, end));
77
78         typedef ButtonController<IgnorantPolicy, xformsBC> BC;
79         BC * const bc = new BC;
80
81         controller().addDaughter(key, view, bc);
82         return view;
83 }
84
85
86 void FormMathsPanel::build()
87 {
88         dialog_.reset(build_maths_panel(this));
89
90         for (int i = 0; i < nr_function_names; ++i)
91                 fl_add_browser_line(dialog_->browser_funcs,
92                                     function_names[i]);
93
94         fl_set_pixmap_data(dialog_->button_sqrt,
95                            const_cast<char**>(sqrt_xpm));
96         fl_set_pixmap_data(dialog_->button_frac,
97                            const_cast<char**>(frac));
98         fl_set_pixmap_data(dialog_->button_super,
99                            const_cast<char**>(super_xpm));
100         fl_set_pixmap_data(dialog_->button_sub,
101                            const_cast<char**>(sub_xpm));
102         fl_set_pixmap_data(dialog_->button_delim,
103                            const_cast<char**>(delim));
104         fl_set_pixmap_data(dialog_->button_deco,
105                            const_cast<char**>(deco));
106         fl_set_pixmap_data(dialog_->button_space,
107                            const_cast<char**>(space_xpm));
108         fl_set_pixmap_data(dialog_->button_style,
109                            const_cast<char**>(style_xpm));
110         fl_set_pixmap_data(dialog_->button_matrix,
111                            const_cast<char**>(matrix));
112         fl_set_pixmap_data(dialog_->button_equation,
113                            const_cast<char**>(equation));
114
115         typedef ButtonController<IgnorantPolicy, xformsBC> BC_ignorant;
116         typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> BC_ok;
117
118         controller().addDaughter(dialog_->button_delim,
119                                  new FormMathsDelim, new BC_ok);
120         controller().addDaughter(dialog_->button_matrix,
121                                  new FormMathsMatrix, new BC_ok);
122         controller().addDaughter(dialog_->button_space,
123                                  new FormMathsSpace, new BC_ignorant);
124         controller().addDaughter(dialog_->button_style,
125                                  new FormMathsStyle,  new BC_ignorant);
126
127         FormMathsBitmap * bitmap;
128         bitmap = addDaughter(dialog_->button_deco,
129                              _("Maths Decorations & Accents"),
130                              latex_deco, nr_latex_deco);
131         bitmap->addBitmap(12, 3, 4, deco1_width, deco1_height, deco1_bits);
132         bitmap->addBitmap(10, 4, 3, deco2_width, deco2_height, deco2_bits);
133
134         bitmap = addDaughter(dialog_->button_arrow, _("Arrows"),
135                              latex_arrow, nr_latex_arrow);
136         bitmap->addBitmap(20, 5, 4, arrow_width,  arrow_height,  arrow_bits);
137         bitmap->addBitmap(7,  2, 4, larrow_width, larrow_height, larrow_bits,
138                           false);
139         bitmap->addBitmap(4,  2, 2, darrow_width,  darrow_height, darrow_bits);
140
141         bitmap = addDaughter(dialog_->button_boperator, _("Binary Ops"),
142                              latex_bop, nr_latex_bop);
143         bitmap->addBitmap(31, 4, 8, bop_width, bop_height, bop_bits);
144
145         bitmap = addDaughter(dialog_->button_brelats, _("Bin Relations"),
146                              latex_brel, nr_latex_brel);
147         bitmap->addBitmap(35, 4, 9, brel_width, brel_height, brel_bits);
148
149         bitmap = addDaughter(dialog_->button_greek, _("Greek"),
150                              latex_greek, nr_latex_greek);
151         bitmap->addBitmap(11, 6, 2, Greek_width, Greek_height, Greek_bits);
152         bitmap->addBitmap(28, 7, 4, greek_width, greek_height, greek_bits);
153
154         bitmap = addDaughter(dialog_->button_misc,_("Misc"),
155                              latex_misc, nr_latex_misc);
156         bitmap->addBitmap(29, 5, 6, misc_width, misc_height, misc_bits);
157         bitmap->addBitmap(5, 5, 1, misc4_width, misc4_height, misc4_bits);
158         bitmap->addBitmap(6, 3, 2, misc2_width, misc2_height, misc2_bits,
159                           false);
160         bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
161
162         bitmap = addDaughter(dialog_->button_dots, _("Dots"),
163                              latex_dots, nr_latex_dots);
164         bitmap->addBitmap(4, 4, 1, dots_width, dots_height, dots_bits);
165
166         bitmap = addDaughter(dialog_->button_varsize, _("Big Operators"),
167                      latex_varsz, nr_latex_varsz);
168         bitmap->addBitmap(14, 3, 5, varsz_width, varsz_height, varsz_bits);
169
170         bitmap = addDaughter(dialog_->button_ams_misc, _("AMS Misc"),
171                              latex_ams_misc, nr_latex_ams_misc);
172         bitmap->addBitmap(9, 5, 2, ams1_width, ams1_height, ams1_bits);
173         bitmap->addBitmap(26, 3, 9, ams7_width, ams7_height, ams7_bits);
174
175         bitmap = addDaughter(dialog_->button_ams_arrows, _("AMS Arrows"),
176                              latex_ams_arrows, nr_latex_ams_arrows);
177         bitmap->addBitmap(32, 3, 11, ams2_width, ams2_height, ams2_bits);
178         bitmap->addBitmap(6, 3, 2, ams3_width, ams3_height, ams3_bits);
179
180         bitmap = addDaughter(dialog_->button_ams_brel, _("AMS Relations"),
181                              latex_ams_rel, nr_latex_ams_rel);
182         bitmap->addBitmap(66, 6, 11, ams_rel_width, ams_rel_height,
183                           ams_rel_bits);
184
185         bitmap = addDaughter(dialog_->button_ams_nrel, _("AMS Negated Rel"),
186                              latex_ams_nrel, nr_latex_ams_nrel);
187         bitmap->addBitmap(51, 6, 9, ams_nrel_width, ams_nrel_height,
188                           ams_nrel_bits);
189
190         bitmap = addDaughter(dialog_->button_ams_ops, _("AMS Operators"),
191                              latex_ams_ops, nr_latex_ams_ops);
192         bitmap->addBitmap(23, 3, 8, ams_ops_width, ams_ops_height,
193                           ams_ops_bits);
194 }
195
196
197 ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
198 {
199         if (ob == dialog_->button_arrow ||
200             ob == dialog_->button_boperator ||
201             ob == dialog_->button_brelats ||
202             ob == dialog_->button_greek ||
203             ob == dialog_->button_misc ||
204             ob == dialog_->button_dots ||
205             ob == dialog_->button_varsize ||
206             ob == dialog_->button_ams_misc ||
207             ob == dialog_->button_ams_arrows ||
208             ob == dialog_->button_ams_brel ||
209             ob == dialog_->button_ams_nrel ||
210             ob == dialog_->button_ams_ops ||
211             ob == dialog_->button_delim ||
212             ob == dialog_->button_matrix ||
213             ob == dialog_->button_deco ||
214             ob == dialog_->button_space ||
215             ob == dialog_->button_style) {
216                 controller().showDaughter(ob);
217
218         } else if (ob == dialog_->button_super) {
219                 controller().dispatchFunc(LFUN_SUPERSCRIPT);
220
221         } else if (ob == dialog_->button_sub) {
222                 controller().dispatchFunc(LFUN_SUBSCRIPT);
223
224 //      } else if (ob == dialog_->???) {
225 //              controller().dispatchFunc(LFUN_SUBSCRIPT);
226 //              controller().dispatchFunc(LFUN_LEFT);
227 //              controller().dispatchFunc(LFUN_SUPERSCRIPT);
228
229         } else if (ob == dialog_->button_equation) {
230                 controller().dispatchFunc(LFUN_MATH_DISPLAY);
231
232         } else if (ob == dialog_->button_frac) {
233                 controller().insertSymbol("frac");
234
235         } else if (ob == dialog_->button_sqrt) {
236                 controller().insertSymbol("sqrt");
237
238         } else if (ob == dialog_->browser_funcs) {
239                 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
240                 controller().insertSymbol(function_names[i]);
241         }
242
243         return ButtonPolicy::SMI_VALID;
244 }