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 #include "ControlMath.h"
14 #include "GMathPanel.h"
17 #include "support/lstrings.h"
19 #include <libglademm.h>
23 #include "equation.xpm"
32 #include "gimages/ams_arrow.xpm"
33 #include "gimages/ams_misc.xpm"
34 #include "gimages/ams_brel.xpm"
35 #include "gimages/ams_nrel.xpm"
36 #include "gimages/ams_ops.xpm"
37 #include "gimages/arrow.xpm"
38 #include "gimages/boperator.xpm"
39 #include "gimages/brelats.xpm"
40 #include "gimages/dots.xpm"
41 #include "gimages/greek.xpm"
42 #include "gimages/misc.xpm"
43 #include "gimages/varsize.xpm"
52 char const * infoUp[][5] =
55 {0, 0, "mathdelimiter", "mathaccents", "mathspace"},
57 {0, 0, "mathstyle", "mathmatrix", 0}
61 GXpmBtnTbl::XpmData xpmUp[] =
64 sqrt_xpm, frac, delim, deco, space_xpm,
66 super_xpm, sub_xpm, style_xpm, matrix, equation
70 char const * infoDown[][3] =
73 {"mathoperators", "mathrelations", "matharrows"},
75 {"mathbigoperators", "mathdots", "mathmisc"},
77 {"mathgreek", "mathamsarrows", "mathamsrelations"},
79 {"mathamsnegatedrelations", "mathamsoperators", "mathamsmisc"}
83 GXpmBtnTbl::XpmData xpmDown[] =
86 boperator_xpm, brelats_xpm, arrow_xpm,
88 varsize_xpm, dots_xpm, misc_xpm,
90 greek_xpm, ams_arrow_xpm, ams_brel_xpm,
92 ams_nrel_xpm, ams_ops_xpm, ams_misc_xpm
98 GMathPanel::GMathPanel(Dialog & parent)
99 : GViewCB<ControlMath, GViewGladeB>(parent, _("Math Panel")),
100 tableUp_(2, 5, xpmUp), tableDown_(4, 3, xpmDown)
105 void GMathPanel::doBuild()
107 string const gladeName = findGladeFile("mathPanel");
108 xml_ = Gnome::Glade::Xml::create(gladeName);
112 xml_->get_widget("Close", close);
115 tableUp_.signalClicked().connect(
116 sigc::mem_fun(*this, &GMathPanel::onTableUpClicked));
118 tableDown_.signalClicked().connect(
119 sigc::mem_fun(*this, &GMathPanel::onTableDownClicked));
122 xml_->get_widget("Vbox", vbox);
123 vbox->pack_start(tableUp_, false, false, 0);
124 vbox->pack_start(tableDown_, false, false, 0);
126 // Functions ListView
127 xml_->get_widget("Functions", functions_);
128 listCols_.add(listCol_);
129 listStore_ = Gtk::ListStore::create(listCols_);
130 functions_->set_model(listStore_);
131 functions_->append_column("Functions", listCol_);
133 listSel_ = functions_->get_selection();
134 listSel_->signal_changed().connect(
135 sigc::mem_fun(*this, &GMathPanel::onFunctionSelected));
136 for (int i = 0; i < nr_function_names; ++i)
137 (*listStore_->append())[listCol_] =
138 Glib::locale_to_utf8(function_names[i]);
142 void GMathPanel::onTableUpClicked(int row, int col)
144 if (infoUp[row][col])
145 controller().showDialog(infoUp[row][col]);
146 else if (row == 0 && col == 0)
147 controller().dispatchInsert("sqrt");
148 else if (row == 0 && col == 1)
149 controller().dispatchInsert("frac");
150 else if (row == 1 && col == 0)
151 controller().dispatchSuperscript();
152 else if (row == 1 && col == 1)
153 controller().dispatchSubscript();
154 else if (row == 1 && col == 4)
155 controller().dispatchToggleDisplay();
159 void GMathPanel::onTableDownClicked(int row, int col)
161 controller().showDialog(infoDown[row][col]);
165 void GMathPanel::onFunctionSelected()
167 Gtk::TreeModel::iterator it = listSel_->get_selected();
168 Glib::ustring sel = (*it)[listCol_];
169 controller().dispatchInsert(
170 Glib::locale_from_utf8(sel));
173 } // namespace frontend