]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsPanel.C
remove defaults stuff, let Qt handle no toolbar
[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         controller().addDaughter(key, view,
79                                  new xformsBC(controller().bc()),
80                                  new IgnorantPolicy);
81         return view;
82 }
83
84
85 void FormMathsPanel::build()
86 {
87         dialog_.reset(build_maths_panel(this));
88
89         for (int i = 0; i < nr_function_names; ++i)
90                 fl_add_browser_line(dialog_->browser_funcs,
91                                     function_names[i]);
92
93         fl_set_pixmap_data(dialog_->button_sqrt,
94                            const_cast<char**>(sqrt_xpm));
95         fl_set_pixmap_data(dialog_->button_frac,
96                            const_cast<char**>(frac));
97         fl_set_pixmap_data(dialog_->button_super,
98                            const_cast<char**>(super_xpm));
99         fl_set_pixmap_data(dialog_->button_sub,
100                            const_cast<char**>(sub_xpm));
101         fl_set_pixmap_data(dialog_->button_delim,
102                            const_cast<char**>(delim));
103         fl_set_pixmap_data(dialog_->button_deco,
104                            const_cast<char**>(deco));
105         fl_set_pixmap_data(dialog_->button_space,
106                            const_cast<char**>(space_xpm));
107         fl_set_pixmap_data(dialog_->button_style,
108                            const_cast<char**>(style_xpm));
109         fl_set_pixmap_data(dialog_->button_matrix,
110                            const_cast<char**>(matrix));
111         fl_set_pixmap_data(dialog_->button_equation,
112                            const_cast<char**>(equation));
113
114         controller().addDaughter(dialog_->button_delim,
115                                  new FormMathsDelim,
116                                  new xformsBC(controller().bc()),
117                                  new OkApplyCancelReadOnlyPolicy);
118         controller().addDaughter(dialog_->button_matrix,
119                                  new FormMathsMatrix,
120                                  new xformsBC(controller().bc()),
121                                  new OkApplyCancelReadOnlyPolicy);
122         controller().addDaughter(dialog_->button_space,
123                                  new FormMathsSpace,
124                                  new xformsBC(controller().bc()),
125                                  new IgnorantPolicy);
126         controller().addDaughter(dialog_->button_style,
127                                  new FormMathsStyle,
128                                  new xformsBC(controller().bc()),
129                                  new IgnorantPolicy);
130
131         FormMathsBitmap * bitmap;
132         bitmap = addDaughter(dialog_->button_deco,
133                              _("Maths Decorations & Accents"),
134                              latex_deco, nr_latex_deco);
135         bitmap->addBitmap(12, 3, 4, deco1_width, deco1_height, deco1_bits);
136         bitmap->addBitmap(10, 4, 3, deco2_width, deco2_height, deco2_bits);
137
138         bitmap = addDaughter(dialog_->button_arrow, _("Arrows"),
139                              latex_arrow, nr_latex_arrow);
140         bitmap->addBitmap(20, 5, 4, arrow_width,  arrow_height,  arrow_bits);
141         bitmap->addBitmap(7,  2, 4, larrow_width, larrow_height, larrow_bits,
142                           false);
143         bitmap->addBitmap(4,  2, 2, darrow_width,  darrow_height, darrow_bits);
144
145         bitmap = addDaughter(dialog_->button_boperator, _("Binary Ops"),
146                              latex_bop, nr_latex_bop);
147         bitmap->addBitmap(31, 4, 8, bop_width, bop_height, bop_bits);
148
149         bitmap = addDaughter(dialog_->button_brelats, _("Bin Relations"),
150                              latex_brel, nr_latex_brel);
151         bitmap->addBitmap(35, 4, 9, brel_width, brel_height, brel_bits);
152
153         bitmap = addDaughter(dialog_->button_greek, _("Greek"),
154                              latex_greek, nr_latex_greek);
155         bitmap->addBitmap(11, 6, 2, Greek_width, Greek_height, Greek_bits);
156         bitmap->addBitmap(28, 7, 4, greek_width, greek_height, greek_bits);
157
158         bitmap = addDaughter(dialog_->button_misc,_("Misc"),
159                              latex_misc, nr_latex_misc);
160         bitmap->addBitmap(29, 5, 6, misc_width, misc_height, misc_bits);
161         bitmap->addBitmap(5, 5, 1, misc4_width, misc4_height, misc4_bits);
162         bitmap->addBitmap(6, 3, 2, misc2_width, misc2_height, misc2_bits,
163                           false);
164         bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
165
166         bitmap = addDaughter(dialog_->button_dots, _("Dots"),
167                              latex_dots, nr_latex_dots);
168         bitmap->addBitmap(4, 4, 1, dots_width, dots_height, dots_bits);
169
170         bitmap = addDaughter(dialog_->button_varsize, _("Big Operators"),
171                      latex_varsz, nr_latex_varsz);
172         bitmap->addBitmap(14, 3, 5, varsz_width, varsz_height, varsz_bits);
173
174         bitmap = addDaughter(dialog_->button_ams_misc, _("AMS Misc"),
175                              latex_ams_misc, nr_latex_ams_misc);
176         bitmap->addBitmap(9, 5, 2, ams1_width, ams1_height, ams1_bits);
177         bitmap->addBitmap(26, 3, 9, ams7_width, ams7_height, ams7_bits);
178
179         bitmap = addDaughter(dialog_->button_ams_arrows, _("AMS Arrows"),
180                              latex_ams_arrows, nr_latex_ams_arrows);
181         bitmap->addBitmap(32, 3, 11, ams2_width, ams2_height, ams2_bits);
182         bitmap->addBitmap(6, 3, 2, ams3_width, ams3_height, ams3_bits);
183
184         bitmap = addDaughter(dialog_->button_ams_brel, _("AMS Relations"),
185                              latex_ams_rel, nr_latex_ams_rel);
186         bitmap->addBitmap(66, 6, 11, ams_rel_width, ams_rel_height,
187                           ams_rel_bits);
188
189         bitmap = addDaughter(dialog_->button_ams_nrel, _("AMS Negated Rel"),
190                              latex_ams_nrel, nr_latex_ams_nrel);
191         bitmap->addBitmap(51, 6, 9, ams_nrel_width, ams_nrel_height,
192                           ams_nrel_bits);
193
194         bitmap = addDaughter(dialog_->button_ams_ops, _("AMS Operators"),
195                              latex_ams_ops, nr_latex_ams_ops);
196         bitmap->addBitmap(23, 3, 8, ams_ops_width, ams_ops_height,
197                           ams_ops_bits);
198 }
199
200
201 ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
202 {
203         if (ob == dialog_->button_arrow ||
204             ob == dialog_->button_boperator ||
205             ob == dialog_->button_brelats ||
206             ob == dialog_->button_greek ||
207             ob == dialog_->button_misc ||
208             ob == dialog_->button_dots ||
209             ob == dialog_->button_varsize ||
210             ob == dialog_->button_ams_misc ||
211             ob == dialog_->button_ams_arrows ||
212             ob == dialog_->button_ams_brel ||
213             ob == dialog_->button_ams_nrel ||
214             ob == dialog_->button_ams_ops ||
215             ob == dialog_->button_delim ||
216             ob == dialog_->button_matrix ||
217             ob == dialog_->button_deco ||
218             ob == dialog_->button_space ||
219             ob == dialog_->button_style) {
220                 controller().showDaughter(ob);
221
222         } else if (ob == dialog_->button_super) {
223                 controller().dispatchFunc(LFUN_SUPERSCRIPT);
224
225         } else if (ob == dialog_->button_sub) {
226                 controller().dispatchFunc(LFUN_SUBSCRIPT);
227
228 //      } else if (ob == dialog_->???) {
229 //              controller().dispatchFunc(LFUN_SUBSCRIPT);
230 //              controller().dispatchFunc(LFUN_LEFT);
231 //              controller().dispatchFunc(LFUN_SUPERSCRIPT);
232
233         } else if (ob == dialog_->button_equation) {
234                 controller().dispatchFunc(LFUN_MATH_DISPLAY);
235
236         } else if (ob == dialog_->button_frac) {
237                 controller().insertSymbol("frac");
238
239         } else if (ob == dialog_->button_sqrt) {
240                 controller().insertSymbol("sqrt");
241
242         } else if (ob == dialog_->browser_funcs) {
243                 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
244                 controller().insertSymbol(function_names[i]);
245         }
246
247         return ButtonPolicy::SMI_VALID;
248 }