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