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 "FormMathsDelim.h"
27 #include "FormMathsMatrix.h"
28 #include "FormMathsSpace.h"
29 #include "FormMathsStyle.h"
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"
36 #include FORMS_H_LOCATION
40 #include "equation.xpm"
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"
65 typedef FormCB<ControlMath, FormDB<FD_maths_panel> > base_class;
67 FormMathsPanel::FormMathsPanel()
68 : base_class(_("Maths Panel"))
72 FormMathsBitmap * FormMathsPanel::addDaughter(void * key,
74 char const * const * data,
77 char const * const * const end = data + size;
78 FormMathsBitmap * const view =
79 new FormMathsBitmap(title, std::vector<string>(data, end));
81 typedef ButtonController<IgnorantPolicy, xformsBC> BC;
82 BC * const bc = new BC;
84 controller().addDaughter(key, view, bc);
89 void FormMathsPanel::build()
91 dialog_.reset(build_maths_panel(this));
93 for (int i = 0; i < nr_function_names; ++i)
94 fl_add_browser_line(dialog_->browser_funcs,
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));
118 typedef ButtonController<IgnorantPolicy, xformsBC> BC_ignorant;
119 typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> BC_ok;
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);
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);
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,
142 bitmap->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
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);
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);
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);
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,
163 bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
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);
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);
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);
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);
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,
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,
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,
200 ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
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);
221 } else if (ob == dialog_->button_super) {
222 controller().dispatchFunc(LFUN_SUPERSCRIPT);
224 } else if (ob == dialog_->button_sub) {
225 controller().dispatchFunc(LFUN_SUBSCRIPT);
227 // } else if (ob == dialog_->???) {
228 // controller().dispatchFunc(LFUN_SUBSCRIPT);
229 // controller().dispatchFunc(LFUN_LEFT);
230 // controller().dispatchFunc(LFUN_SUPERSCRIPT);
232 } else if (ob == dialog_->button_equation) {
233 controller().dispatchFunc(LFUN_MATH_DISPLAY);
235 } else if (ob == dialog_->button_frac) {
236 controller().insertSymbol("frac");
238 } else if (ob == dialog_->button_sqrt) {
239 controller().insertSymbol("sqrt");
241 } else if (ob == dialog_->browser_funcs) {
242 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
243 controller().insertSymbol(function_names[i]);
246 return ButtonPolicy::SMI_VALID;