3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
18 #include "ControlMath.h"
19 #include "GMathPanel.h"
22 #include "support/lstrings.h"
24 #include <libglademm.h>
28 #include "equation.xpm"
37 #include "gimages/ams_arrow.xpm"
38 #include "gimages/ams_misc.xpm"
39 #include "gimages/ams_brel.xpm"
40 #include "gimages/ams_nrel.xpm"
41 #include "gimages/ams_ops.xpm"
42 #include "gimages/arrow.xpm"
43 #include "gimages/boperator.xpm"
44 #include "gimages/brelats.xpm"
45 #include "gimages/dots.xpm"
46 #include "gimages/greek.xpm"
47 #include "gimages/misc.xpm"
48 #include "gimages/varsize.xpm"
57 char const * infoUp[][5] =
60 {0, 0, "mathdelimiter", "mathaccents", "mathspace"},
62 {0, 0, "mathstyle", "mathmatrix", 0}
66 GXpmBtnTbl::XpmData xpmUp[] =
69 sqrt_xpm, frac, delim, deco, space_xpm,
71 super_xpm, sub_xpm, style_xpm, matrix, equation
75 char const * infoDown[][3] =
78 {"mathoperators", "mathrelations", "matharrows"},
80 {"mathbigoperators", "mathdots", "mathmisc"},
82 {"mathgreek", "mathamsarrows", "mathamsrelations"},
84 {"mathamsnegatedrelations", "mathamsoperators", "mathamsmisc"}
88 GXpmBtnTbl::XpmData xpmDown[] =
91 boperator_xpm, brelats_xpm, arrow_xpm,
93 varsize_xpm, dots_xpm, misc_xpm,
95 greek_xpm, ams_arrow_xpm, ams_brel_xpm,
97 ams_nrel_xpm, ams_ops_xpm, ams_misc_xpm
103 GMathPanel::GMathPanel(Dialog & parent)
104 : GViewCB<ControlMath, GViewGladeB>(parent, _("Math Panel")),
105 tableUp_(2, 5, xpmUp), tableDown_(4, 3, xpmDown)
110 void GMathPanel::doBuild()
112 string const gladeName = findGladeFile("mathPanel");
113 xml_ = Gnome::Glade::Xml::create(gladeName);
117 xml_->get_widget("Close", close);
120 tableUp_.signalClicked().connect(
121 sigc::mem_fun(*this, &GMathPanel::onTableUpClicked));
123 tableDown_.signalClicked().connect(
124 sigc::mem_fun(*this, &GMathPanel::onTableDownClicked));
127 xml_->get_widget("Vbox", vbox);
128 vbox->pack_start(tableUp_, false, false, 0);
129 vbox->pack_start(tableDown_, false, false, 0);
131 // Functions ListView
132 xml_->get_widget("Functions", functions_);
133 listCols_.add(listCol_);
134 listStore_ = Gtk::ListStore::create(listCols_);
135 functions_->set_model(listStore_);
136 functions_->append_column("Functions", listCol_);
138 listSel_ = functions_->get_selection();
139 listSel_->signal_changed().connect(
140 sigc::mem_fun(*this, &GMathPanel::onFunctionSelected));
141 for (int i = 0; i < nr_function_names; ++i)
142 (*listStore_->append())[listCol_] =
143 Glib::locale_to_utf8(function_names[i]);
147 void GMathPanel::onTableUpClicked(int row, int col)
149 if (infoUp[row][col])
150 controller().showDialog(infoUp[row][col]);
151 else if (row == 0 && col == 0)
152 controller().dispatchInsert("sqrt");
153 else if (row == 0 && col == 1)
154 controller().dispatchInsert("frac");
155 else if (row == 1 && col == 0)
156 controller().dispatchSuperscript();
157 else if (row == 1 && col == 1)
158 controller().dispatchSubscript();
159 else if (row == 1 && col == 4)
160 controller().dispatchToggleDisplay();
164 void GMathPanel::onTableDownClicked(int row, int col)
166 controller().showDialog(infoDown[row][col]);
170 void GMathPanel::onFunctionSelected()
172 Gtk::TreeModel::iterator it = listSel_->get_selected();
173 Glib::ustring sel = (*it)[listCol_];
174 controller().dispatchInsert(
175 Glib::locale_from_utf8(sel));
178 } // namespace frontend