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"
29 char const * latex_mathstyle[] = {
30 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
33 kb_action latex_mathfontcmds[] = {
34 LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
35 LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREEFONT_APPLY, LFUN_DEFAULT
39 typedef FormController<ControlMath, FormView<FD_maths_style> > base_class;
41 FormMathsStyle::FormMathsStyle(Dialog & parent)
42 : base_class(parent, _("Math Styles & Fonts"), false),
47 void FormMathsStyle::build()
49 dialog_.reset(build_maths_style(this));
51 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
52 style1_width, style1_height, style1_bits);
53 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
54 bcview().addReadOnly(dialog_->bmtable_style1);
56 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
57 style2_width, style2_height, style2_bits);
58 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
59 bcview().addReadOnly(dialog_->bmtable_style2);
61 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
62 font1_width, font1_height, font1_bits);
63 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
64 bcview().addReadOnly(dialog_->bmtable_font1);
66 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
67 font2_width, font2_height, font2_bits);
68 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
69 bcview().addReadOnly(dialog_->bmtable_font2);
71 bcview().setCancel(dialog_->button_close);
75 void FormMathsStyle::apply()
77 if ((style_ >= 0) && (style_ < 4))
78 controller().dispatchInsert(latex_mathstyle[style_]);
79 else if ((style_ >= 4) && (style_ < 14))
80 controller().dispatchFunc(latex_mathfontcmds[style_-4]);
84 ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
86 style_ = fl_get_bmtable(ob);
87 if (style_ < 0) return ButtonPolicy::SMI_INVALID;
89 //if (ob == dialog_->bmtable_style1) style_ += 0;
90 if (ob == dialog_->bmtable_style2) style_ += 1;
91 if (ob == dialog_->bmtable_font1) style_ += 4;
92 if (ob == dialog_->bmtable_font2) style_ += 9;
93 if (data >= 12) style_ = short(data);
96 return ButtonPolicy::SMI_VALID;