]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsStyle.C
remove defaults stuff, let Qt handle no toolbar
[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
18 #include "FormMathsStyle.h"
19 #include "forms/form_maths_style.h"
20 #include "ControlMath.h"
21 #include "xformsBC.h"
22
23 #include "bmtable.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_FREEFONT_APPLY, LFUN_DEFAULT
37 };
38
39
40 typedef FormCB<ControlMathSub, FormDB<FD_maths_style> > base_class;
41
42 FormMathsStyle::FormMathsStyle()
43         : base_class(_("Maths Styles & Fonts"), false),
44           style_(-1)
45 {}
46
47
48 void FormMathsStyle::build()
49 {
50         dialog_.reset(build_maths_style(this));
51
52         fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
53                             style1_width, style1_height, style1_bits);
54         fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
55         bcview().addReadOnly(dialog_->bmtable_style1);
56
57         fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
58                             style2_width, style2_height, style2_bits);
59         fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
60         bcview().addReadOnly(dialog_->bmtable_style2);
61
62         fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
63                             font1_width, font1_height, font1_bits);
64         fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
65         bcview().addReadOnly(dialog_->bmtable_font1);
66
67         fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
68                             font2_width, font2_height, font2_bits);
69         fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
70         bcview().addReadOnly(dialog_->bmtable_font2);
71
72         bcview().setCancel(dialog_->button_close);
73 }
74
75
76 void FormMathsStyle::apply()
77 {
78         if ((style_ >= 0) && (style_ < 4))
79                 controller().insertSymbol(latex_mathstyle[style_]);
80         else if ((style_ >= 4) && (style_ < 14))
81                 controller().dispatchFunc(latex_mathfontcmds[style_-4]);
82 }
83
84
85 ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
86 {
87         style_ = fl_get_bmtable(ob);
88         if (style_ < 0) return ButtonPolicy::SMI_INVALID;
89
90         //if (ob == dialog_->bmtable_style1) style_ += 0;
91         if (ob == dialog_->bmtable_style2) style_ += 1;
92         if (ob == dialog_->bmtable_font1)  style_ += 4;
93         if (ob == dialog_->bmtable_font2)  style_ += 9;
94         if (data >= 12) style_ = short(data);
95         apply();
96
97         return ButtonPolicy::SMI_VALID;
98 }