2 * \file FormMathsPanel.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Pablo De Napoli
9 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS
17 #include "ControlMath.h"
18 #include "FormMathsPanel.h"
19 #include "forms/form_maths_panel.h"
22 #include "FormMathsBitmap.h"
23 #include "FormMathsDelim.h"
24 #include "FormMathsMatrix.h"
25 #include "FormMathsSpace.h"
26 #include "FormMathsStyle.h"
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"
33 #include "lyx_forms.h"
37 #include "equation.xpm"
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"
62 typedef FormCB<ControlMath, FormDB<FD_maths_panel> > base_class;
64 FormMathsPanel::FormMathsPanel()
65 : base_class(_("Math Panel"))
69 FormMathsBitmap * FormMathsPanel::addDaughter(void * key,
71 char const * const * data,
74 char const * const * const end = data + size;
75 FormMathsBitmap * const view =
76 new FormMathsBitmap(title, std::vector<string>(data, end));
78 controller().addDaughter(key, view,
79 new xformsBC(controller().bc()),
85 void FormMathsPanel::build()
87 dialog_.reset(build_maths_panel(this));
89 for (int i = 0; i < nr_function_names; ++i)
90 fl_add_browser_line(dialog_->browser_funcs,
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));
114 controller().addDaughter(dialog_->button_delim,
116 new xformsBC(controller().bc()),
117 new OkApplyCancelReadOnlyPolicy);
118 controller().addDaughter(dialog_->button_matrix,
120 new xformsBC(controller().bc()),
121 new OkApplyCancelReadOnlyPolicy);
122 controller().addDaughter(dialog_->button_space,
124 new xformsBC(controller().bc()),
126 controller().addDaughter(dialog_->button_style,
128 new xformsBC(controller().bc()),
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);
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,
143 bitmap->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
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);
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);
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);
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,
164 bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
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);
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);
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);
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);
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,
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,
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,
201 ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
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);
222 } else if (ob == dialog_->button_super) {
223 controller().dispatchFunc(LFUN_SUPERSCRIPT);
225 } else if (ob == dialog_->button_sub) {
226 controller().dispatchFunc(LFUN_SUBSCRIPT);
228 // } else if (ob == dialog_->???) {
229 // controller().dispatchFunc(LFUN_SUBSCRIPT);
230 // controller().dispatchFunc(LFUN_LEFT);
231 // controller().dispatchFunc(LFUN_SUPERSCRIPT);
233 } else if (ob == dialog_->button_equation) {
234 controller().dispatchFunc(LFUN_MATH_DISPLAY);
236 } else if (ob == dialog_->button_frac) {
237 controller().insertSymbol("frac");
239 } else if (ob == dialog_->button_sqrt) {
240 controller().insertSymbol("sqrt");
242 } else if (ob == dialog_->browser_funcs) {
243 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
244 controller().insertSymbol(function_names[i]);
247 return ButtonPolicy::SMI_VALID;