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 #pragma implementation
20 #include "ControlMath.h"
21 #include "FormMathsPanel.h"
22 #include "forms/form_maths_panel.h"
25 #include "FormMathsBitmap.h"
26 #include "FormMathsDeco.h"
27 #include "FormMathsDelim.h"
28 #include "FormMathsMatrix.h"
29 #include "FormMathsSpace.h"
30 #include "FormMathsStyle.h"
32 #include "forms/form_maths_deco.h"
33 #include "forms/form_maths_delim.h"
34 #include "forms/form_maths_matrix.h"
35 #include "forms/form_maths_space.h"
36 #include "forms/form_maths_style.h"
38 #include FORMS_H_LOCATION
42 #include "equation.xpm"
59 #include "ams_misc.xbm"
60 #include "ams_arrows.xbm"
61 #include "ams_rel.xbm"
62 #include "ams_nrel.xbm"
63 #include "ams_ops.xbm"
66 typedef FormCB<ControlMath, FormDB<FD_maths_panel> > base_class;
68 FormMathsPanel::FormMathsPanel()
69 : base_class(_("Maths Panel"))
73 FormMathsBitmap * FormMathsPanel::addDaughter(void * key,
75 char const * const * data,
78 char const * const * const end = data + size;
79 FormMathsBitmap * const view =
80 new FormMathsBitmap(title, std::vector<string>(data, end));
82 typedef ButtonController<IgnorantPolicy, xformsBC> BC;
83 BC * const bc = new BC;
85 controller().addDaughter(key, view, bc);
90 void FormMathsPanel::build()
92 dialog_.reset(build_maths_panel(this));
94 for (int i = 0; i < nr_function_names; ++i)
95 fl_add_browser_line(dialog_->browser_funcs,
98 fl_set_pixmap_data(dialog_->button_sqrt,
99 const_cast<char**>(sqrt_xpm));
100 fl_set_pixmap_data(dialog_->button_frac,
101 const_cast<char**>(frac));
102 fl_set_pixmap_data(dialog_->button_super,
103 const_cast<char**>(super_xpm));
104 fl_set_pixmap_data(dialog_->button_sub,
105 const_cast<char**>(sub_xpm));
106 fl_set_pixmap_data(dialog_->button_delim,
107 const_cast<char**>(delim));
108 fl_set_pixmap_data(dialog_->button_deco,
109 const_cast<char**>(deco));
110 fl_set_pixmap_data(dialog_->button_space,
111 const_cast<char**>(space_xpm));
112 fl_set_pixmap_data(dialog_->button_style,
113 const_cast<char**>(style_xpm));
114 fl_set_pixmap_data(dialog_->button_matrix,
115 const_cast<char**>(matrix));
116 fl_set_pixmap_data(dialog_->button_equation,
117 const_cast<char**>(equation));
119 typedef ButtonController<IgnorantPolicy, xformsBC> BC_ignorant;
120 typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> BC_ok;
122 controller().addDaughter(dialog_->button_deco,
123 new FormMathsDeco, new BC_ignorant);
124 controller().addDaughter(dialog_->button_delim,
125 new FormMathsDelim, new BC_ok);
126 controller().addDaughter(dialog_->button_matrix,
127 new FormMathsMatrix, new BC_ok);
128 controller().addDaughter(dialog_->button_space,
129 new FormMathsSpace, new BC_ignorant);
130 controller().addDaughter(dialog_->button_style,
131 new FormMathsStyle, new BC_ignorant);
133 FormMathsBitmap * bitmap;
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,
139 bitmap->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
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);
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);
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);
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,
160 bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
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);
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);
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);
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);
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,
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,
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,
195 bc().setCancel(dialog_->button_close);
199 ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
201 if (ob == dialog_->button_arrow ||
202 ob == dialog_->button_boperator ||
203 ob == dialog_->button_brelats ||
204 ob == dialog_->button_greek ||
205 ob == dialog_->button_misc ||
206 ob == dialog_->button_dots ||
207 ob == dialog_->button_varsize ||
208 ob == dialog_->button_ams_misc ||
209 ob == dialog_->button_ams_arrows ||
210 ob == dialog_->button_ams_brel ||
211 ob == dialog_->button_ams_nrel ||
212 ob == dialog_->button_ams_ops ||
213 ob == dialog_->button_delim ||
214 ob == dialog_->button_matrix ||
215 ob == dialog_->button_deco ||
216 ob == dialog_->button_space ||
217 ob == dialog_->button_style) {
218 controller().showDaughter(ob);
220 } else if (ob == dialog_->button_super) {
221 controller().dispatchFunc(LFUN_SUPERSCRIPT);
223 } else if (ob == dialog_->button_sub) {
224 controller().dispatchFunc(LFUN_SUBSCRIPT);
226 // } else if (ob == dialog_->???) {
227 // controller().dispatchFunc(LFUN_SUBSCRIPT);
228 // controller().dispatchFunc(LFUN_LEFT);
229 // controller().dispatchFunc(LFUN_SUPERSCRIPT);
231 } else if (ob == dialog_->button_equation) {
232 controller().dispatchFunc(LFUN_MATH_DISPLAY);
234 } else if (ob == dialog_->button_frac) {
235 controller().insertSymbol("frac");
237 } else if (ob == dialog_->button_sqrt) {
238 controller().insertSymbol("sqrt");
240 } else if (ob == dialog_->browser_funcs) {
241 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
242 controller().insertSymbol(function_names[i]);
245 return ButtonPolicy::SMI_VALID;