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 #pragma implementation
21 #include "FormMathsStyle.h"
22 #include "forms/form_maths_style.h"
27 #include FORMS_H_LOCATION
32 char const * latex_mathstyle[] = {
33 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
36 kb_action latex_mathfontcmds[] = {
37 LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
38 LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT
43 FormMathsStyle::FormMathsStyle(LyXView & lv, Dialogs & d,
44 FormMathsPanel const & p)
45 : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
50 FL_FORM * FormMathsStyle::form() const
58 void FormMathsStyle::build()
60 dialog_.reset(build_maths_style(this));
62 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
63 style1_width, style1_height, style1_bits);
64 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
65 bc().addReadOnly(dialog_->bmtable_style1);
67 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
68 style2_width, style2_height, style2_bits);
69 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
70 bc().addReadOnly(dialog_->bmtable_style2);
72 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
73 font1_width, font1_height, font1_bits);
74 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
75 bc().addReadOnly(dialog_->bmtable_font1);
77 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
78 font2_width, font2_height, font2_bits);
79 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
80 bc().addReadOnly(dialog_->bmtable_font2);
82 bc().setCancel(dialog_->button_close);
86 void FormMathsStyle::apply()
88 if ((style_ >= 0) && (style_ < 4))
89 parent_.insertSymbol(latex_mathstyle[style_]);
90 else if ((style_ >= 4) && (style_ < 14))
91 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
95 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
97 style_ = fl_get_bmtable(ob);
98 if (style_ < 0) return false;
99 //if (ob == dialog_->bmtable_style1) style_ += 0;
100 if (ob == dialog_->bmtable_style2) style_ += 1;
101 if (ob == dialog_->bmtable_font1) style_ += 4;
102 if (ob == dialog_->bmtable_font2) style_ += 9;
103 if (data >= 12) style_ = short(data);