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