2 * \file FormMathsPanel.C
3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Pablo De Napoli, pdenapo@dm.uba.ar
8 * \author John Levon, moz@compsoc.man.ac.uk
9 * \author Angus Leeming, a.leeming@ic.ac.uk
15 #pragma implementation
21 #include "FormMathsPanel.h"
22 #include "form_maths_panel.h"
23 #include "MathsSymbols.h"
26 #include "FormMathsBitmap.h"
27 #include "FormMathsDeco.h"
28 #include "FormMathsDelim.h"
29 #include "FormMathsMatrix.h"
30 #include "FormMathsSpace.h"
34 #include "equation.xpm"
51 FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d)
52 : FormBaseBD(lv, d, _("Maths Panel")),
55 deco_.reset( new FormMathsDeco( lv, d, *this));
56 delim_.reset( new FormMathsDelim( lv, d, *this));
57 matrix_.reset(new FormMathsMatrix(lv, d, *this));
58 space_.reset( new FormMathsSpace( lv, d, *this));
60 vector<string> latex(nr_latex_arrow);
61 for (int i = 0; i<latex.size(); ++i) {
62 latex[i] = latex_arrow[i];
64 arrow_.reset(new FormMathsBitmap(lv, d, *this, latex));
66 latex.resize(nr_latex_bop);
67 for (int i = 0; i<latex.size(); ++i) {
68 latex[i] = latex_bop[i];
70 boperator_.reset(new FormMathsBitmap(lv, d, *this, latex));
72 latex.resize(nr_latex_brel);
73 for (int i = 0; i<latex.size(); ++i) {
74 latex[i] = latex_brel[i];
76 brelats_.reset(new FormMathsBitmap(lv, d, *this, latex));
78 latex.resize(nr_latex_greek);
79 for (int i = 0; i<latex.size(); ++i) {
80 latex[i] = latex_greek[i];
82 greek_.reset(new FormMathsBitmap(lv, d, *this, latex));
84 latex.resize(nr_latex_misc);
85 for (int i = 0; i<latex.size(); ++i) {
86 latex[i] = latex_misc[i];
88 misc_.reset(new FormMathsBitmap(lv, d, *this, latex));
90 latex.resize(nr_latex_varsz);
91 for (int i = 0; i<latex.size(); ++i) {
92 latex[i] = latex_varsz[i];
94 varsize_.reset(new FormMathsBitmap(lv, d, *this, latex));
96 d->showMathPanel.connect(slot(this, &FormMathsPanel::show));
100 FL_FORM * FormMathsPanel::form() const
103 return dialog_->form;
108 void FormMathsPanel::setActive(FormMathsSub * a) const
114 void FormMathsPanel::build()
116 dialog_.reset(build_maths_panel());
118 for (int i = 0; i < nr_function_names; ++i)
119 fl_add_browser_line(dialog_->browser_funcs,
122 fl_set_pixmap_data(dialog_->button_sqrt,
123 const_cast<char**>(sqrt_xpm));
124 fl_set_pixmap_data(dialog_->button_frac,
125 const_cast<char**>(frac));
126 fl_set_pixmap_data(dialog_->button_delim,
127 const_cast<char**>(delim));
128 fl_set_pixmap_data(dialog_->button_deco,
129 const_cast<char**>(deco));
130 fl_set_pixmap_data(dialog_->button_space,
131 const_cast<char**>(space_xpm));
132 fl_set_pixmap_data(dialog_->button_matrix,
133 const_cast<char**>(matrix));
134 fl_set_pixmap_data(dialog_->button_equation,
135 const_cast<char**>(equation));
137 arrow_->addBitmap(20, 5, 4, arrow_width, arrow_height, arrow_bits);
138 arrow_->addBitmap(7, 2, 4, larrow_width, larrow_height, larrow_bits,
140 arrow_->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
142 boperator_->addBitmap(31, 4, 8, bop_width, bop_height, bop_bits);
144 brelats_->addBitmap(35, 4, 9, brel_width, brel_height, brel_bits);
146 greek_->addBitmap(11, 6, 2, Greek_width, Greek_height, Greek_bits);
147 greek_->addBitmap(28, 7, 4, greek_width, greek_height, greek_bits);
149 misc_->addBitmap(29, 5, 6, misc_width, misc_height, misc_bits);
151 varsize_->addBitmap(14, 3, 5, varsz_width, varsz_height, varsz_bits);
153 bc().setCancel(dialog_->button_close);
157 bool FormMathsPanel::input(FL_OBJECT *, long data)
159 MathsCallbackValues val = static_cast<MathsCallbackValues>(data);
163 if (active_ && active_ != greek_.get())
169 if (active_ && active_ != arrow_.get())
175 if (active_ && active_ != boperator_.get())
181 if (active_ && active_ != brelats_.get())
187 if (active_ && active_ != misc_.get())
193 if (active_ && active_ != varsize_.get())
199 insertSymbol("frac");
203 insertSymbol("sqrt");
207 if (active_ && active_ != delim_.get())
213 if (active_ && active_ != matrix_.get())
219 if (active_ && active_ != deco_.get())
225 if (active_ && active_ != space_.get())
235 int const i = fl_get_browser(dialog_->browser_funcs) - 1;
236 insertSymbol(function_names[i]);
244 void FormMathsPanel::insertSymbol(string const & sym) const
246 lv_->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, sym);
250 void FormMathsPanel::mathDisplay() const
252 lv_->getLyXFunc()->Dispatch(LFUN_MATH_DISPLAY);
257 FormMathsSub::FormMathsSub(LyXView * lv, Dialogs * d, FormMathsPanel const & p,
259 : parent_(p), FormBaseBD(lv, d, t)
263 void FormMathsSub::connect()
265 parent_.setActive(this);
266 FormBaseBD::connect();
270 void FormMathsSub::disconnect()
272 parent_.setActive(0);
273 FormBaseBD::disconnect();