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"
23 #include "ControlMath.h"
28 #include FORMS_H_LOCATION
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_FREE, LFUN_DEFAULT
43 typedef FormCB<ControlMathSub, FormDB<FD_maths_style> > base_class;
45 FormMathsStyle::FormMathsStyle()
46 : base_class(_("Maths Styles & Fonts"), false),
51 void FormMathsStyle::build()
53 dialog_.reset(build_maths_style(this));
55 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
56 style1_width, style1_height, style1_bits);
57 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
58 bc().addReadOnly(dialog_->bmtable_style1);
60 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
61 style2_width, style2_height, style2_bits);
62 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
63 bc().addReadOnly(dialog_->bmtable_style2);
65 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
66 font1_width, font1_height, font1_bits);
67 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
68 bc().addReadOnly(dialog_->bmtable_font1);
70 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
71 font2_width, font2_height, font2_bits);
72 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
73 bc().addReadOnly(dialog_->bmtable_font2);
75 bc().setCancel(dialog_->button_close);
79 void FormMathsStyle::apply()
81 if ((style_ >= 0) && (style_ < 4))
82 controller().insertSymbol(latex_mathstyle[style_]);
83 else if ((style_ >= 4) && (style_ < 14))
84 controller().dispatchFunc(latex_mathfontcmds[style_-4]);
88 ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
90 style_ = fl_get_bmtable(ob);
91 if (style_ < 0) return ButtonPolicy::SMI_INVALID;
93 //if (ob == dialog_->bmtable_style1) style_ += 0;
94 if (ob == dialog_->bmtable_style2) style_ += 1;
95 if (ob == dialog_->bmtable_font1) style_ += 4;
96 if (ob == dialog_->bmtable_font2) style_ += 9;
97 if (data >= 12) style_ = short(data);
100 return ButtonPolicy::SMI_VALID;