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 _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
21 #include "ControlMath.h"
22 #include "GMathPanel.h"
25 #include "support/lstrings.h"
27 #include <libglademm.h>
31 #include "equation.xpm"
40 #include "gimages/ams_arrow.xpm"
41 #include "gimages/ams_misc.xpm"
42 #include "gimages/ams_brel.xpm"
43 #include "gimages/ams_nrel.xpm"
44 #include "gimages/ams_ops.xpm"
45 #include "gimages/arrow.xpm"
46 #include "gimages/boperator.xpm"
47 #include "gimages/brelats.xpm"
48 #include "gimages/dots.xpm"
49 #include "gimages/greek.xpm"
50 #include "gimages/misc.xpm"
51 #include "gimages/varsize.xpm"
60 char const * infoUp[][5] =
63 {0, 0, "mathdelimiter", "mathaccents", "mathspace"},
65 {0, 0, "mathstyle", "mathmatrix", 0}
69 GXpmBtnTbl::XpmData xpmUp[] =
72 sqrt_xpm, frac, delim, deco, space_xpm,
74 super_xpm, sub_xpm, style_xpm, matrix, equation
78 char const * infoDown[][3] =
81 {"mathoperators", "mathrelations", "matharrows"},
83 {"mathbigoperators", "mathdots", "mathmisc"},
85 {"mathgreek", "mathamsarrows", "mathamsrelations"},
87 {"mathamsnegatedrelations", "mathamsoperators", "mathamsmisc"}
91 GXpmBtnTbl::XpmData xpmDown[] =
94 boperator_xpm, brelats_xpm, arrow_xpm,
96 varsize_xpm, dots_xpm, misc_xpm,
98 greek_xpm, ams_arrow_xpm, ams_brel_xpm,
100 ams_nrel_xpm, ams_ops_xpm, ams_misc_xpm
106 GMathPanel::GMathPanel(Dialog & parent)
107 : GViewCB<ControlMath, GViewGladeB>(parent, _("Math Panel")),
108 tableUp_(2, 5, xpmUp), tableDown_(4, 3, xpmDown)
113 void GMathPanel::doBuild()
115 string const gladeName = findGladeFile("mathPanel");
116 xml_ = Gnome::Glade::Xml::create(gladeName);
120 xml_->get_widget("Close", close);
123 tableUp_.signalClicked().connect(
124 sigc::mem_fun(*this, &GMathPanel::onTableUpClicked));
126 tableDown_.signalClicked().connect(
127 sigc::mem_fun(*this, &GMathPanel::onTableDownClicked));
130 xml_->get_widget("Vbox", vbox);
131 vbox->pack_start(tableUp_, false, false, 0);
132 vbox->pack_start(tableDown_, false, false, 0);
134 // Functions ListView
135 xml_->get_widget("Functions", functions_);
136 listCols_.add(listCol_);
137 listStore_ = Gtk::ListStore::create(listCols_);
138 functions_->set_model(listStore_);
139 functions_->append_column("Functions", listCol_);
141 listSel_ = functions_->get_selection();
142 listSel_->signal_changed().connect(
143 sigc::mem_fun(*this, &GMathPanel::onFunctionSelected));
144 for (int i = 0; i < nr_function_names; ++i)
145 (*listStore_->append())[listCol_] =
146 Glib::locale_to_utf8(function_names[i]);
150 void GMathPanel::onTableUpClicked(int row, int col)
152 if (infoUp[row][col])
153 controller().showDialog(infoUp[row][col]);
154 else if (row == 0 && col == 0)
155 controller().dispatchInsert("sqrt");
156 else if (row == 0 && col == 1)
157 controller().dispatchInsert("frac");
158 else if (row == 1 && col == 0)
159 controller().dispatchSuperscript();
160 else if (row == 1 && col == 1)
161 controller().dispatchSubscript();
162 else if (row == 1 && col == 4)
163 controller().dispatchToggleDisplay();
167 void GMathPanel::onTableDownClicked(int row, int col)
169 controller().showDialog(infoDown[row][col]);
173 void GMathPanel::onFunctionSelected()
175 Gtk::TreeModel::iterator it = listSel_->get_selected();
176 Glib::ustring sel = (*it)[listCol_];
177 controller().dispatchInsert(
178 Glib::locale_from_utf8(sel));
181 } // namespace frontend