3 * \file FormMathsDelim.C
4 * Copyright 2001 The LyX Team.
5 * See the file COPYING.
7 * \author Alejandro Aguilar Sierra
8 * \author Pablo De Napoli, pdenapo@dm.uba.ar
9 * \author John Levon, moz@compsoc.man.ac.uk
10 * \author Angus Leeming, a.leeming@ic.ac.uk
16 #pragma implementation
19 #include "FormMathsDelim.h"
20 #include "form_maths_delim.h"
25 #include "mathed/symbol_def.h"
31 static int const delim_rversion[] = {
32 1,1,3,3,4,5,7,7,9,9,10,11,
33 13,13,14,15,16,17,19,19,20,21,22,23 };
35 static int delim_values[] = {
36 '(', ')', LM_lceil, LM_rceil, LM_uparrow, LM_Uparrow,
37 '[', ']', LM_lfloor, LM_rfloor, LM_updownarrow, LM_Updownarrow,
38 '{', '}', '/', LM_backslash, LM_downarrow, LM_Downarrow,
39 LM_langle, LM_rangle, '|', LM_Vert, '.', 0
44 FormMathsDelim::FormMathsDelim(LyXView * lv, Dialogs * d,
45 FormMathsPanel const & p)
46 : FormMathsSub(lv, d, p, _("Maths Delimiters"))
50 FL_FORM * FormMathsDelim::form() const
58 void FormMathsDelim::build()
60 dialog_.reset(build_maths_delim());
62 fl_set_button(dialog_->radio_left, 1);
63 fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim0));
64 dialog_->radio_left->u_ldata = 0;
65 dialog_->radio_right->u_ldata = 1;
67 fl_set_bmtable_data(dialog_->bmtable, 6, 4,
68 delim_width, delim_height, delim_bits);
69 fl_set_bmtable_maxitems(dialog_->bmtable, 23);
71 bc().setOK(dialog_->button_ok);
72 bc().setApply(dialog_->button_apply);
73 bc().setCancel(dialog_->button_cancel);
75 bc().addReadOnly(dialog_->bmtable);
76 bc().addReadOnly(dialog_->radio_right);
77 bc().addReadOnly(dialog_->radio_left);
78 bc().addReadOnly(dialog_->button_pix);
82 void FormMathsDelim::apply()
84 int const left = int(dialog_->radio_left->u_ldata);
85 int const right= int(dialog_->radio_right->u_ldata);
87 std::ostringstream ost;
88 ost << delim_values[left] << ' ' << delim_values[right];
90 lv_->getLyXFunc()->Dispatch(LFUN_MATH_DELIM, ost.str().c_str());
93 bool FormMathsDelim::input(FL_OBJECT *, long)
95 int left = int(dialog_->radio_left->u_ldata);
96 int right= int(dialog_->radio_right->u_ldata);
97 int const side = (fl_get_button(dialog_->radio_right) != 0);
99 int const i = fl_get_bmtable(dialog_->bmtable);
100 int const button = fl_get_bmtable_numb(dialog_->bmtable);
101 bool const both = (button == FL_MIDDLE_MOUSE);
104 if (side || (button == FL_RIGHT_MOUSE))
109 right = delim_rversion[i];
115 p1 = fl_get_pixmap_pixmap(dialog_->button_pix, &p1, &p2);
116 fl_draw_bmtable_item(dialog_->bmtable, left, p1, 0, 0);
117 fl_draw_bmtable_item(dialog_->bmtable, right, p1, 16, 0);
118 fl_redraw_object(dialog_->button_pix);
120 dialog_->radio_left->u_ldata = left;
121 dialog_->radio_right->u_ldata = right;