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
18 #include "FormMathsStyle.h"
19 #include "forms/form_maths_style.h"
20 #include "ControlMath.h"
25 #include "lyx_forms.h"
30 char const * latex_mathstyle[] = {
31 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
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
40 typedef FormCB<ControlMathSub, FormDB<FD_maths_style> > base_class;
42 FormMathsStyle::FormMathsStyle()
43 : base_class(_("Math Styles & Fonts"), false),
48 void FormMathsStyle::build()
50 dialog_.reset(build_maths_style(this));
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);
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);
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);
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);
72 bcview().setCancel(dialog_->button_close);
76 void FormMathsStyle::apply()
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]);
85 ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
87 style_ = fl_get_bmtable(ob);
88 if (style_ < 0) return ButtonPolicy::SMI_INVALID;
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);
97 return ButtonPolicy::SMI_VALID;