]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsSpace.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / FormMathsSpace.C
1 /**
2  * \file FormMathsSpace.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 "FormMathsSpace.h"
21 #include "forms/form_maths_space.h"
22 #include "ControlMath.h"
23 #include "xformsBC.h"
24
25 #include FORMS_H_LOCATION
26
27 extern char * latex_mathspace[];
28
29 typedef FormCB<ControlMathSub, FormDB<FD_maths_space> > base_class;
30
31 FormMathsSpace::FormMathsSpace()
32         : base_class(_("Maths Spacing"), false),
33           space_(-1)
34 {}
35
36
37 void FormMathsSpace::build()
38 {
39         dialog_.reset(build_maths_space(this));
40
41         space_ = -1;
42
43         bc().setCancel(dialog_->button_close);
44
45         bc().addReadOnly(dialog_->button_negative);
46         bc().addReadOnly(dialog_->button_negmedspace);
47         bc().addReadOnly(dialog_->button_negthickspace);
48         bc().addReadOnly(dialog_->button_thin);
49         bc().addReadOnly(dialog_->button_medium);
50         bc().addReadOnly(dialog_->button_thick);
51         bc().addReadOnly(dialog_->button_quadratin);
52         bc().addReadOnly(dialog_->button_twoquadratin);
53 }
54
55
56 void FormMathsSpace::apply()
57 {
58         if (space_ >= 0)
59                 controller().insertSymbol(latex_mathspace[space_]);
60 }
61
62 ButtonPolicy::SMInput FormMathsSpace::input(FL_OBJECT *, long data)
63 {
64         space_ = -1;
65
66         if (data >= 0 && data < 8) {
67                 space_ = short(data);
68                 apply();
69         }
70         return ButtonPolicy::SMI_VALID;
71 }