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