]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsDeco.C
This file is part of LyX, the document processor.
[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 "FormMathsDeco.h"
21 #include "forms/form_maths_deco.h"
22 #include "bmtable.h"
23 #include FORMS_H_LOCATION
24
25 #include "deco.xbm"
26
27
28 static char const * decoration_names[] = {
29         "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow",
30         "overline", "underbrace", "underline", "underleftarrow", "underrightarrow",
31         "underleftrightarrow", "overleftrightarrow",
32         "hat", "acute", "bar", "dot",
33         "check", "grave", "vec", "ddot",
34         "breve", "tilde"
35 };
36
37
38 static int const nr_decoration_names = sizeof(decoration_names) / sizeof(char const *);
39
40 FormMathsDeco::FormMathsDeco(LyXView & lv, Dialogs & d,
41                              FormMathsPanel const & p)
42         : FormMathsSub(lv, d, p, _("Maths Decorations & Accents"), false)
43 {}
44
45
46 FL_FORM * FormMathsDeco::form() const
47 {
48         if (dialog_.get())
49                 return dialog_->form;
50         return 0;
51 }
52
53
54 void FormMathsDeco::build()
55 {
56         dialog_.reset(build_maths_deco(this));
57
58         fl_set_bmtable_data(dialog_->bmtable_deco1, 3, 4,
59                             deco1_width, deco1_height, deco1_bits);
60         fl_set_bmtable_maxitems(dialog_->bmtable_deco1, 12);
61
62         fl_set_bmtable_data(dialog_->bmtable_deco2, 4, 3,
63                             deco2_width, deco2_height, deco2_bits);
64         fl_set_bmtable_maxitems(dialog_->bmtable_deco2, 10);
65
66         bc().setCancel(dialog_->button_close);
67         bc().addReadOnly(dialog_->bmtable_deco1);
68         bc().addReadOnly(dialog_->bmtable_deco2);
69 }
70
71
72 void FormMathsDeco::apply()
73 {
74         if (deco_ < nr_decoration_names)
75                 parent_.insertSymbol(decoration_names[deco_]);
76 }
77
78
79 bool FormMathsDeco::input(FL_OBJECT * ob, long)
80 {
81         deco_ = fl_get_bmtable(ob);
82         if (deco_ < 0)
83                 return false;
84         //if (ob == dialog_->bmtable_deco1)
85         //      deco_ += 0;
86         if (ob == dialog_->bmtable_deco2)
87                 deco_ += 12;
88         apply();
89         return true;
90 }