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.
14 #include <libglademm.h>
16 #include "ControlMath.h"
17 #include "GMathPanel.h"
18 #include "support/filetools.h"
19 #include "support/lstrings.h"
23 #include "equation.xpm"
34 GMathPanel::GMathPanel(Dialog & parent)
35 : GViewCB<ControlMath, GViewGladeB>(parent, _("Math Panel"))
40 void GMathPanel::doBuild()
42 string const gladeName =
43 lyx::support::LibFileSearch("glade", "mathPanel", "glade");
44 xml_ = Gnome::Glade::Xml::create(gladeName);
59 Gtk::Button * equation;
62 Gtk::Button * boperator;
63 Gtk::Button * brelats;
67 Gtk::Button * varSize;
73 Gtk::Button * amsArrows;
74 Gtk::Button * amsBrel;
77 Gtk::Button * amsNrel;
79 Gtk::Button * amsMisc;
81 xml_->get_widget("Close", close);
82 close->signal_clicked().connect(
83 SigC::slot(*this, &GViewBase::onCancel));
86 xml_->get_widget("Sqrt", sqrt);
87 xml_->get_widget("Frac", frac);
88 xml_->get_widget("Delim", delim);
89 xml_->get_widget("Deco", deco);
90 xml_->get_widget("Space", space);
93 xml_->get_widget("Super", super);
94 xml_->get_widget("Sub", sub);
95 xml_->get_widget("Style", style);
96 xml_->get_widget("Matrix", matrix);
97 xml_->get_widget("Equation", equation);
100 xml_->get_widget("Boperator", boperator);
101 xml_->get_widget("Brelate", brelats);
102 xml_->get_widget("Arrow", arrow);
105 xml_->get_widget("VarSize", varSize);
106 xml_->get_widget("Dots", dots);
107 xml_->get_widget("Misc", misc);
110 xml_->get_widget("Greek", greek);
111 xml_->get_widget("AmsArrow", amsArrows);
112 xml_->get_widget("AmsBrel", amsBrel);
115 xml_->get_widget("AmsNrel", amsNrel);
116 xml_->get_widget("AmsOps", amsOps);
117 xml_->get_widget("AmsMisc", amsMisc);
119 Glib::RefPtr<Gdk::Bitmap> mask;
120 Glib::RefPtr<Gdk::Pixmap> pixmap;
121 Glib::RefPtr<Gdk::Colormap> clrmap = window()->get_colormap();
123 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::sqrt_xpm);
124 Gtk::Image * iSqrt = SigC::manage(new Gtk::Image(pixmap, mask));
128 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::frac);
129 Gtk::Image * iFrac = SigC::manage(new Gtk::Image(pixmap, mask));
133 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::delim);
134 Gtk::Image * iDelim = SigC::manage(new Gtk::Image(pixmap, mask));
138 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::deco);
139 Gtk::Image * iDeco = SigC::manage(new Gtk::Image(pixmap, mask));
143 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::space_xpm);
144 Gtk::Image * iSpace = SigC::manage(new Gtk::Image(pixmap, mask));
148 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::super_xpm);
149 Gtk::Image * iSuper = SigC::manage(new Gtk::Image(pixmap, mask));
153 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::sub_xpm);
154 Gtk::Image * iSub = SigC::manage(new Gtk::Image(pixmap, mask));
158 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::style_xpm);
159 Gtk::Image * iStyle = SigC::manage(new Gtk::Image(pixmap, mask));
163 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::matrix);
164 Gtk::Image * iMatrix = SigC::manage(new Gtk::Image(pixmap, mask));
166 matrix->add(*iMatrix);
168 pixmap = Gdk::Pixmap::create_from_xpm(clrmap, mask, ::equation);
169 Gtk::Image * iEquation = SigC::manage(new Gtk::Image(pixmap, mask));
171 equation->add(*iEquation);
173 arrow->signal_clicked().connect(
174 SigC::bind<char const *>(
176 &GMathPanel::onShowDialog),
178 deco->signal_clicked().connect(
179 SigC::bind<char const *>(
181 &GMathPanel::onShowDialog),
183 boperator->signal_clicked().connect(
184 SigC::bind<char const *>(
186 &GMathPanel::onShowDialog),
188 brelats->signal_clicked().connect(
189 SigC::bind<char const *>(
191 &GMathPanel::onShowDialog),
193 greek->signal_clicked().connect(
194 SigC::bind<char const *>(
196 &GMathPanel::onShowDialog),
198 misc->signal_clicked().connect(
199 SigC::bind<char const *>(
201 &GMathPanel::onShowDialog),
203 dots->signal_clicked().connect(
204 SigC::bind<char const *>(
206 &GMathPanel::onShowDialog),
208 varSize->signal_clicked().connect(
209 SigC::bind<char const *>(
211 &GMathPanel::onShowDialog),
212 "mathbigoperators"));
213 amsMisc->signal_clicked().connect(
214 SigC::bind<char const *>(
216 &GMathPanel::onShowDialog),
218 amsArrows->signal_clicked().connect(
219 SigC::bind<char const *>(
221 &GMathPanel::onShowDialog),
223 amsBrel->signal_clicked().connect(
224 SigC::bind<char const *>(
226 &GMathPanel::onShowDialog),
227 "mathamsrelations"));
228 amsNrel->signal_clicked().connect(
229 SigC::bind<char const *>(
231 &GMathPanel::onShowDialog),
232 "mathamsnegatedrelations"));
233 amsOps->signal_clicked().connect(
234 SigC::bind<char const *>(
236 &GMathPanel::onShowDialog),
237 "mathamsoperators"));
238 delim->signal_clicked().connect(
239 SigC::bind<char const *>(
241 &GMathPanel::onShowDialog),
243 matrix->signal_clicked().connect(
244 SigC::bind<char const *>(
246 &GMathPanel::onShowDialog),
248 space->signal_clicked().connect(
249 SigC::bind<char const *>(
251 &GMathPanel::onShowDialog),
253 style->signal_clicked().connect(
254 SigC::bind<char const *>(
256 &GMathPanel::onShowDialog),
259 super->signal_clicked().connect(
260 SigC::slot(*this, &GMathPanel::onSuperClicked));
261 sub->signal_clicked().connect(
262 SigC::slot(*this, &GMathPanel::onSubClicked));
263 equation->signal_clicked().connect(
264 SigC::slot(*this, &GMathPanel::onEquationClicked));
266 frac->signal_clicked().connect(
267 SigC::bind<char const *>(
269 &GMathPanel::onInsert),
271 sqrt->signal_clicked().connect(
272 SigC::bind<char const *>(
274 &GMathPanel::onInsert),
277 // Functions ListView
278 xml_->get_widget("Functions", functions_);
279 listCols_.add(listCol_);
280 listStore_ = Gtk::ListStore::create(listCols_);
281 functions_->set_model(listStore_);
282 functions_->append_column("Functions", listCol_);
283 listSel_ = functions_->get_selection();
284 listSel_->signal_changed().connect(
285 SigC::slot(*this, &GMathPanel::onFunctionSelected));
286 for (int i = 0; i < nr_function_names; ++i)
287 (*listStore_->append())[listCol_] =
288 Glib::locale_to_utf8(function_names[i]);
292 void GMathPanel::onFunctionSelected()
294 Gtk::TreeModel::iterator it = listSel_->get_selected();
295 Glib::ustring sel = (*it)[listCol_];
296 controller().dispatchInsert(
297 Glib::locale_from_utf8(sel));
301 void GMathPanel::onShowDialog(char const * dialogName)
303 controller().showDialog(dialogName);
307 void GMathPanel::onSuperClicked()
309 controller().dispatchSuperscript();
313 void GMathPanel::onSubClicked()
315 controller().dispatchSubscript();
319 void GMathPanel::onEquationClicked()
321 controller().dispatchToggleDisplay();
325 void GMathPanel::onInsert(char const * what)
327 controller().dispatchInsert(what);