]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsDeco.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / FormMathsDeco.C
1 /**
2  * \file FormMathsDeco.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Pablo De Napoli
8  * \author John Levon
9  * \author Angus Leeming 
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlMath.h"
21 #include "FormMathsDeco.h"
22 #include "forms/form_maths_deco.h"
23 #include "xformsBC.h"
24
25 #include "bmtable.h"
26 #include FORMS_H_LOCATION
27
28 #include "deco.xbm"
29
30
31 typedef FormCB<ControlMathSub, FormDB<FD_maths_deco> > base_class;
32
33 FormMathsDeco::FormMathsDeco()
34         : base_class(_("Maths Decorations & Accents"), false)
35 {}
36
37
38 void FormMathsDeco::build()
39 {
40         dialog_.reset(build_maths_deco(this));
41
42         fl_set_bmtable_data(dialog_->bmtable_deco1, 3, 4,
43                             deco1_width, deco1_height, deco1_bits);
44         fl_set_bmtable_maxitems(dialog_->bmtable_deco1, 12);
45
46         fl_set_bmtable_data(dialog_->bmtable_deco2, 4, 3,
47                             deco2_width, deco2_height, deco2_bits);
48         fl_set_bmtable_maxitems(dialog_->bmtable_deco2, 10);
49
50         bc().setCancel(dialog_->button_close);
51         bc().addReadOnly(dialog_->bmtable_deco1);
52         bc().addReadOnly(dialog_->bmtable_deco2);
53 }
54
55
56 void FormMathsDeco::apply()
57 {
58         if (deco_ < nr_latex_deco)
59                 controller().insertSymbol(latex_deco[deco_]);
60 }
61
62
63 ButtonPolicy::SMInput FormMathsDeco::input(FL_OBJECT * ob, long)
64 {
65         deco_ = fl_get_bmtable(ob);
66         if (deco_ < 0)
67                 return ButtonPolicy::SMI_INVALID;
68         //if (ob == dialog_->bmtable_deco1)
69         //      deco_ += 0;
70         if (ob == dialog_->bmtable_deco2)
71                 deco_ += 12;
72         apply();
73         return ButtonPolicy::SMI_VALID;
74 }