* \author John Levon
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "ControlMath.h"
-
-#include "frontends/LyXView.h"
#include "FormMathsPanel.h"
+#include "ControlMath.h"
#include "forms/form_maths_panel.h"
-#include "funcrequest.h"
-#include "forms/form_maths_deco.h"
-#include "forms/form_maths_delim.h"
-#include "forms/form_maths_matrix.h"
-#include "forms/form_maths_space.h"
-#include "forms/form_maths_style.h"
+#include "xformsBC.h"
-#include "FormMathsBitmap.h"
-#include "FormMathsDeco.h"
-#include "FormMathsDelim.h"
-#include "FormMathsMatrix.h"
-#include "FormMathsSpace.h"
-#include "FormMathsStyle.h"
-
-#include FORMS_H_LOCATION
-#include <boost/bind.hpp>
+#include "lyx_forms.h"
#include "deco.xpm"
#include "delim.xpm"
#include "sub.xpm"
#include "super.xpm"
-#include "arrows.xbm"
-#include "bop.xbm"
-#include "brel.xbm"
-#include "dots.xbm"
-#include "greek.xbm"
-#include "misc.xbm"
-#include "varsz.xbm"
-
-#include "ams_misc.xbm"
-#include "ams_arrows.xbm"
-#include "ams_rel.xbm"
-#include "ams_nrel.xbm"
-#include "ams_ops.xbm"
+typedef FormController<ControlMath, FormView<FD_maths_panel> > base_class;
-FormMathsPanel::FormMathsPanel(LyXView & lv, Dialogs & d)
- : FormBaseBD(lv, d, _("Maths Panel")),
- active_(0), bc_(_("Close"))
+FormMathsPanel::FormMathsPanel(Dialog & parent)
+ : base_class(parent, _("Math Panel"))
{}
-FL_FORM * FormMathsPanel::form() const
-{
- return dialog_.get() ? dialog_->form : 0;
-}
-
-
-FormMathsBitmap * FormMathsPanel::addDaughter(FL_OBJECT * button,
- string const & title,
- char const * const * data,
- int size)
-{
- char const * const * end = data + size;
- FormMathsBitmap * bitmap =
- new FormMathsBitmap(lv_, d_, *this, title,
- std::vector<string>(data, end));
- daughters_[button] = DaughterDialog(bitmap);
- return bitmap;
-}
-
-
void FormMathsPanel::build()
{
dialog_.reset(build_maths_panel(this));
const_cast<char**>(matrix));
fl_set_pixmap_data(dialog_->button_equation,
const_cast<char**>(equation));
-
- daughters_[dialog_->button_deco] =
- DaughterDialog(new FormMathsDeco(lv_, d_, *this));
- daughters_[dialog_->button_delim] =
- DaughterDialog(new FormMathsDelim(lv_, d_, *this));
- daughters_[dialog_->button_matrix] =
- DaughterDialog(new FormMathsMatrix(lv_, d_, *this));
- daughters_[dialog_->button_space] =
- DaughterDialog(new FormMathsSpace(lv_, d_, *this));
- daughters_[dialog_->button_style] =
- DaughterDialog(new FormMathsStyle(lv_, d_, *this));
-
- FormMathsBitmap * bitmap;
- bitmap = addDaughter(dialog_->button_arrow, _("Arrows"),
- latex_arrow, nr_latex_arrow);
- bitmap->addBitmap(20, 5, 4, arrow_width, arrow_height, arrow_bits);
- bitmap->addBitmap(7, 2, 4, larrow_width, larrow_height, larrow_bits,
- false);
- bitmap->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
-
- bitmap = addDaughter(dialog_->button_boperator, _("Binary Ops"),
- latex_bop, nr_latex_bop);
- bitmap->addBitmap(31, 4, 8, bop_width, bop_height, bop_bits);
-
- bitmap = addDaughter(dialog_->button_brelats, _("Bin Relations"),
- latex_brel, nr_latex_brel);
- bitmap->addBitmap(35, 4, 9, brel_width, brel_height, brel_bits);
-
- bitmap = addDaughter(dialog_->button_greek, _("Greek"),
- latex_greek, nr_latex_greek);
- bitmap->addBitmap(11, 6, 2, Greek_width, Greek_height, Greek_bits);
- bitmap->addBitmap(28, 7, 4, greek_width, greek_height, greek_bits);
-
- bitmap = addDaughter(dialog_->button_misc,_("Misc"),
- latex_misc, nr_latex_misc);
- bitmap->addBitmap(29, 5, 6, misc_width, misc_height, misc_bits);
- bitmap->addBitmap(5, 5, 1, misc4_width, misc4_height, misc4_bits);
- bitmap->addBitmap(6, 3, 2, misc2_width, misc2_height, misc2_bits,
- false);
- bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
-
- bitmap = addDaughter(dialog_->button_dots, _("Dots"),
- latex_dots, nr_latex_dots);
- bitmap->addBitmap(4, 4, 1, dots_width, dots_height, dots_bits);
-
- bitmap = addDaughter(dialog_->button_varsize, _("Big Operators"),
- latex_varsz, nr_latex_varsz);
- bitmap->addBitmap(14, 3, 5, varsz_width, varsz_height, varsz_bits);
-
- bitmap = addDaughter(dialog_->button_ams_misc, _("AMS Misc"),
- latex_ams_misc, nr_latex_ams_misc);
- bitmap->addBitmap(9, 5, 2, ams1_width, ams1_height, ams1_bits);
- bitmap->addBitmap(26, 3, 9, ams7_width, ams7_height, ams7_bits);
-
- bitmap = addDaughter(dialog_->button_ams_arrows, _("AMS Arrows"),
- latex_ams_arrows, nr_latex_ams_arrows);
- bitmap->addBitmap(32, 3, 11, ams2_width, ams2_height, ams2_bits);
- bitmap->addBitmap(6, 3, 2, ams3_width, ams3_height, ams3_bits);
-
- bitmap = addDaughter(dialog_->button_ams_brel, _("AMS Relations"),
- latex_ams_rel, nr_latex_ams_rel);
- bitmap->addBitmap(66, 6, 11, ams_rel_width, ams_rel_height,
- ams_rel_bits);
-
- bitmap = addDaughter(dialog_->button_ams_nrel, _("AMS Negated Rel"),
- latex_ams_nrel, nr_latex_ams_nrel);
- bitmap->addBitmap(51, 6, 9, ams_nrel_width, ams_nrel_height,
- ams_nrel_bits);
-
- bitmap = addDaughter(dialog_->button_ams_ops, _("AMS Operators"),
- latex_ams_ops, nr_latex_ams_ops);
- bitmap->addBitmap(23, 3, 8, ams_ops_width, ams_ops_height,
- ams_ops_bits);
-
- bc().setCancel(dialog_->button_close);
}
-void FormMathsPanel::showDaughter(FL_OBJECT * button)
+ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
{
- Store::iterator it = daughters_.find(button);
- FormMathsSub * const new_active =
- (it == daughters_.end()) ? 0 : it->second.get();
-
- if (active_ != new_active) {
- if (active_ && active_->isVisible())
- active_->hide();
- active_ = new_active;
- }
-
- if (active_ && !active_->isVisible())
- active_->show();
-}
-
-
-bool FormMathsPanel::input(FL_OBJECT * ob, long)
-{
- if (ob == dialog_->button_arrow ||
- ob == dialog_->button_boperator ||
- ob == dialog_->button_brelats ||
- ob == dialog_->button_greek ||
- ob == dialog_->button_misc ||
- ob == dialog_->button_dots ||
- ob == dialog_->button_varsize ||
- ob == dialog_->button_ams_misc ||
- ob == dialog_->button_ams_arrows ||
- ob == dialog_->button_ams_brel ||
- ob == dialog_->button_ams_nrel ||
- ob == dialog_->button_ams_ops ||
- ob == dialog_->button_delim ||
- ob == dialog_->button_matrix ||
- ob == dialog_->button_deco ||
- ob == dialog_->button_space ||
- ob == dialog_->button_style) {
- showDaughter(ob);
+ if (ob == dialog_->button_arrow) {
+ controller().showDialog("matharrows");
+ } else if (ob == dialog_->button_deco) {
+ controller().showDialog("mathaccents");
+ } else if (ob == dialog_->button_boperator) {
+ controller().showDialog("mathoperators");
+ } else if (ob == dialog_->button_brelats) {
+ controller().showDialog("mathrelations");
+ } else if (ob == dialog_->button_greek) {
+ controller().showDialog("mathgreek");
+ } else if (ob == dialog_->button_misc) {
+ controller().showDialog("mathmisc");
+ } else if (ob == dialog_->button_dots) {
+ controller().showDialog("mathdots");
+ } else if (ob == dialog_->button_varsize) {
+ controller().showDialog("mathbigoperators");
+ } else if (ob == dialog_->button_ams_misc) {
+ controller().showDialog("mathamsmisc");
+ } else if (ob == dialog_->button_ams_arrows) {
+ controller().showDialog("mathamsarrows");
+ } else if (ob == dialog_->button_ams_brel) {
+ controller().showDialog("mathamsrelations");
+ } else if (ob == dialog_->button_ams_nrel) {
+ controller().showDialog("mathamsnegatedrelations");
+ } else if (ob == dialog_->button_ams_ops) {
+ controller().showDialog("mathamsoperators");
+ } else if (ob == dialog_->button_delim) {
+ controller().showDialog("mathdelimiter");
+ } else if (ob == dialog_->button_matrix) {
+ controller().showDialog("mathmatrix");
+ } else if (ob == dialog_->button_space) {
+ controller().showDialog("mathspace");
+ } else if (ob == dialog_->button_style) {
+ controller().showDialog("mathstyle");
} else if (ob == dialog_->button_super) {
- dispatchFunc(LFUN_SUPERSCRIPT);
+ controller().dispatchSuperscript();
} else if (ob == dialog_->button_sub) {
- dispatchFunc(LFUN_SUBSCRIPT);
-
-// } else if (ob == dialog_->???) {
-// dispatchFunc(LFUN_SUBSCRIPT);
-// dispatchFunc(LFUN_LEFT);
-// dispatchFunc(LFUN_SUPERSCRIPT);
+ controller().dispatchSubscript();
} else if (ob == dialog_->button_equation) {
- dispatchFunc(LFUN_MATH_DISPLAY);
+ controller().dispatchToggleDisplay();
} else if (ob == dialog_->button_frac) {
- insertSymbol("frac");
+ controller().dispatchInsert("frac");
} else if (ob == dialog_->button_sqrt) {
- insertSymbol("sqrt");
+ controller().dispatchInsert("sqrt");
} else if (ob == dialog_->browser_funcs) {
int const i = fl_get_browser(dialog_->browser_funcs) - 1;
- insertSymbol(function_names[i]);
+ controller().dispatchInsert(function_names[i]);
}
- return true;
-}
-
-
-void FormMathsPanel::insertSymbol(string const & sym, bool bs) const
-{
- if (bs)
- lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + sym));
- else
- lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, sym));
-}
-
-
-void FormMathsPanel::dispatchFunc(kb_action action, string const & arg) const
-{
- lv_.dispatch(FuncRequest(action, arg));
-}
-
-
-FormMathsSub::FormMathsSub(LyXView & lv, Dialogs & d, FormMathsPanel const & p,
- string const & t, bool allowResize)
- : FormBaseBD(lv, d, t, allowResize), parent_(p), bc_(_("Close"))
-{}
-
-
-bool FormMathsSub::isVisible() const
-{
- return form() ? form()->visible : false;
+ return ButtonPolicy::SMI_VALID;
}