2 * \file FormMathsStyle.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Pablo De Napoli
9 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS.
12 * Adapted from FormMathsSpace martin.vermeer@hut.fi
17 #include "FormMathsStyle.h"
18 #include "forms/form_maths_style.h"
19 #include "ControlMath.h"
22 #include "lyx_forms.h"
33 char const * latex_mathstyle[] = {
34 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
37 kb_action latex_mathfontcmds[] = {
38 LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
39 LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREEFONT_APPLY, LFUN_DEFAULT
45 typedef FormController<ControlMath, FormView<FD_maths_style> > base_class;
47 FormMathsStyle::FormMathsStyle(Dialog & parent)
48 : base_class(parent, _("Math Styles & Fonts"), false),
53 void FormMathsStyle::build()
55 dialog_.reset(build_maths_style(this));
57 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
58 style1_width, style1_height, style1_bits);
59 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
60 bcview().addReadOnly(dialog_->bmtable_style1);
62 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
63 style2_width, style2_height, style2_bits);
64 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
65 bcview().addReadOnly(dialog_->bmtable_style2);
67 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
68 font1_width, font1_height, font1_bits);
69 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
70 bcview().addReadOnly(dialog_->bmtable_font1);
72 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
73 font2_width, font2_height, font2_bits);
74 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
75 bcview().addReadOnly(dialog_->bmtable_font2);
77 bcview().setCancel(dialog_->button_close);
81 void FormMathsStyle::apply()
83 if ((style_ >= 0) && (style_ < 4))
84 controller().dispatchInsert(latex_mathstyle[style_]);
85 else if ((style_ >= 4) && (style_ < 14))
86 controller().dispatchFunc(latex_mathfontcmds[style_-4]);
90 ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
92 style_ = fl_get_bmtable(ob);
93 if (style_ < 0) return ButtonPolicy::SMI_INVALID;
95 //if (ob == dialog_->bmtable_style1) style_ += 0;
96 if (ob == dialog_->bmtable_style2) style_ += 1;
97 if (ob == dialog_->bmtable_font1) style_ += 4;
98 if (ob == dialog_->bmtable_font2) style_ += 9;
99 if (data >= 12) style_ = short(data);
102 return ButtonPolicy::SMI_VALID;
105 } // namespace frontend