]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsDeco.C
fix tooltips in toolbar
[lyx.git] / src / frontends / xforms / FormMathsDeco.C
1 /**
2  * \file FormMathsDeco.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Pablo De Napoli, pdenapo@dm.uba.ar
8  * \author John Levon, moz@compsoc.man.ac.uk
9  * \author Angus Leeming, a.leeming@ic.ac.uk
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "FormMathsDeco.h"
19 #include "forms/form_maths_deco.h"
20 #include "Dialogs.h"
21 #include "bmtable.h"
22 #include FORMS_H_LOCATION
23
24 #include "deco.xbm"
25
26
27 static char const * decoration_names[] = {
28         "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow",
29         "overline", "underbrace", "underline", "underleftarrow", "underrightarrow",
30         "underleftrightarrow", "overleftrightarrow",
31         "hat", "acute", "bar", "dot",
32         "check", "grave", "vec", "ddot",
33         "breve", "tilde"
34 };
35
36
37 static int const nr_decoration_names = sizeof(decoration_names) / sizeof(char const *);
38
39 FormMathsDeco::FormMathsDeco(LyXView * lv, Dialogs * d,
40                              FormMathsPanel const & p)
41         : FormMathsSub(lv, d, p, _("Maths Decorations & Accents"), false)
42 {}
43
44
45 FL_FORM * FormMathsDeco::form() const
46 {
47         if (dialog_.get())
48                 return dialog_->form;
49         return 0;
50 }
51
52
53 void FormMathsDeco::build()
54 {
55         dialog_.reset(build_maths_deco(this));
56
57         fl_set_bmtable_data(dialog_->bmtable_deco1, 3, 4,
58                             deco1_width, deco1_height, deco1_bits);
59         fl_set_bmtable_maxitems(dialog_->bmtable_deco1, 12);
60
61         fl_set_bmtable_data(dialog_->bmtable_deco2, 4, 3,
62                             deco2_width, deco2_height, deco2_bits);
63         fl_set_bmtable_maxitems(dialog_->bmtable_deco2, 10);
64
65         bc().setCancel(dialog_->button_close);
66         bc().addReadOnly(dialog_->bmtable_deco1);
67         bc().addReadOnly(dialog_->bmtable_deco2);
68 }
69
70
71 void FormMathsDeco::apply()
72 {
73         if (deco_ < nr_decoration_names)
74                 parent_.insertSymbol(decoration_names[deco_]);
75 }
76
77
78 bool FormMathsDeco::input(FL_OBJECT * ob, long)
79 {
80         deco_ = fl_get_bmtable(ob);
81         if (deco_ < 0)
82                 return false;
83         //if (ob == dialog_->bmtable_deco1)
84         //      deco_ += 0;
85         if (ob == dialog_->bmtable_deco2)
86                 deco_ += 12;
87         apply();
88         return true;
89 }