]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsStyle.C
fix tooltips in toolbar
[lyx.git] / src / frontends / xforms / FormMathsStyle.C
1 /**
2  * \file FormMathsStyle.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  * Adapted from FormMathsSpace martin.vermeer@hut.fi
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "FormMathsStyle.h"
20 #include "forms/form_maths_style.h"
21 #include "bmtable.h"
22
23 #include "debug.h"
24
25 #include FORMS_H_LOCATION
26
27 #include "style.xbm"
28 #include "font.xbm"
29
30 char const * latex_mathstyle[] = {
31         "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
32 };
33
34 kb_action latex_mathfontcmds[] = {
35         LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
36         LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT
37 };
38
39
40
41 FormMathsStyle::FormMathsStyle(LyXView * lv, Dialogs * d,
42                                FormMathsPanel const & p)
43         : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
44           style_(-1)
45 {}
46
47
48 FL_FORM * FormMathsStyle::form() const
49 {
50         if (dialog_.get())
51                 return dialog_->form;
52         return 0;
53 }
54
55
56 void FormMathsStyle::build()
57 {
58         dialog_.reset(build_maths_style(this));
59
60         fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
61                             style1_width, style1_height, style1_bits);
62         fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
63         bc().addReadOnly(dialog_->bmtable_style1);
64
65         fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
66                             style2_width, style2_height, style2_bits);
67         fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
68         bc().addReadOnly(dialog_->bmtable_style2);
69
70         fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
71                             font1_width, font1_height, font1_bits);
72         fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
73         bc().addReadOnly(dialog_->bmtable_font1);
74
75         fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
76                             font2_width, font2_height, font2_bits);
77         fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
78         bc().addReadOnly(dialog_->bmtable_font2);
79
80         bc().setCancel(dialog_->button_close);
81 }
82
83
84 void FormMathsStyle::apply()
85 {
86         if ((style_ >= 0) && (style_ < 4))
87                 parent_.insertSymbol(latex_mathstyle[style_]);
88         else if ((style_ >= 4) && (style_ < 14))
89                 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
90 }
91
92
93 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
94 {
95         style_ = fl_get_bmtable(ob);
96         if (style_ < 0) return false;
97         //if (ob == dialog_->bmtable_style1) style_ += 0;
98         if (ob == dialog_->bmtable_style2) style_ += 1;
99         if (ob == dialog_->bmtable_font1)  style_ += 4;
100         if (ob == dialog_->bmtable_font2)  style_ += 9;
101         if (data >= 12) style_ = short(data);
102         apply();
103         return true;
104 }