]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsDeco.C
Added // -*- C++ -*- to the top of all files in controllers/ and xforms/
[lyx.git] / src / frontends / xforms / FormMathsDeco.C
1 // -*- C++ -*-
2 /**
3  * \file FormMathsDeco.C
4  * Copyright 2001 The LyX Team.
5  * See the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author Pablo De Napoli, pdenapo@dm.uba.ar
9  * \author John Levon, moz@compsoc.man.ac.uk
10  * \author Angus Leeming, a.leeming@ic.ac.uk
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG_
16 #pragma implementation
17 #endif
18
19 #include "FormMathsDeco.h"
20 #include "form_maths_deco.h"
21 #include "Dialogs.h"
22 #include "bmtable.h"
23
24 #include "deco.xbm"
25
26
27 static char const * decoration_names[] = {
28         "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow", 
29         "overline", "underbrace", "underline"
30 };
31
32
33 static int const nr_decoration_names = sizeof(decoration_names) / sizeof(char const *);
34  
35 FormMathsDeco::FormMathsDeco(LyXView * lv, Dialogs * d,
36                              FormMathsPanel const & p)
37         : FormMathsSub(lv, d, p, _("Maths Decorations"))
38 {}
39
40
41 FL_FORM * FormMathsDeco::form() const
42 {
43         if (dialog_.get())
44                 return dialog_->form;
45         return 0;
46 }
47
48
49 void FormMathsDeco::build()
50 {
51         dialog_.reset(build_maths_deco());
52
53         fl_set_bmtable_data(dialog_->bmtable, 3, 3,
54                             deco_width, deco_height, deco_bits);
55         fl_set_bmtable_maxitems(dialog_->bmtable, 8);
56
57         bc().setCancel(dialog_->button_cancel);
58         bc().addReadOnly(dialog_->bmtable);
59 }
60
61
62 void FormMathsDeco::apply()
63 {
64         int const i = fl_get_bmtable(dialog_->bmtable);
65  
66         if (i >= nr_decoration_names)
67                 return;
68  
69         parent_.insertSymbol(decoration_names[i]);
70 }