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